@data-client/core 0.14.13 → 0.14.18

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.
Files changed (76) hide show
  1. package/dist/index.js +65 -43
  2. package/dist/index.umd.min.js +1 -1
  3. package/legacy/actionTypes.js +23 -12
  4. package/legacy/actions.js +1 -1
  5. package/legacy/controller/Controller.js +2 -2
  6. package/legacy/controller/actions/createExpireAll.js +3 -3
  7. package/legacy/controller/actions/createFetch.js +3 -3
  8. package/legacy/controller/actions/createInvalidate.js +3 -3
  9. package/legacy/controller/actions/createInvalidateAll.js +3 -3
  10. package/legacy/controller/actions/createOptimistic.js +3 -3
  11. package/legacy/controller/actions/createReset.js +3 -3
  12. package/legacy/controller/actions/createSet.js +3 -3
  13. package/legacy/controller/actions/createSetResponse.js +3 -3
  14. package/legacy/controller/actions/createSubscription.js +6 -6
  15. package/legacy/manager/DevtoolsManager.js +1 -3
  16. package/legacy/manager/LogoutManager.js +3 -3
  17. package/legacy/manager/NetworkManager.js +6 -6
  18. package/legacy/manager/PollingSubscription.js +1 -1
  19. package/legacy/manager/SubscriptionManager.js +4 -4
  20. package/legacy/state/reducer/createReducer.js +11 -11
  21. package/legacy/state/reducer/invalidateReducer.js +3 -3
  22. package/legacy/state/reducer/setResponseReducer.js +4 -4
  23. package/lib/actionTypes.d.ts +11 -0
  24. package/lib/actionTypes.d.ts.map +1 -1
  25. package/lib/actionTypes.js +23 -12
  26. package/lib/actions.d.ts +12 -12
  27. package/lib/actions.d.ts.map +1 -1
  28. package/lib/actions.js +1 -1
  29. package/lib/controller/Controller.js +2 -2
  30. package/lib/controller/actions/createExpireAll.js +3 -3
  31. package/lib/controller/actions/createFetch.js +3 -3
  32. package/lib/controller/actions/createInvalidate.js +3 -3
  33. package/lib/controller/actions/createInvalidateAll.js +3 -3
  34. package/lib/controller/actions/createOptimistic.js +3 -3
  35. package/lib/controller/actions/createReset.js +3 -3
  36. package/lib/controller/actions/createSet.js +3 -3
  37. package/lib/controller/actions/createSetResponse.js +3 -3
  38. package/lib/controller/actions/createSubscription.js +6 -6
  39. package/lib/manager/DevtoolsManager.d.ts.map +1 -1
  40. package/lib/manager/DevtoolsManager.js +1 -3
  41. package/lib/manager/LogoutManager.js +3 -3
  42. package/lib/manager/NetworkManager.js +6 -6
  43. package/lib/manager/PollingSubscription.js +1 -1
  44. package/lib/manager/SubscriptionManager.js +4 -4
  45. package/lib/state/reducer/createReducer.js +11 -11
  46. package/lib/state/reducer/invalidateReducer.js +3 -3
  47. package/lib/state/reducer/setReducer.d.ts +2 -2
  48. package/lib/state/reducer/setResponseReducer.d.ts +2 -2
  49. package/lib/state/reducer/setResponseReducer.js +4 -4
  50. package/package.json +6 -3
  51. package/src/actionTypes.ts +23 -11
  52. package/src/actions.ts +22 -22
  53. package/src/controller/Controller.ts +1 -1
  54. package/src/controller/actions/createExpireAll.ts +2 -2
  55. package/src/controller/actions/createFetch.ts +2 -2
  56. package/src/controller/actions/createInvalidate.ts +2 -2
  57. package/src/controller/actions/createInvalidateAll.ts +2 -2
  58. package/src/controller/actions/createOptimistic.ts +2 -2
  59. package/src/controller/actions/createReset.ts +2 -2
  60. package/src/controller/actions/createSet.ts +2 -2
  61. package/src/controller/actions/createSetResponse.ts +2 -2
  62. package/src/controller/actions/createSubscription.ts +5 -5
  63. package/src/manager/DevtoolsManager.ts +2 -3
  64. package/src/manager/LogoutManager.ts +2 -2
  65. package/src/manager/NetworkManager.ts +5 -5
  66. package/src/manager/PollingSubscription.ts +9 -9
  67. package/src/manager/SubscriptionManager.ts +4 -4
  68. package/src/manager/__tests__/logoutManager.ts +3 -3
  69. package/src/manager/__tests__/networkManager.ts +6 -6
  70. package/src/manager/__tests__/subscriptionManager.ts +4 -4
  71. package/src/state/__tests__/reducer.ts +22 -22
  72. package/src/state/reducer/createReducer.ts +18 -18
  73. package/src/state/reducer/invalidateReducer.ts +2 -2
  74. package/src/state/reducer/setResponseReducer.ts +3 -3
  75. package/ts3.4/actionTypes.d.ts +11 -0
  76. package/ts3.4/actions.d.ts +12 -12
