@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,576 @@
|
|
|
1
|
+
import { allMapValues, AttrsStoreClass, getAttrByFwdIdentName, getAttrByReverseIdentName, } from './store.js';
|
|
2
|
+
import { getOps, isLookup, parseLookup } from './instatx.js';
|
|
3
|
+
import { immutableRemoveUndefined } from './utils/object.js';
|
|
4
|
+
import { coerceToDate } from './utils/dates.js';
|
|
5
|
+
import uuid from './utils/id.js';
|
|
6
|
+
// Rewrites optimistic attrs with the attrs we get back from the server.
|
|
7
|
+
export function rewriteStep(attrMapping, txStep) {
|
|
8
|
+
const { attrIdMap, refSwapAttrIds } = attrMapping;
|
|
9
|
+
const rewritten = [];
|
|
10
|
+
for (const part of txStep) {
|
|
11
|
+
const newValue = attrIdMap[part];
|
|
12
|
+
if (newValue) {
|
|
13
|
+
// Rewrites attr id
|
|
14
|
+
rewritten.push(newValue);
|
|
15
|
+
}
|
|
16
|
+
else if (Array.isArray(part) && part.length == 2 && attrIdMap[part[0]]) {
|
|
17
|
+
// Rewrites attr id in lookups
|
|
18
|
+
const [aid, value] = part;
|
|
19
|
+
rewritten.push([attrIdMap[aid], value]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
rewritten.push(part);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const [action] = txStep;
|
|
26
|
+
if ((action === 'add-triple' || action === 'retract-triple') &&
|
|
27
|
+
refSwapAttrIds.has(txStep[2])) {
|
|
28
|
+
// Reverse links if the optimistic link attr is backwards
|
|
29
|
+
const tmp = rewritten[1];
|
|
30
|
+
rewritten[1] = rewritten[3];
|
|
31
|
+
rewritten[3] = tmp;
|
|
32
|
+
}
|
|
33
|
+
return rewritten;
|
|
34
|
+
}
|
|
35
|
+
function explodeLookupRef(eid) {
|
|
36
|
+
if (Array.isArray(eid)) {
|
|
37
|
+
return eid;
|
|
38
|
+
}
|
|
39
|
+
const entries = Object.entries(eid);
|
|
40
|
+
if (entries.length !== 1) {
|
|
41
|
+
throw new Error('lookup must be an object with a single unique attr and value.');
|
|
42
|
+
}
|
|
43
|
+
return entries[0];
|
|
44
|
+
}
|
|
45
|
+
function isRefLookupIdent(attrs, etype, identName) {
|
|
46
|
+
return (identName.indexOf('.') !== -1 &&
|
|
47
|
+
// attr names can have `.` in them, so use the attr we find with a `.`
|
|
48
|
+
// before assuming it's a ref lookup.
|
|
49
|
+
!getAttrByFwdIdentName(attrs, etype, identName));
|
|
50
|
+
}
|
|
51
|
+
function extractRefLookupFwdName(identName) {
|
|
52
|
+
const [fwdName, idIdent, ...rest] = identName.split('.');
|
|
53
|
+
if (rest.length > 0 || idIdent !== 'id') {
|
|
54
|
+
throw new Error(`${identName} is not a valid lookup attribute.`);
|
|
55
|
+
}
|
|
56
|
+
return fwdName;
|
|
57
|
+
}
|
|
58
|
+
function lookupIdentToAttr(attrs, etype, identName) {
|
|
59
|
+
if (!isRefLookupIdent(attrs, etype, identName)) {
|
|
60
|
+
return getAttrByFwdIdentName(attrs, etype, identName);
|
|
61
|
+
}
|
|
62
|
+
const fwdName = extractRefLookupFwdName(identName);
|
|
63
|
+
const refAttr = getAttrByFwdIdentName(attrs, etype, fwdName) ||
|
|
64
|
+
getAttrByReverseIdentName(attrs, etype, fwdName);
|
|
65
|
+
if (refAttr && refAttr['value-type'] !== 'ref') {
|
|
66
|
+
throw new Error(`${identName} does not reference a valid link attribute.`);
|
|
67
|
+
}
|
|
68
|
+
return refAttr;
|
|
69
|
+
}
|
|
70
|
+
// Returns [attr, value] for the eid if the eid is a lookup.
|
|
71
|
+
// If it's a regular eid, returns null
|
|
72
|
+
function lookupPairOfEid(eid) {
|
|
73
|
+
if (typeof eid === 'string' && !isLookup(eid)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return typeof eid === 'string' && isLookup(eid)
|
|
77
|
+
? parseLookup(eid)
|
|
78
|
+
: explodeLookupRef(eid);
|
|
79
|
+
}
|
|
80
|
+
function extractLookup(attrs, etype, eid) {
|
|
81
|
+
const lookupPair = lookupPairOfEid(eid);
|
|
82
|
+
if (lookupPair === null) {
|
|
83
|
+
return eid;
|
|
84
|
+
}
|
|
85
|
+
const [identName, value] = lookupPair;
|
|
86
|
+
const attr = lookupIdentToAttr(attrs, etype, identName);
|
|
87
|
+
if (!attr || !attr['unique?']) {
|
|
88
|
+
throw new Error(`${identName} is not a unique attribute.`);
|
|
89
|
+
}
|
|
90
|
+
return [attr.id, value];
|
|
91
|
+
}
|
|
92
|
+
function withIdAttrForLookup(attrs, etype, eidA, txSteps) {
|
|
93
|
+
const lookup = extractLookup(attrs, etype, eidA);
|
|
94
|
+
if (!Array.isArray(lookup)) {
|
|
95
|
+
return txSteps;
|
|
96
|
+
}
|
|
97
|
+
const idTuple = [
|
|
98
|
+
'add-triple',
|
|
99
|
+
lookup,
|
|
100
|
+
getAttrByFwdIdentName(attrs, etype, 'id')?.id,
|
|
101
|
+
lookup,
|
|
102
|
+
];
|
|
103
|
+
return [idTuple].concat(txSteps);
|
|
104
|
+
}
|
|
105
|
+
function expandLink({ attrsStore }, [etype, eidA, obj]) {
|
|
106
|
+
const addTriples = Object.entries(obj).flatMap(([label, eidOrEids]) => {
|
|
107
|
+
const eids = Array.isArray(eidOrEids) ? eidOrEids : [eidOrEids];
|
|
108
|
+
const fwdAttr = getAttrByFwdIdentName(attrsStore, etype, label);
|
|
109
|
+
const revAttr = getAttrByReverseIdentName(attrsStore, etype, label);
|
|
110
|
+
return eids.map((eidB) => {
|
|
111
|
+
const txStep = fwdAttr
|
|
112
|
+
? [
|
|
113
|
+
'add-triple',
|
|
114
|
+
extractLookup(attrsStore, etype, eidA),
|
|
115
|
+
fwdAttr.id,
|
|
116
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
117
|
+
// already exist
|
|
118
|
+
extractLookup(attrsStore, fwdAttr['reverse-identity'][1], eidB),
|
|
119
|
+
]
|
|
120
|
+
: [
|
|
121
|
+
'add-triple',
|
|
122
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
123
|
+
// already exist
|
|
124
|
+
extractLookup(attrsStore, revAttr['forward-identity'][1], eidB),
|
|
125
|
+
revAttr?.id,
|
|
126
|
+
extractLookup(attrsStore, etype, eidA),
|
|
127
|
+
];
|
|
128
|
+
return txStep;
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return withIdAttrForLookup(attrsStore, etype, eidA, addTriples);
|
|
132
|
+
}
|
|
133
|
+
function expandUnlink({ attrsStore }, [etype, eidA, obj]) {
|
|
134
|
+
const retractTriples = Object.entries(obj).flatMap(([label, eidOrEids]) => {
|
|
135
|
+
const eids = Array.isArray(eidOrEids) ? eidOrEids : [eidOrEids];
|
|
136
|
+
const fwdAttr = getAttrByFwdIdentName(attrsStore, etype, label);
|
|
137
|
+
const revAttr = getAttrByReverseIdentName(attrsStore, etype, label);
|
|
138
|
+
return eids.map((eidB) => {
|
|
139
|
+
const txStep = fwdAttr
|
|
140
|
+
? [
|
|
141
|
+
'retract-triple',
|
|
142
|
+
extractLookup(attrsStore, etype, eidA),
|
|
143
|
+
fwdAttr.id,
|
|
144
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
145
|
+
// already exist
|
|
146
|
+
extractLookup(attrsStore, fwdAttr['reverse-identity'][1], eidB),
|
|
147
|
+
]
|
|
148
|
+
: [
|
|
149
|
+
'retract-triple',
|
|
150
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
151
|
+
// already exist
|
|
152
|
+
extractLookup(attrsStore, revAttr['forward-identity'][1], eidB),
|
|
153
|
+
revAttr.id,
|
|
154
|
+
extractLookup(attrsStore, etype, eidA),
|
|
155
|
+
];
|
|
156
|
+
return txStep;
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
return withIdAttrForLookup(attrsStore, etype, eidA, retractTriples);
|
|
160
|
+
}
|
|
161
|
+
function checkEntityExists(stores, attrsStore, etype, eid) {
|
|
162
|
+
if (Array.isArray(eid)) {
|
|
163
|
+
// lookup ref
|
|
164
|
+
const [entity_a, entity_v] = eid;
|
|
165
|
+
for (const store of stores || []) {
|
|
166
|
+
const ev = store?.aev.get(entity_a);
|
|
167
|
+
if (ev) {
|
|
168
|
+
// This would be a lot more efficient with a ave index
|
|
169
|
+
for (const [_e, _a, v] of allMapValues(ev, 2)) {
|
|
170
|
+
if (v === entity_v) {
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
// eid
|
|
179
|
+
for (const store of stores || []) {
|
|
180
|
+
const av = store?.eav.get(eid);
|
|
181
|
+
if (av) {
|
|
182
|
+
for (const attr_id of av.keys()) {
|
|
183
|
+
if (attrsStore.getAttr(attr_id)?.['forward-identity'][1] == etype) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
function convertOpts({ stores, attrsStore }, [etype, eid, obj_, opts]) {
|
|
193
|
+
return opts?.upsert === false
|
|
194
|
+
? { mode: 'update' }
|
|
195
|
+
: opts?.upsert === true
|
|
196
|
+
? null
|
|
197
|
+
: checkEntityExists(stores, attrsStore, etype, eid)
|
|
198
|
+
? { mode: 'update' }
|
|
199
|
+
: null; // auto mode chooses between update and upsert, not update and create, just in case
|
|
200
|
+
}
|
|
201
|
+
function expandCreate(ctx, step) {
|
|
202
|
+
const { attrsStore } = ctx;
|
|
203
|
+
const [etype, eid, obj_, opts] = step;
|
|
204
|
+
const obj = immutableRemoveUndefined(obj_);
|
|
205
|
+
const lookup = extractLookup(attrsStore, etype, eid);
|
|
206
|
+
// id first so that we don't clobber updates on the lookup field
|
|
207
|
+
const attrTuples = [['id', lookup]]
|
|
208
|
+
.concat(Object.entries(obj))
|
|
209
|
+
.map(([identName, value]) => {
|
|
210
|
+
// Uses `!` because we should have optimistically created the attr if it doesn't exist
|
|
211
|
+
const attr = getAttrByFwdIdentName(attrsStore, etype, identName);
|
|
212
|
+
if (attr['checked-data-type'] === 'date' && ctx.useDateObjects) {
|
|
213
|
+
value = coerceToDate(value);
|
|
214
|
+
}
|
|
215
|
+
return ['add-triple', lookup, attr.id, value, { mode: 'create' }];
|
|
216
|
+
});
|
|
217
|
+
return attrTuples;
|
|
218
|
+
}
|
|
219
|
+
function expandUpdate(ctx, step) {
|
|
220
|
+
const { attrsStore } = ctx;
|
|
221
|
+
const [etype, eid, obj_, opts] = step;
|
|
222
|
+
const obj = immutableRemoveUndefined(obj_);
|
|
223
|
+
const lookup = extractLookup(attrsStore, etype, eid);
|
|
224
|
+
const serverOpts = convertOpts(ctx, [etype, lookup, obj_, opts]);
|
|
225
|
+
// id first so that we don't clobber updates on the lookup field
|
|
226
|
+
const attrTuples = [['id', lookup]]
|
|
227
|
+
.concat(Object.entries(obj))
|
|
228
|
+
.map(([identName, value]) => {
|
|
229
|
+
const attr = getAttrByFwdIdentName(attrsStore, etype, identName);
|
|
230
|
+
if (attr['checked-data-type'] === 'date' && ctx.useDateObjects) {
|
|
231
|
+
value = coerceToDate(value);
|
|
232
|
+
}
|
|
233
|
+
return [
|
|
234
|
+
'add-triple',
|
|
235
|
+
lookup,
|
|
236
|
+
attr.id,
|
|
237
|
+
value,
|
|
238
|
+
...(serverOpts ? [serverOpts] : []),
|
|
239
|
+
];
|
|
240
|
+
});
|
|
241
|
+
return attrTuples;
|
|
242
|
+
}
|
|
243
|
+
function expandDelete({ attrsStore }, [etype, eid]) {
|
|
244
|
+
const lookup = extractLookup(attrsStore, etype, eid);
|
|
245
|
+
return [['delete-entity', lookup, etype]];
|
|
246
|
+
}
|
|
247
|
+
function expandDeepMerge(ctx, step) {
|
|
248
|
+
const { attrsStore } = ctx;
|
|
249
|
+
const [etype, eid, obj_, opts] = step;
|
|
250
|
+
const obj = immutableRemoveUndefined(obj_);
|
|
251
|
+
const lookup = extractLookup(attrsStore, etype, eid);
|
|
252
|
+
const serverOpts = convertOpts(ctx, [etype, lookup, obj_, opts]);
|
|
253
|
+
const attrTuples = Object.entries(obj).map(([identName, value]) => {
|
|
254
|
+
const attr = getAttrByFwdIdentName(attrsStore, etype, identName);
|
|
255
|
+
return [
|
|
256
|
+
'deep-merge-triple',
|
|
257
|
+
lookup,
|
|
258
|
+
attr.id,
|
|
259
|
+
value,
|
|
260
|
+
...(serverOpts ? [serverOpts] : []),
|
|
261
|
+
];
|
|
262
|
+
});
|
|
263
|
+
const idTuple = [
|
|
264
|
+
'add-triple',
|
|
265
|
+
lookup,
|
|
266
|
+
getAttrByFwdIdentName(attrsStore, etype, 'id').id,
|
|
267
|
+
lookup,
|
|
268
|
+
...(serverOpts ? [serverOpts] : []),
|
|
269
|
+
];
|
|
270
|
+
// id first so that we don't clobber updates on the lookup field
|
|
271
|
+
return [idTuple].concat(attrTuples);
|
|
272
|
+
}
|
|
273
|
+
function expandRuleParams({ attrsStore }, [etype, eid, ruleParams]) {
|
|
274
|
+
const lookup = extractLookup(attrsStore, etype, eid);
|
|
275
|
+
return [['rule-params', lookup, etype, ruleParams]];
|
|
276
|
+
}
|
|
277
|
+
function removeIdFromArgs(step) {
|
|
278
|
+
const [op, etype, eid, obj, opts] = step;
|
|
279
|
+
if (!obj) {
|
|
280
|
+
return step;
|
|
281
|
+
}
|
|
282
|
+
const newObj = { ...obj };
|
|
283
|
+
delete newObj.id;
|
|
284
|
+
return [op, etype, eid, newObj, ...(opts ? [opts] : [])];
|
|
285
|
+
}
|
|
286
|
+
function toTxSteps(ctx, step) {
|
|
287
|
+
const [action, ...args] = removeIdFromArgs(step);
|
|
288
|
+
switch (action) {
|
|
289
|
+
case 'merge':
|
|
290
|
+
return expandDeepMerge(ctx, args);
|
|
291
|
+
case 'create':
|
|
292
|
+
return expandCreate(ctx, args);
|
|
293
|
+
case 'update':
|
|
294
|
+
return expandUpdate(ctx, args);
|
|
295
|
+
case 'link':
|
|
296
|
+
return expandLink(ctx, args);
|
|
297
|
+
case 'unlink':
|
|
298
|
+
return expandUnlink(ctx, args);
|
|
299
|
+
case 'delete':
|
|
300
|
+
return expandDelete(ctx, args);
|
|
301
|
+
case 'ruleParams':
|
|
302
|
+
return expandRuleParams(ctx, args);
|
|
303
|
+
default:
|
|
304
|
+
throw new Error(`unsupported action ${action}`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// ---------
|
|
308
|
+
// transform
|
|
309
|
+
function checkedDataTypeOfValueType(valueType) {
|
|
310
|
+
switch (valueType) {
|
|
311
|
+
case 'string':
|
|
312
|
+
case 'date':
|
|
313
|
+
case 'boolean':
|
|
314
|
+
case 'number':
|
|
315
|
+
return valueType;
|
|
316
|
+
default:
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function objectPropsFromSchema(schema, etype, label) {
|
|
321
|
+
const attr = schema.entities[etype]?.attrs?.[label];
|
|
322
|
+
if (label === 'id')
|
|
323
|
+
return null;
|
|
324
|
+
if (!attr) {
|
|
325
|
+
throw new Error(`${etype}.${label} does not exist in your schema`);
|
|
326
|
+
}
|
|
327
|
+
const { unique, indexed } = attr?.config;
|
|
328
|
+
const checkedDataType = checkedDataTypeOfValueType(attr?.valueType);
|
|
329
|
+
return {
|
|
330
|
+
'index?': indexed,
|
|
331
|
+
'unique?': unique,
|
|
332
|
+
'checked-data-type': checkedDataType,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function createObjectAttr(schema, etype, label, props) {
|
|
336
|
+
const schemaObjectProps = schema
|
|
337
|
+
? objectPropsFromSchema(schema, etype, label)
|
|
338
|
+
: null;
|
|
339
|
+
const attrId = uuid();
|
|
340
|
+
const fwdIdentId = uuid();
|
|
341
|
+
const fwdIdent = [fwdIdentId, etype, label];
|
|
342
|
+
return {
|
|
343
|
+
id: attrId,
|
|
344
|
+
'forward-identity': fwdIdent,
|
|
345
|
+
'value-type': 'blob',
|
|
346
|
+
cardinality: 'one',
|
|
347
|
+
'unique?': false,
|
|
348
|
+
'index?': false,
|
|
349
|
+
isUnsynced: true,
|
|
350
|
+
...(schemaObjectProps || {}),
|
|
351
|
+
...(props || {}),
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function findSchemaLink(schema, etype, label) {
|
|
355
|
+
const links = Object.values(schema.links);
|
|
356
|
+
const found = links.find((x) => {
|
|
357
|
+
return ((x.forward.on === etype && x.forward.label === label) ||
|
|
358
|
+
(x.reverse.on === etype && x.reverse.label === label));
|
|
359
|
+
});
|
|
360
|
+
return found;
|
|
361
|
+
}
|
|
362
|
+
function refPropsFromSchema(schema, etype, label) {
|
|
363
|
+
const found = findSchemaLink(schema, etype, label);
|
|
364
|
+
if (!found) {
|
|
365
|
+
throw new Error(`Couldn't find the link ${etype}.${label} in your schema`);
|
|
366
|
+
}
|
|
367
|
+
const { forward, reverse } = found;
|
|
368
|
+
return {
|
|
369
|
+
'forward-identity': [uuid(), forward.on, forward.label],
|
|
370
|
+
'reverse-identity': [uuid(), reverse.on, reverse.label],
|
|
371
|
+
cardinality: forward.has === 'one' ? 'one' : 'many',
|
|
372
|
+
'unique?': reverse.has === 'one',
|
|
373
|
+
'on-delete': forward.onDelete,
|
|
374
|
+
'on-delete-reverse': reverse.onDelete,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function createRefAttr(schema, etype, label, props) {
|
|
378
|
+
const schemaRefProps = schema
|
|
379
|
+
? refPropsFromSchema(schema, etype, label)
|
|
380
|
+
: null;
|
|
381
|
+
const attrId = uuid();
|
|
382
|
+
const fwdIdent = [uuid(), etype, label];
|
|
383
|
+
const revIdent = [uuid(), label, etype];
|
|
384
|
+
return {
|
|
385
|
+
id: attrId,
|
|
386
|
+
// @ts-ignore: ts thinks it's any[]
|
|
387
|
+
'forward-identity': fwdIdent,
|
|
388
|
+
// @ts-ignore: ts thinks it's any[]
|
|
389
|
+
'reverse-identity': revIdent,
|
|
390
|
+
'value-type': 'ref',
|
|
391
|
+
// @ts-ignore: ts thinks it's type string
|
|
392
|
+
cardinality: 'many',
|
|
393
|
+
'unique?': false,
|
|
394
|
+
'index?': false,
|
|
395
|
+
isUnsynced: true,
|
|
396
|
+
...(schemaRefProps || {}),
|
|
397
|
+
...(props || {}),
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
// Actions that have an object, e.g. not delete
|
|
401
|
+
const OBJ_ACTIONS = new Set(['create', 'update', 'merge', 'link', 'unlink']);
|
|
402
|
+
const REF_ACTIONS = new Set(['link', 'unlink']);
|
|
403
|
+
const UPDATE_ACTIONS = new Set(['create', 'update', 'merge']);
|
|
404
|
+
const SUPPORTS_LOOKUP_ACTIONS = new Set([
|
|
405
|
+
'link',
|
|
406
|
+
'unlink',
|
|
407
|
+
'create',
|
|
408
|
+
'update',
|
|
409
|
+
'merge',
|
|
410
|
+
'delete',
|
|
411
|
+
'ruleParams',
|
|
412
|
+
]);
|
|
413
|
+
const lookupProps = { 'unique?': true, 'index?': true };
|
|
414
|
+
const refLookupProps = {
|
|
415
|
+
...lookupProps,
|
|
416
|
+
cardinality: 'one',
|
|
417
|
+
};
|
|
418
|
+
function lookupPairsOfOp(op) {
|
|
419
|
+
const res = [];
|
|
420
|
+
const [action, etype, eid, obj] = op;
|
|
421
|
+
if (!SUPPORTS_LOOKUP_ACTIONS.has(action)) {
|
|
422
|
+
return res;
|
|
423
|
+
}
|
|
424
|
+
const eidLookupPair = lookupPairOfEid(eid);
|
|
425
|
+
if (eidLookupPair) {
|
|
426
|
+
res.push({ etype: etype, lookupPair: eidLookupPair });
|
|
427
|
+
}
|
|
428
|
+
if (action === 'link') {
|
|
429
|
+
for (const [label, eidOrEids] of Object.entries(obj)) {
|
|
430
|
+
const eids = Array.isArray(eidOrEids) ? eidOrEids : [eidOrEids];
|
|
431
|
+
for (const linkEid of eids) {
|
|
432
|
+
const linkEidLookupPair = lookupPairOfEid(linkEid);
|
|
433
|
+
if (linkEidLookupPair) {
|
|
434
|
+
res.push({
|
|
435
|
+
etype: etype,
|
|
436
|
+
lookupPair: linkEidLookupPair,
|
|
437
|
+
linkLabel: label,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return res;
|
|
444
|
+
}
|
|
445
|
+
function createMissingAttrs({ attrsStore, schema }, ops) {
|
|
446
|
+
const addedIds = new Set();
|
|
447
|
+
const localAttrs = [];
|
|
448
|
+
const addOps = [];
|
|
449
|
+
function attrByFwdIdent(etype, label) {
|
|
450
|
+
return (getAttrByFwdIdentName(attrsStore, etype, label) ||
|
|
451
|
+
localAttrs.find((x) => x['forward-identity'][1] === etype &&
|
|
452
|
+
x['forward-identity'][2] === label));
|
|
453
|
+
}
|
|
454
|
+
function attrByRevIdent(etype, label) {
|
|
455
|
+
return (getAttrByReverseIdentName(attrsStore, etype, label) ||
|
|
456
|
+
localAttrs.find((x) => x['reverse-identity']?.[1] === etype &&
|
|
457
|
+
x['reverse-identity']?.[2] === label));
|
|
458
|
+
}
|
|
459
|
+
function addAttr(attr) {
|
|
460
|
+
localAttrs.push(attr);
|
|
461
|
+
addOps.push(['add-attr', attr]);
|
|
462
|
+
addedIds.add(attr.id);
|
|
463
|
+
}
|
|
464
|
+
function addUnsynced(attr) {
|
|
465
|
+
if (attr &&
|
|
466
|
+
'isUnsynced' in attr &&
|
|
467
|
+
attr.isUnsynced &&
|
|
468
|
+
!addedIds.has(attr.id)) {
|
|
469
|
+
localAttrs.push(attr);
|
|
470
|
+
addOps.push(['add-attr', attr]);
|
|
471
|
+
addedIds.add(attr.id);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function isRefLookupIdentLocal(etype, identName) {
|
|
475
|
+
return (identName.indexOf('.') !== -1 &&
|
|
476
|
+
// attr names can have `.` in them, so use the attr we find with a `.`
|
|
477
|
+
// before assuming it's a ref lookup.
|
|
478
|
+
!attrByFwdIdent(etype, identName));
|
|
479
|
+
}
|
|
480
|
+
// Adds attrs needed for a ref lookup
|
|
481
|
+
function addForRef(etype, label) {
|
|
482
|
+
const fwdAttr = attrByFwdIdent(etype, label);
|
|
483
|
+
const revAttr = attrByRevIdent(etype, label);
|
|
484
|
+
addUnsynced(fwdAttr);
|
|
485
|
+
addUnsynced(revAttr);
|
|
486
|
+
if (!fwdAttr && !revAttr) {
|
|
487
|
+
addAttr(createRefAttr(schema, etype, label, refLookupProps));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
// Create attrs for lookups if we need to
|
|
491
|
+
// Do these first because otherwise we might add a non-unique attr
|
|
492
|
+
// before we get to it
|
|
493
|
+
for (const op of ops) {
|
|
494
|
+
for (const { etype, lookupPair, linkLabel } of lookupPairsOfOp(op)) {
|
|
495
|
+
const identName = lookupPair[0];
|
|
496
|
+
// We got a link eid that's a lookup, linkLabel is the label of the ident,
|
|
497
|
+
// e.g. `posts` in `link({posts: postIds})`
|
|
498
|
+
if (linkLabel) {
|
|
499
|
+
// Add our ref attr, e.g. users.posts
|
|
500
|
+
addForRef(etype, linkLabel);
|
|
501
|
+
// Figure out the link etype so we can make sure we have the attrs
|
|
502
|
+
// for the link lookup
|
|
503
|
+
const fwdAttr = attrByFwdIdent(etype, linkLabel);
|
|
504
|
+
const revAttr = attrByRevIdent(etype, linkLabel);
|
|
505
|
+
addUnsynced(fwdAttr);
|
|
506
|
+
addUnsynced(revAttr);
|
|
507
|
+
const linkEtype = fwdAttr?.['reverse-identity']?.[1] ||
|
|
508
|
+
revAttr?.['forward-identity']?.[1] ||
|
|
509
|
+
linkLabel;
|
|
510
|
+
if (isRefLookupIdentLocal(linkEtype, identName)) {
|
|
511
|
+
addForRef(linkEtype, extractRefLookupFwdName(identName));
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
const attr = attrByFwdIdent(linkEtype, identName);
|
|
515
|
+
if (!attr) {
|
|
516
|
+
addAttr(createObjectAttr(schema, linkEtype, identName, lookupProps));
|
|
517
|
+
}
|
|
518
|
+
addUnsynced(attr);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
else if (isRefLookupIdentLocal(etype, identName)) {
|
|
522
|
+
addForRef(etype, extractRefLookupFwdName(identName));
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
const attr = attrByFwdIdent(etype, identName);
|
|
526
|
+
if (!attr) {
|
|
527
|
+
addAttr(createObjectAttr(schema, etype, identName, lookupProps));
|
|
528
|
+
}
|
|
529
|
+
addUnsynced(attr);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
// Create object and ref attrs
|
|
534
|
+
for (const op of ops) {
|
|
535
|
+
const [action, etype, eid, obj] = op;
|
|
536
|
+
if (OBJ_ACTIONS.has(action)) {
|
|
537
|
+
const idAttr = attrByFwdIdent(etype, 'id');
|
|
538
|
+
addUnsynced(idAttr);
|
|
539
|
+
if (!idAttr) {
|
|
540
|
+
addAttr(createObjectAttr(schema, etype, 'id', { 'unique?': true }));
|
|
541
|
+
}
|
|
542
|
+
for (const label of Object.keys(obj)) {
|
|
543
|
+
const fwdAttr = attrByFwdIdent(etype, label);
|
|
544
|
+
addUnsynced(fwdAttr);
|
|
545
|
+
if (UPDATE_ACTIONS.has(action)) {
|
|
546
|
+
if (!fwdAttr) {
|
|
547
|
+
addAttr(createObjectAttr(schema, etype, label, label === 'id' ? { 'unique?': true } : null));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (REF_ACTIONS.has(action)) {
|
|
551
|
+
const revAttr = attrByRevIdent(etype, label);
|
|
552
|
+
if (!fwdAttr && !revAttr) {
|
|
553
|
+
addAttr(createRefAttr(schema, etype, label));
|
|
554
|
+
}
|
|
555
|
+
addUnsynced(revAttr);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (localAttrs.length) {
|
|
561
|
+
const nextAttrs = { ...attrsStore.attrs };
|
|
562
|
+
for (const attr of localAttrs) {
|
|
563
|
+
nextAttrs[attr.id] = attr;
|
|
564
|
+
}
|
|
565
|
+
return [new AttrsStoreClass(nextAttrs, attrsStore.linkIndex), addOps];
|
|
566
|
+
}
|
|
567
|
+
return [attrsStore, addOps];
|
|
568
|
+
}
|
|
569
|
+
export function transform(ctx, inputChunks) {
|
|
570
|
+
const chunks = Array.isArray(inputChunks) ? inputChunks : [inputChunks];
|
|
571
|
+
const ops = chunks.flatMap((tx) => getOps(tx));
|
|
572
|
+
const [newAttrs, addAttrTxSteps] = createMissingAttrs(ctx, ops);
|
|
573
|
+
const newCtx = { ...ctx, attrsStore: newAttrs };
|
|
574
|
+
const txSteps = ops.flatMap((op) => toTxSteps(newCtx, op));
|
|
575
|
+
return [...addAttrTxSteps, ...txSteps];
|
|
576
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as s from './store.ts';
|
|
2
|
+
export declare function compareOrder(id_a: string, v_a: any, id_b: string, v_b: any, dataType: any): number;
|
|
3
|
+
export default function query({ store, attrsStore, pageInfo, aggregate, }: {
|
|
4
|
+
store: s.Store;
|
|
5
|
+
attrsStore: s.AttrsStore;
|
|
6
|
+
pageInfo?: any;
|
|
7
|
+
aggregate?: any;
|
|
8
|
+
}, q: any): {
|
|
9
|
+
data: any;
|
|
10
|
+
pageInfo?: any;
|
|
11
|
+
aggregate?: any;
|
|
12
|
+
};
|