@data-client/core 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +134 -409
- package/dist/index.umd.min.js +1 -1
- package/dist/next.js +61 -101
- package/legacy/actionTypes.js +2 -2
- package/legacy/controller/Controller.js +276 -6
- package/legacy/controller/createFetch.js +3 -14
- package/legacy/controller/createInvalidate.js +1 -1
- package/legacy/controller/createInvalidateAll.js +1 -1
- package/legacy/controller/createOptimistic.js +1 -7
- package/legacy/controller/createReset.js +1 -1
- package/legacy/controller/createSet.js +31 -0
- package/legacy/controller/createSubscription.js +3 -7
- package/legacy/index.js +2 -5
- package/legacy/internal.js +2 -2
- package/legacy/manager/DevtoolsManager.js +2 -2
- package/legacy/manager/LogoutManager.js +2 -2
- package/legacy/manager/NetworkManager.js +28 -59
- package/legacy/manager/PollingSubscription.js +18 -27
- package/legacy/manager/SubscriptionManager.js +16 -42
- package/legacy/manager/applyManager.js +2 -1
- package/legacy/middlewareTypes.js +1 -1
- package/legacy/newActions.js +1 -1
- package/legacy/next/index.js +3 -3
- package/legacy/state/reducer/createReducer.js +2 -6
- package/legacy/state/reducer/fetchReducer.js +3 -13
- package/legacy/state/reducer/invalidateReducer.js +1 -1
- package/legacy/state/reducer/setReducer.js +9 -16
- package/legacy/types.js +2 -6
- package/lib/actionTypes.d.ts +1 -0
- package/lib/actionTypes.d.ts.map +1 -1
- package/lib/actionTypes.js +2 -2
- package/lib/controller/Controller.d.ts +126 -6
- package/lib/controller/Controller.d.ts.map +1 -1
- package/lib/controller/Controller.js +276 -6
- package/lib/controller/createFetch.d.ts +2 -2
- package/lib/controller/createFetch.d.ts.map +1 -1
- package/lib/controller/createFetch.js +3 -14
- package/lib/controller/createInvalidate.d.ts +1 -1
- package/lib/controller/createInvalidate.d.ts.map +1 -1
- package/lib/controller/createInvalidate.js +1 -1
- package/lib/controller/createInvalidateAll.d.ts +1 -1
- package/lib/controller/createInvalidateAll.d.ts.map +1 -1
- package/lib/controller/createInvalidateAll.js +1 -1
- package/lib/controller/createOptimistic.d.ts +2 -2
- package/lib/controller/createOptimistic.d.ts.map +1 -1
- package/lib/controller/createOptimistic.js +1 -7
- package/lib/controller/createReset.d.ts +1 -1
- package/lib/controller/createReset.d.ts.map +1 -1
- package/lib/controller/createReset.js +1 -1
- package/lib/controller/{createReceive.d.ts → createSet.d.ts} +6 -6
- package/lib/controller/createSet.d.ts.map +1 -0
- package/lib/controller/createSet.js +31 -0
- package/lib/controller/createSubscription.d.ts +3 -3
- package/lib/controller/createSubscription.d.ts.map +1 -1
- package/lib/controller/createSubscription.js +3 -7
- package/lib/index.d.ts +2 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -5
- package/lib/internal.d.ts +1 -1
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +2 -2
- package/lib/manager/DevtoolsManager.d.ts +1 -1
- package/lib/manager/DevtoolsManager.js +2 -2
- package/lib/manager/LogoutManager.d.ts +4 -5
- package/lib/manager/LogoutManager.d.ts.map +1 -1
- package/lib/manager/LogoutManager.js +2 -2
- package/lib/manager/NetworkManager.d.ts +4 -5
- package/lib/manager/NetworkManager.d.ts.map +1 -1
- package/lib/manager/NetworkManager.js +28 -61
- package/lib/manager/PollingSubscription.d.ts +9 -9
- package/lib/manager/PollingSubscription.d.ts.map +1 -1
- package/lib/manager/PollingSubscription.js +18 -27
- package/lib/manager/SubscriptionManager.d.ts +10 -15
- package/lib/manager/SubscriptionManager.d.ts.map +1 -1
- package/lib/manager/SubscriptionManager.js +16 -42
- package/lib/manager/applyManager.d.ts.map +1 -1
- package/lib/manager/applyManager.js +2 -1
- package/lib/middlewareTypes.d.ts +5 -5
- package/lib/middlewareTypes.d.ts.map +1 -1
- package/lib/middlewareTypes.js +1 -1
- package/lib/newActions.d.ts +26 -18
- package/lib/newActions.d.ts.map +1 -1
- package/lib/newActions.js +1 -1
- package/lib/next/index.d.ts +2 -2
- package/lib/next/index.d.ts.map +1 -1
- package/lib/next/index.js +3 -3
- package/lib/state/reducer/createReducer.d.ts.map +1 -1
- package/lib/state/reducer/createReducer.js +2 -6
- package/lib/state/reducer/fetchReducer.d.ts +1 -2
- package/lib/state/reducer/fetchReducer.d.ts.map +1 -1
- package/lib/state/reducer/fetchReducer.js +3 -14
- package/lib/state/reducer/invalidateReducer.d.ts +3 -4
- package/lib/state/reducer/invalidateReducer.d.ts.map +1 -1
- package/lib/state/reducer/invalidateReducer.js +1 -1
- package/lib/state/reducer/setReducer.d.ts +2 -38
- package/lib/state/reducer/setReducer.d.ts.map +1 -1
- package/lib/state/reducer/setReducer.js +9 -17
- package/lib/types.d.ts +9 -30
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +2 -6
- package/package.json +10 -7
- package/src/actionTypes.ts +1 -1
- package/src/controller/Controller.ts +491 -10
- package/src/controller/createFetch.ts +4 -19
- package/src/controller/createInvalidate.ts +1 -1
- package/src/controller/createInvalidateAll.ts +1 -1
- package/src/controller/createOptimistic.ts +3 -9
- package/src/controller/createReset.ts +1 -1
- package/src/controller/{createReceive.ts → createSet.ts} +9 -17
- package/src/controller/createSubscription.ts +3 -10
- package/src/index.ts +2 -16
- package/src/internal.ts +1 -1
- package/src/manager/DevtoolsManager.ts +1 -1
- package/src/manager/LogoutManager.ts +4 -5
- package/src/manager/NetworkManager.ts +31 -80
- package/src/manager/PollingSubscription.ts +40 -38
- package/src/manager/SubscriptionManager.ts +22 -54
- package/src/manager/__tests__/__snapshots__/pollingSubscription.ts.snap +10 -8
- package/src/manager/__tests__/logoutManager.ts +5 -5
- package/src/manager/__tests__/manager.ts +2 -4
- package/src/manager/__tests__/networkManager.ts +8 -42
- package/src/manager/__tests__/pollingSubscription.ts +259 -151
- package/src/manager/__tests__/subscriptionManager.ts +7 -13
- package/src/manager/applyManager.ts +1 -0
- package/src/middlewareTypes.ts +5 -10
- package/src/newActions.ts +33 -23
- package/src/next/index.ts +2 -2
- package/src/state/__tests__/reducer.ts +59 -297
- package/src/state/reducer/createReducer.ts +3 -11
- package/src/state/reducer/fetchReducer.ts +5 -18
- package/src/state/reducer/invalidateReducer.ts +2 -2
- package/src/state/reducer/setReducer.ts +10 -22
- package/src/types.ts +9 -78
- package/ts3.4/actionTypes.d.ts +1 -0
- package/ts3.4/controller/Controller.d.ts +168 -6
- package/ts3.4/controller/createFetch.d.ts +2 -2
- package/ts3.4/controller/createInvalidate.d.ts +1 -1
- package/ts3.4/controller/createInvalidateAll.d.ts +1 -1
- package/ts3.4/controller/createOptimistic.d.ts +1 -1
- package/ts3.4/controller/createReset.d.ts +1 -1
- package/ts3.4/controller/{createReceive.d.ts → createSet.d.ts} +6 -6
- package/ts3.4/controller/createSubscription.d.ts +3 -3
- package/ts3.4/index.d.ts +2 -7
- package/ts3.4/internal.d.ts +1 -1
- package/ts3.4/manager/DevtoolsManager.d.ts +1 -1
- package/ts3.4/manager/LogoutManager.d.ts +4 -5
- package/ts3.4/manager/NetworkManager.d.ts +4 -5
- package/ts3.4/manager/PollingSubscription.d.ts +9 -9
- package/ts3.4/manager/SubscriptionManager.d.ts +10 -15
- package/ts3.4/middlewareTypes.d.ts +5 -5
- package/ts3.4/newActions.d.ts +26 -18
- package/ts3.4/next/index.d.ts +2 -2
- package/ts3.4/state/reducer/fetchReducer.d.ts +1 -2
- package/ts3.4/state/reducer/invalidateReducer.d.ts +3 -4
- package/ts3.4/state/reducer/setReducer.d.ts +2 -38
- package/ts3.4/types.d.ts +8 -30
- package/legacy/compatibleActions.js +0 -2
- package/legacy/controller/BaseController.js +0 -289
- package/legacy/controller/createReceive.js +0 -36
- package/legacy/endpoint/index.js +0 -2
- package/legacy/endpoint/shapes.js +0 -2
- package/legacy/endpoint/types.js +0 -2
- package/legacy/legacyActions.js +0 -2
- package/legacy/next/Controller.js +0 -24
- package/legacy/previousActions.js +0 -2
- package/legacy/state/applyUpdatersToResults.js +0 -4
- package/legacy/state/legacy-actions/createFetch.js +0 -62
- package/legacy/state/legacy-actions/createReceive.js +0 -37
- package/legacy/state/legacy-actions/createReceiveError.js +0 -28
- package/legacy/state/legacy-actions/index.js +0 -4
- package/legacy/state/reducerInstance.js +0 -9
- package/lib/compatibleActions.d.ts +0 -47
- package/lib/compatibleActions.d.ts.map +0 -1
- package/lib/compatibleActions.js +0 -2
- package/lib/controller/BaseController.d.ts +0 -128
- package/lib/controller/BaseController.d.ts.map +0 -1
- package/lib/controller/BaseController.js +0 -289
- package/lib/controller/createReceive.d.ts.map +0 -1
- package/lib/controller/createReceive.js +0 -36
- package/lib/endpoint/index.d.ts +0 -3
- package/lib/endpoint/index.d.ts.map +0 -1
- package/lib/endpoint/index.js +0 -2
- package/lib/endpoint/shapes.d.ts +0 -25
- package/lib/endpoint/shapes.d.ts.map +0 -1
- package/lib/endpoint/shapes.js +0 -2
- package/lib/endpoint/types.d.ts +0 -45
- package/lib/endpoint/types.d.ts.map +0 -1
- package/lib/endpoint/types.js +0 -2
- package/lib/legacyActions.d.ts +0 -92
- package/lib/legacyActions.d.ts.map +0 -1
- package/lib/legacyActions.js +0 -2
- package/lib/next/Controller.d.ts +0 -14
- package/lib/next/Controller.d.ts.map +0 -1
- package/lib/next/Controller.js +0 -24
- package/lib/previousActions.d.ts +0 -91
- package/lib/previousActions.d.ts.map +0 -1
- package/lib/previousActions.js +0 -2
- package/lib/state/applyUpdatersToResults.d.ts +0 -13
- package/lib/state/applyUpdatersToResults.d.ts.map +0 -1
- package/lib/state/applyUpdatersToResults.js +0 -7
- package/lib/state/legacy-actions/createFetch.d.ts +0 -19
- package/lib/state/legacy-actions/createFetch.d.ts.map +0 -1
- package/lib/state/legacy-actions/createFetch.js +0 -62
- package/lib/state/legacy-actions/createReceive.d.ts +0 -14
- package/lib/state/legacy-actions/createReceive.d.ts.map +0 -1
- package/lib/state/legacy-actions/createReceive.js +0 -37
- package/lib/state/legacy-actions/createReceiveError.d.ts +0 -9
- package/lib/state/legacy-actions/createReceiveError.d.ts.map +0 -1
- package/lib/state/legacy-actions/createReceiveError.js +0 -28
- package/lib/state/legacy-actions/index.d.ts +0 -4
- package/lib/state/legacy-actions/index.d.ts.map +0 -1
- package/lib/state/legacy-actions/index.js +0 -4
- package/lib/state/reducerInstance.d.ts +0 -7
- package/lib/state/reducerInstance.d.ts.map +0 -1
- package/lib/state/reducerInstance.js +0 -9
- package/src/compatibleActions.ts +0 -96
- package/src/controller/BaseController.ts +0 -508
- package/src/endpoint/index.ts +0 -14
- package/src/endpoint/shapes.ts +0 -53
- package/src/endpoint/types.ts +0 -72
- package/src/legacyActions.ts +0 -163
- package/src/manager/__tests__/__snapshots__/pollingSubscription-endpoint.ts.snap +0 -49
- package/src/manager/__tests__/networkManager-legacy.ts +0 -394
- package/src/manager/__tests__/pollingSubscription-endpoint.ts +0 -423
- package/src/next/Controller.ts +0 -39
- package/src/previousActions.ts +0 -159
- package/src/state/__tests__/applyUpdatersToResults.ts +0 -40
- package/src/state/applyUpdatersToResults.ts +0 -29
- package/src/state/legacy-actions/createFetch.ts +0 -95
- package/src/state/legacy-actions/createReceive.ts +0 -68
- package/src/state/legacy-actions/createReceiveError.ts +0 -43
- package/src/state/legacy-actions/index.ts +0 -3
- package/src/state/reducerInstance.ts +0 -14
- package/ts3.4/compatibleActions.d.ts +0 -47
- package/ts3.4/controller/BaseController.d.ts +0 -170
- package/ts3.4/endpoint/index.d.ts +0 -3
- package/ts3.4/endpoint/shapes.d.ts +0 -25
- package/ts3.4/endpoint/types.d.ts +0 -45
- package/ts3.4/legacyActions.d.ts +0 -95
- package/ts3.4/next/Controller.d.ts +0 -14
- package/ts3.4/previousActions.d.ts +0 -94
- package/ts3.4/state/applyUpdatersToResults.d.ts +0 -13
- package/ts3.4/state/legacy-actions/createFetch.d.ts +0 -19
- package/ts3.4/state/legacy-actions/createReceive.d.ts +0 -14
- package/ts3.4/state/legacy-actions/createReceiveError.d.ts +0 -9
- package/ts3.4/state/legacy-actions/index.d.ts +0 -4
- package/ts3.4/state/reducerInstance.d.ts +0 -7
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// TODO(breaking): remove file - not used
|
|
2
|
-
import { Schema } from '@data-client/normalizr';
|
|
3
|
-
|
|
4
|
-
import { FETCH_TYPE } from '../../actionTypes.js';
|
|
5
|
-
import {
|
|
6
|
-
FetchShape,
|
|
7
|
-
SchemaFromShape,
|
|
8
|
-
ParamsFromShape,
|
|
9
|
-
BodyFromShape,
|
|
10
|
-
OptimisticUpdateParams,
|
|
11
|
-
} from '../../endpoint/index.js';
|
|
12
|
-
import { FetchAction } from '../../legacyActions.js';
|
|
13
|
-
|
|
14
|
-
interface Options<
|
|
15
|
-
Shape extends FetchShape<
|
|
16
|
-
Schema | undefined,
|
|
17
|
-
Readonly<object>,
|
|
18
|
-
Readonly<object | string> | void
|
|
19
|
-
>,
|
|
20
|
-
> {
|
|
21
|
-
params: ParamsFromShape<Shape>;
|
|
22
|
-
body?: BodyFromShape<Shape>;
|
|
23
|
-
throttle: boolean;
|
|
24
|
-
updateParams?:
|
|
25
|
-
| OptimisticUpdateParams<
|
|
26
|
-
SchemaFromShape<Shape>,
|
|
27
|
-
FetchShape<Schema | undefined, any, any>
|
|
28
|
-
>[]
|
|
29
|
-
| undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Requesting a fetch to begin
|
|
33
|
-
*
|
|
34
|
-
* @param fetchShape
|
|
35
|
-
* @param param1 { params, body, throttle, updateParams }
|
|
36
|
-
*/
|
|
37
|
-
export default function createFetch<
|
|
38
|
-
Shape extends FetchShape<
|
|
39
|
-
Schema | undefined,
|
|
40
|
-
Readonly<object>,
|
|
41
|
-
Readonly<object | string> | void
|
|
42
|
-
>,
|
|
43
|
-
>(
|
|
44
|
-
fetchShape: Shape & {
|
|
45
|
-
update?: (...args: any) => Record<string, (...args: any) => any>;
|
|
46
|
-
},
|
|
47
|
-
{ params, body, throttle, updateParams }: Options<Shape>,
|
|
48
|
-
): FetchAction {
|
|
49
|
-
const { schema, type, getFetchKey, options } = fetchShape;
|
|
50
|
-
|
|
51
|
-
const key = getFetchKey(params);
|
|
52
|
-
let resolve: (value?: any | PromiseLike<any>) => void = 0 as any;
|
|
53
|
-
let reject: (reason?: any) => void = 0 as any;
|
|
54
|
-
const promise = new Promise<any>((a, b) => {
|
|
55
|
-
[resolve, reject] = [a, b];
|
|
56
|
-
});
|
|
57
|
-
const meta: FetchAction['meta'] = {
|
|
58
|
-
schema,
|
|
59
|
-
type,
|
|
60
|
-
args: [params, body],
|
|
61
|
-
key,
|
|
62
|
-
throttle,
|
|
63
|
-
options,
|
|
64
|
-
resolve,
|
|
65
|
-
reject,
|
|
66
|
-
promise,
|
|
67
|
-
createdAt: Date.now(),
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (fetchShape.update) {
|
|
71
|
-
meta.update = fetchShape.update;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// for simplicity we simply override if updateParams are defined - usage together is silly to support as we are migrating
|
|
75
|
-
if (updateParams) {
|
|
76
|
-
meta.update = (newresult: any): Record<string, (...args: any) => any> => {
|
|
77
|
-
const updateMap: any = {};
|
|
78
|
-
updateParams.forEach(([toShape, toParams, updateFn]) => {
|
|
79
|
-
updateMap[toShape.getFetchKey(toParams)] = (existing: any) =>
|
|
80
|
-
updateFn(newresult, existing);
|
|
81
|
-
});
|
|
82
|
-
return updateMap;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (options?.optimisticUpdate) {
|
|
87
|
-
meta.optimisticResponse = options.optimisticUpdate(params, body);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return {
|
|
91
|
-
type: FETCH_TYPE,
|
|
92
|
-
payload: () => fetchShape.fetch(params, body),
|
|
93
|
-
meta,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Schema,
|
|
3
|
-
EndpointExtraOptions as FetchOptions,
|
|
4
|
-
} from '@data-client/normalizr';
|
|
5
|
-
|
|
6
|
-
import { RECEIVE_TYPE } from '../../actionTypes.js';
|
|
7
|
-
import { FetchAction, ReceiveAction } from '../../legacyActions.js';
|
|
8
|
-
|
|
9
|
-
interface Options<
|
|
10
|
-
Payload extends object | string | number | null =
|
|
11
|
-
| object
|
|
12
|
-
| string
|
|
13
|
-
| number
|
|
14
|
-
| null,
|
|
15
|
-
S extends Schema | undefined = any,
|
|
16
|
-
> extends Pick<
|
|
17
|
-
FetchAction<Payload, S>['meta'],
|
|
18
|
-
'schema' | 'key' | 'type' | 'updaters' | 'update' | 'args'
|
|
19
|
-
> {
|
|
20
|
-
dataExpiryLength: NonNullable<FetchOptions['dataExpiryLength']>;
|
|
21
|
-
fetchedAt?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Update state with data
|
|
25
|
-
*
|
|
26
|
-
* @param data
|
|
27
|
-
* @param param1 { schema, key, type, updaters, dataExpiryLength }
|
|
28
|
-
*/
|
|
29
|
-
export default function createReceive<
|
|
30
|
-
Payload extends object | string | number | null =
|
|
31
|
-
| object
|
|
32
|
-
| string
|
|
33
|
-
| number
|
|
34
|
-
| null,
|
|
35
|
-
S extends Schema | undefined = any,
|
|
36
|
-
>(
|
|
37
|
-
data: Payload,
|
|
38
|
-
{
|
|
39
|
-
schema,
|
|
40
|
-
key,
|
|
41
|
-
args,
|
|
42
|
-
updaters,
|
|
43
|
-
fetchedAt = 0,
|
|
44
|
-
update,
|
|
45
|
-
dataExpiryLength,
|
|
46
|
-
}: Options<Payload, S>,
|
|
47
|
-
): ReceiveAction<Payload, S> {
|
|
48
|
-
/* istanbul ignore next */
|
|
49
|
-
if (process.env.NODE_ENV === 'development' && dataExpiryLength < 0) {
|
|
50
|
-
throw new Error('Negative dataExpiryLength are not allowed.');
|
|
51
|
-
}
|
|
52
|
-
const now = Date.now();
|
|
53
|
-
const meta: ReceiveAction['meta'] = {
|
|
54
|
-
schema,
|
|
55
|
-
key,
|
|
56
|
-
args,
|
|
57
|
-
date: now,
|
|
58
|
-
fetchedAt,
|
|
59
|
-
expiresAt: now + dataExpiryLength,
|
|
60
|
-
};
|
|
61
|
-
meta.updaters = updaters;
|
|
62
|
-
meta.update = update;
|
|
63
|
-
return {
|
|
64
|
-
type: RECEIVE_TYPE,
|
|
65
|
-
payload: data,
|
|
66
|
-
meta,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Schema,
|
|
3
|
-
EndpointExtraOptions as FetchOptions,
|
|
4
|
-
} from '@data-client/normalizr';
|
|
5
|
-
|
|
6
|
-
import { RECEIVE_TYPE } from '../../actionTypes.js';
|
|
7
|
-
import { FetchAction, ReceiveAction } from '../../legacyActions.js';
|
|
8
|
-
|
|
9
|
-
interface Options<S extends Schema | undefined = any>
|
|
10
|
-
extends Pick<FetchAction<any, S>['meta'], 'schema' | 'key' | 'options'> {
|
|
11
|
-
errorExpiryLength?: NonNullable<FetchOptions['errorExpiryLength']>;
|
|
12
|
-
fetchedAt?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function createReceiveError<S extends Schema | undefined = any>(
|
|
16
|
-
error: Error,
|
|
17
|
-
{
|
|
18
|
-
schema,
|
|
19
|
-
key,
|
|
20
|
-
options,
|
|
21
|
-
errorExpiryLength = 60000,
|
|
22
|
-
fetchedAt = 0,
|
|
23
|
-
}: Options<S>,
|
|
24
|
-
): ReceiveAction {
|
|
25
|
-
/* istanbul ignore next */
|
|
26
|
-
if (process.env.NODE_ENV === 'development' && errorExpiryLength < 0) {
|
|
27
|
-
throw new Error('Negative errorExpiryLength are not allowed.');
|
|
28
|
-
}
|
|
29
|
-
const now = Date.now();
|
|
30
|
-
return {
|
|
31
|
-
type: RECEIVE_TYPE,
|
|
32
|
-
payload: error,
|
|
33
|
-
meta: {
|
|
34
|
-
schema,
|
|
35
|
-
key,
|
|
36
|
-
date: now,
|
|
37
|
-
fetchedAt,
|
|
38
|
-
expiresAt: now + errorExpiryLength,
|
|
39
|
-
errorPolicy: options?.errorPolicy,
|
|
40
|
-
},
|
|
41
|
-
error: true,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
import createReducer from './reducer/createReducer.js';
|
|
3
|
-
import Controller from '../controller/Controller.js';
|
|
4
|
-
import { ActionTypes, State } from '../types.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated use createReducer instead
|
|
8
|
-
*/
|
|
9
|
-
const reducer: (
|
|
10
|
-
state: State<unknown> | undefined,
|
|
11
|
-
action: ActionTypes,
|
|
12
|
-
) => State<unknown> = createReducer(new Controller());
|
|
13
|
-
|
|
14
|
-
export default reducer;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { EndpointExtraOptions, EndpointInterface, Schema } from '@data-client/normalizr';
|
|
2
|
-
import { FetchAction, FetchMeta, GCAction, InvalidateAction, OptimisticAction, ReceiveActionError, ReceiveActionSuccess, ReceiveMeta, ResetAction, SubscribeAction, UnsubscribeAction } from './newActions.js';
|
|
3
|
-
export interface CompatibleFetchMeta extends FetchMeta {
|
|
4
|
-
key: string;
|
|
5
|
-
schema?: Schema;
|
|
6
|
-
type: 'mutate' | 'read';
|
|
7
|
-
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
8
|
-
options?: EndpointExtraOptions;
|
|
9
|
-
optimisticResponse?: {};
|
|
10
|
-
}
|
|
11
|
-
export interface CompatibleFetchAction<E extends EndpointInterface = EndpointInterface> extends FetchAction<E> {
|
|
12
|
-
meta: CompatibleFetchMeta;
|
|
13
|
-
}
|
|
14
|
-
export interface CompatibleReceiveMeta extends ReceiveMeta {
|
|
15
|
-
key: string;
|
|
16
|
-
schema?: any;
|
|
17
|
-
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
18
|
-
errorPolicy?: (error: any) => 'hard' | 'soft' | undefined;
|
|
19
|
-
}
|
|
20
|
-
export interface CompatibleReceiveActionSuccess<E extends EndpointInterface = EndpointInterface> extends ReceiveActionSuccess<E> {
|
|
21
|
-
meta: CompatibleReceiveMeta;
|
|
22
|
-
payload: any;
|
|
23
|
-
}
|
|
24
|
-
export interface CompatibleReceiveActionError<E extends EndpointInterface = EndpointInterface> extends ReceiveActionError<E> {
|
|
25
|
-
meta: CompatibleReceiveMeta;
|
|
26
|
-
payload: any;
|
|
27
|
-
}
|
|
28
|
-
export type CompatibleReceiveAction<E extends EndpointInterface = EndpointInterface> = CompatibleReceiveActionSuccess<E> | CompatibleReceiveActionError<E>;
|
|
29
|
-
export interface CompatibleSubscribeAction<E extends EndpointInterface = EndpointInterface> extends SubscribeAction<E> {
|
|
30
|
-
meta: {
|
|
31
|
-
args: readonly any[];
|
|
32
|
-
schema: Schema | undefined;
|
|
33
|
-
fetch: () => Promise<any>;
|
|
34
|
-
key: string;
|
|
35
|
-
options: EndpointExtraOptions | undefined;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface CompatibleUnsubscribeAction<E extends EndpointInterface = EndpointInterface> extends UnsubscribeAction<E> {
|
|
39
|
-
meta: {
|
|
40
|
-
args: readonly any[];
|
|
41
|
-
key: string;
|
|
42
|
-
options: EndpointExtraOptions | undefined;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export { OptimisticAction, InvalidateAction, ResetAction, GCAction, } from './newActions.js';
|
|
46
|
-
export type CompatibleActionTypes = CompatibleFetchAction | OptimisticAction | CompatibleReceiveAction | CompatibleSubscribeAction | CompatibleUnsubscribeAction | InvalidateAction | ResetAction | GCAction;
|
|
47
|
-
//# sourceMappingURL=compatibleActions.d.ts.map
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { ErrorTypes, SnapshotInterface, DenormalizeCache, Schema } from '@data-client/normalizr';
|
|
2
|
-
import { ExpiryStatus, EndpointInterface, FetchFunction, DenormalizeNullable } from '@data-client/normalizr';
|
|
3
|
-
import { EndpointUpdateFunction } from './types.js';
|
|
4
|
-
import { CombinedActionTypes, State } from '../types.js';
|
|
5
|
-
export type GenericDispatch = (value: any) => Promise<void>;
|
|
6
|
-
export type CompatibleDispatch = (value: CombinedActionTypes) => Promise<void>;
|
|
7
|
-
interface ConstructorProps<D extends GenericDispatch = CompatibleDispatch> {
|
|
8
|
-
dispatch?: D;
|
|
9
|
-
getState?: () => State<unknown>;
|
|
10
|
-
globalCache?: DenormalizeCache;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Imperative control of Rest Hooks store
|
|
14
|
-
* @see https://resthooks.io/docs/api/Controller
|
|
15
|
-
*/
|
|
16
|
-
export default class Controller<D extends GenericDispatch = CompatibleDispatch> {
|
|
17
|
-
/**
|
|
18
|
-
* Dispatches an action to Rest Hooks reducer.
|
|
19
|
-
*
|
|
20
|
-
* @see https://resthooks.io/docs/api/Controller#dispatch
|
|
21
|
-
*/
|
|
22
|
-
readonly dispatch: D;
|
|
23
|
-
/**
|
|
24
|
-
* Gets the latest state snapshot that is fully committed.
|
|
25
|
-
*
|
|
26
|
-
* This can be useful for imperative use-cases like event handlers.
|
|
27
|
-
* This should *not* be used to render; instead useSuspense() or useCache()
|
|
28
|
-
* @see https://resthooks.io/docs/api/Controller#getState
|
|
29
|
-
*/
|
|
30
|
-
readonly getState: () => State<unknown>;
|
|
31
|
-
readonly globalCache: DenormalizeCache;
|
|
32
|
-
constructor({ dispatch, getState, globalCache, }?: ConstructorProps<D>);
|
|
33
|
-
/*************** Action Dispatchers ***************/
|
|
34
|
-
/**
|
|
35
|
-
* Forces refetching and suspense on useSuspense with the same Endpoint and parameters.
|
|
36
|
-
* @see https://resthooks.io/docs/api/Controller#invalidate
|
|
37
|
-
*/
|
|
38
|
-
invalidate: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>>(endpoint: E, ...args: readonly [
|
|
39
|
-
...Parameters<E>
|
|
40
|
-
] | readonly [
|
|
41
|
-
null
|
|
42
|
-
]) => Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Forces refetching and suspense on useSuspense on all matching endpoint result keys.
|
|
45
|
-
* @see https://resthooks.io/docs/api/Controller#invalidateAll
|
|
46
|
-
*/
|
|
47
|
-
invalidateAll: (options: {
|
|
48
|
-
testKey: (key: string) => boolean;
|
|
49
|
-
}) => Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Resets the entire Rest Hooks cache. All inflight requests will not resolve.
|
|
52
|
-
* @see https://resthooks.io/docs/api/Controller#resetEntireStore
|
|
53
|
-
*/
|
|
54
|
-
resetEntireStore: () => Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Stores response in cache for given Endpoint and args.
|
|
57
|
-
* @see https://resthooks.io/docs/api/Controller#set
|
|
58
|
-
*/
|
|
59
|
-
setResponse: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
60
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
61
|
-
}>(endpoint: E, ...rest: readonly [
|
|
62
|
-
...Parameters<E>,
|
|
63
|
-
any
|
|
64
|
-
]) => Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Another name for setResponse
|
|
67
|
-
* @see https://resthooks.io/docs/api/Controller#setResponse
|
|
68
|
-
*/
|
|
69
|
-
receive: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
70
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
71
|
-
}>(endpoint: E, ...rest: readonly [
|
|
72
|
-
...Parameters<E>,
|
|
73
|
-
any
|
|
74
|
-
]) => Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Stores the result of Endpoint and args as the error provided.
|
|
77
|
-
* @see https://resthooks.io/docs/api/Controller#setError
|
|
78
|
-
*/
|
|
79
|
-
setError: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
80
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
81
|
-
}>(endpoint: E, ...rest: readonly [
|
|
82
|
-
...Parameters<E>,
|
|
83
|
-
Error
|
|
84
|
-
]) => Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Another name for setError
|
|
87
|
-
* @see https://resthooks.io/docs/api/Controller#setError
|
|
88
|
-
*/
|
|
89
|
-
receiveError: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
90
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
91
|
-
}>(endpoint: E, ...rest: readonly [
|
|
92
|
-
...Parameters<E>,
|
|
93
|
-
Error
|
|
94
|
-
]) => Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* Resolves an inflight fetch. `fetchedAt` should `fetch`'s `createdAt`
|
|
97
|
-
* @see https://resthooks.io/docs/api/Controller#resolve
|
|
98
|
-
*/
|
|
99
|
-
resolve: <E extends EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined> & {
|
|
100
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
101
|
-
}>(endpoint: E, meta: {
|
|
102
|
-
args: readonly [
|
|
103
|
-
...Parameters<E>
|
|
104
|
-
];
|
|
105
|
-
response: Error;
|
|
106
|
-
fetchedAt: number;
|
|
107
|
-
error: true;
|
|
108
|
-
} | {
|
|
109
|
-
args: readonly [
|
|
110
|
-
...Parameters<E>
|
|
111
|
-
];
|
|
112
|
-
response: any;
|
|
113
|
-
fetchedAt: number;
|
|
114
|
-
error?: false | undefined;
|
|
115
|
-
}) => Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Marks a new subscription to a given Endpoint.
|
|
118
|
-
* @see https://resthooks.io/docs/api/Controller#subscribe
|
|
119
|
-
*/
|
|
120
|
-
subscribe: <E extends EndpointInterface<FetchFunction, Schema | undefined, false | undefined>>(endpoint: E, ...args: readonly [
|
|
121
|
-
null
|
|
122
|
-
] | readonly [
|
|
123
|
-
...Parameters<E>
|
|
124
|
-
]) => Promise<void>;
|
|
125
|
-
/**
|
|
126
|
-
* Marks completion of subscription to a given Endpoint.
|
|
127
|
-
* @see https://resthooks.io/docs/api/Controller#unsubscribe
|
|
128
|
-
*/
|
|
129
|
-
unsubscribe: <E extends EndpointInterface<FetchFunction, Schema | undefined, false | undefined>>(endpoint: E, ...args: readonly [
|
|
130
|
-
null
|
|
131
|
-
] | readonly [
|
|
132
|
-
...Parameters<E>
|
|
133
|
-
]) => Promise<void>;
|
|
134
|
-
/*************** More ***************/
|
|
135
|
-
/**
|
|
136
|
-
* Gets a snapshot (https://resthooks.io/docs/api/Snapshot)
|
|
137
|
-
* @see https://resthooks.io/docs/api/Controller#snapshot
|
|
138
|
-
*/
|
|
139
|
-
snapshot: (state: State<unknown>, fetchedAt?: number) => SnapshotInterface;
|
|
140
|
-
/**
|
|
141
|
-
* Gets the error, if any, for a given endpoint. Returns undefined for no errors.
|
|
142
|
-
* @see https://resthooks.io/docs/api/Controller#getError
|
|
143
|
-
*/
|
|
144
|
-
getError: <E extends Pick<EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>, "key">, Args extends readonly [
|
|
145
|
-
null
|
|
146
|
-
] | readonly [
|
|
147
|
-
...Parameters<E["key"]>
|
|
148
|
-
]>(endpoint: E, ...rest: [
|
|
149
|
-
...Args,
|
|
150
|
-
State<unknown>
|
|
151
|
-
]) => ErrorTypes | undefined;
|
|
152
|
-
/**
|
|
153
|
-
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
|
|
154
|
-
* @see https://resthooks.io/docs/api/Controller#getResponse
|
|
155
|
-
*/
|
|
156
|
-
getResponse: <E extends Pick<EndpointInterface<FetchFunction, Schema | undefined, boolean | undefined>, "schema" | "key" | "invalidIfStale">, Args extends readonly [
|
|
157
|
-
null
|
|
158
|
-
] | readonly [
|
|
159
|
-
...Parameters<E["key"]>
|
|
160
|
-
]>(endpoint: E, ...rest: [
|
|
161
|
-
...Args,
|
|
162
|
-
State<unknown>
|
|
163
|
-
]) => {
|
|
164
|
-
data: DenormalizeNullable<E["schema"]>;
|
|
165
|
-
expiryStatus: ExpiryStatus;
|
|
166
|
-
expiresAt: number;
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
export { ErrorTypes };
|
|
170
|
-
//# sourceMappingURL=BaseController.d.ts.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Schema, EndpointExtraOptions as FetchOptions } from '@data-client/normalizr';
|
|
2
|
-
/** Defines the shape of a network request */
|
|
3
|
-
export interface FetchShape<S extends Schema | undefined, Params extends Readonly<object> = Readonly<object>, Body extends Readonly<object | string> | void | unknown = Readonly<object | string> | undefined, Response = any> {
|
|
4
|
-
readonly type: 'read' | 'mutate' | 'delete';
|
|
5
|
-
fetch(params: Params, body?: Body): Promise<Response>;
|
|
6
|
-
getFetchKey(params: Params): string;
|
|
7
|
-
readonly schema: S;
|
|
8
|
-
readonly options?: FetchOptions;
|
|
9
|
-
}
|
|
10
|
-
/** To change values on the server */
|
|
11
|
-
export interface MutateShape<S extends Schema | undefined, Params extends Readonly<object> = Readonly<object>, Body extends Readonly<object | string> | void | unknown = Readonly<object | string> | undefined, Response extends object | string | number | boolean | null = any> extends FetchShape<S, Params, Body, Response> {
|
|
12
|
-
readonly type: 'mutate';
|
|
13
|
-
fetch(params: Params, body: Body): Promise<Response>;
|
|
14
|
-
}
|
|
15
|
-
/** Removes entities */
|
|
16
|
-
export interface DeleteShape<S extends Schema | undefined, Params extends Readonly<object> = Readonly<object>, Response extends object | string | number | boolean | null = any> extends FetchShape<S, Params, undefined, Response> {
|
|
17
|
-
readonly type: 'mutate';
|
|
18
|
-
fetch(params: Params, ...args: any): Promise<Response>;
|
|
19
|
-
}
|
|
20
|
-
/** For retrieval requests */
|
|
21
|
-
export interface ReadShape<S extends Schema | undefined, Params extends Readonly<object> = Readonly<object>, Response extends object | string | number | boolean | null = any> extends FetchShape<S, Params, undefined, Response> {
|
|
22
|
-
readonly type: 'read';
|
|
23
|
-
fetch(params: Params): Promise<Response>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=shapes.d.ts.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Schema } from '@data-client/normalizr';
|
|
2
|
-
import { Denormalize } from '@data-client/normalizr';
|
|
3
|
-
import { FetchShape } from './shapes.js';
|
|
4
|
-
import { UpdateFunction } from '../types.js';
|
|
5
|
-
export type ResultShape<RS> = RS extends {
|
|
6
|
-
schema: infer U;
|
|
7
|
-
} ? U : never;
|
|
8
|
-
export type SelectReturn<RS> = RS extends {
|
|
9
|
-
select: (...args: any[]) => infer U;
|
|
10
|
-
} ? U : never;
|
|
11
|
-
export type AlwaysSelect<RS> = NonNullable<SelectReturn<RS>>;
|
|
12
|
-
export type ParamArg<RS> = RS extends {
|
|
13
|
-
getFetchKey: (params: infer U) => any;
|
|
14
|
-
} ? U : never;
|
|
15
|
-
export type BodyArg<RS> = RS extends {
|
|
16
|
-
fetch: (url: any, body: infer U) => any;
|
|
17
|
-
} ? U : never;
|
|
18
|
-
/** Sets a FetchShape's Param type.
|
|
19
|
-
* Useful to constrain acceptable params (second arg) in hooks like useResource().
|
|
20
|
-
*
|
|
21
|
-
* @param [Shape] FetchShape to act upon
|
|
22
|
-
* @param [Params] what to set the Params to
|
|
23
|
-
*/
|
|
24
|
-
export type SetShapeParams<Shape extends FetchShape<any, any, any>, Params extends Readonly<object>> = {
|
|
25
|
-
[K in keyof Shape]: Shape[K];
|
|
26
|
-
} & (Shape['fetch'] extends (first: any, ...rest: infer Args) => infer Return ? {
|
|
27
|
-
fetch: (first: Params, ...rest: Args) => Return;
|
|
28
|
-
} : never);
|
|
29
|
-
/** Get the Params type for a given Shape */
|
|
30
|
-
export type ParamsFromShape<S> = S extends {
|
|
31
|
-
fetch: (first: infer A, ...rest: any) => any;
|
|
32
|
-
} ? A : S extends {
|
|
33
|
-
getFetchKey: (first: infer A, ...rest: any) => any;
|
|
34
|
-
} ? A : never;
|
|
35
|
-
/** Get the Schema type for a given Shape */
|
|
36
|
-
export type SchemaFromShape<F extends FetchShape<Schema | undefined, any, any>> = F['schema'];
|
|
37
|
-
/** Get the Body type for a given Shape */
|
|
38
|
-
export type BodyFromShape<F extends FetchShape<any, any, any>> = Parameters<F['fetch']>[1];
|
|
39
|
-
export type OptimisticUpdateParams<SourceSchema extends Schema | undefined, DestShape extends FetchShape<any, any, any>> = [
|
|
40
|
-
DestShape,
|
|
41
|
-
ParamsFromShape<DestShape>,
|
|
42
|
-
UpdateFunction<SourceSchema, SchemaFromShape<DestShape>>
|
|
43
|
-
];
|
|
44
|
-
export type ReturnFromShape<S extends FetchShape<any, any, any>> = ReturnType<S['fetch']> extends unknown ? Promise<Denormalize<S['schema']>> : ReturnType<S['fetch']>;
|
|
45
|
-
//# sourceMappingURL=types.d.ts.map
|
package/ts3.4/legacyActions.d.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { UpdateFunction, Schema, EndpointExtraOptions, EndpointInterface } from '@data-client/normalizr';
|
|
2
|
-
import { FSAWithPayloadAndMeta, FSAWithMeta } from 'flux-standard-action';
|
|
3
|
-
import { RECEIVE_TYPE, RESET_TYPE, FETCH_TYPE, SUBSCRIBE_TYPE, UNSUBSCRIBE_TYPE, INVALIDATE_TYPE, GC_TYPE, OPTIMISTIC_TYPE } from './actionTypes.js';
|
|
4
|
-
import { EndpointUpdateFunction } from './controller/types.js';
|
|
5
|
-
import { FetchShape } from './endpoint/index.js';
|
|
6
|
-
import { ErrorableFSAWithPayloadAndMeta } from './fsa.js';
|
|
7
|
-
export interface ReceiveMeta<S extends Schema | undefined> {
|
|
8
|
-
schema?: S;
|
|
9
|
-
key: string;
|
|
10
|
-
args?: readonly any[];
|
|
11
|
-
updaters?: Record<string, UpdateFunction<S, any>>;
|
|
12
|
-
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
13
|
-
fetchedAt?: number;
|
|
14
|
-
date: number;
|
|
15
|
-
expiresAt: number;
|
|
16
|
-
errorPolicy?: (error: any) => 'hard' | 'soft' | undefined;
|
|
17
|
-
}
|
|
18
|
-
export type ReceiveAction<Payload extends object | string | number | null = object | string | number | null, S extends Schema | undefined = any> = ErrorableFSAWithPayloadAndMeta<typeof RECEIVE_TYPE, Payload, ReceiveMeta<S>>;
|
|
19
|
-
export type OptimisticAction<E extends EndpointInterface & {
|
|
20
|
-
update?: EndpointUpdateFunction<E>;
|
|
21
|
-
} = EndpointInterface & {
|
|
22
|
-
update?: EndpointUpdateFunction<EndpointInterface>;
|
|
23
|
-
}> = {
|
|
24
|
-
type: typeof OPTIMISTIC_TYPE;
|
|
25
|
-
meta: {
|
|
26
|
-
schema: E['schema'];
|
|
27
|
-
key: string;
|
|
28
|
-
args: readonly any[];
|
|
29
|
-
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
30
|
-
fetchedAt: number;
|
|
31
|
-
date: number;
|
|
32
|
-
expiresAt: number;
|
|
33
|
-
errorPolicy?: (error: any) => 'hard' | 'soft' | undefined;
|
|
34
|
-
};
|
|
35
|
-
endpoint: E;
|
|
36
|
-
error?: undefined;
|
|
37
|
-
};
|
|
38
|
-
export interface ResetAction {
|
|
39
|
-
type: typeof RESET_TYPE;
|
|
40
|
-
date: number | Date;
|
|
41
|
-
}
|
|
42
|
-
interface FetchMeta<Payload extends object | string | number | null = object | string | number | null, S extends Schema | undefined = any> {
|
|
43
|
-
type: FetchShape<any, any>['type'];
|
|
44
|
-
schema?: S;
|
|
45
|
-
key: string;
|
|
46
|
-
args?: readonly any[];
|
|
47
|
-
updaters?: Record<string, UpdateFunction<S, any>>;
|
|
48
|
-
update?: (result: any, ...args: any) => Record<string, (...args: any) => any>;
|
|
49
|
-
options?: EndpointExtraOptions;
|
|
50
|
-
throttle: boolean;
|
|
51
|
-
resolve: (value?: any | PromiseLike<any>) => void;
|
|
52
|
-
reject: (reason?: any) => void;
|
|
53
|
-
promise: PromiseLike<any>;
|
|
54
|
-
createdAt: number | Date;
|
|
55
|
-
optimisticResponse?: Payload;
|
|
56
|
-
nm?: boolean;
|
|
57
|
-
}
|
|
58
|
-
export interface FetchAction<Payload extends object | string | number | null = object | string | number | null, S extends Schema | undefined = any> extends FSAWithPayloadAndMeta<typeof FETCH_TYPE, () => Promise<Payload>, FetchMeta<any, any>> {
|
|
59
|
-
meta: FetchMeta<Payload, S>;
|
|
60
|
-
endpoint?: undefined;
|
|
61
|
-
}
|
|
62
|
-
export interface SubscribeAction extends FSAWithMeta<typeof SUBSCRIBE_TYPE, undefined, any> {
|
|
63
|
-
meta: {
|
|
64
|
-
args?: readonly any[];
|
|
65
|
-
schema: Schema | undefined;
|
|
66
|
-
fetch: () => Promise<any>;
|
|
67
|
-
key: string;
|
|
68
|
-
options: EndpointExtraOptions | undefined;
|
|
69
|
-
};
|
|
70
|
-
endpoint?: undefined;
|
|
71
|
-
}
|
|
72
|
-
export interface UnsubscribeAction extends FSAWithMeta<typeof UNSUBSCRIBE_TYPE, undefined, any> {
|
|
73
|
-
meta: {
|
|
74
|
-
args?: readonly any[];
|
|
75
|
-
key: string;
|
|
76
|
-
options: EndpointExtraOptions | undefined;
|
|
77
|
-
};
|
|
78
|
-
endpoint?: undefined;
|
|
79
|
-
}
|
|
80
|
-
export interface InvalidateAction extends FSAWithMeta<typeof INVALIDATE_TYPE, undefined, any> {
|
|
81
|
-
meta: {
|
|
82
|
-
key: string;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export interface GCAction {
|
|
86
|
-
type: typeof GC_TYPE;
|
|
87
|
-
entities: [
|
|
88
|
-
string,
|
|
89
|
-
string
|
|
90
|
-
][];
|
|
91
|
-
results: string[];
|
|
92
|
-
}
|
|
93
|
-
export type ActionTypes = FetchAction | OptimisticAction | ReceiveAction | SubscribeAction | UnsubscribeAction | InvalidateAction | ResetAction | GCAction;
|
|
94
|
-
export {};
|
|
95
|
-
//# sourceMappingURL=legacyActions.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EndpointInterface, Denormalize } from '@data-client/normalizr';
|
|
2
|
-
import BaseController, { CompatibleDispatch, GenericDispatch } from '../controller/BaseController.js';
|
|
3
|
-
import { EndpointUpdateFunction } from '../controller/types.js';
|
|
4
|
-
export default class Controller<D extends GenericDispatch = CompatibleDispatch> extends BaseController<D> {
|
|
5
|
-
/**
|
|
6
|
-
* Fetches the endpoint with given args, updating the Rest Hooks cache with the response or error upon completion.
|
|
7
|
-
* @see https://resthooks.io/docs/api/Controller#fetch
|
|
8
|
-
*/
|
|
9
|
-
fetch: <E extends EndpointInterface<import("@data-client/normalizr").FetchFunction, import("@data-client/normalizr").Schema | undefined, boolean | undefined> & {
|
|
10
|
-
update?: EndpointUpdateFunction<E> | undefined;
|
|
11
|
-
}>(endpoint: E, ...args_0: Parameters<E>) => E["schema"] extends null | undefined ? ReturnType<E> : Promise<Denormalize<E["schema"]>>;
|
|
12
|
-
}
|
|
13
|
-
export * from '../controller/BaseController.js';
|
|
14
|
-
//# sourceMappingURL=Controller.d.ts.map
|