@apollo/client 0.0.0-pr-10521-20230206180228
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/LICENSE +22 -0
- package/README.md +45 -0
- package/apollo-client.cjs +7614 -0
- package/apollo-client.cjs.map +1 -0
- package/apollo-client.min.cjs +1 -0
- package/cache/cache.cjs +2425 -0
- package/cache/cache.cjs.map +1 -0
- package/cache/cache.cjs.native.js +2425 -0
- package/cache/core/cache.d.ts +32 -0
- package/cache/core/cache.d.ts.map +1 -0
- package/cache/core/cache.js +84 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/types/Cache.d.ts +55 -0
- package/cache/core/types/Cache.d.ts.map +1 -0
- package/cache/core/types/Cache.js +4 -0
- package/cache/core/types/Cache.js.map +1 -0
- package/cache/core/types/DataProxy.d.ts +52 -0
- package/cache/core/types/DataProxy.d.ts.map +1 -0
- package/cache/core/types/DataProxy.js +2 -0
- package/cache/core/types/DataProxy.js.map +1 -0
- package/cache/core/types/common.d.ts +47 -0
- package/cache/core/types/common.d.ts.map +1 -0
- package/cache/core/types/common.js +26 -0
- package/cache/core/types/common.js.map +1 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.d.ts.map +1 -0
- package/cache/index.js +14 -0
- package/cache/index.js.map +1 -0
- package/cache/inmemory/__mocks__/optimism.d.ts +2 -0
- package/cache/inmemory/__mocks__/optimism.d.ts.map +1 -0
- package/cache/inmemory/__mocks__/optimism.js +14 -0
- package/cache/inmemory/__mocks__/optimism.js.map +1 -0
- package/cache/inmemory/entityStore.d.ts +83 -0
- package/cache/inmemory/entityStore.d.ts.map +1 -0
- package/cache/inmemory/entityStore.js +467 -0
- package/cache/inmemory/entityStore.js.map +1 -0
- package/cache/inmemory/fixPolyfills.d.ts +1 -0
- package/cache/inmemory/fixPolyfills.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.js +1 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -0
- package/cache/inmemory/fixPolyfills.native.d.ts +2 -0
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.native.js +48 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -0
- package/cache/inmemory/fragmentRegistry.d.ts +8 -0
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
- package/cache/inmemory/fragmentRegistry.js +113 -0
- package/cache/inmemory/fragmentRegistry.js.map +1 -0
- package/cache/inmemory/helpers.d.ts +27 -0
- package/cache/inmemory/helpers.d.ts.map +1 -0
- package/cache/inmemory/helpers.js +85 -0
- package/cache/inmemory/helpers.js.map +1 -0
- package/cache/inmemory/inMemoryCache.d.ts +52 -0
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -0
- package/cache/inmemory/inMemoryCache.js +316 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -0
- package/cache/inmemory/key-extractor.d.ts +9 -0
- package/cache/inmemory/key-extractor.d.ts.map +1 -0
- package/cache/inmemory/key-extractor.js +118 -0
- package/cache/inmemory/key-extractor.js.map +1 -0
- package/cache/inmemory/object-canon.d.ts +17 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -0
- package/cache/inmemory/object-canon.js +120 -0
- package/cache/inmemory/object-canon.js.map +1 -0
- package/cache/inmemory/policies.d.ts +96 -0
- package/cache/inmemory/policies.d.ts.map +1 -0
- package/cache/inmemory/policies.js +416 -0
- package/cache/inmemory/policies.js.map +1 -0
- package/cache/inmemory/reactiveVars.d.ts +18 -0
- package/cache/inmemory/reactiveVars.d.ts.map +1 -0
- package/cache/inmemory/reactiveVars.js +65 -0
- package/cache/inmemory/reactiveVars.js.map +1 -0
- package/cache/inmemory/readFromStore.d.ts +36 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -0
- package/cache/inmemory/readFromStore.js +267 -0
- package/cache/inmemory/readFromStore.js.map +1 -0
- package/cache/inmemory/types.d.ts +81 -0
- package/cache/inmemory/types.d.ts.map +1 -0
- package/cache/inmemory/types.js +4 -0
- package/cache/inmemory/types.js.map +1 -0
- package/cache/inmemory/writeToStore.d.ts +37 -0
- package/cache/inmemory/writeToStore.d.ts.map +1 -0
- package/cache/inmemory/writeToStore.js +394 -0
- package/cache/inmemory/writeToStore.js.map +1 -0
- package/cache/package.json +8 -0
- package/config/jest/setup.d.ts +2 -0
- package/config/jest/setup.d.ts.map +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/setup.js.map +1 -0
- package/core/ApolloClient.d.ts +76 -0
- package/core/ApolloClient.d.ts.map +1 -0
- package/core/ApolloClient.js +240 -0
- package/core/ApolloClient.js.map +1 -0
- package/core/LocalState.d.ts +69 -0
- package/core/LocalState.d.ts.map +1 -0
- package/core/LocalState.js +321 -0
- package/core/LocalState.js.map +1 -0
- package/core/ObservableQuery.d.ts +74 -0
- package/core/ObservableQuery.d.ts.map +1 -0
- package/core/ObservableQuery.js +507 -0
- package/core/ObservableQuery.js.map +1 -0
- package/core/QueryInfo.d.ts +62 -0
- package/core/QueryInfo.d.ts.map +1 -0
- package/core/QueryInfo.js +287 -0
- package/core/QueryInfo.js.map +1 -0
- package/core/QueryManager.d.ts +120 -0
- package/core/QueryManager.d.ts.map +1 -0
- package/core/QueryManager.js +890 -0
- package/core/QueryManager.js.map +1 -0
- package/core/core.cjs +2349 -0
- package/core/core.cjs.map +1 -0
- package/core/core.cjs.native.js +2349 -0
- package/core/index.d.ts +17 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +17 -0
- package/core/index.js.map +1 -0
- package/core/networkStatus.d.ts +11 -0
- package/core/networkStatus.d.ts.map +1 -0
- package/core/networkStatus.js +14 -0
- package/core/networkStatus.js.map +1 -0
- package/core/package.json +8 -0
- package/core/types.d.ts +74 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +3 -0
- package/core/types.js.map +1 -0
- package/core/watchQueryOptions.d.ts +78 -0
- package/core/watchQueryOptions.d.ts.map +1 -0
- package/core/watchQueryOptions.js +2 -0
- package/core/watchQueryOptions.js.map +1 -0
- package/errors/errors.cjs +49 -0
- package/errors/errors.cjs.map +1 -0
- package/errors/errors.cjs.native.js +49 -0
- package/errors/index.d.ts +23 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +42 -0
- package/errors/index.js.map +1 -0
- package/errors/package.json +8 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/invariantErrorCodes.js +339 -0
- package/link/batch/batch.cjs +159 -0
- package/link/batch/batch.cjs.map +1 -0
- package/link/batch/batch.cjs.native.js +159 -0
- package/link/batch/batchLink.d.ts +19 -0
- package/link/batch/batchLink.d.ts.map +1 -0
- package/link/batch/batchLink.js +31 -0
- package/link/batch/batchLink.js.map +1 -0
- package/link/batch/batching.d.ts +27 -0
- package/link/batch/batching.d.ts.map +1 -0
- package/link/batch/batching.js +125 -0
- package/link/batch/batching.js.map +1 -0
- package/link/batch/index.d.ts +2 -0
- package/link/batch/index.d.ts.map +1 -0
- package/link/batch/index.js +2 -0
- package/link/batch/index.js.map +1 -0
- package/link/batch/package.json +8 -0
- package/link/batch-http/batch-http.cjs +137 -0
- package/link/batch-http/batch-http.cjs.map +1 -0
- package/link/batch-http/batch-http.cjs.native.js +137 -0
- package/link/batch-http/batchHttpLink.d.ts +16 -0
- package/link/batch-http/batchHttpLink.d.ts.map +1 -0
- package/link/batch-http/batchHttpLink.js +131 -0
- package/link/batch-http/batchHttpLink.js.map +1 -0
- package/link/batch-http/index.d.ts +2 -0
- package/link/batch-http/index.d.ts.map +1 -0
- package/link/batch-http/index.js +2 -0
- package/link/batch-http/index.js.map +1 -0
- package/link/batch-http/package.json +8 -0
- package/link/context/context.cjs +38 -0
- package/link/context/context.cjs.map +1 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/context/index.d.ts +5 -0
- package/link/context/index.d.ts.map +1 -0
- package/link/context/index.js +31 -0
- package/link/context/index.js.map +1 -0
- package/link/context/package.json +8 -0
- package/link/core/ApolloLink.d.ts +16 -0
- package/link/core/ApolloLink.d.ts.map +1 -0
- package/link/core/ApolloLink.js +100 -0
- package/link/core/ApolloLink.js.map +1 -0
- package/link/core/concat.d.ts +3 -0
- package/link/core/concat.d.ts.map +1 -0
- package/link/core/concat.js +3 -0
- package/link/core/concat.js.map +1 -0
- package/link/core/core.cjs +121 -0
- package/link/core/core.cjs.map +1 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/core/empty.d.ts +3 -0
- package/link/core/empty.d.ts.map +1 -0
- package/link/core/empty.js +3 -0
- package/link/core/empty.js.map +1 -0
- package/link/core/execute.d.ts +3 -0
- package/link/core/execute.d.ts.map +1 -0
- package/link/core/execute.js +3 -0
- package/link/core/execute.js.map +1 -0
- package/link/core/from.d.ts +3 -0
- package/link/core/from.d.ts.map +1 -0
- package/link/core/from.js +3 -0
- package/link/core/from.js.map +1 -0
- package/link/core/index.d.ts +9 -0
- package/link/core/index.d.ts.map +1 -0
- package/link/core/index.js +9 -0
- package/link/core/index.js.map +1 -0
- package/link/core/package.json +8 -0
- package/link/core/split.d.ts +3 -0
- package/link/core/split.d.ts.map +1 -0
- package/link/core/split.js +3 -0
- package/link/core/split.js.map +1 -0
- package/link/core/types.d.ts +52 -0
- package/link/core/types.d.ts.map +1 -0
- package/link/core/types.js +2 -0
- package/link/core/types.js.map +1 -0
- package/link/error/error.cjs +90 -0
- package/link/error/error.cjs.map +1 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/error/index.d.ts +24 -0
- package/link/error/index.d.ts.map +1 -0
- package/link/error/index.js +83 -0
- package/link/error/index.js.map +1 -0
- package/link/error/package.json +8 -0
- package/link/http/HttpLink.d.ts +8 -0
- package/link/http/HttpLink.d.ts.map +1 -0
- package/link/http/HttpLink.js +15 -0
- package/link/http/HttpLink.js.map +1 -0
- package/link/http/checkFetcher.d.ts +2 -0
- package/link/http/checkFetcher.d.ts.map +1 -0
- package/link/http/checkFetcher.js +7 -0
- package/link/http/checkFetcher.js.map +1 -0
- package/link/http/createHttpLink.d.ts +4 -0
- package/link/http/createHttpLink.d.ts.map +1 -0
- package/link/http/createHttpLink.js +127 -0
- package/link/http/createHttpLink.js.map +1 -0
- package/link/http/createSignalIfSupported.d.ts +8 -0
- package/link/http/createSignalIfSupported.d.ts.map +1 -0
- package/link/http/createSignalIfSupported.js +8 -0
- package/link/http/createSignalIfSupported.js.map +1 -0
- package/link/http/http.cjs +593 -0
- package/link/http/http.cjs.map +1 -0
- package/link/http/http.cjs.native.js +593 -0
- package/link/http/index.d.ts +11 -0
- package/link/http/index.d.ts.map +1 -0
- package/link/http/index.js +11 -0
- package/link/http/index.js.map +1 -0
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/package.json +8 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +14 -0
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -0
- package/link/http/parseAndCheckHttpResponse.js +148 -0
- package/link/http/parseAndCheckHttpResponse.js.map +1 -0
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/link/http/rewriteURIForGET.d.ts +9 -0
- package/link/http/rewriteURIForGET.d.ts.map +1 -0
- package/link/http/rewriteURIForGET.js +43 -0
- package/link/http/rewriteURIForGET.js.map +1 -0
- package/link/http/selectHttpOptionsAndBody.d.ts +57 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -0
- package/link/http/selectHttpOptionsAndBody.js +78 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -0
- package/link/http/selectURI.d.ts +3 -0
- package/link/http/selectURI.d.ts.map +1 -0
- package/link/http/selectURI.js +14 -0
- package/link/http/selectURI.js.map +1 -0
- package/link/http/serializeFetchParameter.d.ts +6 -0
- package/link/http/serializeFetchParameter.d.ts.map +1 -0
- package/link/http/serializeFetchParameter.js +14 -0
- package/link/http/serializeFetchParameter.js.map +1 -0
- package/link/persisted-queries/index.d.ts +31 -0
- package/link/persisted-queries/index.d.ts.map +1 -0
- package/link/persisted-queries/index.js +170 -0
- package/link/persisted-queries/index.js.map +1 -0
- package/link/persisted-queries/package.json +8 -0
- package/link/persisted-queries/persisted-queries.cjs +174 -0
- package/link/persisted-queries/persisted-queries.cjs.map +1 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/delayFunction.d.ts +11 -0
- package/link/retry/delayFunction.d.ts.map +1 -0
- package/link/retry/delayFunction.js +12 -0
- package/link/retry/delayFunction.js.map +1 -0
- package/link/retry/index.d.ts +2 -0
- package/link/retry/index.d.ts.map +1 -0
- package/link/retry/index.js +2 -0
- package/link/retry/index.js.map +1 -0
- package/link/retry/package.json +8 -0
- package/link/retry/retry.cjs +170 -0
- package/link/retry/retry.cjs.map +1 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/retry/retryFunction.d.ts +10 -0
- package/link/retry/retryFunction.d.ts.map +1 -0
- package/link/retry/retryFunction.js +9 -0
- package/link/retry/retryFunction.js.map +1 -0
- package/link/retry/retryLink.d.ts +17 -0
- package/link/retry/retryLink.d.ts.map +1 -0
- package/link/retry/retryLink.js +145 -0
- package/link/retry/retryLink.js.map +1 -0
- package/link/schema/index.d.ts +22 -0
- package/link/schema/index.d.ts.map +1 -0
- package/link/schema/index.js +50 -0
- package/link/schema/index.js.map +1 -0
- package/link/schema/package.json +8 -0
- package/link/schema/schema.cjs +56 -0
- package/link/schema/schema.cjs.map +1 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/createOperation.d.ts +3 -0
- package/link/utils/createOperation.d.ts.map +1 -0
- package/link/utils/createOperation.js +23 -0
- package/link/utils/createOperation.js.map +1 -0
- package/link/utils/fromError.d.ts +3 -0
- package/link/utils/fromError.d.ts.map +1 -0
- package/link/utils/fromError.js +7 -0
- package/link/utils/fromError.js.map +1 -0
- package/link/utils/fromPromise.d.ts +3 -0
- package/link/utils/fromPromise.d.ts.map +1 -0
- package/link/utils/fromPromise.js +12 -0
- package/link/utils/fromPromise.js.map +1 -0
- package/link/utils/index.d.ts +9 -0
- package/link/utils/index.d.ts.map +1 -0
- package/link/utils/index.js +9 -0
- package/link/utils/index.js.map +1 -0
- package/link/utils/package.json +8 -0
- package/link/utils/throwServerError.d.ts +7 -0
- package/link/utils/throwServerError.d.ts.map +1 -0
- package/link/utils/throwServerError.js +9 -0
- package/link/utils/throwServerError.js.map +1 -0
- package/link/utils/toPromise.d.ts +3 -0
- package/link/utils/toPromise.d.ts.map +1 -0
- package/link/utils/toPromise.js +19 -0
- package/link/utils/toPromise.js.map +1 -0
- package/link/utils/transformOperation.d.ts +3 -0
- package/link/utils/transformOperation.d.ts.map +1 -0
- package/link/utils/transformOperation.js +17 -0
- package/link/utils/transformOperation.js.map +1 -0
- package/link/utils/utils.cjs +115 -0
- package/link/utils/utils.cjs.map +1 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/utils/validateOperation.d.ts +3 -0
- package/link/utils/validateOperation.d.ts.map +1 -0
- package/link/utils/validateOperation.js +18 -0
- package/link/utils/validateOperation.js.map +1 -0
- package/link/ws/index.d.ts +17 -0
- package/link/ws/index.d.ts.map +1 -0
- package/link/ws/index.js +22 -0
- package/link/ws/index.js.map +1 -0
- package/link/ws/package.json +8 -0
- package/link/ws/ws.cjs +28 -0
- package/link/ws/ws.cjs.map +1 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs +16 -0
- package/main.cjs.map +1 -0
- package/main.cjs.native.js +16 -0
- package/package.json +141 -0
- package/react/cache/SuspenseCache.d.ts +18 -0
- package/react/cache/SuspenseCache.d.ts.map +1 -0
- package/react/cache/SuspenseCache.js +49 -0
- package/react/cache/SuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +2 -0
- package/react/cache/index.d.ts.map +1 -0
- package/react/cache/index.js +2 -0
- package/react/cache/index.js.map +1 -0
- package/react/components/Mutation.d.ts +12 -0
- package/react/components/Mutation.d.ts.map +1 -0
- package/react/components/Mutation.js +22 -0
- package/react/components/Mutation.js.map +1 -0
- package/react/components/Query.d.ts +12 -0
- package/react/components/Query.d.ts.map +1 -0
- package/react/components/Query.js +23 -0
- package/react/components/Query.js.map +1 -0
- package/react/components/Subscription.d.ts +12 -0
- package/react/components/Subscription.d.ts.map +1 -0
- package/react/components/Subscription.js +17 -0
- package/react/components/Subscription.js.map +1 -0
- package/react/components/components.cjs +81 -0
- package/react/components/components.cjs.map +1 -0
- package/react/components/components.cjs.native.js +81 -0
- package/react/components/index.d.ts +5 -0
- package/react/components/index.d.ts.map +1 -0
- package/react/components/index.js +5 -0
- package/react/components/index.js.map +1 -0
- package/react/components/package.json +8 -0
- package/react/components/types.d.ts +18 -0
- package/react/components/types.d.ts.map +1 -0
- package/react/components/types.js +2 -0
- package/react/components/types.js.map +1 -0
- package/react/context/ApolloConsumer.d.ts +7 -0
- package/react/context/ApolloConsumer.d.ts.map +1 -0
- package/react/context/ApolloConsumer.js +12 -0
- package/react/context/ApolloConsumer.js.map +1 -0
- package/react/context/ApolloContext.d.ts +12 -0
- package/react/context/ApolloContext.d.ts.map +1 -0
- package/react/context/ApolloContext.js +20 -0
- package/react/context/ApolloContext.js.map +1 -0
- package/react/context/ApolloProvider.d.ts +10 -0
- package/react/context/ApolloProvider.d.ts.map +1 -0
- package/react/context/ApolloProvider.js +20 -0
- package/react/context/ApolloProvider.js.map +1 -0
- package/react/context/context.cjs +70 -0
- package/react/context/context.cjs.map +1 -0
- package/react/context/context.cjs.native.js +70 -0
- package/react/context/index.d.ts +5 -0
- package/react/context/index.d.ts.map +1 -0
- package/react/context/index.js +5 -0
- package/react/context/index.js.map +1 -0
- package/react/context/package.json +8 -0
- package/react/hoc/graphql.d.ts +6 -0
- package/react/hoc/graphql.d.ts.map +1 -0
- package/react/hoc/graphql.js +17 -0
- package/react/hoc/graphql.js.map +1 -0
- package/react/hoc/hoc-utils.d.ts +17 -0
- package/react/hoc/hoc-utils.d.ts.map +1 -0
- package/react/hoc/hoc-utils.js +47 -0
- package/react/hoc/hoc-utils.js.map +1 -0
- package/react/hoc/hoc.cjs +325 -0
- package/react/hoc/hoc.cjs.map +1 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hoc/index.d.ts +8 -0
- package/react/hoc/index.d.ts.map +1 -0
- package/react/hoc/index.js +8 -0
- package/react/hoc/index.js.map +1 -0
- package/react/hoc/mutation-hoc.d.ts +7 -0
- package/react/hoc/mutation-hoc.d.ts.map +1 -0
- package/react/hoc/mutation-hoc.js +63 -0
- package/react/hoc/mutation-hoc.js.map +1 -0
- package/react/hoc/package.json +8 -0
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.d.ts.map +1 -0
- package/react/hoc/query-hoc.js +70 -0
- package/react/hoc/query-hoc.js.map +1 -0
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.d.ts.map +1 -0
- package/react/hoc/subscription-hoc.js +80 -0
- package/react/hoc/subscription-hoc.js.map +1 -0
- package/react/hoc/types.d.ts +43 -0
- package/react/hoc/types.d.ts.map +1 -0
- package/react/hoc/types.js +2 -0
- package/react/hoc/types.js.map +1 -0
- package/react/hoc/withApollo.d.ts +4 -0
- package/react/hoc/withApollo.d.ts.map +1 -0
- package/react/hoc/withApollo.js +45 -0
- package/react/hoc/withApollo.js.map +1 -0
- package/react/hooks/compareResults.d.ts +3 -0
- package/react/hooks/compareResults.d.ts.map +1 -0
- package/react/hooks/compareResults.js +63 -0
- package/react/hooks/compareResults.js.map +1 -0
- package/react/hooks/hooks.cjs +913 -0
- package/react/hooks/hooks.cjs.map +1 -0
- package/react/hooks/hooks.cjs.native.js +913 -0
- package/react/hooks/index.d.ts +10 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/index.js +10 -0
- package/react/hooks/index.js.map +1 -0
- package/react/hooks/internal/index.d.ts +3 -0
- package/react/hooks/internal/index.d.ts.map +1 -0
- package/react/hooks/internal/index.js +3 -0
- package/react/hooks/internal/index.js.map +1 -0
- package/react/hooks/internal/useDeepMemo.d.ts +3 -0
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
- package/react/hooks/internal/useDeepMemo.js +10 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/package.json +8 -0
- package/react/hooks/useApolloClient.d.ts +3 -0
- package/react/hooks/useApolloClient.d.ts.map +1 -0
- package/react/hooks/useApolloClient.js +12 -0
- package/react/hooks/useApolloClient.js.map +1 -0
- package/react/hooks/useFragment.d.ts +13 -0
- package/react/hooks/useFragment.d.ts.map +1 -0
- package/react/hooks/useFragment.js +39 -0
- package/react/hooks/useFragment.js.map +1 -0
- package/react/hooks/useLazyQuery.d.ts +6 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -0
- package/react/hooks/useLazyQuery.js +71 -0
- package/react/hooks/useLazyQuery.js.map +1 -0
- package/react/hooks/useMutation.d.ts +6 -0
- package/react/hooks/useMutation.d.ts.map +1 -0
- package/react/hooks/useMutation.js +100 -0
- package/react/hooks/useMutation.js.map +1 -0
- package/react/hooks/useQuery.d.ts +41 -0
- package/react/hooks/useQuery.d.ts.map +1 -0
- package/react/hooks/useQuery.js +302 -0
- package/react/hooks/useQuery.js.map +1 -0
- package/react/hooks/useReactiveVar.d.ts +3 -0
- package/react/hooks/useReactiveVar.d.ts.map +1 -0
- package/react/hooks/useReactiveVar.js +16 -0
- package/react/hooks/useReactiveVar.js.map +1 -0
- package/react/hooks/useSubscription.d.ts +6 -0
- package/react/hooks/useSubscription.d.ts.map +1 -0
- package/react/hooks/useSubscription.js +141 -0
- package/react/hooks/useSubscription.js.map +1 -0
- package/react/hooks/useSuspenseCache.d.ts +2 -0
- package/react/hooks/useSuspenseCache.d.ts.map +1 -0
- package/react/hooks/useSuspenseCache.js +10 -0
- package/react/hooks/useSuspenseCache.js.map +1 -0
- package/react/hooks/useSuspenseQuery.d.ts +12 -0
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
- package/react/hooks/useSuspenseQuery.js +181 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -0
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/index.d.ts +7 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +7 -0
- package/react/index.js.map +1 -0
- package/react/package.json +8 -0
- package/react/parser/index.d.ts +15 -0
- package/react/parser/index.d.ts.map +1 -0
- package/react/parser/index.js +94 -0
- package/react/parser/index.js.map +1 -0
- package/react/parser/package.json +8 -0
- package/react/parser/parser.cjs +103 -0
- package/react/parser/parser.cjs.map +1 -0
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs +69 -0
- package/react/react.cjs.map +1 -0
- package/react/react.cjs.native.js +69 -0
- package/react/ssr/RenderPromises.d.ts +22 -0
- package/react/ssr/RenderPromises.d.ts.map +1 -0
- package/react/ssr/RenderPromises.js +90 -0
- package/react/ssr/RenderPromises.js.map +1 -0
- package/react/ssr/getDataFromTree.d.ts +13 -0
- package/react/ssr/getDataFromTree.d.ts.map +1 -0
- package/react/ssr/getDataFromTree.js +32 -0
- package/react/ssr/getDataFromTree.js.map +1 -0
- package/react/ssr/index.d.ts +4 -0
- package/react/ssr/index.d.ts.map +1 -0
- package/react/ssr/index.js +4 -0
- package/react/ssr/index.js.map +1 -0
- package/react/ssr/package.json +8 -0
- package/react/ssr/renderToStringWithData.d.ts +3 -0
- package/react/ssr/renderToStringWithData.d.ts.map +1 -0
- package/react/ssr/renderToStringWithData.js +9 -0
- package/react/ssr/renderToStringWithData.js.map +1 -0
- package/react/ssr/ssr.cjs +151 -0
- package/react/ssr/ssr.cjs.map +1 -0
- package/react/ssr/ssr.cjs.native.js +151 -0
- package/react/types/types.d.ts +130 -0
- package/react/types/types.d.ts.map +1 -0
- package/react/types/types.js +2 -0
- package/react/types/types.js.map +1 -0
- package/testing/core/core.cjs +315 -0
- package/testing/core/core.cjs.map +1 -0
- package/testing/core/core.cjs.native.js +315 -0
- package/testing/core/index.d.ts +8 -0
- package/testing/core/index.d.ts.map +1 -0
- package/testing/core/index.js +8 -0
- package/testing/core/index.js.map +1 -0
- package/testing/core/itAsync.d.ts +6 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/testing/core/itAsync.js +19 -0
- package/testing/core/itAsync.js.map +1 -0
- package/testing/core/mocking/mockClient.d.ts +5 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/testing/core/mocking/mockClient.js +14 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/testing/core/mocking/mockFetch.d.ts +24 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/testing/core/mocking/mockFetch.js +83 -0
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/testing/core/mocking/mockLink.d.ts +28 -0
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/testing/core/mocking/mockLink.js +139 -0
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/testing/core/mocking/mockQueryManager.d.ts +5 -0
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/testing/core/mocking/mockQueryManager.js +14 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts +24 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.js +62 -0
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/testing/core/mocking/mockWatchQuery.d.ts +5 -0
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/testing/core/mocking/mockWatchQuery.js +15 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/testing/core/observableToPromise.d.ts +15 -0
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/testing/core/observableToPromise.js +65 -0
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +3 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/testing/core/subscribeAndCount.js +16 -0
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/core/withConsoleSpy.d.ts +4 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/testing/core/withConsoleSpy.js +39 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/testing/core/wrap.d.ts +4 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/testing/core/wrap.js +26 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +4 -0
- package/testing/index.js.map +1 -0
- package/testing/package.json +8 -0
- package/testing/react/MockedProvider.d.ts +30 -0
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/testing/react/MockedProvider.js +39 -0
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +109 -0
- package/testing/testing.cjs.map +1 -0
- package/testing/testing.cjs.native.js +109 -0
- package/utilities/common/arrays.d.ts +2 -0
- package/utilities/common/arrays.d.ts.map +1 -0
- package/utilities/common/arrays.js +4 -0
- package/utilities/common/arrays.js.map +1 -0
- package/utilities/common/canUse.d.ts +7 -0
- package/utilities/common/canUse.d.ts.map +1 -0
- package/utilities/common/canUse.js +11 -0
- package/utilities/common/canUse.js.map +1 -0
- package/utilities/common/cloneDeep.d.ts +2 -0
- package/utilities/common/cloneDeep.d.ts.map +1 -0
- package/utilities/common/cloneDeep.js +33 -0
- package/utilities/common/cloneDeep.js.map +1 -0
- package/utilities/common/compact.d.ts +3 -0
- package/utilities/common/compact.d.ts.map +1 -0
- package/utilities/common/compact.js +19 -0
- package/utilities/common/compact.js.map +1 -0
- package/utilities/common/errorHandling.d.ts +4 -0
- package/utilities/common/errorHandling.d.ts.map +1 -0
- package/utilities/common/errorHandling.js +21 -0
- package/utilities/common/errorHandling.js.map +1 -0
- package/utilities/common/filterInPlace.d.ts +2 -0
- package/utilities/common/filterInPlace.d.ts.map +1 -0
- package/utilities/common/filterInPlace.js +11 -0
- package/utilities/common/filterInPlace.js.map +1 -0
- package/utilities/common/incrementalResult.d.ts +6 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +32 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/makeUniqueId.d.ts +2 -0
- package/utilities/common/makeUniqueId.d.ts.map +1 -0
- package/utilities/common/makeUniqueId.js +7 -0
- package/utilities/common/makeUniqueId.js.map +1 -0
- package/utilities/common/maybeDeepFreeze.d.ts +2 -0
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -0
- package/utilities/common/maybeDeepFreeze.js +34 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -0
- package/utilities/common/mergeDeep.d.ts +14 -0
- package/utilities/common/mergeDeep.d.ts.map +1 -0
- package/utilities/common/mergeDeep.js +76 -0
- package/utilities/common/mergeDeep.js.map +1 -0
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.js.map +1 -0
- package/utilities/common/objects.d.ts +2 -0
- package/utilities/common/objects.d.ts.map +1 -0
- package/utilities/common/objects.js +4 -0
- package/utilities/common/objects.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/common/stringifyForDisplay.d.ts +2 -0
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
- package/utilities/common/stringifyForDisplay.js +8 -0
- package/utilities/common/stringifyForDisplay.js.map +1 -0
- package/utilities/globals/DEV.d.ts +3 -0
- package/utilities/globals/DEV.d.ts.map +1 -0
- package/utilities/globals/DEV.js +9 -0
- package/utilities/globals/DEV.js.map +1 -0
- package/utilities/globals/fix-graphql.d.ts +2 -0
- package/utilities/globals/fix-graphql.d.ts.map +1 -0
- package/utilities/globals/fix-graphql.js +6 -0
- package/utilities/globals/fix-graphql.js.map +1 -0
- package/utilities/globals/global.d.ts +5 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/globals/global.js +6 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs +42 -0
- package/utilities/globals/globals.cjs.map +1 -0
- package/utilities/globals/globals.cjs.native.js +42 -0
- package/utilities/globals/index.d.ts +8 -0
- package/utilities/globals/index.d.ts.map +1 -0
- package/utilities/globals/index.js +10 -0
- package/utilities/globals/index.js.map +1 -0
- package/utilities/globals/maybe.d.ts +2 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/globals/maybe.js +7 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +8 -0
- package/utilities/graphql/directives.d.ts +18 -0
- package/utilities/graphql/directives.d.ts.map +1 -0
- package/utilities/graphql/directives.js +72 -0
- package/utilities/graphql/directives.js.map +1 -0
- package/utilities/graphql/fragments.d.ts +9 -0
- package/utilities/graphql/fragments.d.ts.map +1 -0
- package/utilities/graphql/fragments.js +64 -0
- package/utilities/graphql/fragments.js.map +1 -0
- package/utilities/graphql/getFromAST.d.ts +10 -0
- package/utilities/graphql/getFromAST.d.ts.map +1 -0
- package/utilities/graphql/getFromAST.js +76 -0
- package/utilities/graphql/getFromAST.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +32 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -0
- package/utilities/graphql/storeUtils.js +208 -0
- package/utilities/graphql/storeUtils.js.map +1 -0
- package/utilities/graphql/transform.d.ts +27 -0
- package/utilities/graphql/transform.d.ts.map +1 -0
- package/utilities/graphql/transform.js +281 -0
- package/utilities/graphql/transform.js.map +1 -0
- package/utilities/index.d.ts +27 -0
- package/utilities/index.d.ts.map +1 -0
- package/utilities/index.js +27 -0
- package/utilities/index.js.map +1 -0
- package/utilities/observables/Concast.d.ts +27 -0
- package/utilities/observables/Concast.d.ts.map +1 -0
- package/utilities/observables/Concast.js +137 -0
- package/utilities/observables/Concast.js.map +1 -0
- package/utilities/observables/Observable.d.ts +5 -0
- package/utilities/observables/Observable.d.ts.map +1 -0
- package/utilities/observables/Observable.js +9 -0
- package/utilities/observables/Observable.js.map +1 -0
- package/utilities/observables/asyncMap.d.ts +3 -0
- package/utilities/observables/asyncMap.d.ts.map +1 -0
- package/utilities/observables/asyncMap.js +49 -0
- package/utilities/observables/asyncMap.js.map +1 -0
- package/utilities/observables/iteration.d.ts +3 -0
- package/utilities/observables/iteration.d.ts.map +1 -0
- package/utilities/observables/iteration.js +6 -0
- package/utilities/observables/iteration.js.map +1 -0
- package/utilities/observables/subclassing.d.ts +3 -0
- package/utilities/observables/subclassing.d.ts.map +1 -0
- package/utilities/observables/subclassing.js +13 -0
- package/utilities/observables/subclassing.js.map +1 -0
- package/utilities/package.json +8 -0
- package/utilities/policies/pagination.d.ts +28 -0
- package/utilities/policies/pagination.d.ts.map +1 -0
- package/utilities/policies/pagination.js +151 -0
- package/utilities/policies/pagination.js.map +1 -0
- package/utilities/types/IsStrictlyAny.d.ts +5 -0
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -0
- package/utilities/types/IsStrictlyAny.js +2 -0
- package/utilities/types/IsStrictlyAny.js.map +1 -0
- package/utilities/utilities.cjs +1371 -0
- package/utilities/utilities.cjs.map +1 -0
- package/utilities/utilities.cjs.native.js +1371 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +2 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { invariant, __DEV__ } from "../globals/index.js";
|
|
3
|
+
import { visit, } from 'graphql';
|
|
4
|
+
import { checkDocument, getOperationDefinition, getFragmentDefinition, getFragmentDefinitions, getMainDefinition, } from "./getFromAST.js";
|
|
5
|
+
import { filterInPlace } from "../common/filterInPlace.js";
|
|
6
|
+
import { isField, isInlineFragment } from "./storeUtils.js";
|
|
7
|
+
import { createFragmentMap, } from "./fragments.js";
|
|
8
|
+
var TYPENAME_FIELD = {
|
|
9
|
+
kind: 'Field',
|
|
10
|
+
name: {
|
|
11
|
+
kind: 'Name',
|
|
12
|
+
value: '__typename',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
function isEmpty(op, fragmentMap) {
|
|
16
|
+
return !op || op.selectionSet.selections.every(function (selection) { return selection.kind === 'FragmentSpread' &&
|
|
17
|
+
isEmpty(fragmentMap[selection.name.value], fragmentMap); });
|
|
18
|
+
}
|
|
19
|
+
function nullIfDocIsEmpty(doc) {
|
|
20
|
+
return isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))
|
|
21
|
+
? null
|
|
22
|
+
: doc;
|
|
23
|
+
}
|
|
24
|
+
function getDirectiveMatcher(directives) {
|
|
25
|
+
return function directiveMatcher(directive) {
|
|
26
|
+
return directives.some(function (dir) {
|
|
27
|
+
return (dir.name && dir.name === directive.name.value) ||
|
|
28
|
+
(dir.test && dir.test(directive));
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function removeDirectivesFromDocument(directives, doc) {
|
|
33
|
+
var variablesInUse = Object.create(null);
|
|
34
|
+
var variablesToRemove = [];
|
|
35
|
+
var fragmentSpreadsInUse = Object.create(null);
|
|
36
|
+
var fragmentSpreadsToRemove = [];
|
|
37
|
+
var modifiedDoc = nullIfDocIsEmpty(visit(doc, {
|
|
38
|
+
Variable: {
|
|
39
|
+
enter: function (node, _key, parent) {
|
|
40
|
+
if (parent.kind !== 'VariableDefinition') {
|
|
41
|
+
variablesInUse[node.name.value] = true;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
Field: {
|
|
46
|
+
enter: function (node) {
|
|
47
|
+
if (directives && node.directives) {
|
|
48
|
+
var shouldRemoveField = directives.some(function (directive) { return directive.remove; });
|
|
49
|
+
if (shouldRemoveField &&
|
|
50
|
+
node.directives &&
|
|
51
|
+
node.directives.some(getDirectiveMatcher(directives))) {
|
|
52
|
+
if (node.arguments) {
|
|
53
|
+
node.arguments.forEach(function (arg) {
|
|
54
|
+
if (arg.value.kind === 'Variable') {
|
|
55
|
+
variablesToRemove.push({
|
|
56
|
+
name: arg.value.name.value,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (node.selectionSet) {
|
|
62
|
+
getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(function (frag) {
|
|
63
|
+
fragmentSpreadsToRemove.push({
|
|
64
|
+
name: frag.name.value,
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
FragmentSpread: {
|
|
74
|
+
enter: function (node) {
|
|
75
|
+
fragmentSpreadsInUse[node.name.value] = true;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
Directive: {
|
|
79
|
+
enter: function (node) {
|
|
80
|
+
if (getDirectiveMatcher(directives)(node)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}));
|
|
86
|
+
if (modifiedDoc &&
|
|
87
|
+
filterInPlace(variablesToRemove, function (v) { return !!v.name && !variablesInUse[v.name]; }).length) {
|
|
88
|
+
modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);
|
|
89
|
+
}
|
|
90
|
+
if (modifiedDoc &&
|
|
91
|
+
filterInPlace(fragmentSpreadsToRemove, function (fs) { return !!fs.name && !fragmentSpreadsInUse[fs.name]; })
|
|
92
|
+
.length) {
|
|
93
|
+
modifiedDoc = removeFragmentSpreadFromDocument(fragmentSpreadsToRemove, modifiedDoc);
|
|
94
|
+
}
|
|
95
|
+
return modifiedDoc;
|
|
96
|
+
}
|
|
97
|
+
export var addTypenameToDocument = Object.assign(function (doc) {
|
|
98
|
+
return visit(doc, {
|
|
99
|
+
SelectionSet: {
|
|
100
|
+
enter: function (node, _key, parent) {
|
|
101
|
+
if (parent &&
|
|
102
|
+
parent.kind === 'OperationDefinition') {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var selections = node.selections;
|
|
106
|
+
if (!selections) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var skip = selections.some(function (selection) {
|
|
110
|
+
return (isField(selection) &&
|
|
111
|
+
(selection.name.value === '__typename' ||
|
|
112
|
+
selection.name.value.lastIndexOf('__', 0) === 0));
|
|
113
|
+
});
|
|
114
|
+
if (skip) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
var field = parent;
|
|
118
|
+
if (isField(field) &&
|
|
119
|
+
field.directives &&
|
|
120
|
+
field.directives.some(function (d) { return d.name.value === 'export'; })) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
return __assign(__assign({}, node), { selections: __spreadArray(__spreadArray([], selections, true), [TYPENAME_FIELD], false) });
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}, {
|
|
128
|
+
added: function (field) {
|
|
129
|
+
return field === TYPENAME_FIELD;
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
var connectionRemoveConfig = {
|
|
133
|
+
test: function (directive) {
|
|
134
|
+
var willRemove = directive.name.value === 'connection';
|
|
135
|
+
if (willRemove) {
|
|
136
|
+
if (!directive.arguments ||
|
|
137
|
+
!directive.arguments.some(function (arg) { return arg.name.value === 'key'; })) {
|
|
138
|
+
__DEV__ && invariant.warn('Removing an @connection directive even though it does not have a key. ' +
|
|
139
|
+
'You may want to use the key parameter to specify a store key.');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return willRemove;
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
export function removeConnectionDirectiveFromDocument(doc) {
|
|
146
|
+
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
147
|
+
}
|
|
148
|
+
function hasDirectivesInSelectionSet(directives, selectionSet, nestedCheck) {
|
|
149
|
+
if (nestedCheck === void 0) { nestedCheck = true; }
|
|
150
|
+
return (!!selectionSet &&
|
|
151
|
+
selectionSet.selections &&
|
|
152
|
+
selectionSet.selections.some(function (selection) {
|
|
153
|
+
return hasDirectivesInSelection(directives, selection, nestedCheck);
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
function hasDirectivesInSelection(directives, selection, nestedCheck) {
|
|
157
|
+
if (nestedCheck === void 0) { nestedCheck = true; }
|
|
158
|
+
if (!isField(selection)) {
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
if (!selection.directives) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return (selection.directives.some(getDirectiveMatcher(directives)) ||
|
|
165
|
+
(nestedCheck &&
|
|
166
|
+
hasDirectivesInSelectionSet(directives, selection.selectionSet, nestedCheck)));
|
|
167
|
+
}
|
|
168
|
+
function getArgumentMatcher(config) {
|
|
169
|
+
return function argumentMatcher(argument) {
|
|
170
|
+
return config.some(function (aConfig) {
|
|
171
|
+
return argument.value &&
|
|
172
|
+
argument.value.kind === 'Variable' &&
|
|
173
|
+
argument.value.name &&
|
|
174
|
+
(aConfig.name === argument.value.name.value ||
|
|
175
|
+
(aConfig.test && aConfig.test(argument)));
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export function removeArgumentsFromDocument(config, doc) {
|
|
180
|
+
var argMatcher = getArgumentMatcher(config);
|
|
181
|
+
return nullIfDocIsEmpty(visit(doc, {
|
|
182
|
+
OperationDefinition: {
|
|
183
|
+
enter: function (node) {
|
|
184
|
+
return __assign(__assign({}, node), { variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(function (varDef) {
|
|
185
|
+
return !config.some(function (arg) { return arg.name === varDef.variable.name.value; });
|
|
186
|
+
}) : [] });
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
Field: {
|
|
190
|
+
enter: function (node) {
|
|
191
|
+
var shouldRemoveField = config.some(function (argConfig) { return argConfig.remove; });
|
|
192
|
+
if (shouldRemoveField) {
|
|
193
|
+
var argMatchCount_1 = 0;
|
|
194
|
+
if (node.arguments) {
|
|
195
|
+
node.arguments.forEach(function (arg) {
|
|
196
|
+
if (argMatcher(arg)) {
|
|
197
|
+
argMatchCount_1 += 1;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
if (argMatchCount_1 === 1) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
Argument: {
|
|
208
|
+
enter: function (node) {
|
|
209
|
+
if (argMatcher(node)) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
export function removeFragmentSpreadFromDocument(config, doc) {
|
|
217
|
+
function enter(node) {
|
|
218
|
+
if (config.some(function (def) { return def.name === node.name.value; })) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return nullIfDocIsEmpty(visit(doc, {
|
|
223
|
+
FragmentSpread: { enter: enter },
|
|
224
|
+
FragmentDefinition: { enter: enter },
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
function getAllFragmentSpreadsFromSelectionSet(selectionSet) {
|
|
228
|
+
var allFragments = [];
|
|
229
|
+
selectionSet.selections.forEach(function (selection) {
|
|
230
|
+
if ((isField(selection) || isInlineFragment(selection)) &&
|
|
231
|
+
selection.selectionSet) {
|
|
232
|
+
getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(function (frag) { return allFragments.push(frag); });
|
|
233
|
+
}
|
|
234
|
+
else if (selection.kind === 'FragmentSpread') {
|
|
235
|
+
allFragments.push(selection);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return allFragments;
|
|
239
|
+
}
|
|
240
|
+
export function buildQueryFromSelectionSet(document) {
|
|
241
|
+
var definition = getMainDefinition(document);
|
|
242
|
+
var definitionOperation = definition.operation;
|
|
243
|
+
if (definitionOperation === 'query') {
|
|
244
|
+
return document;
|
|
245
|
+
}
|
|
246
|
+
var modifiedDoc = visit(document, {
|
|
247
|
+
OperationDefinition: {
|
|
248
|
+
enter: function (node) {
|
|
249
|
+
return __assign(__assign({}, node), { operation: 'query' });
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
return modifiedDoc;
|
|
254
|
+
}
|
|
255
|
+
export function removeClientSetsFromDocument(document) {
|
|
256
|
+
checkDocument(document);
|
|
257
|
+
var modifiedDoc = removeDirectivesFromDocument([
|
|
258
|
+
{
|
|
259
|
+
test: function (directive) { return directive.name.value === 'client'; },
|
|
260
|
+
remove: true,
|
|
261
|
+
},
|
|
262
|
+
], document);
|
|
263
|
+
if (modifiedDoc) {
|
|
264
|
+
modifiedDoc = visit(modifiedDoc, {
|
|
265
|
+
FragmentDefinition: {
|
|
266
|
+
enter: function (node) {
|
|
267
|
+
if (node.selectionSet) {
|
|
268
|
+
var isTypenameOnly = node.selectionSet.selections.every(function (selection) {
|
|
269
|
+
return isField(selection) && selection.name.value === '__typename';
|
|
270
|
+
});
|
|
271
|
+
if (isTypenameOnly) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return modifiedDoc;
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/utilities/graphql/transform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAYL,KAAK,GAEN,MAAM,SAAS,CAAC;AAKjB,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,iB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ionSetNode,\n OperationDefinitionNode,\n FieldNode,\n DirectiveNode,\n FragmentDefinitionNode,\n ArgumentNode,\n FragmentSpreadNode,\n VariableDefinitionNode,\n VariableNode,\n visit,\n ASTNode,\n} from 'graphql';\n\n// TODO(brian): A hack until this issue is resolved (https://github.com/graphql/graphql-js/issues/3356)\ntype Kind = any;\n\nimport {\n checkDocument,\n getOperationDefinition,\n getFragmentDefinition,\n getFragmentDefinitions,\n getMainDefinition,\n} from './getFromAST';\nimport { filterInPlace } from '../common/filterInPlace';\nimport { isField, isInlineFragment } from './storeUtils';\nimport {\n createFragmentMap,\n FragmentMap,\n} from './fragments';\n\nexport type RemoveNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n remove?: boolean;\n};\n\nexport type GetNodeConfig<N> = {\n name?: string;\n test?: (node: N) => boolean;\n};\n\nexport type RemoveDirectiveConfig = RemoveNodeConfig<DirectiveNode>;\nexport type GetDirectiveConfig = GetNodeConfig<DirectiveNode>;\nexport type RemoveArgumentsConfig = RemoveNodeConfig<ArgumentNode>;\nexport type GetFragmentSpreadConfig = GetNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpreadNode>;\nexport type RemoveFragmentDefinitionConfig = RemoveNodeConfig<\n FragmentDefinitionNode\n>;\nexport type RemoveVariableDefinitionConfig = RemoveNodeConfig<\n VariableDefinitionNode\n>;\n\nconst TYPENAME_FIELD: FieldNode = {\n kind: 'Field' as Kind,\n name: {\n kind: 'Name' as Kind,\n value: '__typename',\n },\n};\n\nfunction isEmpty(\n op: OperationDefinitionNode | FragmentDefinitionNode,\n fragmentMap: FragmentMap,\n): boolean {\n return !op || op.selectionSet.selections.every(\n selection => selection.kind === 'FragmentSpread' &&\n isEmpty(fragmentMap[selection.name.value], fragmentMap)\n );\n}\n\nfunction nullIfDocIsEmpty(doc: DocumentNode) {\n return isEmpty(\n getOperationDefinition(doc) || getFragmentDefinition(doc),\n createFragmentMap(getFragmentDefinitions(doc)),\n )\n ? null\n : doc;\n}\n\nfunction getDirectiveMatcher(\n directives: (RemoveDirectiveConfig | GetDirectiveConfig)[],\n) {\n return function directiveMatcher(directive: DirectiveNode) {\n return directives.some(\n dir =>\n (dir.name && dir.name === directive.name.value) ||\n (dir.test && dir.test(directive)),\n );\n };\n}\n\nexport function removeDirectivesFromDocument(\n directives: RemoveDirectiveConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const variablesInUse: Record<string, boolean> = Object.create(null);\n let variablesToRemove: RemoveArgumentsConfig[] = [];\n\n const fragmentSpreadsInUse: Record<string, boolean> = Object.create(null);\n let fragmentSpreadsToRemove: RemoveFragmentSpreadConfig[] = [];\n\n let modifiedDoc = nullIfDocIsEmpty(\n visit(doc, {\n Variable: {\n enter(node, _key, parent) {\n // Store each variable that's referenced as part of an argument\n // (excluding operation definition variables), so we know which\n // variables are being used. If we later want to remove a variable\n // we'll first check to see if it's being used, before continuing with\n // the removal.\n if (\n (parent as VariableDefinitionNode).kind !== 'VariableDefinition'\n ) {\n variablesInUse[node.name.value] = true;\n }\n },\n },\n\n Field: {\n enter(node) {\n if (directives && node.directives) {\n // If `remove` is set to true for a directive, and a directive match\n // is found for a field, remove the field as well.\n const shouldRemoveField = directives.some(\n directive => directive.remove,\n );\n\n if (\n shouldRemoveField &&\n node.directives &&\n node.directives.some(getDirectiveMatcher(directives))\n ) {\n if (node.arguments) {\n // Store field argument variables so they can be removed\n // from the operation definition.\n node.arguments.forEach(arg => {\n if (arg.value.kind === 'Variable') {\n variablesToRemove.push({\n name: (arg.value as VariableNode).name.value,\n });\n }\n });\n }\n\n if (node.selectionSet) {\n // Store fragment spread names so they can be removed from the\n // document.\n getAllFragmentSpreadsFromSelectionSet(node.selectionSet).forEach(\n frag => {\n fragmentSpreadsToRemove.push({\n name: frag.name.value,\n });\n },\n );\n }\n\n // Remove the field.\n return null;\n }\n }\n },\n },\n\n FragmentSpread: {\n enter(node) {\n // Keep track of referenced fragment spreads. This is used to\n // determine if top level fragment definitions should be removed.\n fragmentSpreadsInUse[node.name.value] = true;\n },\n },\n\n Directive: {\n enter(node) {\n // If a matching directive is found, remove it.\n if (getDirectiveMatcher(directives)(node)) {\n return null;\n }\n },\n },\n }),\n );\n\n // If we've removed fields with arguments, make sure the associated\n // variables are also removed from the rest of the document, as long as they\n // aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(variablesToRemove, v => !!v.name && !variablesInUse[v.name]).length\n ) {\n modifiedDoc = removeArgumentsFromDocument(variablesToRemove, modifiedDoc);\n }\n\n // If we've removed selection sets with fragment spreads, make sure the\n // associated fragment definitions are also removed from the rest of the\n // document, as long as they aren't being used elsewhere.\n if (\n modifiedDoc &&\n filterInPlace(fragmentSpreadsToRemove, fs => !!fs.name && !fragmentSpreadsInUse[fs.name])\n .length\n ) {\n modifiedDoc = removeFragmentSpreadFromDocument(\n fragmentSpreadsToRemove,\n modifiedDoc,\n );\n }\n\n return modifiedDoc;\n}\n\nexport const addTypenameToDocument = Object.assign(function <\n TNode extends ASTNode\n>(\n doc: TNode\n): TNode {\n return visit(doc, {\n SelectionSet: {\n enter(node, _key, parent) {\n // Don't add __typename to OperationDefinitions.\n if (\n parent &&\n (parent as OperationDefinitionNode).kind === 'OperationDefinition'\n ) {\n return;\n }\n\n // No changes if no selections.\n const { selections } = node;\n if (!selections) {\n return;\n }\n\n // If selections already have a __typename, or are part of an\n // introspection query, do nothing.\n const skip = selections.some(selection => {\n return (\n isField(selection) &&\n (selection.name.value === '__typename' ||\n selection.name.value.lastIndexOf('__', 0) === 0)\n );\n });\n if (skip) {\n return;\n }\n\n // If this SelectionSet is @export-ed as an input variable, it should\n // not have a __typename field (see issue #4691).\n const field = parent as FieldNode;\n if (\n isField(field) &&\n field.directives &&\n field.directives.some(d => d.name.value === 'export')\n ) {\n return;\n }\n\n // Create and return a new SelectionSet with a __typename Field.\n return {\n ...node,\n selections: [...selections, TYPENAME_FIELD],\n };\n },\n },\n });\n}, {\n added(field: FieldNode): boolean {\n return field === TYPENAME_FIELD;\n },\n});\n\nconst connectionRemoveConfig = {\n test: (directive: DirectiveNode) => {\n const willRemove = directive.name.value === 'connection';\n if (willRemove) {\n if (\n !directive.arguments ||\n !directive.arguments.some(arg => arg.name.value === 'key')\n ) {\n invariant.warn(\n 'Removing an @connection directive even though it does not have a key. ' +\n 'You may want to use the key parameter to specify a store key.',\n );\n }\n }\n\n return willRemove;\n },\n};\n\nexport function removeConnectionDirectiveFromDocument(doc: DocumentNode) {\n return removeDirectivesFromDocument(\n [connectionRemoveConfig],\n checkDocument(doc),\n );\n}\n\nfunction hasDirectivesInSelectionSet(\n directives: GetDirectiveConfig[],\n selectionSet: SelectionSetNode | undefined,\n nestedCheck = true,\n): boolean {\n return (\n !!selectionSet &&\n selectionSet.selections &&\n selectionSet.selections.some(selection =>\n hasDirectivesInSelection(directives, selection, nestedCheck),\n )\n );\n}\n\nfunction hasDirectivesInSelection(\n directives: GetDirectiveConfig[],\n selection: SelectionNode,\n nestedCheck = true,\n): boolean {\n if (!isField(selection)) {\n return true;\n }\n\n if (!selection.directives) {\n return false;\n }\n\n return (\n selection.directives.some(getDirectiveMatcher(directives)) ||\n (nestedCheck &&\n hasDirectivesInSelectionSet(\n directives,\n selection.selectionSet,\n nestedCheck,\n ))\n );\n}\n\nfunction getArgumentMatcher(config: RemoveArgumentsConfig[]) {\n return function argumentMatcher(argument: ArgumentNode) {\n return config.some(\n (aConfig: RemoveArgumentsConfig) =>\n argument.value &&\n argument.value.kind === 'Variable' &&\n argument.value.name &&\n (aConfig.name === argument.value.name.value ||\n (aConfig.test && aConfig.test(argument))),\n );\n };\n}\n\nexport function removeArgumentsFromDocument(\n config: RemoveArgumentsConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n const argMatcher = getArgumentMatcher(config);\n\n return nullIfDocIsEmpty(\n visit(doc, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n // Remove matching top level variables definitions.\n variableDefinitions: node.variableDefinitions ? node.variableDefinitions.filter(\n varDef =>\n !config.some(arg => arg.name === varDef.variable.name.value),\n ) : [],\n };\n },\n },\n\n Field: {\n enter(node) {\n // If `remove` is set to true for an argument, and an argument match\n // is found for a field, remove the field as well.\n const shouldRemoveField = config.some(argConfig => argConfig.remove);\n\n if (shouldRemoveField) {\n let argMatchCount = 0;\n if (node.arguments) {\n node.arguments.forEach(arg => {\n if (argMatcher(arg)) {\n argMatchCount += 1;\n }\n });\n }\n\n if (argMatchCount === 1) {\n return null;\n }\n }\n },\n },\n\n Argument: {\n enter(node) {\n // Remove all matching arguments.\n if (argMatcher(node)) {\n return null;\n }\n },\n },\n }),\n );\n}\n\nexport function removeFragmentSpreadFromDocument(\n config: RemoveFragmentSpreadConfig[],\n doc: DocumentNode,\n): DocumentNode | null {\n function enter(\n node: FragmentSpreadNode | FragmentDefinitionNode,\n ): null | void {\n if (config.some(def => def.name === node.name.value)) {\n return null;\n }\n }\n\n return nullIfDocIsEmpty(\n visit(doc, {\n FragmentSpread: { enter },\n FragmentDefinition: { enter },\n }),\n );\n}\n\nfunction getAllFragmentSpreadsFromSelectionSet(\n selectionSet: SelectionSetNode,\n): FragmentSpreadNode[] {\n const allFragments: FragmentSpreadNode[] = [];\n\n selectionSet.selections.forEach(selection => {\n if (\n (isField(selection) || isInlineFragment(selection)) &&\n selection.selectionSet\n ) {\n getAllFragmentSpreadsFromSelectionSet(selection.selectionSet).forEach(\n frag => allFragments.push(frag),\n );\n } else if (selection.kind === 'FragmentSpread') {\n allFragments.push(selection);\n }\n });\n\n return allFragments;\n}\n\n// If the incoming document is a query, return it as is. Otherwise, build a\n// new document containing a query operation based on the selection set\n// of the previous main operation.\nexport function buildQueryFromSelectionSet(\n document: DocumentNode,\n): DocumentNode {\n const definition = getMainDefinition(document);\n const definitionOperation = (<OperationDefinitionNode>definition).operation;\n\n if (definitionOperation === 'query') {\n // Already a query, so return the existing document.\n return document;\n }\n\n // Build a new query using the selection set of the main operation.\n const modifiedDoc = visit(document, {\n OperationDefinition: {\n enter(node) {\n return {\n ...node,\n operation: 'query',\n };\n },\n },\n });\n return modifiedDoc;\n}\n\n// Remove fields / selection sets that include an @client directive.\nexport function removeClientSetsFromDocument(\n document: DocumentNode,\n): DocumentNode | null {\n checkDocument(document);\n\n let modifiedDoc = removeDirectivesFromDocument(\n [\n {\n test: (directive: DirectiveNode) => directive.name.value === 'client',\n remove: true,\n },\n ],\n document,\n );\n\n // After a fragment definition has had its @client related document\n // sets removed, if the only field it has left is a __typename field,\n // remove the entire fragment operation to prevent it from being fired\n // on the server.\n if (modifiedDoc) {\n modifiedDoc = visit(modifiedDoc, {\n FragmentDefinition: {\n enter(node) {\n if (node.selectionSet) {\n const isTypenameOnly = node.selectionSet.selections.every(\n selection =>\n isField(selection) && selection.name.value === '__typename',\n );\n if (isTypenameOnly) {\n return null;\n }\n }\n },\n },\n });\n }\n\n return modifiedDoc;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { DEV, maybe } from './globals';
|
|
2
|
+
export { DirectiveInfo, InclusionDirectives, shouldInclude, hasDirectives, hasAnyDirectives, hasAllDirectives, hasClientExports, getDirectiveNames, getInclusionDirectives, } from './graphql/directives';
|
|
3
|
+
export { FragmentMap, FragmentMapFunction, createFragmentMap, getFragmentQueryDocument, getFragmentFromSelection, } from './graphql/fragments';
|
|
4
|
+
export { checkDocument, getOperationDefinition, getOperationName, getFragmentDefinitions, getQueryDefinition, getFragmentDefinition, getMainDefinition, getDefaultValues, } from './graphql/getFromAST';
|
|
5
|
+
export { StoreObject, Reference, StoreValue, Directives, VariableValue, makeReference, isDocumentNode, isReference, isField, isInlineFragment, valueToObjectRepresentation, storeKeyNameFromField, argumentsObjectFromField, resultKeyNameFromField, getStoreKeyName, getTypenameFromResult, } from './graphql/storeUtils';
|
|
6
|
+
export { RemoveNodeConfig, GetNodeConfig, RemoveDirectiveConfig, GetDirectiveConfig, RemoveArgumentsConfig, GetFragmentSpreadConfig, RemoveFragmentSpreadConfig, RemoveFragmentDefinitionConfig, RemoveVariableDefinitionConfig, addTypenameToDocument, buildQueryFromSelectionSet, removeDirectivesFromDocument, removeConnectionDirectiveFromDocument, removeArgumentsFromDocument, removeFragmentSpreadFromDocument, removeClientSetsFromDocument, } from './graphql/transform';
|
|
7
|
+
export { concatPagination, offsetLimitPagination, relayStylePagination, } from './policies/pagination';
|
|
8
|
+
export { Observable, Observer, ObservableSubscription } from './observables/Observable';
|
|
9
|
+
export * from './common/mergeDeep';
|
|
10
|
+
export * from './common/cloneDeep';
|
|
11
|
+
export * from './common/maybeDeepFreeze';
|
|
12
|
+
export * from './observables/iteration';
|
|
13
|
+
export * from './observables/asyncMap';
|
|
14
|
+
export * from './observables/Concast';
|
|
15
|
+
export * from './observables/subclassing';
|
|
16
|
+
export * from './common/arrays';
|
|
17
|
+
export * from './common/objects';
|
|
18
|
+
export * from './common/errorHandling';
|
|
19
|
+
export * from './common/canUse';
|
|
20
|
+
export * from './common/compact';
|
|
21
|
+
export * from './common/makeUniqueId';
|
|
22
|
+
export * from './common/stringifyForDisplay';
|
|
23
|
+
export * from './common/mergeOptions';
|
|
24
|
+
export * from './common/responseIterator';
|
|
25
|
+
export * from './common/incrementalResult';
|
|
26
|
+
export * from './types/IsStrictlyAny';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,C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,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { DEV, maybe } from "./globals/index.js";
|
|
2
|
+
export { shouldInclude, hasDirectives, hasAnyDirectives, hasAllDirectives, hasClientExports, getDirectiveNames, getInclusionDirectives, } from "./graphql/directives.js";
|
|
3
|
+
export { createFragmentMap, getFragmentQueryDocument, getFragmentFromSelection, } from "./graphql/fragments.js";
|
|
4
|
+
export { checkDocument, getOperationDefinition, getOperationName, getFragmentDefinitions, getQueryDefinition, getFragmentDefinition, getMainDefinition, getDefaultValues, } from "./graphql/getFromAST.js";
|
|
5
|
+
export { makeReference, isDocumentNode, isReference, isField, isInlineFragment, valueToObjectRepresentation, storeKeyNameFromField, argumentsObjectFromField, resultKeyNameFromField, getStoreKeyName, getTypenameFromResult, } from "./graphql/storeUtils.js";
|
|
6
|
+
export { addTypenameToDocument, buildQueryFromSelectionSet, removeDirectivesFromDocument, removeConnectionDirectiveFromDocument, removeArgumentsFromDocument, removeFragmentSpreadFromDocument, removeClientSetsFromDocument, } from "./graphql/transform.js";
|
|
7
|
+
export { concatPagination, offsetLimitPagination, relayStylePagination, } from "./policies/pagination.js";
|
|
8
|
+
export { Observable } from "./observables/Observable.js";
|
|
9
|
+
export * from "./common/mergeDeep.js";
|
|
10
|
+
export * from "./common/cloneDeep.js";
|
|
11
|
+
export * from "./common/maybeDeepFreeze.js";
|
|
12
|
+
export * from "./observables/iteration.js";
|
|
13
|
+
export * from "./observables/asyncMap.js";
|
|
14
|
+
export * from "./observables/Concast.js";
|
|
15
|
+
export * from "./observables/subclassing.js";
|
|
16
|
+
export * from "./common/arrays.js";
|
|
17
|
+
export * from "./common/objects.js";
|
|
18
|
+
export * from "./common/errorHandling.js";
|
|
19
|
+
export * from "./common/canUse.js";
|
|
20
|
+
export * from "./common/compact.js";
|
|
21
|
+
export * from "./common/makeUniqueId.js";
|
|
22
|
+
export * from "./common/stringifyForDisplay.js";
|
|
23
|
+
export * from "./common/mergeOptions.js";
|
|
24
|
+
export * from "./common/responseIterator.js";
|
|
25
|
+
export * from "./common/incrementalResult.js";
|
|
26
|
+
export * from "./types/IsStrictlyAny.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAGL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAGL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAML,aAAa,EACb,cAAc,EACd,WAAW,EACX,OAAO,EACP,gBAAgB,EAChB,2BAA2B,EAC3B,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAUL,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC5B,qCAAqC,EACrC,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EAGX,MAAM,0BAA0B,CAAC;AAElC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,uBAAuB,CAAC","sourcesContent":["export { DEV, maybe } from './globals';\n\nexport {\n DirectiveInfo,\n InclusionDirectives,\n shouldInclude,\n hasDirectives,\n hasAnyDirectives,\n hasAllDirectives,\n hasClientExports,\n getDirectiveNames,\n getInclusionDirectives,\n} from './graphql/directives';\n\nexport {\n FragmentMap,\n FragmentMapFunction,\n createFragmentMap,\n getFragmentQueryDocument,\n getFragmentFromSelection,\n} from './graphql/fragments';\n\nexport {\n checkDocument,\n getOperationDefinition,\n getOperationName,\n getFragmentDefinitions,\n getQueryDefinition,\n getFragmentDefinition,\n getMainDefinition,\n getDefaultValues,\n} from './graphql/getFromAST';\n\nexport {\n StoreObject,\n Reference,\n StoreValue,\n Directives,\n VariableValue,\n makeReference,\n isDocumentNode,\n isReference,\n isField,\n isInlineFragment,\n valueToObjectRepresentation,\n storeKeyNameFromField,\n argumentsObjectFromField,\n resultKeyNameFromField,\n getStoreKeyName,\n getTypenameFromResult,\n} from './graphql/storeUtils';\n\nexport {\n RemoveNodeConfig,\n GetNodeConfig,\n RemoveDirectiveConfig,\n GetDirectiveConfig,\n RemoveArgumentsConfig,\n GetFragmentSpreadConfig,\n RemoveFragmentSpreadConfig,\n RemoveFragmentDefinitionConfig,\n RemoveVariableDefinitionConfig,\n addTypenameToDocument,\n buildQueryFromSelectionSet,\n removeDirectivesFromDocument,\n removeConnectionDirectiveFromDocument,\n removeArgumentsFromDocument,\n removeFragmentSpreadFromDocument,\n removeClientSetsFromDocument,\n} from './graphql/transform';\n\nexport {\n concatPagination,\n offsetLimitPagination,\n relayStylePagination,\n} from './policies/pagination';\n\nexport {\n Observable,\n Observer,\n ObservableSubscription\n} from './observables/Observable';\n\nexport * from './common/mergeDeep';\nexport * from './common/cloneDeep';\nexport * from './common/maybeDeepFreeze';\nexport * from './observables/iteration';\nexport * from './observables/asyncMap';\nexport * from './observables/Concast';\nexport * from './observables/subclassing';\nexport * from './common/arrays';\nexport * from './common/objects';\nexport * from './common/errorHandling';\nexport * from './common/canUse';\nexport * from './common/compact';\nexport * from './common/makeUniqueId';\nexport * from './common/stringifyForDisplay';\nexport * from './common/mergeOptions';\nexport * from './common/responseIterator';\nexport * from './common/incrementalResult';\n\nexport * from './types/IsStrictlyAny';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Observable, Observer, Subscriber } from "./Observable";
|
|
2
|
+
type MaybeAsync<T> = T | PromiseLike<T>;
|
|
3
|
+
type Source<T> = MaybeAsync<Observable<T>>;
|
|
4
|
+
export type ConcastSourcesIterable<T> = Iterable<Source<T>>;
|
|
5
|
+
export type ConcastSourcesArray<T> = Array<Source<T>>;
|
|
6
|
+
export declare class Concast<T> extends Observable<T> {
|
|
7
|
+
private observers;
|
|
8
|
+
private sub?;
|
|
9
|
+
constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>);
|
|
10
|
+
private sources;
|
|
11
|
+
private start;
|
|
12
|
+
private deliverLastMessage;
|
|
13
|
+
addObserver(observer: Observer<T>): void;
|
|
14
|
+
removeObserver(observer: Observer<T>): void;
|
|
15
|
+
private resolve;
|
|
16
|
+
private reject;
|
|
17
|
+
readonly promise: Promise<T>;
|
|
18
|
+
private latest?;
|
|
19
|
+
private handlers;
|
|
20
|
+
private nextResultListeners;
|
|
21
|
+
private notify;
|
|
22
|
+
beforeNext(callback: NextResultListener): void;
|
|
23
|
+
cancel: (reason: any) => void;
|
|
24
|
+
}
|
|
25
|
+
type NextResultListener = (method: "next" | "error" | "complete", arg?: any) => any;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=Concast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Concast.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAA0B,UAAU,EAAE,MAAM,cAAc,CAAC;AAIxF,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAOxC,KAAK,MAAM,CAAC,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AA+BtD,qBAAa,OAAO,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAI3C,OAAO,CAAC,SAAS,CAA0B;IAM3C,OAAO,CAAC,GAAG,CAAC,CAAgC;gBAIhC,OAAO,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA8B1E,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,kBAAkB;IAkBnB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IASjC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAgB3C,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,MAAM,CAAwB;IACtC,SAAgB,OAAO,aAGpB;IAIH,OAAO,CAAC,MAAM,CAAC,CAA+B;IAI9C,OAAO,CAAC,QAAQ,CAoDd;IAEF,OAAO,CAAC,mBAAmB,CAAiC;IAE5D,OAAO,CAAC,MAAM;IAmBd,UAAU,CAAC,QAAQ,EAAE,kBAAkB;IAWhC,MAAM,WAAY,GAAG,UAI3B;CACF;AAED,KAAK,kBAAkB,GAAG,CACxB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,EACrC,GAAG,CAAC,EAAE,GAAG,KACN,GAAG,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { __extends } from "tslib";
|
|
2
|
+
import { Observable } from "./Observable.js";
|
|
3
|
+
import { iterateObserversSafely } from "./iteration.js";
|
|
4
|
+
import { fixObservableSubclass } from "./subclassing.js";
|
|
5
|
+
function isPromiseLike(value) {
|
|
6
|
+
return value && typeof value.then === "function";
|
|
7
|
+
}
|
|
8
|
+
var Concast = (function (_super) {
|
|
9
|
+
__extends(Concast, _super);
|
|
10
|
+
function Concast(sources) {
|
|
11
|
+
var _this = _super.call(this, function (observer) {
|
|
12
|
+
_this.addObserver(observer);
|
|
13
|
+
return function () { return _this.removeObserver(observer); };
|
|
14
|
+
}) || this;
|
|
15
|
+
_this.observers = new Set();
|
|
16
|
+
_this.promise = new Promise(function (resolve, reject) {
|
|
17
|
+
_this.resolve = resolve;
|
|
18
|
+
_this.reject = reject;
|
|
19
|
+
});
|
|
20
|
+
_this.handlers = {
|
|
21
|
+
next: function (result) {
|
|
22
|
+
if (_this.sub !== null) {
|
|
23
|
+
_this.latest = ["next", result];
|
|
24
|
+
_this.notify("next", result);
|
|
25
|
+
iterateObserversSafely(_this.observers, "next", result);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
error: function (error) {
|
|
29
|
+
var sub = _this.sub;
|
|
30
|
+
if (sub !== null) {
|
|
31
|
+
if (sub)
|
|
32
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
33
|
+
_this.sub = null;
|
|
34
|
+
_this.latest = ["error", error];
|
|
35
|
+
_this.reject(error);
|
|
36
|
+
_this.notify("error", error);
|
|
37
|
+
iterateObserversSafely(_this.observers, "error", error);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
complete: function () {
|
|
41
|
+
var sub = _this.sub;
|
|
42
|
+
if (sub !== null) {
|
|
43
|
+
var value = _this.sources.shift();
|
|
44
|
+
if (!value) {
|
|
45
|
+
if (sub)
|
|
46
|
+
setTimeout(function () { return sub.unsubscribe(); });
|
|
47
|
+
_this.sub = null;
|
|
48
|
+
if (_this.latest &&
|
|
49
|
+
_this.latest[0] === "next") {
|
|
50
|
+
_this.resolve(_this.latest[1]);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
_this.resolve();
|
|
54
|
+
}
|
|
55
|
+
_this.notify("complete");
|
|
56
|
+
iterateObserversSafely(_this.observers, "complete");
|
|
57
|
+
}
|
|
58
|
+
else if (isPromiseLike(value)) {
|
|
59
|
+
value.then(function (obs) { return _this.sub = obs.subscribe(_this.handlers); });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
_this.sub = value.subscribe(_this.handlers);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
_this.nextResultListeners = new Set();
|
|
68
|
+
_this.cancel = function (reason) {
|
|
69
|
+
_this.reject(reason);
|
|
70
|
+
_this.sources = [];
|
|
71
|
+
_this.handlers.complete();
|
|
72
|
+
};
|
|
73
|
+
_this.promise.catch(function (_) { });
|
|
74
|
+
if (typeof sources === "function") {
|
|
75
|
+
sources = [new Observable(sources)];
|
|
76
|
+
}
|
|
77
|
+
if (isPromiseLike(sources)) {
|
|
78
|
+
sources.then(function (iterable) { return _this.start(iterable); }, _this.handlers.error);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
_this.start(sources);
|
|
82
|
+
}
|
|
83
|
+
return _this;
|
|
84
|
+
}
|
|
85
|
+
Concast.prototype.start = function (sources) {
|
|
86
|
+
if (this.sub !== void 0)
|
|
87
|
+
return;
|
|
88
|
+
this.sources = Array.from(sources);
|
|
89
|
+
this.handlers.complete();
|
|
90
|
+
};
|
|
91
|
+
Concast.prototype.deliverLastMessage = function (observer) {
|
|
92
|
+
if (this.latest) {
|
|
93
|
+
var nextOrError = this.latest[0];
|
|
94
|
+
var method = observer[nextOrError];
|
|
95
|
+
if (method) {
|
|
96
|
+
method.call(observer, this.latest[1]);
|
|
97
|
+
}
|
|
98
|
+
if (this.sub === null &&
|
|
99
|
+
nextOrError === "next" &&
|
|
100
|
+
observer.complete) {
|
|
101
|
+
observer.complete();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
Concast.prototype.addObserver = function (observer) {
|
|
106
|
+
if (!this.observers.has(observer)) {
|
|
107
|
+
this.deliverLastMessage(observer);
|
|
108
|
+
this.observers.add(observer);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
Concast.prototype.removeObserver = function (observer) {
|
|
112
|
+
if (this.observers.delete(observer) &&
|
|
113
|
+
this.observers.size < 1) {
|
|
114
|
+
this.handlers.complete();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
Concast.prototype.notify = function (method, arg) {
|
|
118
|
+
var nextResultListeners = this.nextResultListeners;
|
|
119
|
+
if (nextResultListeners.size) {
|
|
120
|
+
this.nextResultListeners = new Set;
|
|
121
|
+
nextResultListeners.forEach(function (listener) { return listener(method, arg); });
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
Concast.prototype.beforeNext = function (callback) {
|
|
125
|
+
var called = false;
|
|
126
|
+
this.nextResultListeners.add(function (method, arg) {
|
|
127
|
+
if (!called) {
|
|
128
|
+
called = true;
|
|
129
|
+
callback(method, arg);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
return Concast;
|
|
134
|
+
}(Observable));
|
|
135
|
+
export { Concast };
|
|
136
|
+
fixObservableSubclass(Concast);
|
|
137
|
+
//# sourceMappingURL=Concast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Concast.js","sourceRoot":"","sources":["../../../src/utilities/observables/Concast.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgD,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,SAAS,aAAa,CAAI,KAAoB;IAC5C,OAAO,KAAK,IAAI,OAAQ,KAAa,CAAC,IAAI,KAAK,UAAU,CAAC;AAC5D,CAAC;AAqCD;IAAgC,2BAAa;IAc3C,iBAAY,OAA8D;QAA1E,YACE,kBAAM,UAAA,QAAQ;YACZ,KAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC3B,OAAO,cAAM,OAAA,KAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC;QAC7C,CAAC,CAAC,SAsBH;QApCO,eAAS,GAAG,IAAI,GAAG,EAAe,CAAC;QAsG3B,aAAO,GAAG,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YACvD,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACvB,CAAC,CAAC,CAAC;QAQK,cAAQ,GAAG;YACjB,IAAI,EAAE,UAAC,MAAS;gBACd,IAAI,KAAI,CAAC,GAAG,KAAK,IAAI,EAAE;oBACrB,KAAI,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC/B,KAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAC5B,sBAAsB,CAAC,KAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;iBACxD;YACH,CAAC;YAED,KAAK,EAAE,UAAC,KAAU;gBACR,IAAA,GAAG,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H,CAAC;IAQD,4BAAU,GAAV,UAAW,QAA4B;QACrC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAC,MAAM,EAAE,GAAG;YACvC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,GAAG,IAAI,CAAC;gBACd,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAQH,cAAC;AAAD,CAAC,AAhND,CAAgC,UAAU,GAgNzC;;AASD,qBAAqB,CAAC,OAAO,CAAC,CAAC","sourcesContent":["import { Observable, Observer, ObservableSubscription, Subscriber } from \"./Observable\";\nimport { iterateObserversSafely } from \"./iteration\";\nimport { fixObservableSubclass } from \"./subclassing\";\n\ntype MaybeAsync<T> = T | PromiseLike<T>;\n\nfunction isPromiseLike<T>(value: MaybeAsync<T>): value is PromiseLike<T> {\n return value && typeof (value as any).then === \"function\";\n}\n\n// Any individual Source<T> can be an Observable<T> or a promise for one.\ntype Source<T> = MaybeAsync<Observable<T>>;\n\nexport type ConcastSourcesIterable<T> = Iterable<Source<T>>;\nexport type ConcastSourcesArray<T> = Array<Source<T>>;\n\n// A Concast<T> observable concatenates the given sources into a single\n// non-overlapping sequence of Ts, automatically unwrapping any promises,\n// and broadcasts the T elements of that sequence to any number of\n// subscribers, all without creating a bunch of intermediary Observable\n// wrapper objects.\n//\n// Even though any number of observers can subscribe to the Concast, each\n// source observable is guaranteed to receive at most one subscribe call,\n// and the results are multicast to all observers.\n//\n// In addition to broadcasting every next/error message to this.observers,\n// the Concast stores the most recent message using this.latest, so any\n// new observers can immediately receive the latest message, even if it\n// was originally delivered in the past. This behavior means we can assume\n// every active observer in this.observers has received the same most\n// recent message.\n//\n// With the exception of this.latest replay, a Concast is a \"hot\"\n// observable in the sense that it does not replay past results from the\n// beginning of time for each new observer.\n//\n// Could we have used some existing RxJS class instead? Concast<T> is\n// similar to a BehaviorSubject<T>, because it is multicast and redelivers\n// the latest next/error message to new subscribers. Unlike Subject<T>,\n// Concast<T> does not expose an Observer<T> interface (this.handlers is\n// intentionally private), since Concast<T> gets its inputs from the\n// concatenated sources. If we ever switch to RxJS, there may be some\n// value in reusing their code, but for now we use zen-observable, which\n// does not contain any Subject implementations.\nexport class Concast<T> extends Observable<T> {\n // Active observers receiving broadcast messages. Thanks to this.latest,\n // we can assume all observers in this Set have received the same most\n // recent message, though possibly at different times in the past.\n private observers = new Set<Observer<T>>();\n\n // This property starts off undefined to indicate the initial\n // subscription has not yet begun, then points to each source\n // subscription in turn, and finally becomes null after the sources have\n // been exhausted. After that, it stays null.\n private sub?: ObservableSubscription | null;\n\n // Not only can the individual elements of the iterable be promises, but\n // also the iterable itself can be wrapped in a promise.\n constructor(sources: MaybeAsync<ConcastSourcesIterable<T>> | Subscriber<T>) {\n super(observer => {\n this.addObserver(observer);\n return () => this.removeObserver(observer);\n });\n\n // Suppress rejection warnings for this.promise, since it's perfectly\n // acceptable to pay no attention to this.promise if you're consuming\n // the results through the normal observable API.\n this.promise.catch(_ => {});\n\n // If someone accidentally tries to create a Concast using a subscriber\n // function, recover by creating an Observable from that subscriber and\n // using it as the source.\n if (typeof sources === \"function\") {\n sources = [new Observable(sources)];\n }\n\n if (isPromiseLike(sources)) {\n sources.then(\n iterable => this.start(iterable),\n this.handlers.error,\n );\n } else {\n this.start(sources);\n }\n }\n\n // A consumable array of source observables, incrementally consumed\n // each time this.handlers.complete is called.\n private sources: Source<T>[];\n\n private start(sources: ConcastSourcesIterable<T>) {\n if (this.sub !== void 0) return;\n\n // In practice, sources is most often simply an Array of observables.\n // TODO Consider using sources[Symbol.iterator]() to take advantage\n // of the laziness of non-Array iterables.\n this.sources = Array.from(sources);\n\n // Calling this.handlers.complete() kicks off consumption of the first\n // source observable. It's tempting to do this step lazily in\n // addObserver, but this.promise can be accessed without calling\n // addObserver, so consumption needs to begin eagerly.\n this.handlers.complete();\n }\n\n private deliverLastMessage(observer: Observer<T>) {\n if (this.latest) {\n const nextOrError = this.latest[0];\n const method = observer[nextOrError];\n if (method) {\n method.call(observer, this.latest[1]);\n }\n // If the subscription is already closed, and the last message was\n // a 'next' message, simulate delivery of the final 'complete'\n // message again.\n if (this.sub === null &&\n nextOrError === \"next\" &&\n observer.complete) {\n observer.complete();\n }\n }\n }\n\n public addObserver(observer: Observer<T>) {\n if (!this.observers.has(observer)) {\n // Immediately deliver the most recent message, so we can always\n // be sure all observers have the latest information.\n this.deliverLastMessage(observer);\n this.observers.add(observer);\n }\n }\n\n public removeObserver(observer: Observer<T>) {\n if (\n this.observers.delete(observer) &&\n this.observers.size < 1\n ) {\n // In case there are still any listeners in this.nextResultListeners, and\n // no error or completion has been broadcast yet, make sure those\n // observers have a chance to run and then remove themselves from\n // this.observers.\n this.handlers.complete();\n }\n }\n\n // Any Concast object can be trivially converted to a Promise, without\n // having to create a new wrapper Observable. This promise provides an\n // easy way to observe the final state of the Concast.\n private resolve: (result?: T | PromiseLike<T>) => void;\n private reject: (reason: any) => void;\n public readonly promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n\n // Name and argument of the most recently invoked observer method, used\n // to deliver latest results immediately to new observers.\n private latest?: [\"next\", T] | [\"error\", any];\n\n // Bound handler functions that can be reused for every internal\n // subscription.\n private handlers = {\n next: (result: T) => {\n if (this.sub !== null) {\n this.latest = [\"next\", result];\n this.notify(\"next\", result);\n iterateObserversSafely(this.observers, \"next\", result);\n }\n },\n\n error: (error: any) => {\n const { sub } = this;\n if (sub !== null) {\n // Delay unsubscribing from the underlying subscription slightly,\n // so that immediately subscribing another observer can keep the\n // subscription active.\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n this.latest = [\"error\", error];\n this.reject(error);\n this.notify(\"error\", error);\n iterateObserversSafely(this.observers, \"error\", error);\n }\n },\n\n complete: () => {\n const { sub } = this;\n if (sub !== null) {\n const value = this.sources.shift();\n if (!value) {\n if (sub) setTimeout(() => sub.unsubscribe());\n this.sub = null;\n if (this.latest &&\n this.latest[0] === \"next\") {\n this.resolve(this.latest[1]);\n } else {\n this.resolve();\n }\n this.notify(\"complete\");\n // We do not store this.latest = [\"complete\"], because doing so\n // discards useful information about the previous next (or\n // error) message. Instead, if new observers subscribe after\n // this Concast has completed, they will receive the final\n // 'next' message (unless there was an error) immediately\n // followed by a 'complete' message (see addObserver).\n iterateObserversSafely(this.observers, \"complete\");\n } else if (isPromiseLike(value)) {\n value.then(obs => this.sub = obs.subscribe(this.handlers));\n } else {\n this.sub = value.subscribe(this.handlers);\n }\n }\n },\n };\n\n private nextResultListeners = new Set<NextResultListener>();\n\n private notify(\n method: Parameters<NextResultListener>[0],\n arg?: Parameters<NextResultListener>[1],\n ) {\n const { nextResultListeners } = this;\n if (nextResultListeners.size) {\n // Replacing this.nextResultListeners first ensures it does not grow while\n // we are iterating over it, potentially leading to infinite loops.\n this.nextResultListeners = new Set;\n nextResultListeners.forEach(listener => listener(method, arg));\n }\n }\n\n // We need a way to run callbacks just *before* the next result (or error or\n // completion) is delivered by this Concast, so we can be sure any code that\n // runs as a result of delivering that result/error observes the effects of\n // running the callback(s). It was tempting to reuse the Observer type instead\n // of introducing NextResultListener, but that messes with the sizing and\n // maintenance of this.observers, and ends up being more code overall.\n beforeNext(callback: NextResultListener) {\n let called = false;\n this.nextResultListeners.add((method, arg) => {\n if (!called) {\n called = true;\n callback(method, arg);\n }\n });\n }\n\n // A public way to abort observation and broadcast.\n public cancel = (reason: any) => {\n this.reject(reason);\n this.sources = [];\n this.handlers.complete();\n }\n}\n\ntype NextResultListener = (\n method: \"next\" | \"error\" | \"complete\",\n arg?: any,\n) => any;\n\n// Necessary because the Concast constructor has a different signature\n// than the Observable constructor.\nfixObservableSubclass(Concast);\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Observable, Observer, Subscription as ObservableSubscription, Subscriber } from 'zen-observable-ts';
|
|
2
|
+
import 'symbol-observable';
|
|
3
|
+
export type { Observer, ObservableSubscription, Subscriber, };
|
|
4
|
+
export { Observable };
|
|
5
|
+
//# sourceMappingURL=Observable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Observable.d.ts","sourceRoot":"","sources":["../../../src/utilities/observables/Observable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,YAAY,IAAI,sBAAsB,EACtC,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,OAAO,mBAAmB,CAAC;AAE3B,YAAY,EACV,QAAQ,EACR,sBAAsB,EACtB,UAAU,GACX,CAAC;AAWF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Observable, } from 'zen-observable-ts';
|
|
2
|
+
import 'symbol-observable';
|
|
3
|
+
var prototype = Observable.prototype;
|
|
4
|
+
var fakeObsSymbol = '@@observable';
|
|
5
|
+
if (!prototype[fakeObsSymbol]) {
|
|
6
|
+
prototype[fakeObsSymbol] = function () { return this; };
|
|
7
|
+
}
|
|
8
|
+
export { Observable };
|
|
9
|
+
//# sourceMappingURL=Observable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Observable.js","sourceRoot":"","sources":["../../../src/utilities/observables/Observable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAIX,MAAM,mBAAmB,CAAC;AAI3B,OAAO,mBAAmB,CAAC;AAWnB,IAAA,SAAS,GAAK,UAAU,UAAf,CAAgB;AACjC,IAAM,aAAa,GAAG,cAAwC,CAAC;AAC/D,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE;IAC7B,SAAS,CAAC,aAAa,CAAC,GAAG,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;CACzD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import {\n Observable,\n Observer,\n Subscription as ObservableSubscription,\n Subscriber,\n} from 'zen-observable-ts';\n\n// This simplified polyfill attempts to follow the ECMAScript Observable\n// proposal (https://github.com/zenparsing/es-observable)\nimport 'symbol-observable';\n\nexport type {\n Observer,\n ObservableSubscription,\n Subscriber,\n};\n\n// The zen-observable package defines Observable.prototype[Symbol.observable]\n// when Symbol is supported, but RxJS interop depends on also setting this fake\n// '@@observable' string as a polyfill for Symbol.observable.\nconst { prototype } = Observable;\nconst fakeObsSymbol = '@@observable' as keyof typeof prototype;\nif (!prototype[fakeObsSymbol]) {\n prototype[fakeObsSymbol] = function () { return this; };\n}\n\nexport { Observable };\n"]}
|