@sidekickdb/core 0.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tshy/build.json +8 -0
- package/.tshy/commonjs.json +16 -0
- package/.tshy/esm.json +15 -0
- package/LICENSE.md +202 -0
- package/NOTICE +27 -0
- package/README.md +25 -2
- package/__example__/standalone.esm.html +23 -0
- package/__example__/standalone.umd.html +21 -0
- package/__tests__/src/Reactor.test.ts +480 -0
- package/__tests__/src/auth-extra-fields.e2e.test.ts +160 -0
- package/__tests__/src/cookieSync.e2e.test.ts +165 -0
- package/__tests__/src/data/movies/attrs.json +145 -0
- package/__tests__/src/data/movies/triples.json +1507 -0
- package/__tests__/src/data/zeneca/attrs.json +251 -0
- package/__tests__/src/data/zeneca/triples.json +15854 -0
- package/__tests__/src/dataForQueryMemo.test.ts +136 -0
- package/__tests__/src/datalog.test.ts +175 -0
- package/__tests__/src/devtool.test.ts +48 -0
- package/__tests__/src/endpoints.test.ts +228 -0
- package/__tests__/src/infiniteQuery.e2e.test.ts +454 -0
- package/__tests__/src/instaml.test.ts +1593 -0
- package/__tests__/src/instaql.bench.ts +34 -0
- package/__tests__/src/instaql.test.ts +1388 -0
- package/__tests__/src/instaqlInference.test.ts +243 -0
- package/__tests__/src/notifyScope.test.ts +1145 -0
- package/__tests__/src/queryValidation.test.ts +1033 -0
- package/__tests__/src/schema.test.ts +641 -0
- package/__tests__/src/serializeSchema.test.ts +123 -0
- package/__tests__/src/simple.e2e.test.ts +10 -0
- package/__tests__/src/storageUpload.test.ts +70 -0
- package/__tests__/src/store.test.ts +718 -0
- package/__tests__/src/transactionValidation.test.ts +450 -0
- package/__tests__/src/typeUtils.ts +39 -0
- package/__tests__/src/utils/PersistedObject.test.ts +529 -0
- package/__tests__/src/utils/dates.test.ts +82 -0
- package/__tests__/src/utils/e2e.ts +95 -0
- package/__tests__/src/utils/msw.ts +3 -0
- package/__tests__/src/utils/object.test.ts +78 -0
- package/__tests__/src/utils/weakHash.test.ts +68 -0
- package/__tests__/src/utils/weakHashLegacy.test.ts +22 -0
- package/__tests__/src/vite.env.d.ts +1 -0
- package/dist/commonjs/Connection.d.ts +93 -0
- package/dist/commonjs/Connection.d.ts.map +1 -0
- package/dist/commonjs/Connection.js +194 -0
- package/dist/commonjs/Connection.js.map +1 -0
- package/dist/commonjs/InMemoryStorage.d.ts +11 -0
- package/dist/commonjs/InMemoryStorage.d.ts.map +1 -0
- package/dist/commonjs/InMemoryStorage.js +29 -0
- package/dist/commonjs/InMemoryStorage.js.map +1 -0
- package/dist/commonjs/IndexedDBStorage.d.ts +18 -0
- package/dist/commonjs/IndexedDBStorage.d.ts.map +1 -0
- package/dist/commonjs/IndexedDBStorage.js +341 -0
- package/dist/commonjs/IndexedDBStorage.js.map +1 -0
- package/dist/commonjs/InstantError.d.ts +7 -0
- package/dist/commonjs/InstantError.d.ts.map +1 -0
- package/dist/commonjs/InstantError.js +28 -0
- package/dist/commonjs/InstantError.js.map +1 -0
- package/dist/commonjs/Reactor.d.ts +445 -0
- package/dist/commonjs/Reactor.d.ts.map +1 -0
- package/dist/commonjs/Reactor.js +2471 -0
- package/dist/commonjs/Reactor.js.map +1 -0
- package/dist/commonjs/StorageAPI.d.ts +40 -0
- package/dist/commonjs/StorageAPI.d.ts.map +1 -0
- package/dist/commonjs/StorageAPI.js +82 -0
- package/dist/commonjs/StorageAPI.js.map +1 -0
- package/dist/commonjs/Stream.d.ts +121 -0
- package/dist/commonjs/Stream.d.ts.map +1 -0
- package/dist/commonjs/Stream.js +819 -0
- package/dist/commonjs/Stream.js.map +1 -0
- package/dist/commonjs/SyncTable.d.ts +145 -0
- package/dist/commonjs/SyncTable.d.ts.map +1 -0
- package/dist/commonjs/SyncTable.js +564 -0
- package/dist/commonjs/SyncTable.js.map +1 -0
- package/dist/commonjs/WindowNetworkListener.d.ts +5 -0
- package/dist/commonjs/WindowNetworkListener.d.ts.map +1 -0
- package/dist/commonjs/WindowNetworkListener.js +23 -0
- package/dist/commonjs/WindowNetworkListener.js.map +1 -0
- package/dist/commonjs/__types__/fieldsTypeTest.d.ts +2 -0
- package/dist/commonjs/__types__/fieldsTypeTest.d.ts.map +1 -0
- package/dist/commonjs/__types__/fieldsTypeTest.js +68 -0
- package/dist/commonjs/__types__/fieldsTypeTest.js.map +1 -0
- package/dist/commonjs/__types__/typeUtils.d.ts +20 -0
- package/dist/commonjs/__types__/typeUtils.d.ts.map +1 -0
- package/dist/commonjs/__types__/typeUtils.js +5 -0
- package/dist/commonjs/__types__/typeUtils.js.map +1 -0
- package/dist/commonjs/__types__/useDatesTypeTest.d.ts +2 -0
- package/dist/commonjs/__types__/useDatesTypeTest.d.ts.map +1 -0
- package/dist/commonjs/__types__/useDatesTypeTest.js +55 -0
- package/dist/commonjs/__types__/useDatesTypeTest.js.map +1 -0
- package/dist/commonjs/attrTypes.d.ts +26 -0
- package/dist/commonjs/attrTypes.d.ts.map +1 -0
- package/dist/commonjs/attrTypes.js +3 -0
- package/dist/commonjs/attrTypes.js.map +1 -0
- package/dist/commonjs/authAPI.d.ts +65 -0
- package/dist/commonjs/authAPI.d.ts.map +1 -0
- package/dist/commonjs/authAPI.js +114 -0
- package/dist/commonjs/authAPI.js.map +1 -0
- package/dist/commonjs/clientTypes.d.ts +41 -0
- package/dist/commonjs/clientTypes.d.ts.map +1 -0
- package/dist/commonjs/clientTypes.js +3 -0
- package/dist/commonjs/clientTypes.js.map +1 -0
- package/dist/commonjs/coreTypes.d.ts +34 -0
- package/dist/commonjs/coreTypes.d.ts.map +1 -0
- package/dist/commonjs/coreTypes.js +3 -0
- package/dist/commonjs/coreTypes.js.map +1 -0
- package/dist/commonjs/createRouteHandler.d.ts +8 -0
- package/dist/commonjs/createRouteHandler.d.ts.map +1 -0
- package/dist/commonjs/createRouteHandler.js +56 -0
- package/dist/commonjs/createRouteHandler.js.map +1 -0
- package/dist/commonjs/datalog.d.ts +8 -0
- package/dist/commonjs/datalog.d.ts.map +1 -0
- package/dist/commonjs/datalog.js +106 -0
- package/dist/commonjs/datalog.js.map +1 -0
- package/dist/commonjs/devtool.d.ts +4 -0
- package/dist/commonjs/devtool.d.ts.map +1 -0
- package/dist/commonjs/devtool.js +191 -0
- package/dist/commonjs/devtool.js.map +1 -0
- package/dist/commonjs/endpoints.d.ts +35 -0
- package/dist/commonjs/endpoints.d.ts.map +1 -0
- package/dist/commonjs/endpoints.js +80 -0
- package/dist/commonjs/endpoints.js.map +1 -0
- package/dist/commonjs/framework.d.ts +81 -0
- package/dist/commonjs/framework.d.ts.map +1 -0
- package/dist/commonjs/framework.js +284 -0
- package/dist/commonjs/framework.js.map +1 -0
- package/dist/commonjs/helperTypes.d.ts +76 -0
- package/dist/commonjs/helperTypes.d.ts.map +1 -0
- package/dist/commonjs/helperTypes.js +3 -0
- package/dist/commonjs/helperTypes.js.map +1 -0
- package/dist/commonjs/index.d.ts +614 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +677 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/infiniteQuery.d.ts +26 -0
- package/dist/commonjs/infiniteQuery.d.ts.map +1 -0
- package/dist/commonjs/infiniteQuery.js +438 -0
- package/dist/commonjs/infiniteQuery.js.map +1 -0
- package/dist/commonjs/instaml.d.ts +18 -0
- package/dist/commonjs/instaml.d.ts.map +1 -0
- package/dist/commonjs/instaml.js +584 -0
- package/dist/commonjs/instaml.js.map +1 -0
- package/dist/commonjs/instaql.d.ts +13 -0
- package/dist/commonjs/instaql.d.ts.map +1 -0
- package/dist/commonjs/instaql.js +670 -0
- package/dist/commonjs/instaql.js.map +1 -0
- package/dist/commonjs/instatx.d.ts +128 -0
- package/dist/commonjs/instatx.d.ts.map +1 -0
- package/dist/commonjs/instatx.js +102 -0
- package/dist/commonjs/instatx.js.map +1 -0
- package/dist/commonjs/model/instaqlResult.d.ts +8 -0
- package/dist/commonjs/model/instaqlResult.d.ts.map +1 -0
- package/dist/commonjs/model/instaqlResult.js +28 -0
- package/dist/commonjs/model/instaqlResult.js.map +1 -0
- package/dist/commonjs/notifyScope.d.ts +32 -0
- package/dist/commonjs/notifyScope.d.ts.map +1 -0
- package/dist/commonjs/notifyScope.js +306 -0
- package/dist/commonjs/notifyScope.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parseSchemaFromJSON.d.ts +3 -0
- package/dist/commonjs/parseSchemaFromJSON.d.ts.map +1 -0
- package/dist/commonjs/parseSchemaFromJSON.js +147 -0
- package/dist/commonjs/parseSchemaFromJSON.js.map +1 -0
- package/dist/commonjs/presence.d.ts +51 -0
- package/dist/commonjs/presence.d.ts.map +1 -0
- package/dist/commonjs/presence.js +55 -0
- package/dist/commonjs/presence.js.map +1 -0
- package/dist/commonjs/presenceTypes.d.ts +10 -0
- package/dist/commonjs/presenceTypes.d.ts.map +1 -0
- package/dist/commonjs/presenceTypes.js +5 -0
- package/dist/commonjs/presenceTypes.js.map +1 -0
- package/dist/commonjs/queryTypes.d.ts +272 -0
- package/dist/commonjs/queryTypes.d.ts.map +1 -0
- package/dist/commonjs/queryTypes.js +5 -0
- package/dist/commonjs/queryTypes.js.map +1 -0
- package/dist/commonjs/queryValidation.d.ts +6 -0
- package/dist/commonjs/queryValidation.d.ts.map +1 -0
- package/dist/commonjs/queryValidation.js +293 -0
- package/dist/commonjs/queryValidation.js.map +1 -0
- package/dist/commonjs/reactorTypes.d.ts +30 -0
- package/dist/commonjs/reactorTypes.d.ts.map +1 -0
- package/dist/commonjs/reactorTypes.js +3 -0
- package/dist/commonjs/reactorTypes.js.map +1 -0
- package/dist/commonjs/routeHandlerProtocol.d.ts +20 -0
- package/dist/commonjs/routeHandlerProtocol.d.ts.map +1 -0
- package/dist/commonjs/routeHandlerProtocol.js +3 -0
- package/dist/commonjs/routeHandlerProtocol.js.map +1 -0
- package/dist/commonjs/rulesTypes.d.ts +86 -0
- package/dist/commonjs/rulesTypes.d.ts.map +1 -0
- package/dist/commonjs/rulesTypes.js +3 -0
- package/dist/commonjs/rulesTypes.js.map +1 -0
- package/dist/commonjs/sanityCheckQueries.d.ts +19 -0
- package/dist/commonjs/sanityCheckQueries.d.ts.map +1 -0
- package/dist/commonjs/sanityCheckQueries.js +156 -0
- package/dist/commonjs/sanityCheckQueries.js.map +1 -0
- package/dist/commonjs/schema.d.ts +73 -0
- package/dist/commonjs/schema.d.ts.map +1 -0
- package/dist/commonjs/schema.js +132 -0
- package/dist/commonjs/schema.js.map +1 -0
- package/dist/commonjs/schemaTypes.d.ts +245 -0
- package/dist/commonjs/schemaTypes.d.ts.map +1 -0
- package/dist/commonjs/schemaTypes.js +116 -0
- package/dist/commonjs/schemaTypes.js.map +1 -0
- package/dist/commonjs/store.d.ts +90 -0
- package/dist/commonjs/store.d.ts.map +1 -0
- package/dist/commonjs/store.js +745 -0
- package/dist/commonjs/store.js.map +1 -0
- package/dist/commonjs/transactionValidation.d.ts +8 -0
- package/dist/commonjs/transactionValidation.d.ts.map +1 -0
- package/dist/commonjs/transactionValidation.js +137 -0
- package/dist/commonjs/transactionValidation.js.map +1 -0
- package/dist/commonjs/utils/Deferred.d.ts +9 -0
- package/dist/commonjs/utils/Deferred.d.ts.map +1 -0
- package/dist/commonjs/utils/Deferred.js +22 -0
- package/dist/commonjs/utils/Deferred.js.map +1 -0
- package/dist/commonjs/utils/PersistedObject.d.ts +81 -0
- package/dist/commonjs/utils/PersistedObject.d.ts.map +1 -0
- package/dist/commonjs/utils/PersistedObject.js +469 -0
- package/dist/commonjs/utils/PersistedObject.js.map +1 -0
- package/dist/commonjs/utils/dates.d.ts +2 -0
- package/dist/commonjs/utils/dates.d.ts.map +1 -0
- package/dist/commonjs/utils/dates.js +215 -0
- package/dist/commonjs/utils/dates.js.map +1 -0
- package/dist/commonjs/utils/error.d.ts +3 -0
- package/dist/commonjs/utils/error.d.ts.map +1 -0
- package/dist/commonjs/utils/error.js +13 -0
- package/dist/commonjs/utils/error.js.map +1 -0
- package/dist/commonjs/utils/fetch.d.ts +126 -0
- package/dist/commonjs/utils/fetch.d.ts.map +1 -0
- package/dist/commonjs/utils/fetch.js +37 -0
- package/dist/commonjs/utils/fetch.js.map +1 -0
- package/dist/commonjs/utils/flags.d.ts +5 -0
- package/dist/commonjs/utils/flags.d.ts.map +1 -0
- package/dist/commonjs/utils/flags.js +16 -0
- package/dist/commonjs/utils/flags.js.map +1 -0
- package/dist/commonjs/utils/id.d.ts +4 -0
- package/dist/commonjs/utils/id.d.ts.map +1 -0
- package/dist/commonjs/utils/id.js +29 -0
- package/dist/commonjs/utils/id.js.map +1 -0
- package/dist/commonjs/utils/linkIndex.d.ts +8 -0
- package/dist/commonjs/utils/linkIndex.d.ts.map +1 -0
- package/dist/commonjs/utils/linkIndex.js +21 -0
- package/dist/commonjs/utils/linkIndex.js.map +1 -0
- package/dist/commonjs/utils/log.d.ts +7 -0
- package/dist/commonjs/utils/log.d.ts.map +1 -0
- package/dist/commonjs/utils/log.js +17 -0
- package/dist/commonjs/utils/log.js.map +1 -0
- package/dist/commonjs/utils/object.d.ts +17 -0
- package/dist/commonjs/utils/object.d.ts.map +1 -0
- package/dist/commonjs/utils/object.js +157 -0
- package/dist/commonjs/utils/object.js.map +1 -0
- package/dist/commonjs/utils/pgtime.d.ts +198 -0
- package/dist/commonjs/utils/pgtime.d.ts.map +1 -0
- package/dist/commonjs/utils/pgtime.js +201 -0
- package/dist/commonjs/utils/pgtime.js.map +1 -0
- package/dist/commonjs/utils/pick.d.ts +2 -0
- package/dist/commonjs/utils/pick.d.ts.map +1 -0
- package/dist/commonjs/utils/pick.js +13 -0
- package/dist/commonjs/utils/pick.js.map +1 -0
- package/dist/commonjs/utils/strings.d.ts +2 -0
- package/dist/commonjs/utils/strings.d.ts.map +1 -0
- package/dist/commonjs/utils/strings.js +19 -0
- package/dist/commonjs/utils/strings.js.map +1 -0
- package/dist/commonjs/utils/weakHash.d.ts +16 -0
- package/dist/commonjs/utils/weakHash.d.ts.map +1 -0
- package/dist/commonjs/utils/weakHash.js +75 -0
- package/dist/commonjs/utils/weakHash.js.map +1 -0
- package/dist/commonjs/utils/weakHashLegacy.d.ts +8 -0
- package/dist/commonjs/utils/weakHashLegacy.d.ts.map +1 -0
- package/dist/commonjs/utils/weakHashLegacy.js +76 -0
- package/dist/commonjs/utils/weakHashLegacy.js.map +1 -0
- package/dist/commonjs/version.d.ts +3 -0
- package/dist/commonjs/version.d.ts.map +1 -0
- package/dist/commonjs/version.js +5 -0
- package/dist/commonjs/version.js.map +1 -0
- package/dist/commonjs/warningToggle.d.ts +3 -0
- package/dist/commonjs/warningToggle.d.ts.map +1 -0
- package/dist/commonjs/warningToggle.js +9 -0
- package/dist/commonjs/warningToggle.js.map +1 -0
- package/dist/esm/Connection.d.ts +93 -0
- package/dist/esm/Connection.d.ts.map +1 -0
- package/dist/esm/Connection.js +189 -0
- package/dist/esm/Connection.js.map +1 -0
- package/dist/esm/InMemoryStorage.d.ts +11 -0
- package/dist/esm/InMemoryStorage.d.ts.map +1 -0
- package/dist/esm/InMemoryStorage.js +26 -0
- package/dist/esm/InMemoryStorage.js.map +1 -0
- package/dist/esm/IndexedDBStorage.d.ts +18 -0
- package/dist/esm/IndexedDBStorage.d.ts.map +1 -0
- package/dist/esm/IndexedDBStorage.js +338 -0
- package/dist/esm/IndexedDBStorage.js.map +1 -0
- package/dist/esm/InstantError.d.ts +7 -0
- package/dist/esm/InstantError.d.ts.map +1 -0
- package/dist/esm/InstantError.js +24 -0
- package/dist/esm/InstantError.js.map +1 -0
- package/dist/esm/Reactor.d.ts +445 -0
- package/dist/esm/Reactor.d.ts.map +1 -0
- package/dist/esm/Reactor.js +2431 -0
- package/dist/esm/Reactor.js.map +1 -0
- package/dist/esm/StorageAPI.d.ts +40 -0
- package/dist/esm/StorageAPI.d.ts.map +1 -0
- package/dist/esm/StorageAPI.js +75 -0
- package/dist/esm/StorageAPI.js.map +1 -0
- package/dist/esm/Stream.d.ts +121 -0
- package/dist/esm/Stream.d.ts.map +1 -0
- package/dist/esm/Stream.js +812 -0
- package/dist/esm/Stream.js.map +1 -0
- package/dist/esm/SyncTable.d.ts +145 -0
- package/dist/esm/SyncTable.d.ts.map +1 -0
- package/dist/esm/SyncTable.js +524 -0
- package/dist/esm/SyncTable.js.map +1 -0
- package/dist/esm/WindowNetworkListener.d.ts +5 -0
- package/dist/esm/WindowNetworkListener.d.ts.map +1 -0
- package/dist/esm/WindowNetworkListener.js +20 -0
- package/dist/esm/WindowNetworkListener.js.map +1 -0
- package/dist/esm/__types__/fieldsTypeTest.d.ts +2 -0
- package/dist/esm/__types__/fieldsTypeTest.d.ts.map +1 -0
- package/dist/esm/__types__/fieldsTypeTest.js +66 -0
- package/dist/esm/__types__/fieldsTypeTest.js.map +1 -0
- package/dist/esm/__types__/typeUtils.d.ts +20 -0
- package/dist/esm/__types__/typeUtils.d.ts.map +1 -0
- package/dist/esm/__types__/typeUtils.js +4 -0
- package/dist/esm/__types__/typeUtils.js.map +1 -0
- package/dist/esm/__types__/useDatesTypeTest.d.ts +2 -0
- package/dist/esm/__types__/useDatesTypeTest.d.ts.map +1 -0
- package/dist/esm/__types__/useDatesTypeTest.js +53 -0
- package/dist/esm/__types__/useDatesTypeTest.js.map +1 -0
- package/dist/esm/attrTypes.d.ts +26 -0
- package/dist/esm/attrTypes.d.ts.map +1 -0
- package/dist/esm/attrTypes.js +2 -0
- package/dist/esm/attrTypes.js.map +1 -0
- package/dist/esm/authAPI.d.ts +65 -0
- package/dist/esm/authAPI.d.ts.map +1 -0
- package/dist/esm/authAPI.js +104 -0
- package/dist/esm/authAPI.js.map +1 -0
- package/dist/esm/clientTypes.d.ts +41 -0
- package/dist/esm/clientTypes.d.ts.map +1 -0
- package/dist/esm/clientTypes.js +2 -0
- package/dist/esm/clientTypes.js.map +1 -0
- package/dist/esm/coreTypes.d.ts +34 -0
- package/dist/esm/coreTypes.d.ts.map +1 -0
- package/dist/esm/coreTypes.js +2 -0
- package/dist/esm/coreTypes.js.map +1 -0
- package/dist/esm/createRouteHandler.d.ts +8 -0
- package/dist/esm/createRouteHandler.d.ts.map +1 -0
- package/dist/esm/createRouteHandler.js +52 -0
- package/dist/esm/createRouteHandler.js.map +1 -0
- package/dist/esm/datalog.d.ts +8 -0
- package/dist/esm/datalog.d.ts.map +1 -0
- package/dist/esm/datalog.js +100 -0
- package/dist/esm/datalog.js.map +1 -0
- package/dist/esm/devtool.d.ts +4 -0
- package/dist/esm/devtool.d.ts.map +1 -0
- package/dist/esm/devtool.js +154 -0
- package/dist/esm/devtool.js.map +1 -0
- package/dist/esm/endpoints.d.ts +35 -0
- package/dist/esm/endpoints.d.ts.map +1 -0
- package/dist/esm/endpoints.js +73 -0
- package/dist/esm/endpoints.js.map +1 -0
- package/dist/esm/framework.d.ts +81 -0
- package/dist/esm/framework.d.ts.map +1 -0
- package/dist/esm/framework.js +244 -0
- package/dist/esm/framework.js.map +1 -0
- package/dist/esm/helperTypes.d.ts +76 -0
- package/dist/esm/helperTypes.d.ts.map +1 -0
- package/dist/esm/helperTypes.js +2 -0
- package/dist/esm/helperTypes.js.map +1 -0
- package/dist/esm/index.d.ts +614 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +655 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/infiniteQuery.d.ts +26 -0
- package/dist/esm/infiniteQuery.d.ts.map +1 -0
- package/dist/esm/infiniteQuery.js +433 -0
- package/dist/esm/infiniteQuery.js.map +1 -0
- package/dist/esm/instaml.d.ts +18 -0
- package/dist/esm/instaml.d.ts.map +1 -0
- package/dist/esm/instaml.js +577 -0
- package/dist/esm/instaml.js.map +1 -0
- package/dist/esm/instaql.d.ts +13 -0
- package/dist/esm/instaql.d.ts.map +1 -0
- package/dist/esm/instaql.js +633 -0
- package/dist/esm/instaql.js.map +1 -0
- package/dist/esm/instatx.d.ts +128 -0
- package/dist/esm/instatx.d.ts.map +1 -0
- package/dist/esm/instatx.js +94 -0
- package/dist/esm/instatx.js.map +1 -0
- package/dist/esm/model/instaqlResult.d.ts +8 -0
- package/dist/esm/model/instaqlResult.d.ts.map +1 -0
- package/dist/esm/model/instaqlResult.js +25 -0
- package/dist/esm/model/instaqlResult.js.map +1 -0
- package/dist/esm/notifyScope.d.ts +32 -0
- package/dist/esm/notifyScope.d.ts.map +1 -0
- package/dist/esm/notifyScope.js +300 -0
- package/dist/esm/notifyScope.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parseSchemaFromJSON.d.ts +3 -0
- package/dist/esm/parseSchemaFromJSON.d.ts.map +1 -0
- package/dist/esm/parseSchemaFromJSON.js +143 -0
- package/dist/esm/parseSchemaFromJSON.js.map +1 -0
- package/dist/esm/presence.d.ts +51 -0
- package/dist/esm/presence.d.ts.map +1 -0
- package/dist/esm/presence.js +51 -0
- package/dist/esm/presence.js.map +1 -0
- package/dist/esm/presenceTypes.d.ts +10 -0
- package/dist/esm/presenceTypes.d.ts.map +1 -0
- package/dist/esm/presenceTypes.js +4 -0
- package/dist/esm/presenceTypes.js.map +1 -0
- package/dist/esm/queryTypes.d.ts +272 -0
- package/dist/esm/queryTypes.d.ts.map +1 -0
- package/dist/esm/queryTypes.js +4 -0
- package/dist/esm/queryTypes.js.map +1 -0
- package/dist/esm/queryValidation.d.ts +6 -0
- package/dist/esm/queryValidation.d.ts.map +1 -0
- package/dist/esm/queryValidation.js +288 -0
- package/dist/esm/queryValidation.js.map +1 -0
- package/dist/esm/reactorTypes.d.ts +30 -0
- package/dist/esm/reactorTypes.d.ts.map +1 -0
- package/dist/esm/reactorTypes.js +2 -0
- package/dist/esm/reactorTypes.js.map +1 -0
- package/dist/esm/routeHandlerProtocol.d.ts +20 -0
- package/dist/esm/routeHandlerProtocol.d.ts.map +1 -0
- package/dist/esm/routeHandlerProtocol.js +2 -0
- package/dist/esm/routeHandlerProtocol.js.map +1 -0
- package/dist/esm/rulesTypes.d.ts +86 -0
- package/dist/esm/rulesTypes.d.ts.map +1 -0
- package/dist/esm/rulesTypes.js +2 -0
- package/dist/esm/rulesTypes.js.map +1 -0
- package/dist/esm/sanityCheckQueries.d.ts +19 -0
- package/dist/esm/sanityCheckQueries.d.ts.map +1 -0
- package/dist/esm/sanityCheckQueries.js +153 -0
- package/dist/esm/sanityCheckQueries.js.map +1 -0
- package/dist/esm/schema.d.ts +73 -0
- package/dist/esm/schema.d.ts.map +1 -0
- package/dist/esm/schema.js +129 -0
- package/dist/esm/schema.js.map +1 -0
- package/dist/esm/schemaTypes.d.ts +245 -0
- package/dist/esm/schemaTypes.d.ts.map +1 -0
- package/dist/esm/schemaTypes.js +107 -0
- package/dist/esm/schemaTypes.js.map +1 -0
- package/dist/esm/store.d.ts +90 -0
- package/dist/esm/store.d.ts.map +1 -0
- package/dist/esm/store.js +723 -0
- package/dist/esm/store.js.map +1 -0
- package/dist/esm/transactionValidation.d.ts +8 -0
- package/dist/esm/transactionValidation.d.ts.map +1 -0
- package/dist/esm/transactionValidation.js +131 -0
- package/dist/esm/transactionValidation.js.map +1 -0
- package/dist/esm/utils/Deferred.d.ts +9 -0
- package/dist/esm/utils/Deferred.d.ts.map +1 -0
- package/dist/esm/utils/Deferred.js +18 -0
- package/dist/esm/utils/Deferred.js.map +1 -0
- package/dist/esm/utils/PersistedObject.d.ts +81 -0
- package/dist/esm/utils/PersistedObject.d.ts.map +1 -0
- package/dist/esm/utils/PersistedObject.js +464 -0
- package/dist/esm/utils/PersistedObject.js.map +1 -0
- package/dist/esm/utils/dates.d.ts +2 -0
- package/dist/esm/utils/dates.d.ts.map +1 -0
- package/dist/esm/utils/dates.js +212 -0
- package/dist/esm/utils/dates.js.map +1 -0
- package/dist/esm/utils/error.d.ts +3 -0
- package/dist/esm/utils/error.d.ts.map +1 -0
- package/dist/esm/utils/error.js +9 -0
- package/dist/esm/utils/error.js.map +1 -0
- package/dist/esm/utils/fetch.d.ts +126 -0
- package/dist/esm/utils/fetch.d.ts.map +1 -0
- package/dist/esm/utils/fetch.js +32 -0
- package/dist/esm/utils/fetch.js.map +1 -0
- package/dist/esm/utils/flags.d.ts +5 -0
- package/dist/esm/utils/flags.d.ts.map +1 -0
- package/dist/esm/utils/flags.js +11 -0
- package/dist/esm/utils/flags.js.map +1 -0
- package/dist/esm/utils/id.d.ts +4 -0
- package/dist/esm/utils/id.d.ts.map +1 -0
- package/dist/esm/utils/id.js +26 -0
- package/dist/esm/utils/id.js.map +1 -0
- package/dist/esm/utils/linkIndex.d.ts +8 -0
- package/dist/esm/utils/linkIndex.d.ts.map +1 -0
- package/dist/esm/utils/linkIndex.js +18 -0
- package/dist/esm/utils/linkIndex.js.map +1 -0
- package/dist/esm/utils/log.d.ts +7 -0
- package/dist/esm/utils/log.d.ts.map +1 -0
- package/dist/esm/utils/log.js +14 -0
- package/dist/esm/utils/log.js.map +1 -0
- package/dist/esm/utils/object.d.ts +17 -0
- package/dist/esm/utils/object.d.ts.map +1 -0
- package/dist/esm/utils/object.js +144 -0
- package/dist/esm/utils/object.js.map +1 -0
- package/dist/esm/utils/pgtime.d.ts +198 -0
- package/dist/esm/utils/pgtime.d.ts.map +1 -0
- package/dist/esm/utils/pgtime.js +198 -0
- package/dist/esm/utils/pgtime.js.map +1 -0
- package/dist/esm/utils/pick.d.ts +2 -0
- package/dist/esm/utils/pick.d.ts.map +1 -0
- package/dist/esm/utils/pick.js +10 -0
- package/dist/esm/utils/pick.js.map +1 -0
- package/dist/esm/utils/strings.d.ts +2 -0
- package/dist/esm/utils/strings.d.ts.map +1 -0
- package/dist/esm/utils/strings.js +16 -0
- package/dist/esm/utils/strings.js.map +1 -0
- package/dist/esm/utils/weakHash.d.ts +16 -0
- package/dist/esm/utils/weakHash.d.ts.map +1 -0
- package/dist/esm/utils/weakHash.js +72 -0
- package/dist/esm/utils/weakHash.js.map +1 -0
- package/dist/esm/utils/weakHashLegacy.d.ts +8 -0
- package/dist/esm/utils/weakHashLegacy.d.ts.map +1 -0
- package/dist/esm/utils/weakHashLegacy.js +73 -0
- package/dist/esm/utils/weakHashLegacy.js.map +1 -0
- package/dist/esm/version.d.ts +3 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/esm/warningToggle.d.ts +3 -0
- package/dist/esm/warningToggle.d.ts.map +1 -0
- package/dist/esm/warningToggle.js +5 -0
- package/dist/esm/warningToggle.js.map +1 -0
- package/dist/standalone/index.js +8740 -0
- package/dist/standalone/index.umd.cjs +7 -0
- package/package.json +81 -3
- package/src/Connection.ts +277 -0
- package/src/InMemoryStorage.ts +34 -0
- package/src/IndexedDBStorage.ts +387 -0
- package/src/InstantError.ts +28 -0
- package/src/Reactor.js +2921 -0
- package/src/StorageAPI.ts +156 -0
- package/src/Stream.ts +1164 -0
- package/src/SyncTable.ts +919 -0
- package/src/WindowNetworkListener.js +19 -0
- package/src/__types__/fieldsTypeTest.ts +113 -0
- package/src/__types__/typeUtils.ts +39 -0
- package/src/__types__/useDatesTypeTest.ts +69 -0
- package/src/attrTypes.ts +29 -0
- package/src/authAPI.ts +205 -0
- package/src/clientTypes.ts +28 -0
- package/src/coreTypes.ts +58 -0
- package/src/createRouteHandler.ts +66 -0
- package/src/datalog.js +116 -0
- package/src/devtool.ts +186 -0
- package/src/endpoints.ts +101 -0
- package/src/framework.ts +395 -0
- package/src/helperTypes.ts +115 -0
- package/src/index.ts +1283 -0
- package/src/infiniteQuery.ts +602 -0
- package/src/instaml.ts +714 -0
- package/src/instaql.ts +952 -0
- package/src/instatx.ts +265 -0
- package/src/model/instaqlResult.js +25 -0
- package/src/notifyScope.ts +343 -0
- package/src/parseSchemaFromJSON.ts +176 -0
- package/src/presence.ts +123 -0
- package/src/presenceTypes.ts +19 -0
- package/src/queryTypes.ts +721 -0
- package/src/queryValidation.ts +535 -0
- package/src/reactorTypes.ts +33 -0
- package/src/routeHandlerProtocol.ts +24 -0
- package/src/rulesTypes.ts +122 -0
- package/src/sanityCheckQueries.ts +189 -0
- package/src/schema.ts +194 -0
- package/src/schemaTypes.ts +642 -0
- package/src/store.ts +949 -0
- package/src/transactionValidation.ts +204 -0
- package/src/utils/Deferred.ts +20 -0
- package/src/utils/PersistedObject.ts +589 -0
- package/src/utils/dates.ts +258 -0
- package/src/utils/error.ts +9 -0
- package/src/utils/fetch.ts +129 -0
- package/src/utils/flags.ts +14 -0
- package/src/utils/id.ts +28 -0
- package/src/utils/linkIndex.ts +33 -0
- package/src/utils/log.ts +23 -0
- package/src/utils/object.js +176 -0
- package/src/utils/pgtime.ts +199 -0
- package/src/utils/pick.js +9 -0
- package/src/utils/strings.ts +19 -0
- package/src/utils/weakHash.ts +77 -0
- package/src/utils/weakHashLegacy.ts +75 -0
- package/src/version.ts +3 -0
- package/src/warningToggle.ts +5 -0
- package/tsconfig.cjs.dev.json +15 -0
- package/tsconfig.dev.json +14 -0
- package/tsconfig.json +13 -0
- package/tsconfig.test.json +5 -0
- package/vite.config.ts +19 -0
- package/vitest.config.ts +75 -0
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
// Query
|
|
2
|
+
// -----
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
EntitiesDef,
|
|
6
|
+
IContainEntitiesAndLinks,
|
|
7
|
+
InstantGraph,
|
|
8
|
+
LinkAttrDef,
|
|
9
|
+
RuleParams,
|
|
10
|
+
ResolveAttrs,
|
|
11
|
+
ResolveEntityAttrs,
|
|
12
|
+
DataAttrDef,
|
|
13
|
+
AttrsDefs,
|
|
14
|
+
EntityDefFromSchema,
|
|
15
|
+
InstantUnknownSchemaDef,
|
|
16
|
+
} from './schemaTypes.ts';
|
|
17
|
+
|
|
18
|
+
type BuiltIn = Date | Function | Error | RegExp;
|
|
19
|
+
|
|
20
|
+
type Primitive = string | number | boolean | symbol | null | undefined;
|
|
21
|
+
|
|
22
|
+
export type Expand<T> = T extends BuiltIn | Primitive
|
|
23
|
+
? T
|
|
24
|
+
: T extends object
|
|
25
|
+
? T extends infer O
|
|
26
|
+
? { [K in keyof O]: Expand<O[K]> }
|
|
27
|
+
: never
|
|
28
|
+
: T;
|
|
29
|
+
|
|
30
|
+
// NonEmpty disallows {}, so that you must provide at least one field
|
|
31
|
+
export type NonEmpty<T> = {
|
|
32
|
+
[K in keyof T]-?: Required<Pick<T, K>>;
|
|
33
|
+
}[keyof T];
|
|
34
|
+
|
|
35
|
+
type BaseWhereClauseValueComplex<V> = {
|
|
36
|
+
/** @deprecated use `$in` instead of `in` */
|
|
37
|
+
in?: V[];
|
|
38
|
+
$in?: V[];
|
|
39
|
+
/** @deprecated use `$ne` instead of `not` */
|
|
40
|
+
$not?: V;
|
|
41
|
+
$ne?: V;
|
|
42
|
+
$gt?: V;
|
|
43
|
+
$lt?: V;
|
|
44
|
+
$gte?: V;
|
|
45
|
+
$lte?: V;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
49
|
+
|
|
50
|
+
type WhereClauseValueComplex<V, R, I> = BaseWhereClauseValueComplex<V> &
|
|
51
|
+
(IsAny<V> extends true
|
|
52
|
+
? {
|
|
53
|
+
$ilike?: string;
|
|
54
|
+
$like?: string;
|
|
55
|
+
$isNull?: boolean;
|
|
56
|
+
}
|
|
57
|
+
: (V extends string
|
|
58
|
+
? {
|
|
59
|
+
$like?: string;
|
|
60
|
+
}
|
|
61
|
+
: {}) &
|
|
62
|
+
(R extends false
|
|
63
|
+
? {
|
|
64
|
+
$isNull?: boolean;
|
|
65
|
+
}
|
|
66
|
+
: {}) &
|
|
67
|
+
(I extends true
|
|
68
|
+
? {
|
|
69
|
+
$ilike?: string;
|
|
70
|
+
}
|
|
71
|
+
: {}));
|
|
72
|
+
|
|
73
|
+
// Make type display better
|
|
74
|
+
type WhereClauseValue<
|
|
75
|
+
D extends DataAttrDef<string | number | boolean, boolean, boolean, boolean>,
|
|
76
|
+
> =
|
|
77
|
+
D extends DataAttrDef<infer V, infer R, infer I, boolean>
|
|
78
|
+
?
|
|
79
|
+
| (IsAny<V> extends true ? string | number | boolean : V)
|
|
80
|
+
| NonEmpty<WhereClauseValueComplex<V, R, I>>
|
|
81
|
+
: never;
|
|
82
|
+
|
|
83
|
+
type WhereClauseColumnEntries<
|
|
84
|
+
T extends {
|
|
85
|
+
[key: string]: DataAttrDef<any, boolean, boolean, boolean>;
|
|
86
|
+
},
|
|
87
|
+
> = {
|
|
88
|
+
[key in keyof T]?: WhereClauseValue<T[key]>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type WhereClauseComboEntries<
|
|
92
|
+
T extends Record<any, DataAttrDef<any, boolean, boolean, boolean>>,
|
|
93
|
+
> = {
|
|
94
|
+
or?:
|
|
95
|
+
| WhereClauses<T>[]
|
|
96
|
+
| WhereClauseValue<DataAttrDef<any, false, true, boolean>>;
|
|
97
|
+
and?:
|
|
98
|
+
| WhereClauses<T>[]
|
|
99
|
+
| WhereClauseValue<DataAttrDef<any, false, true, boolean>>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type WhereClauses<
|
|
103
|
+
T extends Record<any, DataAttrDef<any, boolean, boolean, boolean>>,
|
|
104
|
+
> = (
|
|
105
|
+
| WhereClauseComboEntries<T>
|
|
106
|
+
| (WhereClauseComboEntries<T> & WhereClauseColumnEntries<T>)
|
|
107
|
+
) & {
|
|
108
|
+
id?: WhereClauseValue<DataAttrDef<string, false, true, boolean>>;
|
|
109
|
+
[key: `${string}.${string}`]: WhereClauseValue<
|
|
110
|
+
DataAttrDef<any, false, true, boolean>
|
|
111
|
+
>;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A tuple representing a cursor.
|
|
116
|
+
* These should not be constructed manually. The current format
|
|
117
|
+
* is an implementation detail that may change in the future.
|
|
118
|
+
* Use the `endCursor` or `startCursor` from the PageInfoResponse as the
|
|
119
|
+
* `before` or `after` field in the query options.
|
|
120
|
+
*/
|
|
121
|
+
type Cursor = [string, string, any, number];
|
|
122
|
+
|
|
123
|
+
type Direction = 'asc' | 'desc';
|
|
124
|
+
|
|
125
|
+
type IndexedKeys<Attrs extends AttrsDefs> = {
|
|
126
|
+
[K in keyof Attrs]: Attrs[K] extends DataAttrDef<
|
|
127
|
+
any,
|
|
128
|
+
any,
|
|
129
|
+
infer IsIndexed,
|
|
130
|
+
boolean
|
|
131
|
+
>
|
|
132
|
+
? IsIndexed extends true
|
|
133
|
+
? K
|
|
134
|
+
: never
|
|
135
|
+
: never;
|
|
136
|
+
}[keyof Attrs];
|
|
137
|
+
|
|
138
|
+
export type Order<
|
|
139
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
140
|
+
EntityName extends keyof Schema['entities'],
|
|
141
|
+
> =
|
|
142
|
+
IndexedKeys<Schema['entities'][EntityName]['attrs']> extends never
|
|
143
|
+
? {
|
|
144
|
+
serverCreatedAt?: Direction;
|
|
145
|
+
}
|
|
146
|
+
: {
|
|
147
|
+
[K in IndexedKeys<Schema['entities'][EntityName]['attrs']>]?: Direction;
|
|
148
|
+
} & {
|
|
149
|
+
serverCreatedAt?: Direction;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
type $Option<
|
|
153
|
+
S extends IContainEntitiesAndLinks<any, any>,
|
|
154
|
+
K extends keyof S['entities'],
|
|
155
|
+
> = {
|
|
156
|
+
$?: {
|
|
157
|
+
where?: WhereClauses<EntityDefFromSchema<S, K>>;
|
|
158
|
+
order?: Order<S, K>;
|
|
159
|
+
limit?: number;
|
|
160
|
+
last?: number;
|
|
161
|
+
first?: number;
|
|
162
|
+
offset?: number;
|
|
163
|
+
after?: Cursor;
|
|
164
|
+
afterInclusive?: boolean;
|
|
165
|
+
before?: Cursor;
|
|
166
|
+
beforeInclusive?: boolean;
|
|
167
|
+
fields?: InstaQLFields<S, K>;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
type NamespaceVal =
|
|
172
|
+
| $Option<IContainEntitiesAndLinks<any, any>, keyof EntitiesDef>
|
|
173
|
+
| ($Option<IContainEntitiesAndLinks<any, any>, keyof EntitiesDef> & Subquery);
|
|
174
|
+
|
|
175
|
+
type Subquery = { [namespace: string]: NamespaceVal };
|
|
176
|
+
|
|
177
|
+
interface Query {
|
|
178
|
+
[namespace: string]: NamespaceVal;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
type InstantObject = {
|
|
182
|
+
id: string;
|
|
183
|
+
[prop: string]: any;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
type ResponseObject<K, Schema> = K extends keyof Schema
|
|
187
|
+
? { id: string } & Schema[K]
|
|
188
|
+
: InstantObject;
|
|
189
|
+
|
|
190
|
+
type IsEmptyObject<T> = T extends Record<string, never> ? true : false;
|
|
191
|
+
|
|
192
|
+
type ResponseOf<Q, Schema> = {
|
|
193
|
+
[K in keyof Q]: IsEmptyObject<Q[K]> extends true
|
|
194
|
+
? ResponseObject<K, Schema>[]
|
|
195
|
+
: (ResponseOf<Q[K], Schema> & ResponseObject<K, Schema>)[];
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
type Remove$<T> = T extends object
|
|
199
|
+
? { [K in keyof T as Exclude<K, '$'>]: Remove$<T[K]> }
|
|
200
|
+
: T;
|
|
201
|
+
|
|
202
|
+
type Remove$NonRecursive<T> = T extends object
|
|
203
|
+
? { [K in keyof T as Exclude<K, '$'>]: T[K] }
|
|
204
|
+
: T;
|
|
205
|
+
|
|
206
|
+
type QueryResponse<
|
|
207
|
+
Q,
|
|
208
|
+
Schema,
|
|
209
|
+
WithCardinalityInference extends boolean = false,
|
|
210
|
+
UseDates extends boolean = false,
|
|
211
|
+
> =
|
|
212
|
+
Schema extends InstantGraph<infer E, any>
|
|
213
|
+
? InstaQLQueryResult<E, Q, WithCardinalityInference, UseDates>
|
|
214
|
+
: ResponseOf<{ [K in keyof Q]: Remove$<Q[K]> }, Schema>;
|
|
215
|
+
|
|
216
|
+
type InstaQLResponse<Schema, Q, UseDates extends boolean = false> =
|
|
217
|
+
Schema extends IContainEntitiesAndLinks<any, any>
|
|
218
|
+
? Q extends InstaQLParams<Schema> | undefined
|
|
219
|
+
? InstaQLResult<Schema, Q, UseDates>
|
|
220
|
+
: never
|
|
221
|
+
: never;
|
|
222
|
+
|
|
223
|
+
type PageInfoResponse<T> = {
|
|
224
|
+
[K in keyof T]: {
|
|
225
|
+
startCursor: Cursor;
|
|
226
|
+
endCursor: Cursor;
|
|
227
|
+
hasNextPage: boolean;
|
|
228
|
+
hasPreviousPage: boolean;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* (XXX)
|
|
234
|
+
* https://github.com/microsoft/TypeScript/issues/26051
|
|
235
|
+
*
|
|
236
|
+
* TypeScript can permit extra keys when a generic extends a type.
|
|
237
|
+
*
|
|
238
|
+
* For some reason, it makes it possible to write a query like so:
|
|
239
|
+
*
|
|
240
|
+
* dummyQuery({
|
|
241
|
+
* users: {
|
|
242
|
+
* $: { where: { "foo": 1 } },
|
|
243
|
+
* posts: {
|
|
244
|
+
* $: { "far": {} }
|
|
245
|
+
* }
|
|
246
|
+
* }
|
|
247
|
+
*
|
|
248
|
+
* The problem: $: { "far": {} }
|
|
249
|
+
*
|
|
250
|
+
* This passes, when it should in reality fail. I don't know why
|
|
251
|
+
* adding `Exactly` fixes this, but it does.
|
|
252
|
+
*
|
|
253
|
+
* */
|
|
254
|
+
type Exactly<Parent, Child> = Parent & {
|
|
255
|
+
[K in keyof Child]: K extends keyof Parent ? Child[K] : never;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
// SafeLookup<T, ['A', 'B', number]> is like doing
|
|
259
|
+
// T['A']['B'][number], but it will merge with undefined if any
|
|
260
|
+
// of the intermediates are undefined
|
|
261
|
+
type SafeLookup<T, K extends readonly PropertyKey[]> = K extends [
|
|
262
|
+
infer First,
|
|
263
|
+
...infer Rest extends readonly PropertyKey[],
|
|
264
|
+
]
|
|
265
|
+
? First extends keyof NonNullable<T>
|
|
266
|
+
?
|
|
267
|
+
| SafeLookup<NonNullable<T>[First], Rest>
|
|
268
|
+
| (T extends null | undefined ? undefined : never)
|
|
269
|
+
: undefined
|
|
270
|
+
: T;
|
|
271
|
+
|
|
272
|
+
// ==========
|
|
273
|
+
// InstaQL helpers
|
|
274
|
+
|
|
275
|
+
type InstaQLEntitySubqueryResult<
|
|
276
|
+
Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
|
|
277
|
+
EntityName extends keyof Schema['entities'],
|
|
278
|
+
Query extends InstaQLEntitySubquery<Schema, EntityName> | undefined = {},
|
|
279
|
+
UseDates extends boolean = false,
|
|
280
|
+
> = {
|
|
281
|
+
[QueryPropName in keyof Query]: Schema['entities'][EntityName]['links'][QueryPropName] extends LinkAttrDef<
|
|
282
|
+
infer Cardinality,
|
|
283
|
+
infer LinkedEntityName
|
|
284
|
+
>
|
|
285
|
+
? LinkedEntityName extends keyof Schema['entities']
|
|
286
|
+
? Cardinality extends 'one'
|
|
287
|
+
?
|
|
288
|
+
| InstaQLEntity<
|
|
289
|
+
Schema,
|
|
290
|
+
LinkedEntityName,
|
|
291
|
+
Remove$NonRecursive<SafeLookup<Query, [QueryPropName]>>,
|
|
292
|
+
SafeLookup<Query, [QueryPropName, '$', 'fields']>,
|
|
293
|
+
UseDates
|
|
294
|
+
>
|
|
295
|
+
| undefined
|
|
296
|
+
: InstaQLEntity<
|
|
297
|
+
Schema,
|
|
298
|
+
LinkedEntityName,
|
|
299
|
+
Remove$NonRecursive<SafeLookup<Query, [QueryPropName]>>,
|
|
300
|
+
SafeLookup<Query, [QueryPropName, '$', 'fields']>,
|
|
301
|
+
UseDates
|
|
302
|
+
>[]
|
|
303
|
+
: never
|
|
304
|
+
: never;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
type InstaQLQueryEntityLinksResult<
|
|
308
|
+
Entities extends EntitiesDef,
|
|
309
|
+
EntityName extends keyof Entities,
|
|
310
|
+
Query extends {
|
|
311
|
+
[LinkAttrName in keyof Entities[EntityName]['links']]?: any;
|
|
312
|
+
},
|
|
313
|
+
WithCardinalityInference extends boolean,
|
|
314
|
+
UseDates extends boolean = false,
|
|
315
|
+
> = {
|
|
316
|
+
[QueryPropName in keyof Query]: Entities[EntityName]['links'][QueryPropName] extends LinkAttrDef<
|
|
317
|
+
infer Cardinality,
|
|
318
|
+
infer LinkedEntityName
|
|
319
|
+
>
|
|
320
|
+
? LinkedEntityName extends keyof Entities
|
|
321
|
+
? WithCardinalityInference extends true
|
|
322
|
+
? Cardinality extends 'one'
|
|
323
|
+
?
|
|
324
|
+
| InstaQLQueryEntityResult<
|
|
325
|
+
Entities,
|
|
326
|
+
LinkedEntityName,
|
|
327
|
+
Query[QueryPropName],
|
|
328
|
+
WithCardinalityInference,
|
|
329
|
+
UseDates
|
|
330
|
+
>
|
|
331
|
+
| undefined
|
|
332
|
+
: InstaQLQueryEntityResult<
|
|
333
|
+
Entities,
|
|
334
|
+
LinkedEntityName,
|
|
335
|
+
Query[QueryPropName],
|
|
336
|
+
WithCardinalityInference,
|
|
337
|
+
UseDates
|
|
338
|
+
>[]
|
|
339
|
+
: InstaQLQueryEntityResult<
|
|
340
|
+
Entities,
|
|
341
|
+
LinkedEntityName,
|
|
342
|
+
Query[QueryPropName],
|
|
343
|
+
WithCardinalityInference,
|
|
344
|
+
UseDates
|
|
345
|
+
>[]
|
|
346
|
+
: never
|
|
347
|
+
: never;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// Pick, but applies the pick to each union
|
|
351
|
+
type DistributePick<T, K extends string> = T extends any
|
|
352
|
+
? { [P in K]: P extends keyof T ? T[P] : never }
|
|
353
|
+
: never;
|
|
354
|
+
|
|
355
|
+
type InstaQLFields<
|
|
356
|
+
S extends IContainEntitiesAndLinks<any, any>,
|
|
357
|
+
K extends keyof S['entities'],
|
|
358
|
+
> = (Extract<keyof ResolveEntityAttrs<S['entities'][K]>, string> | 'id')[];
|
|
359
|
+
|
|
360
|
+
type ComputeAttrs<
|
|
361
|
+
AllAttrs,
|
|
362
|
+
Fields extends readonly string[] | undefined,
|
|
363
|
+
> = Fields extends readonly string[]
|
|
364
|
+
? DistributePick<AllAttrs, Exclude<Fields[number], 'id'>>
|
|
365
|
+
: AllAttrs;
|
|
366
|
+
|
|
367
|
+
type InstaQLEntity<
|
|
368
|
+
Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
|
|
369
|
+
EntityName extends keyof Schema['entities'],
|
|
370
|
+
Subquery extends InstaQLEntitySubquery<Schema, EntityName> | undefined = {},
|
|
371
|
+
Fields extends InstaQLFields<Schema, EntityName> | undefined = undefined,
|
|
372
|
+
UseDates extends boolean = false,
|
|
373
|
+
> = Expand<
|
|
374
|
+
{ id: string } & ComputeAttrs<
|
|
375
|
+
ResolveEntityAttrs<Schema['entities'][EntityName], UseDates>,
|
|
376
|
+
Fields
|
|
377
|
+
> &
|
|
378
|
+
InstaQLEntitySubqueryResult<Schema, EntityName, Subquery, UseDates>
|
|
379
|
+
>;
|
|
380
|
+
|
|
381
|
+
export type InstaQLQueryEntityResult<
|
|
382
|
+
Entities extends EntitiesDef,
|
|
383
|
+
EntityName extends keyof Entities,
|
|
384
|
+
Query extends {
|
|
385
|
+
[QueryPropName in keyof Entities[EntityName]['links']]?: any;
|
|
386
|
+
},
|
|
387
|
+
WithCardinalityInference extends boolean,
|
|
388
|
+
UseDates extends boolean,
|
|
389
|
+
> = { id: string } & ResolveAttrs<Entities, EntityName, UseDates> &
|
|
390
|
+
InstaQLQueryEntityLinksResult<
|
|
391
|
+
Entities,
|
|
392
|
+
EntityName,
|
|
393
|
+
Query,
|
|
394
|
+
WithCardinalityInference,
|
|
395
|
+
UseDates
|
|
396
|
+
>;
|
|
397
|
+
|
|
398
|
+
type InstaQLQueryResult<
|
|
399
|
+
Entities extends EntitiesDef,
|
|
400
|
+
Query,
|
|
401
|
+
WithCardinalityInference extends boolean,
|
|
402
|
+
UseDates extends boolean,
|
|
403
|
+
> = {
|
|
404
|
+
[QueryPropName in keyof Query]: QueryPropName extends keyof Entities
|
|
405
|
+
? InstaQLQueryEntityResult<
|
|
406
|
+
Entities,
|
|
407
|
+
QueryPropName,
|
|
408
|
+
Query[QueryPropName],
|
|
409
|
+
WithCardinalityInference,
|
|
410
|
+
UseDates
|
|
411
|
+
>[]
|
|
412
|
+
: never;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
type InstaQLResult<
|
|
416
|
+
Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
|
|
417
|
+
Query extends InstaQLParams<Schema> | undefined,
|
|
418
|
+
UseDates extends boolean = false,
|
|
419
|
+
> = Expand<{
|
|
420
|
+
[QueryPropName in keyof Query]: QueryPropName extends keyof Schema['entities']
|
|
421
|
+
? InstaQLEntity<
|
|
422
|
+
Schema,
|
|
423
|
+
QueryPropName,
|
|
424
|
+
Remove$NonRecursive<SafeLookup<Query, [QueryPropName]>>,
|
|
425
|
+
SafeLookup<Query, [QueryPropName, '$', 'fields']>,
|
|
426
|
+
UseDates
|
|
427
|
+
>[]
|
|
428
|
+
: never;
|
|
429
|
+
}>;
|
|
430
|
+
|
|
431
|
+
type InstaQLEntitySubquery<
|
|
432
|
+
Schema extends IContainEntitiesAndLinks<EntitiesDef, any>,
|
|
433
|
+
EntityName extends keyof Schema['entities'],
|
|
434
|
+
> = {
|
|
435
|
+
[QueryPropName in keyof Schema['entities'][EntityName]['links']]?:
|
|
436
|
+
| $Option<Schema, EntityName>
|
|
437
|
+
| ($Option<Schema, EntityName> &
|
|
438
|
+
InstaQLEntitySubquery<
|
|
439
|
+
Schema,
|
|
440
|
+
Schema['entities'][EntityName]['links'][QueryPropName]['entityName']
|
|
441
|
+
>);
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
type InstaQLQuerySubqueryParams<
|
|
445
|
+
S extends IContainEntitiesAndLinks<any, any>,
|
|
446
|
+
E extends keyof S['entities'],
|
|
447
|
+
> = {
|
|
448
|
+
[K in keyof S['entities'][E]['links']]?:
|
|
449
|
+
| $Option<S, S['entities'][E]['links'][K]['entityName']>
|
|
450
|
+
| ($Option<S, S['entities'][E]['links'][K]['entityName']> &
|
|
451
|
+
InstaQLQuerySubqueryParams<
|
|
452
|
+
S,
|
|
453
|
+
S['entities'][E]['links'][K]['entityName']
|
|
454
|
+
>);
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
type InstaQLParams<S extends IContainEntitiesAndLinks<any, any>> = {
|
|
458
|
+
[K in keyof S['entities']]?:
|
|
459
|
+
| $Option<S, K>
|
|
460
|
+
| ($Option<S, K> & InstaQLQuerySubqueryParams<S, K>);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* @deprecated
|
|
465
|
+
* `InstaQLQueryParams` is deprecated. Use `InstaQLParams` instead.
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* // Before
|
|
469
|
+
* const myQuery = {...} satisfies InstaQLQueryParams<Schema>
|
|
470
|
+
* // After
|
|
471
|
+
* const myQuery = {...} satisfies InstaQLParams<Schema>
|
|
472
|
+
*/
|
|
473
|
+
type InstaQLQueryParams<S extends IContainEntitiesAndLinks<any, any>> =
|
|
474
|
+
InstaQLParams<S>;
|
|
475
|
+
|
|
476
|
+
type InstaQLOptions = {
|
|
477
|
+
ruleParams: RuleParams;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// Start of new types
|
|
481
|
+
|
|
482
|
+
type ValidQueryObject<
|
|
483
|
+
T extends Record<string, any>,
|
|
484
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
485
|
+
EntityName extends keyof Schema['entities'],
|
|
486
|
+
TopLevel extends boolean,
|
|
487
|
+
> = keyof T extends keyof Schema['entities'][EntityName]['links'] | '$'
|
|
488
|
+
? {
|
|
489
|
+
[K in keyof Schema['entities'][EntityName]['links']]?: ValidQueryObject<
|
|
490
|
+
T[K],
|
|
491
|
+
Schema,
|
|
492
|
+
Schema['entities'][EntityName]['links'][K]['entityName'],
|
|
493
|
+
false
|
|
494
|
+
>;
|
|
495
|
+
} & {
|
|
496
|
+
$?: ValidDollarSignQuery<T['$'], Schema, EntityName, TopLevel>;
|
|
497
|
+
}
|
|
498
|
+
: never;
|
|
499
|
+
|
|
500
|
+
type PaginationKeys =
|
|
501
|
+
| 'limit'
|
|
502
|
+
| 'last'
|
|
503
|
+
| 'first'
|
|
504
|
+
| 'offset'
|
|
505
|
+
| 'after'
|
|
506
|
+
| 'afterInclusive'
|
|
507
|
+
| 'before'
|
|
508
|
+
| 'beforeInclusive';
|
|
509
|
+
|
|
510
|
+
type AllowedDollarSignKeys<TopLevel extends boolean> = TopLevel extends true
|
|
511
|
+
? PaginationKeys | 'where' | 'fields' | 'order'
|
|
512
|
+
: 'where' | 'fields' | 'order' | 'limit';
|
|
513
|
+
|
|
514
|
+
type ValidFieldNames<
|
|
515
|
+
S extends IContainEntitiesAndLinks<any, any>,
|
|
516
|
+
EntityName extends keyof S['entities'],
|
|
517
|
+
> = Extract<keyof ResolveEntityAttrs<S['entities'][EntityName]>, string> | 'id';
|
|
518
|
+
|
|
519
|
+
type ValidDollarSignQuery<
|
|
520
|
+
Input extends { [key: string]: any },
|
|
521
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
522
|
+
EntityName extends keyof Schema['entities'],
|
|
523
|
+
TopLevel extends boolean,
|
|
524
|
+
> =
|
|
525
|
+
keyof Input extends AllowedDollarSignKeys<TopLevel>
|
|
526
|
+
? {
|
|
527
|
+
where?: ValidWhereObject<Input['where'], Schema, EntityName>;
|
|
528
|
+
fields?: ValidFieldNames<Schema, EntityName>[];
|
|
529
|
+
order?: Order<Schema, EntityName>;
|
|
530
|
+
limit?: number;
|
|
531
|
+
} & (TopLevel extends true
|
|
532
|
+
? {
|
|
533
|
+
last?: number;
|
|
534
|
+
first?: number;
|
|
535
|
+
offset?: number;
|
|
536
|
+
after?: Cursor;
|
|
537
|
+
afterInclusive?: boolean;
|
|
538
|
+
before?: Cursor;
|
|
539
|
+
beforeInclusive?: boolean;
|
|
540
|
+
}
|
|
541
|
+
: {})
|
|
542
|
+
: never;
|
|
543
|
+
|
|
544
|
+
type StringifiableKey<T> = Extract<T, string | number | bigint | boolean>;
|
|
545
|
+
|
|
546
|
+
type ValidWhereNestedPath<
|
|
547
|
+
T,
|
|
548
|
+
K extends string | number | symbol,
|
|
549
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
550
|
+
> = T extends object
|
|
551
|
+
? K extends keyof T
|
|
552
|
+
? K // Allow link names as valid paths (they'll default to id)
|
|
553
|
+
: K extends `${infer K0}.${infer KR}`
|
|
554
|
+
? K0 extends keyof T
|
|
555
|
+
? T[K0] extends keyof Schema['entities']
|
|
556
|
+
? `${K0}.${
|
|
557
|
+
| ValidWhereNestedPath<
|
|
558
|
+
{
|
|
559
|
+
[K in keyof Schema['entities'][T[K0]]['links']]: Schema['entities'][T[K0]]['links'][K]['entityName'];
|
|
560
|
+
},
|
|
561
|
+
KR,
|
|
562
|
+
Schema
|
|
563
|
+
>
|
|
564
|
+
| StringifiableKey<keyof Schema['entities'][T[K0]]['attrs']>
|
|
565
|
+
| 'id'}`
|
|
566
|
+
: string & keyof T
|
|
567
|
+
: string & keyof T
|
|
568
|
+
: string & keyof T
|
|
569
|
+
: never;
|
|
570
|
+
|
|
571
|
+
type ValidDotPath<
|
|
572
|
+
Input extends string | number | symbol,
|
|
573
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
574
|
+
EntityName extends keyof Schema['entities'],
|
|
575
|
+
> = ValidWhereNestedPath<
|
|
576
|
+
{
|
|
577
|
+
[K in keyof Schema['entities'][EntityName]['links']]: Schema['entities'][EntityName]['links'][K]['entityName'];
|
|
578
|
+
},
|
|
579
|
+
Input,
|
|
580
|
+
Schema
|
|
581
|
+
>;
|
|
582
|
+
|
|
583
|
+
type WhereOperatorObject<Input, V, R, I> = keyof Input extends
|
|
584
|
+
| keyof BaseWhereClauseValueComplex<V>
|
|
585
|
+
| '$ilike'
|
|
586
|
+
| '$like'
|
|
587
|
+
| '$isNull'
|
|
588
|
+
? BaseWhereClauseValueComplex<V> &
|
|
589
|
+
(IsAny<V> extends true
|
|
590
|
+
? {
|
|
591
|
+
$ilike?: string;
|
|
592
|
+
$like?: string;
|
|
593
|
+
$isNull?: boolean;
|
|
594
|
+
}
|
|
595
|
+
: (V extends string
|
|
596
|
+
? {
|
|
597
|
+
$like?: string;
|
|
598
|
+
}
|
|
599
|
+
: {}) &
|
|
600
|
+
(R extends false
|
|
601
|
+
? {
|
|
602
|
+
$isNull?: boolean;
|
|
603
|
+
}
|
|
604
|
+
: {}) &
|
|
605
|
+
(I extends true
|
|
606
|
+
? {
|
|
607
|
+
$ilike?: string;
|
|
608
|
+
}
|
|
609
|
+
: {}))
|
|
610
|
+
: never;
|
|
611
|
+
|
|
612
|
+
type ValidWhereValue<
|
|
613
|
+
Input,
|
|
614
|
+
AttrDef extends DataAttrDef<any, any, any, boolean>,
|
|
615
|
+
> =
|
|
616
|
+
AttrDef extends DataAttrDef<infer V, infer R, infer I, boolean>
|
|
617
|
+
? Input extends V
|
|
618
|
+
? V
|
|
619
|
+
: NonEmpty<WhereOperatorObject<Input, V, R, I>>
|
|
620
|
+
: never;
|
|
621
|
+
|
|
622
|
+
type NoDistribute<T> = [T] extends [any] ? T : never;
|
|
623
|
+
|
|
624
|
+
type ValidWhereObject<
|
|
625
|
+
Input extends { [key: string]: any } | undefined,
|
|
626
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
627
|
+
EntityName extends keyof Schema['entities'],
|
|
628
|
+
> = Input extends undefined
|
|
629
|
+
? undefined
|
|
630
|
+
: keyof Input extends
|
|
631
|
+
| ValidDotPath<keyof Input, Schema, EntityName>
|
|
632
|
+
| keyof Schema['entities'][EntityName]['attrs']
|
|
633
|
+
| 'and'
|
|
634
|
+
| 'or'
|
|
635
|
+
| 'id'
|
|
636
|
+
? {
|
|
637
|
+
[K in ValidDotPath<keyof Input, Schema, EntityName>]?: ValidWhereValue<
|
|
638
|
+
Input[K],
|
|
639
|
+
ExtractAttrFromDotPath<K, Schema, EntityName>
|
|
640
|
+
>;
|
|
641
|
+
} & {
|
|
642
|
+
[K in keyof Schema['entities'][EntityName]['attrs']]?: ValidWhereValue<
|
|
643
|
+
Input[K],
|
|
644
|
+
Schema['entities'][EntityName]['attrs'][K]
|
|
645
|
+
>;
|
|
646
|
+
} & {
|
|
647
|
+
and?: Input extends {
|
|
648
|
+
and: Array<infer Item extends { [key: string]: any } | undefined>;
|
|
649
|
+
}
|
|
650
|
+
? ValidWhereObject<NoDistribute<Item>, Schema, EntityName>[]
|
|
651
|
+
: never;
|
|
652
|
+
or?: Input extends {
|
|
653
|
+
or: Array<infer Item extends { [key: string]: any } | undefined>;
|
|
654
|
+
}
|
|
655
|
+
? ValidWhereObject<NoDistribute<Item>, Schema, EntityName>[]
|
|
656
|
+
: never;
|
|
657
|
+
} & {
|
|
658
|
+
// Special case for id
|
|
659
|
+
id?: ValidWhereValue<
|
|
660
|
+
SafeLookup<Input, ['id']>,
|
|
661
|
+
DataAttrDef<string, false, false, boolean>
|
|
662
|
+
>;
|
|
663
|
+
}
|
|
664
|
+
: never;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Extracts the attribute definition from a valid dot path.
|
|
668
|
+
* Given a dot path like "user.posts.title", this will resolve to the type of the "title" attribute.
|
|
669
|
+
* If the path is just a link name (e.g., "posts"), it defaults to the id field.
|
|
670
|
+
* Returns DataAttrDef or never
|
|
671
|
+
*/
|
|
672
|
+
type ExtractAttrFromDotPath<
|
|
673
|
+
Path extends string | number | symbol,
|
|
674
|
+
Schema extends IContainEntitiesAndLinks<any, any>,
|
|
675
|
+
EntityName extends keyof Schema['entities'],
|
|
676
|
+
> = Path extends keyof Schema['entities'][EntityName]['attrs']
|
|
677
|
+
? Schema['entities'][EntityName]['attrs'][Path]
|
|
678
|
+
: Path extends 'id'
|
|
679
|
+
? DataAttrDef<string, false, false, boolean>
|
|
680
|
+
: Path extends `${infer LinkName}.${infer RestPath}`
|
|
681
|
+
? LinkName extends keyof Schema['entities'][EntityName]['links']
|
|
682
|
+
? ExtractAttrFromDotPath<
|
|
683
|
+
RestPath,
|
|
684
|
+
Schema,
|
|
685
|
+
Schema['entities'][EntityName]['links'][LinkName]['entityName']
|
|
686
|
+
>
|
|
687
|
+
: never
|
|
688
|
+
: Path extends keyof Schema['entities'][EntityName]['links']
|
|
689
|
+
? DataAttrDef<string, false, false, boolean>
|
|
690
|
+
: never;
|
|
691
|
+
|
|
692
|
+
type ValidQuery<
|
|
693
|
+
Q extends Record<string, any>,
|
|
694
|
+
S extends IContainEntitiesAndLinks<any, any>,
|
|
695
|
+
> = S extends InstantUnknownSchemaDef
|
|
696
|
+
? InstaQLParams<S>
|
|
697
|
+
: keyof Q extends keyof S['entities']
|
|
698
|
+
? {
|
|
699
|
+
[K in keyof S['entities']]?: ValidQueryObject<Q[K], S, K, true>;
|
|
700
|
+
}
|
|
701
|
+
: never;
|
|
702
|
+
|
|
703
|
+
export {
|
|
704
|
+
Query,
|
|
705
|
+
QueryResponse,
|
|
706
|
+
InstaQLResponse,
|
|
707
|
+
PageInfoResponse,
|
|
708
|
+
InstantObject,
|
|
709
|
+
Exactly,
|
|
710
|
+
Remove$,
|
|
711
|
+
ValidQuery,
|
|
712
|
+
InstaQLQueryResult,
|
|
713
|
+
InstaQLParams,
|
|
714
|
+
InstaQLOptions,
|
|
715
|
+
InstaQLEntitySubquery,
|
|
716
|
+
InstaQLEntity,
|
|
717
|
+
InstaQLResult,
|
|
718
|
+
InstaQLFields,
|
|
719
|
+
Cursor,
|
|
720
|
+
InstaQLQueryParams,
|
|
721
|
+
};
|