Skip to content

Commit bfcf708

Browse files
author
Unknown
committed
remove circular dependencies
1 parent 1f4820b commit bfcf708

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+75
-193
lines changed

lib/core/createRetryMechanism.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config, State } from '.';
1+
import { Config, State } from './types';
22
import { Reducer, Middleware } from 'redux';
33
declare type RetryMechanism<T, U> = {
44
stateKeyName: string;

lib/core/createRetryMechanism.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const ramda_1 = require("ramda");
4-
const _1 = require(".");
4+
const types_1 = require("./types");
55
const upsert_1 = require("./upsert");
66
const reset_1 = require("./reset");
77
const remove_1 = require("./remove");
@@ -11,7 +11,7 @@ const MiddlewareProtocol_1 = require("./protocols/MiddlewareProtocol");
1111
const garbageCollector_1 = require("./garbageCollector");
1212
function createRetryMechanism(initConfig) {
1313
const defaultConfig = {
14-
stateKeyName: _1.REDUX_ACTION_RETRY,
14+
stateKeyName: types_1.REDUX_ACTION_RETRY,
1515
cache: {},
1616
extensions: [
1717
upsert_1.upsert,
@@ -39,7 +39,7 @@ function createRetryMechanism(initConfig) {
3939
}, []);
4040
return {
4141
stateKeyName: config.stateKeyName,
42-
reducer: function (state = _1.INITIAL_STATE, action) {
42+
reducer: function (state = types_1.INITIAL_STATE, action) {
4343
return reducers.reduce((s, fn) => fn(s, action), state);
4444
},
4545
reduxActionRetryMiddleware: [

lib/core/garbageCollector.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { Config } from '.';
1+
import { Config } from './types';
22
import { MiddlewareProtocol } from './protocols/MiddlewareProtocol';
33
export declare function garbageCollector(config: Config): MiddlewareProtocol;

lib/core/garbageCollector.js

-42
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,8 @@
11
"use strict";
2-
// import {
3-
// reject,
4-
// over,
5-
// anyPass,
6-
// find,
7-
// } from 'ramda';
8-
// import {
9-
// Config,
10-
// State,
11-
// INITIAL_STATE,
12-
// REDUX_ACTION_RETRY,
13-
// CachedAction,
14-
// CacheableAction,
15-
// RarAction,
16-
// } from '.';
172
Object.defineProperty(exports, "__esModule", { value: true });
18-
// import { AnyAction } from 'redux';
19-
// import { cacheLens } from './utils';
20-
// import { COLLECT_GARBAGE, isCollectGarbaseCommand } from './protocols/garbageCollectorProtocol';
21-
// export function garbageCollector(_config: Config) {
22-
// return {
23-
// mi: () =>
24-
// (state: State = INITIAL_STATE, action: AnyAction): State => {
25-
// if (isCollectGarbaseCommand(action)) {
26-
// return over(
27-
// cacheLens,
28-
// reject<CachedAction>(
29-
// anyPass([
30-
// cachedAction => !!find(
31-
// removedAction => {
32-
// return removedAction.meta[REDUX_ACTION_RETRY].id === cachedAction.action.meta[REDUX_ACTION_RETRY].id
33-
// }
34-
// , action[REMOVED]),
35-
// ])
36-
// ),
37-
// state
38-
// )
39-
// }
40-
// return state
41-
// }
42-
// }
43-
// }
443
const ramda_1 = require("ramda");
454
const GarbageCollectorProtocol_1 = require("./protocols/GarbageCollectorProtocol");
465
const RemovedProtocol_1 = require("./protocols/RemovedProtocol");
47-
// import anyPass from 'ramda/es/anyPass';
486
function garbageCollector(config) {
497
return {
508
middleware: visitors => {

lib/core/protocols/AppendProtocol.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { RarAction } from '..';
2-
import { REDUX_ACTION_RETRY, CacheableAction } from '..';
31
import { UPSERTED } from '../upsert';
2+
import { RarAction, REDUX_ACTION_RETRY, CacheableAction } from '../types';
43
export declare const APPENDED_PROTOCOL = "@@APPENDED_PROTOCOL";
54
export interface AppendedProtocolFn<U = {}> {
65
(action: UpsertedAction): U;

lib/core/protocols/GarbageCollectorProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CachedAction, RarAction } from '..';
21
import { AnyAction } from 'redux';
2+
import { CachedAction, RarAction } from '../types';
33
export declare const GARBAGE_COLLECTOR_PROTOCOL = "@@GARBAGE_COLLECTOR_PROTOCOL";
44
export interface GarbageCollectorProtocolFn<U = {}> {
55
(action: CachedAction<U>): boolean;

lib/core/protocols/GarbageCollectorProtocol.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const __1 = require("..");
3+
const types_1 = require("../types");
44
exports.GARBAGE_COLLECTOR_PROTOCOL = '@@GARBAGE_COLLECTOR_PROTOCOL';
55
exports.COLLECT_GARBAGE = 'COLLECT_GARBAGE';
66
function collectGarbageActionCreator() {
77
return {
8-
type: __1.REDUX_ACTION_RETRY,
8+
type: types_1.REDUX_ACTION_RETRY,
99
[exports.COLLECT_GARBAGE]: true,
1010
};
1111
}

lib/core/protocols/MiddlewareProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Middleware } from 'redux';
2-
import { State } from '../../core';
2+
import { State } from '../types';
33
export interface MiddlewareProtocol<U = {}> {
44
middleware: (initializedExtensions: any[]) => Middleware<State<U>>;
55
}

lib/core/protocols/ReducerProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Reducer, AnyAction } from 'redux';
2-
import { State } from '../../core';
2+
import { State } from '../../core/types';
33
export interface ReducerProtocol<U = {}> {
44
reducer: (initializedExtensions: any[]) => Reducer<State<U>, AnyAction>;
55
}

lib/core/protocols/RemovedProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CachedAction, CacheableAction, RarAction } from '..';
1+
import { CachedAction, CacheableAction, RarAction } from '../types';
22
import { AnyAction } from 'redux';
33
export declare const REMOVED_PROTOCOL = "@@REMOVED_PROTOCOL";
44
export interface RemoveProtocolFn<U> {

lib/core/protocols/RemovedProtocol.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const __1 = require("..");
3+
const types_1 = require("../types");
44
exports.REMOVED_PROTOCOL = '@@REMOVED_PROTOCOL';
55
exports.REMOVED = 'REMOVED';
66
function removeActionCreator(action) {
77
return {
8-
type: __1.REDUX_ACTION_RETRY,
8+
type: types_1.REDUX_ACTION_RETRY,
99
[exports.REMOVED]: [action]
1010
};
1111
}
1212
exports.removeActionCreator = removeActionCreator;
1313
function removeActionsCreator(actions) {
1414
return {
15-
type: __1.REDUX_ACTION_RETRY,
15+
type: types_1.REDUX_ACTION_RETRY,
1616
[exports.REMOVED]: actions
1717
};
1818
}

lib/core/protocols/RetryAllProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CachedAction, RETRY_ALL, RarAction } from '..';
1+
import { CachedAction, RETRY_ALL, RarAction } from '../types';
22
export declare const RETRY_ALL_PROTOCOL = "@@RETRY_ALL_PROTOCOL";
33
export interface RetryAllProtocolFn<U = {}> {
44
(action: RetryAllCommand, cachedAction: CachedAction<U>): boolean;

lib/core/protocols/RetryAllProtocol.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const __1 = require("..");
3+
const types_1 = require("../types");
44
exports.RETRY_ALL_PROTOCOL = '@@RETRY_ALL_PROTOCOL';
55
function isRetryAllProtocol(action) {
66
return exports.RETRY_ALL_PROTOCOL in action;

lib/core/protocols/UpdatedProtocol.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CachedAction } from '..';
1+
import { CachedAction } from '../types';
22
import { UpsertedAction } from './AppendProtocol';
33
export declare const UPDATED_PROTOCOL = "@@UPDATED_PROTOCOL";
44
export interface UpdatedProtocolFn<U = {}> {

lib/core/remove.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config, State } from '.';
1+
import { Config, State } from './types';
22
import { AnyAction } from 'redux';
33
export declare function remove(_config: Config): {
44
reducer: () => (state: State<{}> | undefined, action: AnyAction) => State<{}>;

lib/core/remove.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const ramda_1 = require("ramda");
4-
const _1 = require(".");
4+
const types_1 = require("./types");
55
const utils_1 = require("./utils");
66
const RemovedProtocol_1 = require("./protocols/RemovedProtocol");
77
function remove(_config) {
88
return {
9-
reducer: () => (state = _1.INITIAL_STATE, action) => {
9+
reducer: () => (state = types_1.INITIAL_STATE, action) => {
1010
if (RemovedProtocol_1.isRemovedEvent(action)) {
1111
return ramda_1.over(utils_1.cacheLens, ramda_1.reject(ramda_1.anyPass([
1212
cachedAction => !!ramda_1.find(removedAction => {
13-
return removedAction.meta[_1.REDUX_ACTION_RETRY].id === cachedAction.action.meta[_1.REDUX_ACTION_RETRY].id;
13+
return removedAction.meta[types_1.REDUX_ACTION_RETRY].id === cachedAction.action.meta[types_1.REDUX_ACTION_RETRY].id;
1414
}, action[RemovedProtocol_1.REMOVED]),
1515
])), state);
1616
}

lib/core/reset.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config, State, RarAction } from '.';
1+
import { Config, State, RarAction } from './types';
22
import { AnyAction } from 'redux';
33
export declare const RESET = "RESET";
44
export declare function reset(_: Config): {

lib/core/reset.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const _1 = require(".");
3+
const types_1 = require("./types");
44
exports.RESET = 'RESET';
55
function reset(_) {
66
return {
7-
reducer: () => (state = _1.INITIAL_STATE, action) => {
8-
return (action.type === _1.REDUX_ACTION_RETRY && action[exports.RESET])
9-
? _1.INITIAL_STATE
7+
reducer: () => (state = types_1.INITIAL_STATE, action) => {
8+
return (action.type === types_1.REDUX_ACTION_RETRY && action[exports.RESET])
9+
? types_1.INITIAL_STATE
1010
: state;
1111
}
1212
};
1313
}
1414
exports.reset = reset;
1515
function resetActionCreator() {
1616
return {
17-
type: _1.REDUX_ACTION_RETRY,
17+
type: types_1.REDUX_ACTION_RETRY,
1818
[exports.RESET]: true
1919
};
2020
}

lib/core/retryAll.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config } from '.';
1+
import { Config } from './types';
22
import { RetryAllCommand } from "./protocols/RetryAllProtocol";
33
import { MiddlewareProtocol } from './protocols/MiddlewareProtocol';
44
export declare function retryAll(config: Config): MiddlewareProtocol;

lib/core/retryAll.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const ramda_1 = require("ramda");
4-
const _1 = require(".");
4+
const types_1 = require("./types");
55
const RetryAllProtocol_1 = require("./protocols/RetryAllProtocol");
66
function retryAll(config) {
77
return {
@@ -14,7 +14,7 @@ function retryAll(config) {
1414
}, []);
1515
const shouldRetry = ramda_1.allPass(shouldRetryFunctions);
1616
return api => next => action => {
17-
if (action.type === _1.REDUX_ACTION_RETRY && action[_1.RETRY_ALL]) {
17+
if (action.type === types_1.REDUX_ACTION_RETRY && action[types_1.RETRY_ALL]) {
1818
const result = next(action);
1919
const cache = ramda_1.path([config.stateKeyName, 'cache'], api.getState());
2020
cache.forEach(wrap => {
@@ -34,8 +34,8 @@ function retryAll(config) {
3434
exports.retryAll = retryAll;
3535
function retryAllActionCreator() {
3636
return {
37-
type: _1.REDUX_ACTION_RETRY,
38-
[_1.RETRY_ALL]: true
37+
type: types_1.REDUX_ACTION_RETRY,
38+
[types_1.RETRY_ALL]: true
3939
};
4040
}
4141
exports.retryAllActionCreator = retryAllActionCreator;

lib/core/upsert.d.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { AnyAction } from 'redux';
2-
import { Config } from '.';
3-
import { RarAction, CacheableAction } from '.';
2+
import { Config, RarAction, CacheableAction } from './types';
43
import { UpsertedAction } from "./protocols/AppendProtocol";
54
import { ReducerProtocol } from './protocols/ReducerProtocol';
65
import { MiddlewareProtocol } from './protocols/MiddlewareProtocol';

lib/core/upsert.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const ramda_1 = require("ramda");
4-
const _1 = require(".");
5-
const _2 = require(".");
4+
const types_1 = require("./types");
65
const UpdatedProtocol_1 = require("./protocols/UpdatedProtocol");
76
const AppendProtocol_1 = require("./protocols/AppendProtocol");
87
const utils_1 = require("./utils");
@@ -29,9 +28,9 @@ function upsert(config) {
2928
[],
3029
[]
3130
]);
32-
return (state = _2.INITIAL_STATE, action) => {
31+
return (state = types_1.INITIAL_STATE, action) => {
3332
if (isUpsertedAction(action)) {
34-
const coincidenceIndex = ramda_1.findIndex((cachedAction => cachedAction.action.meta[_1.REDUX_ACTION_RETRY].id === action[exports.UPSERTED].meta[_1.REDUX_ACTION_RETRY].id), state.cache);
33+
const coincidenceIndex = ramda_1.findIndex((cachedAction => cachedAction.action.meta[types_1.REDUX_ACTION_RETRY].id === action[exports.UPSERTED].meta[types_1.REDUX_ACTION_RETRY].id), state.cache);
3534
const actionWrap = (coincidenceIndex < 0)
3635
? appendedProtocols.reduce((acc, fn) => ({
3736
...acc,
@@ -53,7 +52,7 @@ function upsert(config) {
5352
exports.upsert = upsert;
5453
function upsertActionCreator(action) {
5554
return {
56-
type: _1.REDUX_ACTION_RETRY,
55+
type: types_1.REDUX_ACTION_RETRY,
5756
[exports.UPSERTED]: action,
5857
};
5958
}

lib/timeToLive/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Config, CacheableAction, GarbageCollectorProtocol } from "../core/index";
1+
import { Config, CacheableAction } from "../core/types";
22
import { Duration, Moment } from "moment";
33
import { UpdatedProtocol } from "../core/protocols/UpdatedProtocol";
44
import { AppendedProtocol } from "../core/protocols/AppendProtocol";
5+
import { GarbageCollectorProtocol } from "../core/protocols/GarbageCollectorProtocol";
56
export declare type timeToLiveConfg = {
67
timeToLive: Duration;
78
};

lib/timeToLive/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
const index_1 = require("../core/index");
43
const now_1 = require("../now");
54
const UpdatedProtocol_1 = require("../core/protocols/UpdatedProtocol");
65
const AppendProtocol_1 = require("../core/protocols/AppendProtocol");
76
const upsert_1 = require("../core/upsert");
7+
const GarbageCollectorProtocol_1 = require("../core/protocols/GarbageCollectorProtocol");
88
exports.liveUntilKey = 'liveUntil';
99
function liveUntil(action, config) {
1010
return now_1.now().add(config.cache[action.type].timeToLive);
@@ -18,7 +18,7 @@ function TimeToLive(config) {
1818
[AppendProtocol_1.APPENDED_PROTOCOL]: (action) => ({
1919
[exports.liveUntilKey]: liveUntil(action[upsert_1.UPSERTED], config)
2020
}),
21-
[index_1.GARBAGE_COLLECTOR_PROTOCOL]: (cachedAction) => now_1.now().isSameOrAfter(cachedAction[exports.liveUntilKey]),
21+
[GarbageCollectorProtocol_1.GARBAGE_COLLECTOR_PROTOCOL]: (cachedAction) => now_1.now().isSameOrAfter(cachedAction[exports.liveUntilKey]),
2222
};
2323
}
2424
exports.TimeToLive = TimeToLive;

lib/times/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config } from "../core";
1+
import { Config } from "../core/types";
22
import { UpdatedProtocol } from "../core/protocols/UpdatedProtocol";
33
import { AppendedProtocol } from "../core/protocols/AppendProtocol";
44
export declare type timesConfg = {};

src/core/createRetryMechanism.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
REDUX_ACTION_RETRY,
88
State,
99
INITIAL_STATE,
10-
} from '.';
10+
} from './types';
1111

1212
import { upsert } from './upsert';
1313
import { reset } from './reset';

0 commit comments

Comments
 (0)