package/src/actions.ts CHANGED
@@ -7,17 +7,17 @@ import type {
7
7
  } from '@data-client/normalizr';
8
8
 
9
9
  import type {
10
- SET_TYPE,
11
- RESET_TYPE,
12
- FETCH_TYPE,
13
- SUBSCRIBE_TYPE,
14
- UNSUBSCRIBE_TYPE,
15
- INVALIDATE_TYPE,
16
- GC_TYPE,
17
- OPTIMISTIC_TYPE,
18
- INVALIDATEALL_TYPE,
19
- EXPIREALL_TYPE,
20
- SET_RESPONSE_TYPE,
10
+ SET,
11
+ RESET,
12
+ FETCH,
13
+ SUBSCRIBE,
14
+ UNSUBSCRIBE,
15
+ INVALIDATE,
16
+ GC,
17
+ OPTIMISTIC,
18
+ INVALIDATEALL,
19
+ EXPIREALL,
20
+ SET_RESPONSE,
21
21
  } from './actionTypes.js';
22
22
  import type { EndpointUpdateFunction } from './controller/types.js';
23
23
 
@@ -37,7 +37,7 @@ export interface ActionMeta {
37
37
 
38
38
  /** Action for Controller.set() */
39
39
  export interface SetAction<S extends Queryable = any> {
40
- type: typeof SET_TYPE;
40
+ type: typeof SET;
41
41
  schema: S;
42
42
  args: readonly any[];
43
43
  meta: ActionMeta;
@@ -48,7 +48,7 @@ export interface SetAction<S extends Queryable = any> {
48
48
  export interface SetResponseActionBase<
49
49
  E extends EndpointAndUpdate<E> = EndpointDefault,
50
50
  > {
51
- type: typeof SET_RESPONSE_TYPE;
51
+ type: typeof SET_RESPONSE;
52
52
  endpoint: E;
53
53
  args: readonly any[];
54
54
  key: string;
@@ -81,7 +81,7 @@ export interface FetchMeta {
81
81
 
82
82
  /** Action for Controller.fetch() */
83
83
  export interface FetchAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
84
- type: typeof FETCH_TYPE;
84
+ type: typeof FETCH;
85
85
  endpoint: E;
86
86
  args: readonly [...Parameters<E>];
87
87
  key: string;
@@ -93,7 +93,7 @@ export interface FetchAction<E extends EndpointAndUpdate<E> = EndpointDefault> {
93
93
  export interface OptimisticAction<
94
94
  E extends EndpointAndUpdate<E> = EndpointDefault,
95
95
  > {
96
- type: typeof OPTIMISTIC_TYPE;
96
+ type: typeof OPTIMISTIC;
97
97
  endpoint: E;
98
98
  args: readonly any[];
99
99
  key: string;
@@ -106,7 +106,7 @@ export interface OptimisticAction<
106
106
  export interface SubscribeAction<
107
107
  E extends EndpointAndUpdate<E> = EndpointDefault,
108
108
  > {
109
- type: typeof SUBSCRIBE_TYPE;
109
+ type: typeof SUBSCRIBE;
110
110
  endpoint: E;
111
111
  args: readonly any[];
112
112
  key: string;
@@ -116,7 +116,7 @@ export interface SubscribeAction<
116
116
  export interface UnsubscribeAction<
117
117
  E extends EndpointAndUpdate<E> = EndpointDefault,
118
118
  > {
119
- type: typeof UNSUBSCRIBE_TYPE;
119
+ type: typeof UNSUBSCRIBE;
120
120
  endpoint: E;
121
121
  args: readonly any[];
122
122
  key: string;
@@ -124,30 +124,30 @@ export interface UnsubscribeAction<
124
124
 
125
125
  /* EXPIRY */
126
126
  export interface ExpireAllAction {
127
- type: typeof EXPIREALL_TYPE;
127
+ type: typeof EXPIREALL;
128
128
  testKey: (key: string) => boolean;
129
129
  }
130
130
 
131
131
  /* INVALIDATE */
132
132
  export interface InvalidateAllAction {
133
- type: typeof INVALIDATEALL_TYPE;
133
+ type: typeof INVALIDATEALL;
134
134
  testKey: (key: string) => boolean;
135
135
  }
136
136
 
137
137
  export interface InvalidateAction {
138
- type: typeof INVALIDATE_TYPE;
138
+ type: typeof INVALIDATE;
139
139
  key: string;
140
140
  }
141
141
 
142
142
  /* RESET */
143
143
  export interface ResetAction {
144
- type: typeof RESET_TYPE;
144
+ type: typeof RESET;
145
145
  date: number;
146
146
  }
147
147
 
148
148
  /* GC */
149
149
  export interface GCAction {
150
- type: typeof GC_TYPE;
150
+ type: typeof GC;
151
151
  entities: [string, string][];
152
152
  endpoints: string[];
153
153
  }
@@ -464,7 +464,7 @@ export default class Controller<
464
464
  }
465
465
 
466
466
  // second argument is false if any entities are missing
467
- // eslint-disable-next-line prefer-const
467
+
468
468
  const { data, paths } = this.memo.denormalize(
469
469
  schema,
470
470
  input,
@@ -1,11 +1,11 @@
1
- import { EXPIREALL_TYPE } from '../../actionTypes.js';
1
+ import { EXPIREALL } from '../../actionTypes.js';
2
2
  import type { ExpireAllAction } from '../../types.js';
3
3
 
4
4
  export function createExpireAll(
5
5
  testKey: (key: string) => boolean,
6
6
  ): ExpireAllAction {
7
7
  return {
8
- type: EXPIREALL_TYPE,
8
+ type: EXPIREALL,
9
9
  testKey,
10
10
  };
11
11
  }
@@ -1,6 +1,6 @@
1
1
  import type { EndpointInterface, NI } from '@data-client/normalizr';
2
2
 
3
- import { FETCH_TYPE } from '../../actionTypes.js';
3
+ import { FETCH } from '../../actionTypes.js';
4
4
  import type { FetchAction, FetchMeta } from '../../types.js';
5
5
  import { EndpointUpdateFunction } from '../types.js';
6
6
 
@@ -26,7 +26,7 @@ export function createFetch<
26
26
  };
27
27
 
28
28
  return {
29
- type: FETCH_TYPE,
29
+ type: FETCH,
30
30
  key: endpoint.key(...args),
31
31
  args,
32
32
  endpoint,
@@ -1,6 +1,6 @@
1
1
  import type { EndpointInterface } from '@data-client/normalizr';
2
2
 
3
- import { INVALIDATE_TYPE } from '../../actionTypes.js';
3
+ import { INVALIDATE } from '../../actionTypes.js';
4
4
  import type { InvalidateAction } from '../../types.js';
5
5
 
6
6
  export function createInvalidate<E extends EndpointInterface>(
@@ -8,7 +8,7 @@ export function createInvalidate<E extends EndpointInterface>(
8
8
  { args }: { args: readonly [...Parameters<E>] },
9
9
  ): InvalidateAction {
10
10
  return {
11
- type: INVALIDATE_TYPE,
11
+ type: INVALIDATE,
12
12
  key: endpoint.key(...args),
13
13
  };
14
14
  }
@@ -1,11 +1,11 @@
1
- import { INVALIDATEALL_TYPE } from '../../actionTypes.js';
1
+ import { INVALIDATEALL } from '../../actionTypes.js';
2
2
  import type { InvalidateAllAction } from '../../types.js';
3
3
 
4
4
  export function createInvalidateAll(
5
5
  testKey: (key: string) => boolean,
6
6
  ): InvalidateAllAction {
7
7
  return {
8
- type: INVALIDATEALL_TYPE,
8
+ type: INVALIDATEALL,
9
9
  testKey,
10
10
  };
11
11
  }
@@ -1,7 +1,7 @@
1
1
  import type { EndpointInterface } from '@data-client/normalizr';
2
2
 
3
3
  import { createMeta } from './createMeta.js';
4
- import { OPTIMISTIC_TYPE } from '../../actionTypes.js';
4
+ import { OPTIMISTIC } from '../../actionTypes.js';
5
5
  import type { OptimisticAction } from '../../types.js';
6
6
  import type { EndpointUpdateFunction } from '../types.js';
7
7
 
@@ -23,7 +23,7 @@ export function createOptimistic<
23
23
  }
24
24
 
25
25
  return {
26
- type: OPTIMISTIC_TYPE,
26
+ type: OPTIMISTIC,
27
27
  key: endpoint.key(...args),
28
28
  args,
29
29
  endpoint,
@@ -1,9 +1,9 @@
1
- import { RESET_TYPE } from '../../actionTypes.js';
1
+ import { RESET } from '../../actionTypes.js';
2
2
  import type { ResetAction } from '../../types.js';
3
3
 
4
4
  export function createReset(): ResetAction {
5
5
  return {
6
- type: RESET_TYPE,
6
+ type: RESET,
7
7
  date: Date.now(),
8
8
  };
9
9
  }
@@ -5,7 +5,7 @@ import type {
5
5
  } from '@data-client/normalizr';
6
6
 
7
7
  import { createMeta } from './createMeta.js';
8
- import { SET_TYPE } from '../../actionTypes.js';
8
+ import { SET } from '../../actionTypes.js';
9
9
  import type { SetAction } from '../../types.js';
10
10
  import ensurePojo from '../ensurePojo.js';
11
11
 
@@ -22,7 +22,7 @@ export function createSet<S extends Queryable>(
22
22
  },
23
23
  ): SetAction<S> {
24
24
  return {
25
- type: SET_TYPE,
25
+ type: SET,
26
26
  value,
27
27
  args: args.map(ensurePojo) as SchemaArgs<S>,
28
28
  schema,
@@ -1,7 +1,7 @@
1
1
  import type { EndpointInterface, ResolveType } from '@data-client/normalizr';
2
2
 
3
3
  import { createMeta } from './createMeta.js';
4
- import { SET_RESPONSE_TYPE } from '../../actionTypes.js';
4
+ import { SET_RESPONSE } from '../../actionTypes.js';
5
5
  import type { SetResponseAction } from '../../types.js';
6
6
  import ensurePojo from '../ensurePojo.js';
7
7
  import { EndpointUpdateFunction } from '../types.js';
@@ -62,7 +62,7 @@ export function createSetResponse<
62
62
  }
63
63
 
64
64
  return {
65
- type: SET_RESPONSE_TYPE,
65
+ type: SET_RESPONSE,
66
66
  key: endpoint.key(...args),
67
67
  response,
68
68
  args: args.map(ensurePojo),
@@ -1,6 +1,6 @@
1
1
  import type { EndpointInterface } from '@data-client/normalizr';
2
2
 
3
- import { SUBSCRIBE_TYPE, UNSUBSCRIBE_TYPE } from '../../actionTypes.js';
3
+ import { SUBSCRIBE, UNSUBSCRIBE } from '../../actionTypes.js';
4
4
  import type { SubscribeAction, UnsubscribeAction } from '../../types.js';
5
5
 
6
6
  export function createSubscription<E extends EndpointInterface>(
@@ -8,10 +8,10 @@ export function createSubscription<E extends EndpointInterface>(
8
8
  { args }: { args: readonly [...Parameters<E>] },
9
9
  ): SubscribeAction<E> {
10
10
  return {
11
- type: SUBSCRIBE_TYPE,
12
- endpoint,
13
- args,
11
+ type: SUBSCRIBE,
14
12
  key: endpoint.key(...args),
13
+ args,
14
+ endpoint,
15
15
  };
16
16
  }
17
17
 
@@ -20,7 +20,7 @@ export function createUnsubscription<E extends EndpointInterface>(
20
20
  { args }: { args: readonly [...Parameters<E>] },
21
21
  ): UnsubscribeAction<E> {
22
22
  return {
23
- type: UNSUBSCRIBE_TYPE,
23
+ type: UNSUBSCRIBE,
24
24
  key: endpoint.key(...args),
25
25
  args,
26
26
  endpoint,
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-inner-declarations */
2
1
  import type { DevToolsConfig } from './devtoolsTypes.js';
3
2
  import type { Controller, EndpointInterface } from '../index.js';
4
3
  import type { Middleware } from '../middlewareTypes.js';
@@ -90,10 +89,10 @@ if (process.env.NODE_ENV !== 'production') {
90
89
  */
91
90
  export default class DevToolsManager implements Manager {
92
91
  declare middleware: Middleware;
93
- protected declare devTools: undefined | any;
92
+ declare protected devTools: undefined | any;
94
93
  protected started = false;
95
94
  protected actions: [ActionTypes, State<unknown>][] = [];
96
- protected declare controller: Controller;
95
+ declare protected controller: Controller;
97
96
  declare skipLogging?: (action: ActionTypes) => boolean;
98
97
  maxBufferLength = 100;
99
98
 
@@ -1,4 +1,4 @@
1
- import { SET_RESPONSE_TYPE } from '../actionTypes.js';
1
+ import { SET_RESPONSE } from '../actionTypes.js';
2
2
  import type Controller from '../controller/Controller.js';
3
3
  import { UnknownError } from '../index.js';
4
4
  import type { Manager, Middleware } from '../types.js';
@@ -16,7 +16,7 @@ export default class LogoutManager implements Manager {
16
16
  middleware: Middleware = controller => next => async action => {
17
17
  await next(action);
18
18
  if (
19
- action.type === SET_RESPONSE_TYPE &&
19
+ action.type === SET_RESPONSE &&
20
20
  action.error &&
21
21
  this.shouldLogout(action.response)
22
22
  ) {
@@ -1,4 +1,4 @@
1
- import { SET_RESPONSE_TYPE, FETCH_TYPE, RESET_TYPE } from '../actionTypes.js';
1
+ import { SET_RESPONSE, FETCH, RESET } from '../actionTypes.js';
2
2
  import { createSetResponse } from '../controller/actions/index.js';
3
3
  import Controller from '../controller/Controller.js';
4
4
  import type {
@@ -46,7 +46,7 @@ export default class NetworkManager implements Manager {
46
46
  this.controller = controller;
47
47
  return next => action => {
48
48
  switch (action.type) {
49
- case FETCH_TYPE:
49
+ case FETCH:
50
50
  this.handleFetch(action);
51
51
  // This is the only case that causes any state change
52
52
  // It's important to intercept other fetches as we don't want to trigger reducers during
@@ -58,7 +58,7 @@ export default class NetworkManager implements Manager {
58
58
  return next(action);
59
59
  }
60
60
  return Promise.resolve();
61
- case SET_RESPONSE_TYPE:
61
+ case SET_RESPONSE:
62
62
  // only set after new state is computed
63
63
  return next(action).then(() => {
64
64
  if (action.key in this.fetched) {
@@ -79,7 +79,7 @@ export default class NetworkManager implements Manager {
79
79
  }
80
80
  }
81
81
  });
82
- case RESET_TYPE: {
82
+ case RESET: {
83
83
  const rejectors = { ...this.rejectors };
84
84
 
85
85
  this.clearAll();
@@ -112,7 +112,7 @@ export default class NetworkManager implements Manager {
112
112
  /** Used by DevtoolsManager to determine whether to log an action */
113
113
  skipLogging(action: ActionTypes) {
114
114
  /* istanbul ignore next */
115
- return action.type === FETCH_TYPE && action.key in this.fetched;
115
+ return action.type === FETCH && action.key in this.fetched;
116
116
  }
117
117
 
118
118
  allSettled() {
@@ -14,16 +14,16 @@ import type { SubscribeAction } from '../types.js';
14
14
  * @see https://dataclient.io/docs/api/PollingSubscription
15
15
  */
16
16
  export default class PollingSubscription implements Subscription {
17
- protected declare readonly endpoint: EndpointInterface;
18
- protected declare readonly args: readonly any[];
19
- protected declare readonly key: string;
20
- protected declare frequency: number;
17
+ declare protected readonly endpoint: EndpointInterface;
18
+ declare protected readonly args: readonly any[];
19
+ declare protected readonly key: string;
20
+ declare protected frequency: number;
21
21
  protected frequencyHistogram: Map<number, number> = new Map();
22
- protected declare controller: Controller;
23
- protected declare intervalId?: ReturnType<typeof setInterval>;
24
- protected declare lastIntervalId?: ReturnType<typeof setInterval>;
25
- protected declare startId?: ReturnType<typeof setTimeout>;
26
- private declare connectionListener: ConnectionListener;
22
+ declare protected controller: Controller;
23
+ declare protected intervalId?: ReturnType<typeof setInterval>;
24
+ declare protected lastIntervalId?: ReturnType<typeof setInterval>;
25
+ declare protected startId?: ReturnType<typeof setTimeout>;
26
+ declare private connectionListener: ConnectionListener;
27
27
 
28
28
  constructor(
29
29
  action: Omit<SubscribeAction, 'type'>,
@@ -1,4 +1,4 @@
1
- import { SUBSCRIBE_TYPE, UNSUBSCRIBE_TYPE } from '../actionTypes.js';
1
+ import { SUBSCRIBE, UNSUBSCRIBE } from '../actionTypes.js';
2
2
  import Controller from '../controller/Controller.js';
3
3
  import type {
4
4
  Manager,
@@ -40,7 +40,7 @@ export default class SubscriptionManager<
40
40
  [key: string]: InstanceType<S>;
41
41
  } = {};
42
42
 
43
- protected declare readonly Subscription: S;
43
+ declare protected readonly Subscription: S;
44
44
  protected controller: Controller = new Controller();
45
45
 
46
46
  constructor(Subscription: S) {
@@ -51,14 +51,14 @@ export default class SubscriptionManager<
51
51
  this.controller = controller;
52
52
  return next => action => {
53
53
  switch (action.type) {
54
- case SUBSCRIBE_TYPE:
54
+ case SUBSCRIBE:
55
55
  try {
56
56
  this.handleSubscribe(action);
57
57
  } catch (e) {
58
58
  console.error(e);
59
59
  }
60
60
  return Promise.resolve();
61
- case UNSUBSCRIBE_TYPE:
61
+ case UNSUBSCRIBE:
62
62
  this.handleUnsubscribe(action);
63
63
  return Promise.resolve();
64
64
  default:
@@ -1,7 +1,7 @@
1
1
  import { CoolerArticleResource } from '__tests__/new';
2
2
 
3
3
  import { Controller, initialState } from '../..';
4
- import { FETCH_TYPE, RESET_TYPE } from '../../actionTypes';
4
+ import { FETCH, RESET } from '../../actionTypes';
5
5
  import { createSetResponse } from '../../controller/actions';
6
6
  import LogoutManager from '../LogoutManager.js';
7
7
 
@@ -73,7 +73,7 @@ describe('LogoutManager', () => {
73
73
  await manager.middleware(API)(next)(action);
74
74
 
75
75
  expect(dispatch.mock.calls.length).toBe(1);
76
- expect(dispatch.mock.calls[0][0]?.type).toBe(RESET_TYPE);
76
+ expect(dispatch.mock.calls[0][0]?.type).toBe(RESET);
77
77
  });
78
78
 
79
79
  it('should call custom handleLogout', async () => {
@@ -97,7 +97,7 @@ describe('LogoutManager', () => {
97
97
  });
98
98
 
99
99
  it('should let other actions pass through', async () => {
100
- const action = { type: FETCH_TYPE };
100
+ const action = { type: FETCH };
101
101
  next.mockReset();
102
102
 
103
103
  await manager.middleware(API)(next)(action as any);
@@ -1,7 +1,7 @@
1
1
  import { Endpoint } from '@data-client/endpoint';
2
2
  import { Article, ArticleResource } from '__tests__/new';
3
3
 
4
- import { SET_RESPONSE_TYPE } from '../../actionTypes';
4
+ import { SET_RESPONSE } from '../../actionTypes';
5
5
  import { createFetch } from '../../controller/actions';
6
6
  import Controller from '../../controller/Controller';
7
7
  import NetworkManager from '../../manager/NetworkManager';
@@ -159,7 +159,7 @@ describe('NetworkManager', () => {
159
159
  await new Promise(resolve => setTimeout(resolve, 0));
160
160
 
161
161
  const action: SetResponseAction = {
162
- type: SET_RESPONSE_TYPE,
162
+ type: SET_RESPONSE,
163
163
  endpoint: fetchResolveAction.endpoint,
164
164
  response,
165
165
  args: fetchResolveAction.args,
@@ -195,7 +195,7 @@ describe('NetworkManager', () => {
195
195
  await new Promise(resolve => setTimeout(resolve, 0));
196
196
 
197
197
  const action: SetResponseAction = {
198
- type: SET_RESPONSE_TYPE,
198
+ type: SET_RESPONSE,
199
199
  endpoint: fetchSetWithUpdatersAction.endpoint,
200
200
  response,
201
201
  args: fetchSetWithUpdatersAction.args,
@@ -231,7 +231,7 @@ describe('NetworkManager', () => {
231
231
  await new Promise(resolve => setTimeout(resolve, 0));
232
232
 
233
233
  const action: SetResponseAction = {
234
- type: SET_RESPONSE_TYPE,
234
+ type: SET_RESPONSE,
235
235
  endpoint: fetchRpcWithUpdatersAction.endpoint,
236
236
  response,
237
237
  args: fetchRpcWithUpdatersAction.args,
@@ -267,7 +267,7 @@ describe('NetworkManager', () => {
267
267
  // mutations resolve before dispatch, so we must wait for next tick to see set
268
268
  await new Promise(resolve => setTimeout(resolve, 0));
269
269
  expect(dispatch).toHaveBeenCalledWith({
270
- type: SET_RESPONSE_TYPE,
270
+ type: SET_RESPONSE,
271
271
  endpoint: fetchRpcWithUpdatersAndOptimisticAction.endpoint,
272
272
  response,
273
273
  args: fetchRpcWithUpdatersAndOptimisticAction.args,
@@ -338,7 +338,7 @@ describe('NetworkManager', () => {
338
338
  } catch (error) {
339
339
  expect(next).not.toHaveBeenCalled();
340
340
  expect(dispatch).toHaveBeenCalledWith({
341
- type: SET_RESPONSE_TYPE,
341
+ type: SET_RESPONSE,
342
342
  response: error,
343
343
  key: fetchRejectAction.key,
344
344
  meta: {
@@ -4,7 +4,7 @@ import { actionTypes, Controller, initialState } from '../..';
4
4
  import { SubscribeAction, UnsubscribeAction } from '../../types';
5
5
  import SubscriptionManager, { Subscription } from '../SubscriptionManager.js';
6
6
 
7
- const { UNSUBSCRIBE_TYPE, SUBSCRIBE_TYPE, SET_RESPONSE_TYPE } = actionTypes;
7
+ const { UNSUBSCRIBE, SUBSCRIBE, SET_RESPONSE } = actionTypes;
8
8
 
9
9
  function onError(e: any) {
10
10
  e.preventDefault();
@@ -55,7 +55,7 @@ describe('SubscriptionManager', () => {
55
55
  () => Promise.reject(new Error('Failed'))
56
56
  : () => Promise.resolve(response);
57
57
  return {
58
- type: SUBSCRIBE_TYPE,
58
+ type: SUBSCRIBE,
59
59
  endpoint: PollingArticleResource.get.extend({ fetch }),
60
60
  args: [{ id: response.id }],
61
61
  key: PollingArticleResource.get.key({ id: response.id }),
@@ -65,7 +65,7 @@ describe('SubscriptionManager', () => {
65
65
  response: Record<string, any>,
66
66
  ): UnsubscribeAction {
67
67
  return {
68
- type: UNSUBSCRIBE_TYPE,
68
+ type: UNSUBSCRIBE,
69
69
  endpoint: PollingArticleResource.get,
70
70
  key: PollingArticleResource.get.key({ id: response.id }),
71
71
  args: [{ id: response.id }],
@@ -185,7 +185,7 @@ describe('SubscriptionManager', () => {
185
185
  });
186
186
 
187
187
  it('should let other actions pass through', () => {
188
- const action = { type: SET_RESPONSE_TYPE };
188
+ const action = { type: SET_RESPONSE };
189
189
  next.mockReset();
190
190
 
191
191
  manager.middleware(API)(next)(action as any);