@gravity-ui/data-source 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/LICENSE +22 -0
- package/README.md +82 -0
- package/build/cjs/core/constants.d.ts +1 -0
- package/build/cjs/core/constants.js +8 -0
- package/build/cjs/core/constants.js.map +1 -0
- package/build/cjs/core/index.d.ts +13 -0
- package/build/cjs/core/index.js +81 -0
- package/build/cjs/core/index.js.map +1 -0
- package/build/cjs/core/types/DataLoaderStatus.d.ts +1 -0
- package/build/cjs/core/types/DataLoaderStatus.js +6 -0
- package/build/cjs/core/types/DataLoaderStatus.js.map +1 -0
- package/build/cjs/core/types/DataManger.d.ts +10 -0
- package/build/cjs/core/types/DataManger.js +6 -0
- package/build/cjs/core/types/DataManger.js.map +1 -0
- package/build/cjs/core/types/DataSource.d.ts +28 -0
- package/build/cjs/core/types/DataSource.js +6 -0
- package/build/cjs/core/types/DataSource.js.map +1 -0
- package/build/cjs/core/types/utils.d.ts +1 -0
- package/build/cjs/core/types/utils.js +6 -0
- package/build/cjs/core/types/utils.js.map +1 -0
- package/build/cjs/core/utils/composeFullKey.d.ts +2 -0
- package/build/cjs/core/utils/composeFullKey.js +15 -0
- package/build/cjs/core/utils/composeFullKey.js.map +1 -0
- package/build/cjs/core/utils/composeKey.d.ts +2 -0
- package/build/cjs/core/utils/composeKey.js +14 -0
- package/build/cjs/core/utils/composeKey.js.map +1 -0
- package/build/cjs/core/utils/getError.d.ts +3 -0
- package/build/cjs/core/utils/getError.js +14 -0
- package/build/cjs/core/utils/getError.js.map +1 -0
- package/build/cjs/core/utils/getStatus.d.ts +4 -0
- package/build/cjs/core/utils/getStatus.js +14 -0
- package/build/cjs/core/utils/getStatus.js.map +1 -0
- package/build/cjs/core/utils/hasTag.d.ts +2 -0
- package/build/cjs/core/utils/hasTag.js +18 -0
- package/build/cjs/core/utils/hasTag.js.map +1 -0
- package/build/cjs/core/utils/mergeStatuses.d.ts +2 -0
- package/build/cjs/core/utils/mergeStatuses.js +20 -0
- package/build/cjs/core/utils/mergeStatuses.js.map +1 -0
- package/build/cjs/core/utils/skipContext.d.ts +2 -0
- package/build/cjs/core/utils/skipContext.js +15 -0
- package/build/cjs/core/utils/skipContext.js.map +1 -0
- package/build/cjs/core/utils/withCancellation.d.ts +9 -0
- package/build/cjs/core/utils/withCancellation.js +26 -0
- package/build/cjs/core/utils/withCancellation.js.map +1 -0
- package/build/cjs/index.d.ts +3 -0
- package/build/cjs/index.js +39 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/react/DataManagerContext.d.ts +3 -0
- package/build/cjs/react/DataManagerContext.js +16 -0
- package/build/cjs/react/DataManagerContext.js.map +1 -0
- package/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.d.ts +3 -0
- package/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.js +48 -0
- package/build/cjs/react/components/DataInfiniteLoader/DataInfiniteLoader.js.map +1 -0
- package/build/cjs/react/components/DataInfiniteLoader/index.d.ts +2 -0
- package/build/cjs/react/components/DataInfiniteLoader/index.js +13 -0
- package/build/cjs/react/components/DataInfiniteLoader/index.js.map +1 -0
- package/build/cjs/react/components/DataInfiniteLoader/types.d.ts +19 -0
- package/build/cjs/react/components/DataInfiniteLoader/types.js +6 -0
- package/build/cjs/react/components/DataInfiniteLoader/types.js.map +1 -0
- package/build/cjs/react/components/DataLoader/DataLoader.d.ts +3 -0
- package/build/cjs/react/components/DataLoader/DataLoader.js +35 -0
- package/build/cjs/react/components/DataLoader/DataLoader.js.map +1 -0
- package/build/cjs/react/components/DataLoader/index.d.ts +2 -0
- package/build/cjs/react/components/DataLoader/index.js +13 -0
- package/build/cjs/react/components/DataLoader/index.js.map +1 -0
- package/build/cjs/react/components/DataLoader/types.d.ts +11 -0
- package/build/cjs/react/components/DataLoader/types.js +6 -0
- package/build/cjs/react/components/DataLoader/types.js.map +1 -0
- package/build/cjs/react/components/types.d.ts +9 -0
- package/build/cjs/react/components/types.js +6 -0
- package/build/cjs/react/components/types.js.map +1 -0
- package/build/cjs/react/index.d.ts +5 -0
- package/build/cjs/react/index.js +55 -0
- package/build/cjs/react/index.js.map +1 -0
- package/build/cjs/react/withDataManager.d.ts +6 -0
- package/build/cjs/react/withDataManager.js +22 -0
- package/build/cjs/react/withDataManager.js.map +1 -0
- package/build/cjs/react-query/ClientDataManager.d.ts +15 -0
- package/build/cjs/react-query/ClientDataManager.js +94 -0
- package/build/cjs/react-query/ClientDataManager.js.map +1 -0
- package/build/cjs/react-query/hooks/useQueryContext.d.ts +2 -0
- package/build/cjs/react-query/hooks/useQueryContext.js +18 -0
- package/build/cjs/react-query/hooks/useQueryContext.js.map +1 -0
- package/build/cjs/react-query/hooks/useQueryData.d.ts +3 -0
- package/build/cjs/react-query/hooks/useQueryData.js +26 -0
- package/build/cjs/react-query/hooks/useQueryData.js.map +1 -0
- package/build/cjs/react-query/hooks/useQueryResponses.d.ts +11 -0
- package/build/cjs/react-query/hooks/useQueryResponses.js +18 -0
- package/build/cjs/react-query/hooks/useQueryResponses.js.map +1 -0
- package/build/cjs/react-query/hooks/useRefetchAll.d.ts +3 -0
- package/build/cjs/react-query/hooks/useRefetchAll.js +21 -0
- package/build/cjs/react-query/hooks/useRefetchAll.js.map +1 -0
- package/build/cjs/react-query/hooks/useRefetchErrored.d.ts +4 -0
- package/build/cjs/react-query/hooks/useRefetchErrored.js +25 -0
- package/build/cjs/react-query/hooks/useRefetchErrored.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/factory.d.ts +2 -0
- package/build/cjs/react-query/impl/infinite/factory.js +14 -0
- package/build/cjs/react-query/impl/infinite/factory.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/hooks.d.ts +3 -0
- package/build/cjs/react-query/impl/infinite/hooks.js +17 -0
- package/build/cjs/react-query/impl/infinite/hooks.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/types.d.ts +18 -0
- package/build/cjs/react-query/impl/infinite/types.js +6 -0
- package/build/cjs/react-query/impl/infinite/types.js.map +1 -0
- package/build/cjs/react-query/impl/infinite/utils.d.ts +5 -0
- package/build/cjs/react-query/impl/infinite/utils.js +49 -0
- package/build/cjs/react-query/impl/infinite/utils.js.map +1 -0
- package/build/cjs/react-query/impl/plain/factory.d.ts +2 -0
- package/build/cjs/react-query/impl/plain/factory.js +14 -0
- package/build/cjs/react-query/impl/plain/factory.js.map +1 -0
- package/build/cjs/react-query/impl/plain/hooks.d.ts +3 -0
- package/build/cjs/react-query/impl/plain/hooks.js +17 -0
- package/build/cjs/react-query/impl/plain/hooks.js.map +1 -0
- package/build/cjs/react-query/impl/plain/types.d.ts +14 -0
- package/build/cjs/react-query/impl/plain/types.js +6 -0
- package/build/cjs/react-query/impl/plain/types.js.map +1 -0
- package/build/cjs/react-query/impl/plain/utils.d.ts +5 -0
- package/build/cjs/react-query/impl/plain/utils.js +28 -0
- package/build/cjs/react-query/impl/plain/utils.js.map +1 -0
- package/build/cjs/react-query/index.d.ts +15 -0
- package/build/cjs/react-query/index.js +83 -0
- package/build/cjs/react-query/index.js.map +1 -0
- package/build/cjs/react-query/types.d.ts +7 -0
- package/build/cjs/react-query/types.js +6 -0
- package/build/cjs/react-query/types.js.map +1 -0
- package/build/cjs/react-query/utils/normalizeStatus.d.ts +3 -0
- package/build/cjs/react-query/utils/normalizeStatus.js +13 -0
- package/build/cjs/react-query/utils/normalizeStatus.js.map +1 -0
- package/build/esm/core/constants.d.ts +1 -0
- package/build/esm/core/constants.js +2 -0
- package/build/esm/core/constants.js.map +1 -0
- package/build/esm/core/index.d.ts +13 -0
- package/build/esm/core/index.js +10 -0
- package/build/esm/core/index.js.map +1 -0
- package/build/esm/core/types/DataLoaderStatus.d.ts +1 -0
- package/build/esm/core/types/DataLoaderStatus.js +2 -0
- package/build/esm/core/types/DataLoaderStatus.js.map +1 -0
- package/build/esm/core/types/DataManger.d.ts +10 -0
- package/build/esm/core/types/DataManger.js +2 -0
- package/build/esm/core/types/DataManger.js.map +1 -0
- package/build/esm/core/types/DataSource.d.ts +28 -0
- package/build/esm/core/types/DataSource.js +2 -0
- package/build/esm/core/types/DataSource.js.map +1 -0
- package/build/esm/core/types/utils.d.ts +1 -0
- package/build/esm/core/types/utils.js +2 -0
- package/build/esm/core/types/utils.js.map +1 -0
- package/build/esm/core/utils/composeFullKey.d.ts +2 -0
- package/build/esm/core/utils/composeFullKey.js +8 -0
- package/build/esm/core/utils/composeFullKey.js.map +1 -0
- package/build/esm/core/utils/composeKey.d.ts +2 -0
- package/build/esm/core/utils/composeKey.js +7 -0
- package/build/esm/core/utils/composeKey.js.map +1 -0
- package/build/esm/core/utils/getError.d.ts +3 -0
- package/build/esm/core/utils/getError.js +8 -0
- package/build/esm/core/utils/getError.js.map +1 -0
- package/build/esm/core/utils/getStatus.d.ts +4 -0
- package/build/esm/core/utils/getStatus.js +8 -0
- package/build/esm/core/utils/getStatus.js.map +1 -0
- package/build/esm/core/utils/hasTag.d.ts +2 -0
- package/build/esm/core/utils/hasTag.js +12 -0
- package/build/esm/core/utils/hasTag.js.map +1 -0
- package/build/esm/core/utils/mergeStatuses.d.ts +2 -0
- package/build/esm/core/utils/mergeStatuses.js +14 -0
- package/build/esm/core/utils/mergeStatuses.js.map +1 -0
- package/build/esm/core/utils/skipContext.d.ts +2 -0
- package/build/esm/core/utils/skipContext.js +9 -0
- package/build/esm/core/utils/skipContext.js.map +1 -0
- package/build/esm/core/utils/withCancellation.d.ts +9 -0
- package/build/esm/core/utils/withCancellation.js +19 -0
- package/build/esm/core/utils/withCancellation.js.map +1 -0
- package/build/esm/index.d.ts +3 -0
- package/build/esm/index.js +4 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/react/DataManagerContext.d.ts +3 -0
- package/build/esm/react/DataManagerContext.js +10 -0
- package/build/esm/react/DataManagerContext.js.map +1 -0
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.d.ts +3 -0
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.js +41 -0
- package/build/esm/react/components/DataInfiniteLoader/DataInfiniteLoader.js.map +1 -0
- package/build/esm/react/components/DataInfiniteLoader/index.d.ts +2 -0
- package/build/esm/react/components/DataInfiniteLoader/index.js +2 -0
- package/build/esm/react/components/DataInfiniteLoader/index.js.map +1 -0
- package/build/esm/react/components/DataInfiniteLoader/types.d.ts +19 -0
- package/build/esm/react/components/DataInfiniteLoader/types.js +2 -0
- package/build/esm/react/components/DataInfiniteLoader/types.js.map +1 -0
- package/build/esm/react/components/DataLoader/DataLoader.d.ts +3 -0
- package/build/esm/react/components/DataLoader/DataLoader.js +28 -0
- package/build/esm/react/components/DataLoader/DataLoader.js.map +1 -0
- package/build/esm/react/components/DataLoader/index.d.ts +2 -0
- package/build/esm/react/components/DataLoader/index.js +2 -0
- package/build/esm/react/components/DataLoader/index.js.map +1 -0
- package/build/esm/react/components/DataLoader/types.d.ts +11 -0
- package/build/esm/react/components/DataLoader/types.js +2 -0
- package/build/esm/react/components/DataLoader/types.js.map +1 -0
- package/build/esm/react/components/types.d.ts +9 -0
- package/build/esm/react/components/types.js +2 -0
- package/build/esm/react/components/types.js.map +1 -0
- package/build/esm/react/index.d.ts +5 -0
- package/build/esm/react/index.js +5 -0
- package/build/esm/react/index.js.map +1 -0
- package/build/esm/react/withDataManager.d.ts +6 -0
- package/build/esm/react/withDataManager.js +15 -0
- package/build/esm/react/withDataManager.js.map +1 -0
- package/build/esm/react-query/ClientDataManager.d.ts +15 -0
- package/build/esm/react-query/ClientDataManager.js +87 -0
- package/build/esm/react-query/ClientDataManager.js.map +1 -0
- package/build/esm/react-query/hooks/useQueryContext.d.ts +2 -0
- package/build/esm/react-query/hooks/useQueryContext.js +12 -0
- package/build/esm/react-query/hooks/useQueryContext.js.map +1 -0
- package/build/esm/react-query/hooks/useQueryData.d.ts +3 -0
- package/build/esm/react-query/hooks/useQueryData.js +20 -0
- package/build/esm/react-query/hooks/useQueryData.js.map +1 -0
- package/build/esm/react-query/hooks/useQueryResponses.d.ts +11 -0
- package/build/esm/react-query/hooks/useQueryResponses.js +12 -0
- package/build/esm/react-query/hooks/useQueryResponses.js.map +1 -0
- package/build/esm/react-query/hooks/useRefetchAll.d.ts +3 -0
- package/build/esm/react-query/hooks/useRefetchAll.js +15 -0
- package/build/esm/react-query/hooks/useRefetchAll.js.map +1 -0
- package/build/esm/react-query/hooks/useRefetchErrored.d.ts +4 -0
- package/build/esm/react-query/hooks/useRefetchErrored.js +18 -0
- package/build/esm/react-query/hooks/useRefetchErrored.js.map +1 -0
- package/build/esm/react-query/impl/infinite/factory.d.ts +2 -0
- package/build/esm/react-query/impl/infinite/factory.js +7 -0
- package/build/esm/react-query/impl/infinite/factory.js.map +1 -0
- package/build/esm/react-query/impl/infinite/hooks.d.ts +3 -0
- package/build/esm/react-query/impl/infinite/hooks.js +11 -0
- package/build/esm/react-query/impl/infinite/hooks.js.map +1 -0
- package/build/esm/react-query/impl/infinite/types.d.ts +18 -0
- package/build/esm/react-query/impl/infinite/types.js +2 -0
- package/build/esm/react-query/impl/infinite/types.js.map +1 -0
- package/build/esm/react-query/impl/infinite/utils.d.ts +5 -0
- package/build/esm/react-query/impl/infinite/utils.js +42 -0
- package/build/esm/react-query/impl/infinite/utils.js.map +1 -0
- package/build/esm/react-query/impl/plain/factory.d.ts +2 -0
- package/build/esm/react-query/impl/plain/factory.js +7 -0
- package/build/esm/react-query/impl/plain/factory.js.map +1 -0
- package/build/esm/react-query/impl/plain/hooks.d.ts +3 -0
- package/build/esm/react-query/impl/plain/hooks.js +11 -0
- package/build/esm/react-query/impl/plain/hooks.js.map +1 -0
- package/build/esm/react-query/impl/plain/types.d.ts +14 -0
- package/build/esm/react-query/impl/plain/types.js +2 -0
- package/build/esm/react-query/impl/plain/types.js.map +1 -0
- package/build/esm/react-query/impl/plain/utils.d.ts +5 -0
- package/build/esm/react-query/impl/plain/utils.js +21 -0
- package/build/esm/react-query/impl/plain/utils.js.map +1 -0
- package/build/esm/react-query/index.d.ts +15 -0
- package/build/esm/react-query/index.js +12 -0
- package/build/esm/react-query/index.js.map +1 -0
- package/build/esm/react-query/types.d.ts +7 -0
- package/build/esm/react-query/types.js +2 -0
- package/build/esm/react-query/types.js.map +1 -0
- package/build/esm/react-query/utils/normalizeStatus.d.ts +3 -0
- package/build/esm/react-query/utils/normalizeStatus.js +7 -0
- package/build/esm/react-query/utils/normalizeStatus.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 YANDEX LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Data Source
|
|
2
|
+
|
|
3
|
+
**Data Source** is a simple wrapper around data fetching. It is a kind of "port" in [clean architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html). It allows you to make wrappers for stuff around data fetching depending on your use cases. **Data Source** uses [react-query](https://tanstack.com/query/latest) under the hood.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gravity-ui/data-source @tanstack/react-query
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`@tanstack/react-query` is a peer dependency.
|
|
12
|
+
|
|
13
|
+
## Getting started
|
|
14
|
+
|
|
15
|
+
Firstly, define a type of error and make your constructors for data sources and your error based on default constructors (makePlainQueryDataSource / makeInfiniteQueryDataSource). For example:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {makePlainQueryDataSource as makePlainQueryDataSourceBase} from '@gravity-ui/data-source';
|
|
19
|
+
|
|
20
|
+
export interface ApiError {
|
|
21
|
+
title: string;
|
|
22
|
+
code?: number;
|
|
23
|
+
description?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const makePlainQueryDataSource = <TParams, TRequest, TResponse, TData, TError = ApiError>(
|
|
27
|
+
config: Omit<PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError>, 'type'>,
|
|
28
|
+
): PlainQueryDataSource<TParams, TRequest, TResponse, TData, TError> => {
|
|
29
|
+
return makePlainQueryDataSourceBase(config);
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Write a `DataLoader` component based on default. This is convenient to define your display of the loading status and errors. For example:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import {
|
|
37
|
+
DataLoader as DataLoaderBase,
|
|
38
|
+
DataLoaderProps as DataLoaderPropsBase,
|
|
39
|
+
ErrorViewProps,
|
|
40
|
+
} from '@gravity-ui/data-source';
|
|
41
|
+
|
|
42
|
+
export interface DataLoaderProps
|
|
43
|
+
extends Omit<DataLoaderPropsBase<ApiError>, 'LoadingView' | 'ErrorView'> {
|
|
44
|
+
LoadingView?: ComponentType;
|
|
45
|
+
ErrorView?: ComponentType<ErrorViewProps<ApiError>>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const DataLoader: React.FC<DataLoaderProps> = ({
|
|
49
|
+
LoadingView = YourLoader,
|
|
50
|
+
ErrorView = YourError,
|
|
51
|
+
...restProps
|
|
52
|
+
}) => {
|
|
53
|
+
return <DataLoaderBase LoadingView={LoadingView} ErrorView={ErrorView} {...restProps} />;
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Define your first data source:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export const objectDataSource = makePlainQueryDataSource({
|
|
61
|
+
// Keys have to be unique. Maybe you should create a helper for making names of data sources
|
|
62
|
+
name: 'object',
|
|
63
|
+
// skipContext is just a helper to skip 2 first parameters in the function (context and fetchContext)
|
|
64
|
+
fetch: skipContext(objectFetch),
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Use it in the application:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import {useQueryData} from '@gravity-ui/data-source';
|
|
72
|
+
|
|
73
|
+
export const SomeComponent: React.FC = () => {
|
|
74
|
+
const {data, status, error, refetch} = useQueryData(objectDataSource, {objectId: 1});
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<DataLoader status={status} error={error} errorAction={refetch}>
|
|
78
|
+
{data && <ObjectComponent object={data} />}
|
|
79
|
+
</DataLoader>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const idle: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["idle","exports","Symbol"],"sources":["constants.ts"],"sourcesContent":["export const idle = Symbol('idle');\n"],"mappings":";;;;;;AAAO,IAAMA,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAGE,MAAM,CAAC,MAAM,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { DataSourceKey, DataSourceTag, DataSource, AnyDataSource, DataSourceContext, DataSourceParams, DataSourceRequest, DataSourceResponse, DataSourceData, DataSourceError, DataSourceOptions, DataSourceState, DataSourceFetchContext, ActualParams, ActualData, } from './types/DataSource';
|
|
2
|
+
export type { DataManager } from './types/DataManger';
|
|
3
|
+
export type { DataLoaderStatus } from './types/DataLoaderStatus';
|
|
4
|
+
export { idle } from './constants';
|
|
5
|
+
export { composeKey } from './utils/composeKey';
|
|
6
|
+
export { composeFullKey } from './utils/composeFullKey';
|
|
7
|
+
export { getError } from './utils/getError';
|
|
8
|
+
export { getStatus } from './utils/getStatus';
|
|
9
|
+
export { hasTag } from './utils/hasTag';
|
|
10
|
+
export { mergeStatuses } from './utils/mergeStatuses';
|
|
11
|
+
export { skipContext } from './utils/skipContext';
|
|
12
|
+
export type { Cancellable } from './utils/withCancellation';
|
|
13
|
+
export { isCancellable, isAbortable, withCancellation } from './utils/withCancellation';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "composeFullKey", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _composeFullKey.composeFullKey;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "composeKey", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _composeKey.composeKey;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "getError", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _getError.getError;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getStatus", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _getStatus.getStatus;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "hasTag", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _hasTag.hasTag;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "idle", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _constants.idle;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "isAbortable", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _withCancellation.isAbortable;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "isCancellable", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _withCancellation.isCancellable;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "mergeStatuses", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _mergeStatuses.mergeStatuses;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "skipContext", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _skipContext.skipContext;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "withCancellation", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _withCancellation.withCancellation;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var _constants = require("./constants");
|
|
73
|
+
var _composeKey = require("./utils/composeKey");
|
|
74
|
+
var _composeFullKey = require("./utils/composeFullKey");
|
|
75
|
+
var _getError = require("./utils/getError");
|
|
76
|
+
var _getStatus = require("./utils/getStatus");
|
|
77
|
+
var _hasTag = require("./utils/hasTag");
|
|
78
|
+
var _mergeStatuses = require("./utils/mergeStatuses");
|
|
79
|
+
var _skipContext = require("./utils/skipContext");
|
|
80
|
+
var _withCancellation = require("./utils/withCancellation");
|
|
81
|
+
// #sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_constants","require","_composeKey","_composeFullKey","_getError","_getStatus","_hasTag","_mergeStatuses","_skipContext","_withCancellation"],"sources":["index.ts"],"sourcesContent":["export type {\n DataSourceKey,\n DataSourceTag,\n DataSource,\n AnyDataSource,\n DataSourceContext,\n DataSourceParams,\n DataSourceRequest,\n DataSourceResponse,\n DataSourceData,\n DataSourceError,\n DataSourceOptions,\n DataSourceState,\n DataSourceFetchContext,\n ActualParams,\n ActualData,\n} from './types/DataSource';\nexport type {DataManager} from './types/DataManger';\nexport type {DataLoaderStatus} from './types/DataLoaderStatus';\n\nexport {idle} from './constants';\n\nexport {composeKey} from './utils/composeKey';\nexport {composeFullKey} from './utils/composeFullKey';\nexport {getError} from './utils/getError';\nexport {getStatus} from './utils/getStatus';\nexport {hasTag} from './utils/hasTag';\nexport {mergeStatuses} from './utils/mergeStatuses';\nexport {skipContext} from './utils/skipContext';\nexport type {Cancellable} from './utils/withCancellation';\nexport {isCancellable, isAbortable, withCancellation} from './utils/withCancellation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAR,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DataLoaderStatus = 'loading' | 'success' | 'error';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["DataLoaderStatus.ts"],"sourcesContent":["export type DataLoaderStatus = 'loading' | 'success' | 'error';\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyDataSource, DataSourceParams, DataSourceTag } from './DataSource';
|
|
2
|
+
export interface DataManager {
|
|
3
|
+
invalidateTag(tag: DataSourceTag): Promise<void>;
|
|
4
|
+
invalidateTags(tags: DataSourceTag[]): Promise<void>;
|
|
5
|
+
invalidateSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;
|
|
6
|
+
resetSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;
|
|
7
|
+
invalidateParams<TDataSource extends AnyDataSource>(dataSource: TDataSource, params: DataSourceParams<TDataSource>): Promise<void>;
|
|
8
|
+
resetParams<TDataSource extends AnyDataSource>(dataSource: TDataSource, params: DataSourceParams<TDataSource>): Promise<void>;
|
|
9
|
+
invalidateSourceTags<TDataSource extends AnyDataSource>(dataSource: TDataSource, params: DataSourceParams<TDataSource>): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["DataManger.ts"],"sourcesContent":["import type {AnyDataSource, DataSourceParams, DataSourceTag} from './DataSource';\n\nexport interface DataManager {\n invalidateTag(tag: DataSourceTag): Promise<void>;\n invalidateTags(tags: DataSourceTag[]): Promise<void>;\n\n invalidateSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;\n\n resetSource<TDataSource extends AnyDataSource>(dataSource: TDataSource): Promise<void>;\n\n invalidateParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n ): Promise<void>;\n\n resetParams<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n ): Promise<void>;\n\n invalidateSourceTags<TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n ): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { idle } from '../constants';
|
|
2
|
+
export type DataSourceKey = readonly unknown[];
|
|
3
|
+
export type DataSourceTag = string;
|
|
4
|
+
declare const errorHintSymbol: unique symbol;
|
|
5
|
+
declare const stateHintSymbol: unique symbol;
|
|
6
|
+
export interface DataSource<TContext, TParams, TRequest, TResponse, TData, TError, TOptions, TState, TFetchContext> {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
fetch: (context: TContext, fetchContext: TFetchContext, request: TRequest) => Promise<TResponse> | TResponse;
|
|
9
|
+
tags?: (params: ActualParams<this, TParams, TRequest>) => DataSourceTag[];
|
|
10
|
+
transformParams?: (params: TParams) => TRequest;
|
|
11
|
+
transformResponse?: (response: TResponse) => TData;
|
|
12
|
+
[errorHintSymbol]?: TError;
|
|
13
|
+
options?: TOptions;
|
|
14
|
+
[stateHintSymbol]?: TState;
|
|
15
|
+
}
|
|
16
|
+
export type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any>;
|
|
17
|
+
export type DataSourceContext<TDataSource> = TDataSource extends DataSource<infer TContext, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TContext : never;
|
|
18
|
+
export type DataSourceParams<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualParams<TDataSource, TParams, TRequest> : never;
|
|
19
|
+
export type DataSourceRequest<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TRequest : never;
|
|
20
|
+
export type DataSourceResponse<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TResponse : never;
|
|
21
|
+
export type DataSourceData<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer TResponse, infer TData, infer _TError, infer _TOptions, infer _TState, infer _TFetchContext> ? ActualData<TData, TResponse> : never;
|
|
22
|
+
export type DataSourceError<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer TError, infer _TOptions, infer _TState, infer _TFetchContext> ? TError : never;
|
|
23
|
+
export type DataSourceOptions<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer TOptions, infer _TState, infer _TFetchContext> ? TOptions : never;
|
|
24
|
+
export type DataSourceState<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer TState, infer _TFetchContext> ? TState : never;
|
|
25
|
+
export type DataSourceFetchContext<TDataSource> = TDataSource extends DataSource<infer _TContenxt, infer _TParams, infer _TRequest, infer _TResponse, infer _TData, infer _TError, infer _TOptions, infer _TState, infer TFetchContext> ? TFetchContext : never;
|
|
26
|
+
export type ActualParams<TDataSource extends AnyDataSource, TParams, TRequest> = (unknown extends TParams ? TRequest : undefined extends TDataSource['transformParams'] ? TRequest : TParams) | typeof idle;
|
|
27
|
+
export type ActualData<TData, TResponse> = unknown extends TData ? TResponse : TData;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["DataSource.ts"],"sourcesContent":["import type {idle} from '../constants';\n\nexport type DataSourceKey = readonly unknown[];\nexport type DataSourceTag = string;\n\ndeclare const errorHintSymbol: unique symbol;\ndeclare const stateHintSymbol: unique symbol;\n\nexport interface DataSource<\n TContext,\n TParams,\n TRequest,\n TResponse,\n TData,\n TError,\n TOptions,\n TState,\n TFetchContext,\n> {\n readonly name: string;\n\n fetch: (\n context: TContext,\n fetchContext: TFetchContext,\n request: TRequest,\n ) => Promise<TResponse> | TResponse;\n tags?: (params: ActualParams<this, TParams, TRequest>) => DataSourceTag[];\n\n transformParams?: (params: TParams) => TRequest;\n transformResponse?: (response: TResponse) => TData;\n\n [errorHintSymbol]?: TError;\n\n options?: TOptions;\n [stateHintSymbol]?: TState;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyDataSource = DataSource<any, any, any, any, any, any, any, any, any>;\n\nexport type DataSourceContext<TDataSource> =\n TDataSource extends DataSource<\n infer TContext,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TContext\n : never;\n\nexport type DataSourceParams<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualParams<TDataSource, TParams, TRequest>\n : never;\n\nexport type DataSourceRequest<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TRequest\n : never;\n\nexport type DataSourceResponse<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TResponse\n : never;\n\nexport type DataSourceData<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer TResponse,\n infer TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? ActualData<TData, TResponse>\n : never;\n\nexport type DataSourceError<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer TError,\n infer _TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TError\n : never;\n\nexport type DataSourceOptions<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer TOptions,\n infer _TState,\n infer _TFetchContext\n >\n ? TOptions\n : never;\n\nexport type DataSourceState<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer TState,\n infer _TFetchContext\n >\n ? TState\n : never;\n\nexport type DataSourceFetchContext<TDataSource> =\n TDataSource extends DataSource<\n infer _TContenxt,\n infer _TParams,\n infer _TRequest,\n infer _TResponse,\n infer _TData,\n infer _TError,\n infer _TOptions,\n infer _TState,\n infer TFetchContext\n >\n ? TFetchContext\n : never;\n\nexport type ActualParams<TDataSource extends AnyDataSource, TParams, TRequest> =\n | (unknown extends TParams\n ? TRequest\n : undefined extends TDataSource['transformParams']\n ? TRequest\n : TParams)\n | typeof idle;\n\nexport type ActualData<TData, TResponse> = unknown extends TData ? TResponse : TData;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["utils.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyFunction = (...args: any[]) => any;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.composeFullKey = void 0;
|
|
7
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
|
+
var _composeKey = require("./composeKey");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var composeFullKey = exports.composeFullKey = function composeFullKey(dataSource, params) {
|
|
11
|
+
var _dataSource$tags, _dataSource$tags2;
|
|
12
|
+
var tags = (_dataSource$tags = (_dataSource$tags2 = dataSource.tags) === null || _dataSource$tags2 === void 0 ? void 0 : _dataSource$tags2.call(dataSource, params)) !== null && _dataSource$tags !== void 0 ? _dataSource$tags : [];
|
|
13
|
+
return [dataSource.name].concat((0, _toConsumableArray2.default)(tags), [(0, _composeKey.composeKey)(dataSource, params)]);
|
|
14
|
+
};
|
|
15
|
+
// #sourceMappingURL=composeFullKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_composeKey","require","_interopRequireDefault","e","__esModule","default","composeFullKey","exports","dataSource","params","_dataSource$tags","_dataSource$tags2","tags","call","name","concat","_toConsumableArray","composeKey"],"sources":["composeFullKey.ts"],"sourcesContent":["import type {AnyDataSource, DataSourceParams} from '../types/DataSource';\n\nimport {composeKey} from './composeKey';\n\nexport const composeFullKey = <TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n): readonly string[] => {\n const tags = dataSource.tags?.(params) ?? [];\n\n return [dataSource.name, ...tags, composeKey(dataSource, params)];\n};\n"],"mappings":";;;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AAAuC,SAAAC,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,IAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CACvBE,UAAuB,EACvBC,MAAqC,EACjB;EAAA,IAAAC,gBAAA,EAAAC,iBAAA;EACpB,IAAMC,IAAI,IAAAF,gBAAA,IAAAC,iBAAA,GAAGH,UAAU,CAACI,IAAI,cAAAD,iBAAA,uBAAfA,iBAAA,CAAAE,IAAA,CAAAL,UAAU,EAAQC,MAAM,CAAC,cAAAC,gBAAA,cAAAA,gBAAA,GAAI,EAAE;EAE5C,QAAQF,UAAU,CAACM,IAAI,EAAAC,MAAA,KAAAC,2BAAA,EAAKJ,IAAI,IAAE,IAAAK,sBAAU,EAACT,UAAU,EAAEC,MAAM,CAAC;AACpE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.composeKey = void 0;
|
|
7
|
+
var _reactQuery = require("@tanstack/react-query");
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
// TODO(DakEnviy): Do not use react-query in core
|
|
10
|
+
|
|
11
|
+
var composeKey = exports.composeKey = function composeKey(dataSource, params) {
|
|
12
|
+
return params === _constants.idle ? "".concat(dataSource.name, ":idle") : "".concat(dataSource.name, "(").concat((0, _reactQuery.hashQueryKey)(params), ")");
|
|
13
|
+
};
|
|
14
|
+
// #sourceMappingURL=composeKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactQuery","require","_constants","composeKey","exports","dataSource","params","idle","concat","name","hashQueryKey"],"sources":["composeKey.ts"],"sourcesContent":["// TODO(DakEnviy): Do not use react-query in core\nimport {hashQueryKey} from '@tanstack/react-query';\n\nimport {idle} from '../constants';\nimport type {AnyDataSource, DataSourceParams} from '../types/DataSource';\n\nexport const composeKey = <TDataSource extends AnyDataSource>(\n dataSource: TDataSource,\n params: DataSourceParams<TDataSource>,\n): string =>\n params === idle ? `${dataSource.name}:idle` : `${dataSource.name}(${hashQueryKey(params)})`;\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAHA;;AAMO,IAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,SAAbA,UAAUA,CACnBE,UAAuB,EACvBC,MAAqC;EAAA,OAErCA,MAAM,KAAKC,eAAI,MAAAC,MAAA,CAAMH,UAAU,CAACI,IAAI,gBAAAD,MAAA,CAAaH,UAAU,CAACI,IAAI,OAAAD,MAAA,CAAI,IAAAE,wBAAY,EAACJ,MAAM,CAAC,MAAG;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getError = void 0;
|
|
7
|
+
var getError = exports.getError = function getError(states) {
|
|
8
|
+
var _states$find$error, _states$find;
|
|
9
|
+
return (_states$find$error = (_states$find = states.find(function (_ref) {
|
|
10
|
+
var error = _ref.error;
|
|
11
|
+
return Boolean(error);
|
|
12
|
+
})) === null || _states$find === void 0 ? void 0 : _states$find.error) !== null && _states$find$error !== void 0 ? _states$find$error : null;
|
|
13
|
+
};
|
|
14
|
+
// #sourceMappingURL=getError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getError","exports","states","_states$find$error","_states$find","find","_ref","error","Boolean"],"sources":["getError.ts"],"sourcesContent":["export const getError = <T>(states: {error: T | null}[]) => {\n return states.find(({error}) => Boolean(error))?.error ?? null;\n};\n"],"mappings":";;;;;;AAAO,IAAMA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,SAAXA,QAAQA,CAAOE,MAA2B,EAAK;EAAA,IAAAC,kBAAA,EAAAC,YAAA;EACxD,QAAAD,kBAAA,IAAAC,YAAA,GAAOF,MAAM,CAACG,IAAI,CAAC,UAAAC,IAAA;IAAA,IAAEC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAA,OAAMC,OAAO,CAACD,KAAK,CAAC;EAAA,EAAC,cAAAH,YAAA,uBAAxCA,YAAA,CAA0CG,KAAK,cAAAJ,kBAAA,cAAAA,kBAAA,GAAI,IAAI;AAClE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getStatus = void 0;
|
|
7
|
+
var _mergeStatuses = require("./mergeStatuses");
|
|
8
|
+
var getStatus = exports.getStatus = function getStatus(states) {
|
|
9
|
+
return (0, _mergeStatuses.mergeStatuses)(states.map(function (_ref) {
|
|
10
|
+
var status = _ref.status;
|
|
11
|
+
return status;
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
// #sourceMappingURL=getStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_mergeStatuses","require","getStatus","exports","states","mergeStatuses","map","_ref","status"],"sources":["getStatus.ts"],"sourcesContent":["import type {DataLoaderStatus} from '../types/DataLoaderStatus';\n\nimport {mergeStatuses} from './mergeStatuses';\n\nexport const getStatus = (states: {status: DataLoaderStatus}[]) => {\n return mergeStatuses(states.map(({status}) => status));\n};\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAEO,IAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,SAAZA,SAASA,CAAIE,MAAoC,EAAK;EAC/D,OAAO,IAAAC,4BAAa,EAACD,MAAM,CAACE,GAAG,CAAC,UAAAC,IAAA;IAAA,IAAEC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAA,OAAMA,MAAM;EAAA,EAAC,CAAC;AAC1D,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasTag = void 0;
|
|
7
|
+
var hasTag = exports.hasTag = function hasTag(key, tag) {
|
|
8
|
+
if (!Array.isArray(key)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
var index = key.indexOf(tag);
|
|
12
|
+
|
|
13
|
+
// First element — data source name
|
|
14
|
+
// Last element — full key
|
|
15
|
+
// Skip them for consistency
|
|
16
|
+
return index > 0 && index < key.length - 2;
|
|
17
|
+
};
|
|
18
|
+
// #sourceMappingURL=hasTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hasTag","exports","key","tag","Array","isArray","index","indexOf","length"],"sources":["hasTag.ts"],"sourcesContent":["import type {DataSourceKey, DataSourceTag} from '../types/DataSource';\n\nexport const hasTag = (key: DataSourceKey, tag: DataSourceTag) => {\n if (!Array.isArray(key)) {\n return false;\n }\n\n const index = key.indexOf(tag);\n\n // First element — data source name\n // Last element — full key\n // Skip them for consistency\n return index > 0 && index < key.length - 2;\n};\n"],"mappings":";;;;;;AAEO,IAAMA,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,SAATA,MAAMA,CAAIE,GAAkB,EAAEC,GAAkB,EAAK;EAC9D,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,GAAG,CAAC,EAAE;IACrB,OAAO,KAAK;EAChB;EAEA,IAAMI,KAAK,GAAGJ,GAAG,CAACK,OAAO,CAACJ,GAAG,CAAC;;EAE9B;EACA;EACA;EACA,OAAOG,KAAK,GAAG,CAAC,IAAIA,KAAK,GAAGJ,GAAG,CAACM,MAAM,GAAG,CAAC;AAC9C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mergeStatuses = void 0;
|
|
7
|
+
var mergeStatuses = exports.mergeStatuses = function mergeStatuses(statuses) {
|
|
8
|
+
if (statuses.some(function (status) {
|
|
9
|
+
return status === 'error';
|
|
10
|
+
})) {
|
|
11
|
+
return 'error';
|
|
12
|
+
}
|
|
13
|
+
if (statuses.some(function (status) {
|
|
14
|
+
return status === 'loading';
|
|
15
|
+
})) {
|
|
16
|
+
return 'loading';
|
|
17
|
+
}
|
|
18
|
+
return 'success';
|
|
19
|
+
};
|
|
20
|
+
// #sourceMappingURL=mergeStatuses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mergeStatuses","exports","statuses","some","status"],"sources":["mergeStatuses.ts"],"sourcesContent":["import type {DataLoaderStatus} from '../types/DataLoaderStatus';\n\nexport const mergeStatuses = (statuses: DataLoaderStatus[]): DataLoaderStatus => {\n if (statuses.some((status) => status === 'error')) {\n return 'error';\n }\n\n if (statuses.some((status) => status === 'loading')) {\n return 'loading';\n }\n\n return 'success';\n};\n"],"mappings":";;;;;;AAEO,IAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAIE,QAA4B,EAAuB;EAC7E,IAAIA,QAAQ,CAACC,IAAI,CAAC,UAACC,MAAM;IAAA,OAAKA,MAAM,KAAK,OAAO;EAAA,EAAC,EAAE;IAC/C,OAAO,OAAO;EAClB;EAEA,IAAIF,QAAQ,CAACC,IAAI,CAAC,UAACC,MAAM;IAAA,OAAKA,MAAM,KAAK,SAAS;EAAA,EAAC,EAAE;IACjD,OAAO,SAAS;EACpB;EAEA,OAAO,SAAS;AACpB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.skipContext = void 0;
|
|
7
|
+
var skipContext = exports.skipContext = function skipContext(fetch) {
|
|
8
|
+
return function (_0, _1) {
|
|
9
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
10
|
+
args[_key - 2] = arguments[_key];
|
|
11
|
+
}
|
|
12
|
+
return fetch.apply(void 0, args);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
// #sourceMappingURL=skipContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["skipContext","exports","fetch","_0","_1","_len","arguments","length","args","Array","_key","apply"],"sources":["skipContext.ts"],"sourcesContent":["import type {AnyFunction} from '../types/utils';\n\nexport const skipContext = <TFunc extends AnyFunction>(fetch: TFunc) => {\n return (_0: unknown, _1: unknown, ...args: Parameters<TFunc>): ReturnType<TFunc> => {\n return fetch(...args);\n };\n};\n"],"mappings":";;;;;;AAEO,IAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,SAAdA,WAAWA,CAA+BE,KAAY,EAAK;EACpE,OAAO,UAACC,EAAW,EAAEC,EAAW,EAAoD;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAA/CC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;IAAA;IACrC,OAAOR,KAAK,CAAAS,KAAA,SAAIH,IAAI,CAAC;EACzB,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnyDataSource } from '../types/DataSource';
|
|
2
|
+
export interface Cancellable {
|
|
3
|
+
cancel: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const isCancellable: (value: unknown) => value is Cancellable;
|
|
6
|
+
export declare const isAbortable: (value: unknown) => value is {
|
|
7
|
+
signal: AbortSignal;
|
|
8
|
+
};
|
|
9
|
+
export declare const withCancellation: <TDataSource extends AnyDataSource>(fetch: TDataSource["fetch"]) => TDataSource["fetch"];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withCancellation = exports.isCancellable = exports.isAbortable = void 0;
|
|
7
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var isCancellable = exports.isCancellable = function isCancellable(value) {
|
|
10
|
+
return (0, _typeof2.default)(value) === 'object' && value !== null && 'cancel' in value && typeof value.cancel === 'function';
|
|
11
|
+
};
|
|
12
|
+
var isAbortable = exports.isAbortable = function isAbortable(value) {
|
|
13
|
+
return (0, _typeof2.default)(value) === 'object' && value !== null && 'signal' in value && (0, _typeof2.default)(value.signal) === 'object' && value.signal !== null && 'addEventListener' in value.signal && typeof value.signal.addEventListener === 'function';
|
|
14
|
+
};
|
|
15
|
+
var withCancellation = exports.withCancellation = function withCancellation(fetch) {
|
|
16
|
+
return function (context, fetchContext, request) {
|
|
17
|
+
var value = fetch(context, fetchContext, request);
|
|
18
|
+
if (isAbortable(fetchContext) && isCancellable(value)) {
|
|
19
|
+
fetchContext.signal.addEventListener('abort', function () {
|
|
20
|
+
value.cancel();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
// #sourceMappingURL=withCancellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isCancellable","exports","value","_typeof","cancel","isAbortable","signal","addEventListener","withCancellation","fetch","context","fetchContext","request"],"sources":["withCancellation.ts"],"sourcesContent":["import type {AnyDataSource} from '../types/DataSource';\n\nexport interface Cancellable {\n cancel: () => void;\n}\n\nexport const isCancellable = (value: unknown): value is Cancellable => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'cancel' in value &&\n typeof value.cancel === 'function'\n );\n};\n\nexport const isAbortable = (value: unknown): value is {signal: AbortSignal} => {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'signal' in value &&\n typeof value.signal === 'object' &&\n value.signal !== null &&\n 'addEventListener' in value.signal &&\n typeof value.signal.addEventListener === 'function'\n );\n};\n\nexport const withCancellation = <TDataSource extends AnyDataSource>(\n fetch: TDataSource['fetch'],\n): TDataSource['fetch'] => {\n return (context, fetchContext, request) => {\n const value = fetch(context, fetchContext, request);\n\n if (isAbortable(fetchContext) && isCancellable(value)) {\n fetchContext.signal.addEventListener('abort', () => {\n value.cancel();\n });\n }\n\n return value;\n };\n};\n"],"mappings":";;;;;;;;AAMO,IAAMA,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAIE,KAAc,EAA2B;EACnE,OACI,IAAAC,gBAAA,EAAOD,KAAK,MAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,QAAQ,IAAIA,KAAK,IACjB,OAAOA,KAAK,CAACE,MAAM,KAAK,UAAU;AAE1C,CAAC;AAEM,IAAMC,WAAW,GAAAJ,OAAA,CAAAI,WAAA,GAAG,SAAdA,WAAWA,CAAIH,KAAc,EAAqC;EAC3E,OACI,IAAAC,gBAAA,EAAOD,KAAK,MAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,QAAQ,IAAIA,KAAK,IACjB,IAAAC,gBAAA,EAAOD,KAAK,CAACI,MAAM,MAAK,QAAQ,IAChCJ,KAAK,CAACI,MAAM,KAAK,IAAI,IACrB,kBAAkB,IAAIJ,KAAK,CAACI,MAAM,IAClC,OAAOJ,KAAK,CAACI,MAAM,CAACC,gBAAgB,KAAK,UAAU;AAE3D,CAAC;AAEM,IAAMC,gBAAgB,GAAAP,OAAA,CAAAO,gBAAA,GAAG,SAAnBA,gBAAgBA,CACzBC,KAA2B,EACJ;EACvB,OAAO,UAACC,OAAO,EAAEC,YAAY,EAAEC,OAAO,EAAK;IACvC,IAAMV,KAAK,GAAGO,KAAK,CAACC,OAAO,EAAEC,YAAY,EAAEC,OAAO,CAAC;IAEnD,IAAIP,WAAW,CAACM,YAAY,CAAC,IAAIX,aAAa,CAACE,KAAK,CAAC,EAAE;MACnDS,YAAY,CAACL,MAAM,CAACC,gBAAgB,CAAC,OAAO,EAAE,YAAM;QAChDL,KAAK,CAACE,MAAM,CAAC,CAAC;MAClB,CAAC,CAAC;IACN;IAEA,OAAOF,KAAK;EAChB,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _core = require("./core");
|
|
7
|
+
Object.keys(_core).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _core[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _core[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _react = require("./react");
|
|
18
|
+
Object.keys(_react).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _react[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _react[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _reactQuery = require("./react-query");
|
|
29
|
+
Object.keys(_reactQuery).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _reactQuery[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _reactQuery[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
// #sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_core","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_react","_reactQuery"],"sources":["index.ts"],"sourcesContent":["export * from './core';\nexport * from './react';\nexport * from './react-query';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,WAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,WAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,WAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,WAAA,CAAAN,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|