@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,632 @@
|
|
|
1
|
+
import { query as datalogQuery } from './datalog.js';
|
|
2
|
+
import { uuidCompare } from './utils/id.js';
|
|
3
|
+
import { stringCompare } from './utils/strings.js';
|
|
4
|
+
import * as s from './store.js';
|
|
5
|
+
import { warningEnabled } from './warningToggle.js';
|
|
6
|
+
let _seed = 0;
|
|
7
|
+
function wildcard(friendlyName) {
|
|
8
|
+
return makeVarImpl(`_${friendlyName}`, _seed++);
|
|
9
|
+
}
|
|
10
|
+
function makeVarImpl(x, level) {
|
|
11
|
+
return `?${x}-${level}`;
|
|
12
|
+
}
|
|
13
|
+
// Where
|
|
14
|
+
// -----------------
|
|
15
|
+
class AttrNotFoundError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'AttrNotFoundError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function idAttr(attrsStore, ns) {
|
|
22
|
+
const attr = s.getPrimaryKeyAttr(attrsStore, ns);
|
|
23
|
+
if (!attr) {
|
|
24
|
+
throw new AttrNotFoundError(`Could not find id attr for ${ns}`);
|
|
25
|
+
}
|
|
26
|
+
return attr;
|
|
27
|
+
}
|
|
28
|
+
function defaultWhere(makeVar, attrsStore, etype, level) {
|
|
29
|
+
return [eidWhere(makeVar, attrsStore, etype, level)];
|
|
30
|
+
}
|
|
31
|
+
function eidWhere(makeVar, attrsStore, etype, level) {
|
|
32
|
+
return [
|
|
33
|
+
makeVar(etype, level),
|
|
34
|
+
idAttr(attrsStore, etype).id,
|
|
35
|
+
makeVar(etype, level),
|
|
36
|
+
makeVar('time', level),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
function replaceInAttrPat(attrPat, needle, v) {
|
|
40
|
+
return attrPat.map((x) => (x === needle ? v : x));
|
|
41
|
+
}
|
|
42
|
+
function refAttrPat(makeVar, attrsStore, etype, level, label) {
|
|
43
|
+
const fwdAttr = s.getAttrByFwdIdentName(attrsStore, etype, label);
|
|
44
|
+
const revAttr = s.getAttrByReverseIdentName(attrsStore, etype, label);
|
|
45
|
+
const attr = fwdAttr || revAttr;
|
|
46
|
+
if (!attr) {
|
|
47
|
+
throw new AttrNotFoundError(`Could not find attr for ${[etype, label]}`);
|
|
48
|
+
}
|
|
49
|
+
if (attr['value-type'] !== 'ref') {
|
|
50
|
+
throw new Error(`Attr ${attr.id} is not a ref`);
|
|
51
|
+
}
|
|
52
|
+
const [_f, fwdEtype] = attr['forward-identity'];
|
|
53
|
+
const [_r, revEtype] = attr['reverse-identity'];
|
|
54
|
+
const nextLevel = level + 1;
|
|
55
|
+
const attrPat = fwdAttr
|
|
56
|
+
? [
|
|
57
|
+
makeVar(fwdEtype, level),
|
|
58
|
+
attr.id,
|
|
59
|
+
makeVar(revEtype, nextLevel),
|
|
60
|
+
wildcard('time'),
|
|
61
|
+
]
|
|
62
|
+
: [
|
|
63
|
+
makeVar(fwdEtype, nextLevel),
|
|
64
|
+
attr.id,
|
|
65
|
+
makeVar(revEtype, level),
|
|
66
|
+
wildcard('time'),
|
|
67
|
+
];
|
|
68
|
+
const nextEtype = fwdAttr ? revEtype : fwdEtype;
|
|
69
|
+
const isForward = Boolean(fwdAttr);
|
|
70
|
+
return [nextEtype, nextLevel, attrPat, attr, isForward];
|
|
71
|
+
}
|
|
72
|
+
function makeLikeMatcher(caseSensitive, pattern) {
|
|
73
|
+
if (typeof pattern !== 'string') {
|
|
74
|
+
return function likeMatcher(_value) {
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const escapedPattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
79
|
+
const regexPattern = escapedPattern.replace(/%/g, '.*').replace(/_/g, '.');
|
|
80
|
+
// The `s` (dotall) flag makes `%` (-> .*) and `_` (-> .) match newline
|
|
81
|
+
// characters, matching Postgres LIKE/ILIKE on the server.
|
|
82
|
+
const regex = new RegExp(`^${regexPattern}$`, caseSensitive ? 's' : 'is');
|
|
83
|
+
return function likeMatcher(value) {
|
|
84
|
+
if (typeof value !== 'string') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return regex.test(value);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function parseValue(attr, v) {
|
|
91
|
+
if (typeof v !== 'object' ||
|
|
92
|
+
v.hasOwnProperty('$in') ||
|
|
93
|
+
v.hasOwnProperty('in')) {
|
|
94
|
+
return v;
|
|
95
|
+
}
|
|
96
|
+
const isDate = attr['checked-data-type'] === 'date';
|
|
97
|
+
if (v.hasOwnProperty('$gt')) {
|
|
98
|
+
return {
|
|
99
|
+
$comparator: true,
|
|
100
|
+
$op: isDate
|
|
101
|
+
? function gtDate(triple) {
|
|
102
|
+
return new Date(triple[2]) > new Date(v.$gt);
|
|
103
|
+
}
|
|
104
|
+
: function gt(triple) {
|
|
105
|
+
return triple[2] > v.$gt;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (v.hasOwnProperty('$gte')) {
|
|
110
|
+
return {
|
|
111
|
+
$comparator: true,
|
|
112
|
+
$op: isDate
|
|
113
|
+
? function gteDate(triple) {
|
|
114
|
+
return new Date(triple[2]) >= new Date(v.$gte);
|
|
115
|
+
}
|
|
116
|
+
: function gte(triple) {
|
|
117
|
+
return triple[2] >= v.$gte;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (v.hasOwnProperty('$lt')) {
|
|
122
|
+
return {
|
|
123
|
+
$comparator: true,
|
|
124
|
+
$op: isDate
|
|
125
|
+
? function ltDate(triple) {
|
|
126
|
+
return new Date(triple[2]) < new Date(v.$lt);
|
|
127
|
+
}
|
|
128
|
+
: function lt(triple) {
|
|
129
|
+
return triple[2] < v.$lt;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (v.hasOwnProperty('$lte')) {
|
|
134
|
+
return {
|
|
135
|
+
$comparator: true,
|
|
136
|
+
$op: isDate
|
|
137
|
+
? function lteDate(triple) {
|
|
138
|
+
return new Date(triple[2]) <= new Date(v.$lte);
|
|
139
|
+
}
|
|
140
|
+
: function lte(triple) {
|
|
141
|
+
return triple[2] <= v.$lte;
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (v.hasOwnProperty('$like')) {
|
|
146
|
+
const matcher = makeLikeMatcher(true, v.$like);
|
|
147
|
+
return {
|
|
148
|
+
$comparator: true,
|
|
149
|
+
$op: function like(triple) {
|
|
150
|
+
return matcher(triple[2]);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (v.hasOwnProperty('$ilike')) {
|
|
155
|
+
const matcher = makeLikeMatcher(false, v.$ilike);
|
|
156
|
+
return {
|
|
157
|
+
$comparator: true,
|
|
158
|
+
$op: function ilike(triple) {
|
|
159
|
+
return matcher(triple[2]);
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return v;
|
|
164
|
+
}
|
|
165
|
+
function valueAttrPat(makeVar, attrsStore, valueEtype, valueLevel, valueLabel, v) {
|
|
166
|
+
const fwdAttr = s.getAttrByFwdIdentName(attrsStore, valueEtype, valueLabel);
|
|
167
|
+
const revAttr = s.getAttrByReverseIdentName(attrsStore, valueEtype, valueLabel);
|
|
168
|
+
const attr = fwdAttr || revAttr;
|
|
169
|
+
if (!attr) {
|
|
170
|
+
throw new AttrNotFoundError(`No attr for etype = ${valueEtype} label = ${valueLabel}`);
|
|
171
|
+
}
|
|
172
|
+
if (v?.hasOwnProperty('$isNull')) {
|
|
173
|
+
const idAttr = s.getAttrByFwdIdentName(attrsStore, valueEtype, 'id');
|
|
174
|
+
if (!idAttr) {
|
|
175
|
+
throw new AttrNotFoundError(`No attr for etype = ${valueEtype} label = id`);
|
|
176
|
+
}
|
|
177
|
+
return [
|
|
178
|
+
makeVar(valueEtype, valueLevel),
|
|
179
|
+
idAttr.id,
|
|
180
|
+
{ $isNull: { attrId: attr.id, isNull: v.$isNull, reverse: !fwdAttr } },
|
|
181
|
+
wildcard('time'),
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
if (fwdAttr) {
|
|
185
|
+
return [
|
|
186
|
+
makeVar(valueEtype, valueLevel),
|
|
187
|
+
attr.id,
|
|
188
|
+
parseValue(attr, v),
|
|
189
|
+
wildcard('time'),
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
return [v, attr.id, makeVar(valueEtype, valueLevel), wildcard('time')];
|
|
193
|
+
}
|
|
194
|
+
function refAttrPats(makeVar, attrsStore, etype, level, refsPath) {
|
|
195
|
+
const [lastEtype, lastLevel, attrPats] = refsPath.reduce((acc, label) => {
|
|
196
|
+
const [etype, level, attrPats] = acc;
|
|
197
|
+
const [nextEtype, nextLevel, attrPat] = refAttrPat(makeVar, attrsStore, etype, level, label);
|
|
198
|
+
return [nextEtype, nextLevel, [...attrPats, attrPat]];
|
|
199
|
+
}, [etype, level, []]);
|
|
200
|
+
return [lastEtype, lastLevel, attrPats];
|
|
201
|
+
}
|
|
202
|
+
function whereCondAttrPats(makeVar, attrsStore, etype, level, path, v) {
|
|
203
|
+
const refsPath = path.slice(0, path.length - 1);
|
|
204
|
+
const valueLabel = path[path.length - 1];
|
|
205
|
+
const [lastEtype, lastLevel, refPats] = refAttrPats(makeVar, attrsStore, etype, level, refsPath);
|
|
206
|
+
const valuePat = valueAttrPat(makeVar, attrsStore, lastEtype, lastLevel, valueLabel, v);
|
|
207
|
+
return refPats.concat([valuePat]);
|
|
208
|
+
}
|
|
209
|
+
function withJoin(where, join) {
|
|
210
|
+
return join ? [join].concat(where) : where;
|
|
211
|
+
}
|
|
212
|
+
function isOrClauses([k, v]) {
|
|
213
|
+
return k === 'or' && Array.isArray(v);
|
|
214
|
+
}
|
|
215
|
+
function isAndClauses([k, v]) {
|
|
216
|
+
return k === 'and' && Array.isArray(v);
|
|
217
|
+
}
|
|
218
|
+
// Creates a makeVar that will namespace symbols for or clauses
|
|
219
|
+
// to prevent conflicts, except for the base etype
|
|
220
|
+
function genMakeVar(baseMakeVar, joinSym, orIdx) {
|
|
221
|
+
return (x, lvl) => {
|
|
222
|
+
const base = baseMakeVar(x, lvl);
|
|
223
|
+
if (joinSym == base) {
|
|
224
|
+
return base;
|
|
225
|
+
}
|
|
226
|
+
return `${base}-${orIdx}`;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function parseWhereClauses(makeVar, clauseType /* 'or' | 'and' */, attrsStore, etype, level, whereValue) {
|
|
230
|
+
const joinSym = makeVar(etype, level);
|
|
231
|
+
const patterns = whereValue.map((w, i) => {
|
|
232
|
+
const makeNamespacedVar = genMakeVar(makeVar, joinSym, i);
|
|
233
|
+
return parseWhere(makeNamespacedVar, attrsStore, etype, level, w);
|
|
234
|
+
});
|
|
235
|
+
return { [clauseType]: { patterns, joinSym } };
|
|
236
|
+
}
|
|
237
|
+
// Given a path, returns a list of paths leading up to this path:
|
|
238
|
+
// growPath([1, 2, 3]) -> [[1], [1, 2], [1, 2, 3]]
|
|
239
|
+
function growPath(path) {
|
|
240
|
+
const ret = [];
|
|
241
|
+
for (let i = 1; i <= path.length; i++) {
|
|
242
|
+
ret.push(path.slice(0, i));
|
|
243
|
+
}
|
|
244
|
+
return ret;
|
|
245
|
+
}
|
|
246
|
+
// Returns array of pattern arrays that should be grouped in OR
|
|
247
|
+
// to capture any intermediate nulls
|
|
248
|
+
function whereCondAttrPatsForNullIsTrue(makeVar, attrsStore, etype, level, path) {
|
|
249
|
+
return growPath(path).map((path) => whereCondAttrPats(makeVar, attrsStore, etype, level, path, {
|
|
250
|
+
$isNull: true,
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
function parseWhere(makeVar, attrsStore, etype, level, where) {
|
|
254
|
+
return Object.entries(where).flatMap(([k, v]) => {
|
|
255
|
+
if (isOrClauses([k, v])) {
|
|
256
|
+
return parseWhereClauses(makeVar, 'or', attrsStore, etype, level, v);
|
|
257
|
+
}
|
|
258
|
+
if (isAndClauses([k, v])) {
|
|
259
|
+
return parseWhereClauses(makeVar, 'and', attrsStore, etype, level, v);
|
|
260
|
+
}
|
|
261
|
+
// Temporary hack until we have support for a uuid index on `id`
|
|
262
|
+
if (k === '$entityIdStartsWith') {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
const path = k.split('.');
|
|
266
|
+
// Normalize $ne to $not
|
|
267
|
+
if (v?.hasOwnProperty('$ne')) {
|
|
268
|
+
v = { ...v, $not: v.$ne };
|
|
269
|
+
delete v.$ne;
|
|
270
|
+
}
|
|
271
|
+
if (v?.hasOwnProperty('$not')) {
|
|
272
|
+
// `$not` won't pick up entities that are missing the attr, so we
|
|
273
|
+
// add in a `$isNull` to catch those too.
|
|
274
|
+
const notPats = whereCondAttrPats(makeVar, attrsStore, etype, level, path, v);
|
|
275
|
+
const nilPats = whereCondAttrPatsForNullIsTrue(makeVar, attrsStore, etype, level, path);
|
|
276
|
+
return [
|
|
277
|
+
{
|
|
278
|
+
or: {
|
|
279
|
+
patterns: [notPats, ...nilPats],
|
|
280
|
+
joinSym: makeVar(etype, level),
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
if (v?.hasOwnProperty('$isNull') && v.$isNull === true && path.length > 1) {
|
|
286
|
+
// Make sure we're capturing all of the intermediate paths that might be null
|
|
287
|
+
// by checking for null at each step along the path
|
|
288
|
+
return [
|
|
289
|
+
{
|
|
290
|
+
or: {
|
|
291
|
+
patterns: whereCondAttrPatsForNullIsTrue(makeVar, attrsStore, etype, level, path),
|
|
292
|
+
joinSym: makeVar(etype, level),
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
return whereCondAttrPats(makeVar, attrsStore, etype, level, path, v);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function makeWhere(attrsStore, etype, level, where) {
|
|
301
|
+
const makeVar = makeVarImpl;
|
|
302
|
+
if (!where) {
|
|
303
|
+
return defaultWhere(makeVar, attrsStore, etype, level);
|
|
304
|
+
}
|
|
305
|
+
const parsedWhere = parseWhere(makeVar, attrsStore, etype, level, where);
|
|
306
|
+
return parsedWhere.concat(defaultWhere(makeVar, attrsStore, etype, level));
|
|
307
|
+
}
|
|
308
|
+
// Find
|
|
309
|
+
// -----------------
|
|
310
|
+
function makeFind(makeVar, etype, level) {
|
|
311
|
+
return [makeVar(etype, level), makeVar('time', level)];
|
|
312
|
+
}
|
|
313
|
+
// extendObjects
|
|
314
|
+
// -----------------
|
|
315
|
+
function makeJoin(makeVar, attrsStore, etype, level, label, eid) {
|
|
316
|
+
const [nextEtype, nextLevel, pat, attr, isForward] = refAttrPat(makeVar, attrsStore, etype, level, label);
|
|
317
|
+
const actualized = replaceInAttrPat(pat, makeVar(etype, level), eid);
|
|
318
|
+
return [nextEtype, nextLevel, actualized, attr, isForward];
|
|
319
|
+
}
|
|
320
|
+
function extendObjects(makeVar, store, attrsStore, { etype, level, form }, objects) {
|
|
321
|
+
const childQueries = Object.keys(form).filter((c) => c !== '$');
|
|
322
|
+
if (!childQueries.length) {
|
|
323
|
+
return Object.values(objects);
|
|
324
|
+
}
|
|
325
|
+
return Object.entries(objects).map(function extendChildren([eid, parent]) {
|
|
326
|
+
const childResults = childQueries.map(function getChildResult(label) {
|
|
327
|
+
const isSingular = Boolean(store.cardinalityInference &&
|
|
328
|
+
attrsStore.linkIndex?.[etype]?.[label]?.isSingular);
|
|
329
|
+
try {
|
|
330
|
+
const [nextEtype, nextLevel, join] = makeJoin(makeVar, attrsStore, etype, level, label, eid);
|
|
331
|
+
const childrenArray = queryOne(store, attrsStore, {
|
|
332
|
+
etype: nextEtype,
|
|
333
|
+
level: nextLevel,
|
|
334
|
+
form: form[label],
|
|
335
|
+
join,
|
|
336
|
+
});
|
|
337
|
+
const childOrChildren = isSingular ? childrenArray[0] : childrenArray;
|
|
338
|
+
return { [label]: childOrChildren };
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
if (e instanceof AttrNotFoundError) {
|
|
342
|
+
return { [label]: isSingular ? undefined : [] };
|
|
343
|
+
}
|
|
344
|
+
throw e;
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
return childResults.reduce(function reduceChildren(parent, child) {
|
|
348
|
+
return { ...parent, ...child };
|
|
349
|
+
}, parent);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
// resolveObjects
|
|
353
|
+
// -----------------
|
|
354
|
+
function shouldIgnoreAttr(attrs, id) {
|
|
355
|
+
const attr = attrs[id];
|
|
356
|
+
return attr['value-type'] === 'ref' && attr['forward-identity'][2] !== 'id';
|
|
357
|
+
}
|
|
358
|
+
// Compares values where we already know that the two values are distinct
|
|
359
|
+
// and not null.
|
|
360
|
+
// Takes into account the data type.
|
|
361
|
+
function compareDisparateValues(a, b, dataType) {
|
|
362
|
+
if (dataType === 'string') {
|
|
363
|
+
return stringCompare(a, b);
|
|
364
|
+
}
|
|
365
|
+
if (a > b) {
|
|
366
|
+
return 1;
|
|
367
|
+
}
|
|
368
|
+
return -1;
|
|
369
|
+
}
|
|
370
|
+
export function compareOrder(id_a, v_a, id_b, v_b, dataType) {
|
|
371
|
+
if (v_a === v_b || (v_a == null && v_b == null)) {
|
|
372
|
+
return uuidCompare(id_a, id_b);
|
|
373
|
+
}
|
|
374
|
+
if (v_b == null) {
|
|
375
|
+
return 1;
|
|
376
|
+
}
|
|
377
|
+
if (v_a == null) {
|
|
378
|
+
return -1;
|
|
379
|
+
}
|
|
380
|
+
return compareDisparateValues(v_a, v_b, dataType);
|
|
381
|
+
}
|
|
382
|
+
function compareOrderTriples([id_a, v_a], [id_b, v_b], dataType) {
|
|
383
|
+
return compareOrder(id_a, v_a, id_b, v_b, dataType);
|
|
384
|
+
}
|
|
385
|
+
function comparableDate(x) {
|
|
386
|
+
if (x == null) {
|
|
387
|
+
return x;
|
|
388
|
+
}
|
|
389
|
+
return new Date(x).getTime();
|
|
390
|
+
}
|
|
391
|
+
function compareToCursor(cursor, orderAttr, idVec) {
|
|
392
|
+
const [c_e, _c_a, c_v, c_t] = cursor;
|
|
393
|
+
if (orderAttr['forward-identity']?.[2] === 'id') {
|
|
394
|
+
return compareOrderTriples(idVec, [c_e, c_t], null);
|
|
395
|
+
}
|
|
396
|
+
const [e, v] = idVec;
|
|
397
|
+
const dataType = orderAttr['checked-data-type'];
|
|
398
|
+
const v_new = dataType === 'date' ? comparableDate(v) : v;
|
|
399
|
+
const c_v_new = dataType === 'date' ? comparableDate(c_v) : c_v;
|
|
400
|
+
return compareOrderTriples([e, v_new], [c_e, c_v_new], dataType);
|
|
401
|
+
}
|
|
402
|
+
function isBefore(startCursor, orderAttr, direction, idVec) {
|
|
403
|
+
const cmp = compareToCursor(startCursor, orderAttr, idVec);
|
|
404
|
+
return direction === 'desc' ? cmp > 0 : cmp < 0;
|
|
405
|
+
}
|
|
406
|
+
function isAfter(endCursor, orderAttr, direction, idVec) {
|
|
407
|
+
const cmp = compareToCursor(endCursor, orderAttr, idVec);
|
|
408
|
+
return direction === 'desc' ? cmp < 0 : cmp > 0;
|
|
409
|
+
}
|
|
410
|
+
function orderAttrFromCursor(attrsStore, cursor) {
|
|
411
|
+
const cursorAttrId = cursor[1];
|
|
412
|
+
return attrsStore.getAttr(cursorAttrId);
|
|
413
|
+
}
|
|
414
|
+
function orderAttrFromOrder(attrsStore, etype, order) {
|
|
415
|
+
const label = Object.keys(order)[0];
|
|
416
|
+
return s.getAttrByFwdIdentName(attrsStore, etype, label);
|
|
417
|
+
}
|
|
418
|
+
function getOrderAttr(attrsStore, etype, cursor, order) {
|
|
419
|
+
if (cursor) {
|
|
420
|
+
return orderAttrFromCursor(attrsStore, cursor);
|
|
421
|
+
}
|
|
422
|
+
if (order) {
|
|
423
|
+
return orderAttrFromOrder(attrsStore, etype, order);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function objectAttrs(attrsStore, etype, dq) {
|
|
427
|
+
if (!Array.isArray(dq.fields)) {
|
|
428
|
+
return s.getBlobAttrs(attrsStore, etype);
|
|
429
|
+
}
|
|
430
|
+
const attrs = new Map();
|
|
431
|
+
for (const field of dq.fields) {
|
|
432
|
+
const attr = s.getAttrByFwdIdentName(attrsStore, etype, field);
|
|
433
|
+
const label = attr?.['forward-identity']?.[2];
|
|
434
|
+
if (label && s.isBlob(attr)) {
|
|
435
|
+
attrs.set(label, attr);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// Ensure we add the id field to avoid empty objects
|
|
439
|
+
if (!attrs.has('id')) {
|
|
440
|
+
const attr = s.getAttrByFwdIdentName(attrsStore, etype, 'id');
|
|
441
|
+
const label = attr?.['forward-identity']?.[2];
|
|
442
|
+
if (label) {
|
|
443
|
+
attrs.set(label, attr);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return attrs;
|
|
447
|
+
}
|
|
448
|
+
function runDataloadAndReturnObjects(store, attrsStore, { etype, pageInfo, dq, form }) {
|
|
449
|
+
const order = form?.$?.order;
|
|
450
|
+
const isLeadingQuery = isLeading(form);
|
|
451
|
+
const direction = determineDirection(form);
|
|
452
|
+
let idVecs = datalogQuery(store, dq);
|
|
453
|
+
const startCursor = pageInfo?.['start-cursor'];
|
|
454
|
+
const endCursor = pageInfo?.['end-cursor'];
|
|
455
|
+
const orderAttr = getOrderAttr(attrsStore, etype, startCursor, order);
|
|
456
|
+
if (orderAttr && orderAttr?.['forward-identity']?.[2] !== 'id') {
|
|
457
|
+
const isDate = orderAttr['checked-data-type'] === 'date';
|
|
458
|
+
const a = orderAttr.id;
|
|
459
|
+
idVecs = idVecs.map(([id]) => {
|
|
460
|
+
// order attr is required to be cardinality one, so there will
|
|
461
|
+
// be at most one value here
|
|
462
|
+
let v = store.eav.get(id)?.get(a)?.values()?.next()?.value?.[2];
|
|
463
|
+
if (isDate) {
|
|
464
|
+
v = comparableDate(v);
|
|
465
|
+
}
|
|
466
|
+
return [id, v];
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
idVecs.sort(direction === 'asc'
|
|
470
|
+
? function compareIdVecs(a, b) {
|
|
471
|
+
return compareOrderTriples(a, b, orderAttr?.['checked-data-type']);
|
|
472
|
+
}
|
|
473
|
+
: function compareIdVecs(a, b) {
|
|
474
|
+
return compareOrderTriples(b, a, orderAttr?.['checked-data-type']);
|
|
475
|
+
});
|
|
476
|
+
let objects = {};
|
|
477
|
+
const attrs = objectAttrs(attrsStore, etype, dq);
|
|
478
|
+
for (const idVec of idVecs) {
|
|
479
|
+
const [id] = idVec;
|
|
480
|
+
if (objects[id]) {
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (!isLeadingQuery &&
|
|
484
|
+
startCursor &&
|
|
485
|
+
orderAttr &&
|
|
486
|
+
isBefore(startCursor, orderAttr, direction, idVec)) {
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (!isLeadingQuery &&
|
|
490
|
+
endCursor &&
|
|
491
|
+
orderAttr &&
|
|
492
|
+
isAfter(endCursor, orderAttr, direction, idVec)) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const obj = s.getAsObject(store, attrs, id);
|
|
496
|
+
if (obj) {
|
|
497
|
+
objects[id] = obj;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return objects;
|
|
501
|
+
}
|
|
502
|
+
function determineDirection(form) {
|
|
503
|
+
const orderOpts = form.$?.order;
|
|
504
|
+
if (!orderOpts) {
|
|
505
|
+
return 'asc';
|
|
506
|
+
}
|
|
507
|
+
return orderOpts[Object.keys(orderOpts)[0]] || 'asc';
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* A "leading" query has no `offset`, `before`, or `after`
|
|
511
|
+
*
|
|
512
|
+
* It is at the 'beginning' of the order
|
|
513
|
+
*/
|
|
514
|
+
function isLeading(form) {
|
|
515
|
+
const offset = form.$?.offset;
|
|
516
|
+
const before = form.$?.before;
|
|
517
|
+
const after = form.$?.after;
|
|
518
|
+
return !offset && !before && !after;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Given a query like:
|
|
522
|
+
*
|
|
523
|
+
* {
|
|
524
|
+
* users: {
|
|
525
|
+
* $: { where: { name: "Joe" } },
|
|
526
|
+
* },
|
|
527
|
+
* };
|
|
528
|
+
*
|
|
529
|
+
* `resolveObjects`, turns where clause: `{ name: "Joe" }`
|
|
530
|
+
* into a datalog query. We then run the datalog query,
|
|
531
|
+
* and reduce all the triples into objects.
|
|
532
|
+
*/
|
|
533
|
+
function resolveObjects(store, attrsStore, { etype, level, form, join, pageInfo }) {
|
|
534
|
+
// Wait for server to tell us where we start if we don't start from the beginning
|
|
535
|
+
if (!isLeading(form) && (!pageInfo || !pageInfo['start-cursor'])) {
|
|
536
|
+
return [];
|
|
537
|
+
}
|
|
538
|
+
const where = withJoin(makeWhere(attrsStore, etype, level, form.$?.where), join);
|
|
539
|
+
const find = makeFind(makeVarImpl, etype, level);
|
|
540
|
+
const fields = form.$?.fields;
|
|
541
|
+
const objs = runDataloadAndReturnObjects(store, attrsStore, {
|
|
542
|
+
etype,
|
|
543
|
+
pageInfo,
|
|
544
|
+
form,
|
|
545
|
+
dq: { where, find, fields },
|
|
546
|
+
});
|
|
547
|
+
const limit = form.$?.limit || form.$?.first || form.$?.last;
|
|
548
|
+
if (limit != null) {
|
|
549
|
+
if (level > 0 && warningEnabled) {
|
|
550
|
+
console.warn('WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.');
|
|
551
|
+
}
|
|
552
|
+
const entries = Object.entries(objs);
|
|
553
|
+
if (entries.length <= limit) {
|
|
554
|
+
return objs;
|
|
555
|
+
}
|
|
556
|
+
return Object.fromEntries(entries.slice(0, limit));
|
|
557
|
+
}
|
|
558
|
+
return objs;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* It's possible that we query
|
|
562
|
+
* for an attribute that doesn't exist yet.
|
|
563
|
+
*
|
|
564
|
+
* { users: { $: { where: { nonExistentProperty: "foo" } } } }
|
|
565
|
+
*
|
|
566
|
+
* This swallows the missing attr error and returns
|
|
567
|
+
* an empty result instead
|
|
568
|
+
*/
|
|
569
|
+
function guardedResolveObjects(store, attrsStore, opts) {
|
|
570
|
+
try {
|
|
571
|
+
return resolveObjects(store, attrsStore, opts);
|
|
572
|
+
}
|
|
573
|
+
catch (e) {
|
|
574
|
+
if (e instanceof AttrNotFoundError) {
|
|
575
|
+
return {};
|
|
576
|
+
}
|
|
577
|
+
throw e;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Given a query like:
|
|
582
|
+
*
|
|
583
|
+
* {
|
|
584
|
+
* users: {
|
|
585
|
+
* $: { where: { name: "Joe" } },
|
|
586
|
+
* posts: {},
|
|
587
|
+
* },
|
|
588
|
+
* };
|
|
589
|
+
*
|
|
590
|
+
* `guardResolveObjects` will return the relevant `users` objects
|
|
591
|
+
* `extendObjects` will then extend each `user` object with relevant `posts`.
|
|
592
|
+
*/
|
|
593
|
+
function queryOne(store, attrsStore, opts) {
|
|
594
|
+
const objects = guardedResolveObjects(store, attrsStore, opts);
|
|
595
|
+
return extendObjects(makeVarImpl, store, attrsStore, opts, objects);
|
|
596
|
+
}
|
|
597
|
+
function formatPageInfo(pageInfo) {
|
|
598
|
+
const res = {};
|
|
599
|
+
for (const [k, v] of Object.entries(pageInfo)) {
|
|
600
|
+
res[k] = {
|
|
601
|
+
startCursor: v['start-cursor'],
|
|
602
|
+
endCursor: v['end-cursor'],
|
|
603
|
+
hasNextPage: v['has-next-page?'],
|
|
604
|
+
hasPreviousPage: v['has-previous-page?'],
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
return res;
|
|
608
|
+
}
|
|
609
|
+
export default function query({ store, attrsStore, pageInfo, aggregate, }, q) {
|
|
610
|
+
const data = Object.keys(q).reduce(function reduceResult(res, k) {
|
|
611
|
+
if (aggregate?.[k] || '$$ruleParams' === k) {
|
|
612
|
+
// Aggregate doesn't return any join rows and has no children,
|
|
613
|
+
// so don't bother querying further
|
|
614
|
+
return res;
|
|
615
|
+
}
|
|
616
|
+
res[k] = queryOne(store, attrsStore, {
|
|
617
|
+
etype: k,
|
|
618
|
+
form: q[k],
|
|
619
|
+
level: 0,
|
|
620
|
+
pageInfo: pageInfo?.[k],
|
|
621
|
+
});
|
|
622
|
+
return res;
|
|
623
|
+
}, {});
|
|
624
|
+
const result = { data };
|
|
625
|
+
if (pageInfo) {
|
|
626
|
+
result.pageInfo = formatPageInfo(pageInfo);
|
|
627
|
+
}
|
|
628
|
+
if (aggregate) {
|
|
629
|
+
result.aggregate = aggregate;
|
|
630
|
+
}
|
|
631
|
+
return result;
|
|
632
|
+
}
|