mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Remove definitions for redux-persist (shipped with library), update definitions for transformers
This commit is contained in:
@@ -293,6 +293,12 @@
|
||||
"typingsPackageName": "redux-saga",
|
||||
"sourceRepoURL": "https://github.com/redux-saga/redux-saga",
|
||||
"asOfVersion": "0.10.5"
|
||||
},
|
||||
{
|
||||
"libraryName": "redux-persist",
|
||||
"typingsPackageName": "redux-persist",
|
||||
"sourceRepoURL": "https://github.com/rt2zz/redux-persist",
|
||||
"asOfVersion": "4.3.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { PersistConfig, PersistTransformer } from "redux-persist";
|
||||
import { PersistorConfig, Transform } from "redux-persist";
|
||||
|
||||
export = createCompressor;
|
||||
declare function createCompressor (config?: PersistConfig): PersistTransformer;
|
||||
declare function createCompressor<State, Raw>(config?: PersistorConfig): Transform<State, Raw>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
"redux": "^3.6.0",
|
||||
"redux-persist": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { createStore, Reducer, Store } from "redux"
|
||||
import { createPersistor, Persistor, PersistTransformer } from "redux-persist"
|
||||
import { createPersistor, Transform } from "redux-persist"
|
||||
import createCompressor = require("redux-persist-transform-compress")
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({})
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({ state, action })
|
||||
|
||||
const compressor: PersistTransformer = createCompressor({ whitelist : ["foo"] })
|
||||
const compressor: Transform<any, any> = createCompressor({ whitelist : ["foo"] })
|
||||
|
||||
const store: Store<any> = createStore(reducer)
|
||||
|
||||
const persistor: Persistor = createPersistor(store, { transforms : [compressor] })
|
||||
createPersistor(store, { transforms : [compressor] })
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import createAsyncEncryptor from "redux-persist-transform-encrypt";
|
||||
|
||||
export default createAsyncEncryptor;
|
||||
+7
-13
@@ -1,18 +1,12 @@
|
||||
// Type definitions for redux-persist-transform-encrypt 0.1
|
||||
// Project: https://github.com/maxdeviant/redux-persist-transform-encrypt#readme
|
||||
// Type definitions for redux-persist-transform-encrypt 1.0
|
||||
// Project: https://github.com/maxdeviant/redux-persist-transform-encrypt
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { PersistTransformer } from "redux-persist";
|
||||
import { Transform } from "redux-persist";
|
||||
|
||||
export as namespace ReduxPersistEncryptor;
|
||||
|
||||
export = createEncryptor;
|
||||
|
||||
declare function createEncryptor (config: createEncryptor.EncryptorConfig): PersistTransformer;
|
||||
|
||||
declare namespace createEncryptor {
|
||||
export interface EncryptorConfig {
|
||||
secretKey: string;
|
||||
}
|
||||
export interface EncryptorConfig {
|
||||
secretKey: string;
|
||||
}
|
||||
|
||||
export default function createEncryptor<State, Raw>(config: EncryptorConfig): Transform<State, Raw>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
"redux": "^3.6.0",
|
||||
"redux-persist": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { createStore, Reducer, Store } from "redux"
|
||||
import { createPersistor, Persistor, PersistTransformer } from "redux-persist"
|
||||
import { createPersistor, Transform } from "redux-persist"
|
||||
import { EncryptorConfig } from "redux-persist-transform-encrypt"
|
||||
import * as createEncryptor from "redux-persist-transform-encrypt"
|
||||
import createEncryptor from "redux-persist-transform-encrypt"
|
||||
import createAsyncEncryptor from "redux-persist-transform-encrypt/async"
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({})
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({ state, action })
|
||||
|
||||
const config: EncryptorConfig = { secretKey : "foo" }
|
||||
const encryptor: PersistTransformer = createEncryptor(config)
|
||||
const encryptor: Transform<any, any> = createEncryptor(config)
|
||||
const asyncEncryptor: Transform<any, any> = createAsyncEncryptor(config)
|
||||
|
||||
const store: Store<any> = createStore(reducer)
|
||||
|
||||
const persistor: Persistor = createPersistor(store, { transforms : [encryptor] })
|
||||
createPersistor(store, { transforms : [encryptor, asyncEncryptor] })
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noUnusedParameters": true,
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-persist-transform-encrypt-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// Type definitions for redux-persist-transform-encrypt 0.1
|
||||
// Project: https://github.com/maxdeviant/redux-persist-transform-encrypt#readme
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { PersistTransformer } from "redux-persist";
|
||||
|
||||
export as namespace ReduxPersistEncryptor;
|
||||
|
||||
export = createEncryptor;
|
||||
|
||||
declare function createEncryptor (config: createEncryptor.EncryptorConfig): PersistTransformer;
|
||||
|
||||
declare namespace createEncryptor {
|
||||
export interface EncryptorConfig {
|
||||
secretKey: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { createStore, Reducer, Store } from "redux"
|
||||
import { createPersistor, Persistor, PersistTransformer } from "redux-persist"
|
||||
import { EncryptorConfig } from "redux-persist-transform-encrypt"
|
||||
import * as createEncryptor from "redux-persist-transform-encrypt"
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({})
|
||||
|
||||
const config: EncryptorConfig = { secretKey : "foo" }
|
||||
const encryptor: PersistTransformer = createEncryptor(config)
|
||||
|
||||
const store: Store<any> = createStore(reducer)
|
||||
|
||||
const persistor: Persistor = createPersistor(store, { transforms : [encryptor] })
|
||||
@@ -17,8 +17,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"constants.d.ts",
|
||||
"storages.d.ts",
|
||||
"redux-persist-tests.ts"
|
||||
"redux-persist-transform-encrypt-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
+2
-2
@@ -3,6 +3,6 @@
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { PersistTransformer } from "redux-persist";
|
||||
import { Transform } from "redux-persist";
|
||||
|
||||
export default function createFilter (reducerName: string, inboundPaths?: string[], outboundPaths?: string[]): PersistTransformer;
|
||||
export default function createFilter<State, Raw>(reducerName: string, inboundPaths?: string[], outboundPaths?: string[]): Transform<State, Raw>;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
"redux": "^3.6.0",
|
||||
"redux-persist": "^4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createStore, Reducer, Store } from "redux"
|
||||
import { createPersistor, Persistor, PersistTransformer } from "redux-persist"
|
||||
import { createPersistor, Transform } from "redux-persist"
|
||||
import createFilter from "redux-persist-transform-filter"
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({})
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({ state, action })
|
||||
|
||||
const filter: PersistTransformer = createFilter(
|
||||
const filter: Transform<any, any> = createFilter(
|
||||
"foo",
|
||||
["foo.bar"],
|
||||
["fizz.buzz"]
|
||||
@@ -12,4 +12,4 @@ const filter: PersistTransformer = createFilter(
|
||||
|
||||
const store: Store<any> = createStore(reducer)
|
||||
|
||||
const persistor: Persistor = createPersistor(store, { transforms : [filter] })
|
||||
createPersistor(store, { transforms : [filter] })
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noUnusedParameters": true,
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"redux-persist-transform-filter-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
export const KEY_PREFIX: string;
|
||||
export const REHYDRATE: string;
|
||||
Vendored
-66
@@ -1,66 +0,0 @@
|
||||
// Type definitions for redux-persist 4.0
|
||||
// Project: https://github.com/rt2zz/redux-persist
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Action, GenericStoreEnhancer, Store } from "redux";
|
||||
|
||||
export interface PersistAction<S> extends Action {
|
||||
payload?: S;
|
||||
error?: any;
|
||||
}
|
||||
|
||||
export interface PersistorRehydrateOptions {
|
||||
serial?: boolean;
|
||||
}
|
||||
|
||||
export interface Persistor {
|
||||
purge(keys?: string[]): void;
|
||||
rehydrate<A>(incoming: A, options?: PersistorRehydrateOptions): A;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
}
|
||||
|
||||
export type PersistCallback<A> = (err: any, response?: A) => void;
|
||||
|
||||
export interface PersistTransformer {
|
||||
in(state: any, key: string): any;
|
||||
out(state: any, key: string): any;
|
||||
}
|
||||
|
||||
export interface PersistStorage {
|
||||
setItem(key: string, value: any, callback?: PersistCallback<void>): Promise<void>;
|
||||
getItem<A>(key: string, callback?: PersistCallback<A>): Promise<A>;
|
||||
removeItem(key: string, callback?: PersistCallback<void>): Promise<void>;
|
||||
getAllKeys<A>(callback?: PersistCallback<A>): Promise<A>;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type PersistStateReconciler<A, B, C> = (state: A, inboundState: B, reducedState: C, log?: boolean) => C;
|
||||
|
||||
export interface PersistAutoRehydrateConfig<A, B, C> {
|
||||
stateReconcile?: PersistStateReconciler<A, B, C>;
|
||||
}
|
||||
|
||||
export interface PersistConfig {
|
||||
whitelist?: string[];
|
||||
blacklist?: string[];
|
||||
transforms?: PersistTransformer[];
|
||||
storage?: PersistStorage;
|
||||
debounce?: number;
|
||||
keyPrefix?: string;
|
||||
serialize?: (data: any) => string;
|
||||
deserialize?: (data: string) => any;
|
||||
}
|
||||
|
||||
export function autoRehydrate<A, B ,C> (config?: PersistAutoRehydrateConfig<A, B, C>): GenericStoreEnhancer;
|
||||
|
||||
export function createPersistor<A> (store: Store<A>, config?: PersistConfig): Persistor;
|
||||
|
||||
export function createTransform (inbound: any, outbound: any, config?: PersistConfig): PersistTransformer;
|
||||
|
||||
export function getStoredState(config?: PersistConfig, callback?: PersistCallback<any>): Promise<any>;
|
||||
|
||||
export function persistStore<A> (store: Store<A>, config?: PersistConfig, callback?: PersistCallback<any>): Persistor;
|
||||
|
||||
export function purgeStoredState (config?: PersistConfig, keys?: string[]): Promise<void>;
|
||||
@@ -1,53 +0,0 @@
|
||||
import { createStore, Store, Reducer } from "redux"
|
||||
import {
|
||||
autoRehydrate,
|
||||
createPersistor,
|
||||
createTransform,
|
||||
getStoredState,
|
||||
persistStore,
|
||||
purgeStoredState,
|
||||
PersistConfig,
|
||||
PersistAutoRehydrateConfig,
|
||||
PersistCallback,
|
||||
Persistor,
|
||||
PersistorRehydrateOptions,
|
||||
PersistTransformer
|
||||
} from "redux-persist"
|
||||
import { KEY_PREFIX, REHYDRATE } from "redux-persist/constants"
|
||||
import { asyncLocalStorage, asyncSessionStorage } from "redux-persist/storages"
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({})
|
||||
|
||||
const persistCallback: PersistCallback<any> = (err: any, response: any) => {}
|
||||
|
||||
const transform: PersistTransformer = createTransform({}, {}, { whitelist : ["foo"] })
|
||||
|
||||
const persistConfig: PersistConfig = {
|
||||
blacklist : ["foo"],
|
||||
whitelist : ["bar"],
|
||||
storage : asyncLocalStorage,
|
||||
transforms : [transform],
|
||||
debounce : 1000,
|
||||
keyPrefix : KEY_PREFIX
|
||||
}
|
||||
|
||||
const rehydrateOptions: PersistorRehydrateOptions = { serial : true }
|
||||
|
||||
const autoRehydrateConfig: PersistAutoRehydrateConfig<any, any, any> = {
|
||||
stateReconcile: (state: any, inboundState: any, reducedState: any, log: boolean) => ({})
|
||||
}
|
||||
|
||||
const store: Store<any> = createStore(reducer, autoRehydrate(autoRehydrateConfig))
|
||||
const persistor: Persistor = persistStore(store, persistConfig, persistCallback)
|
||||
|
||||
purgeStoredState({ whitelist : ["foo"] }, ["bar"])
|
||||
|
||||
getStoredState(persistConfig, (err: any, restoredState: any) => {
|
||||
const store: Store<any> = createStore(reducer, restoredState)
|
||||
const persistor: Persistor = createPersistor(store, persistConfig)
|
||||
const secondaryPersistor: Persistor = createPersistor(store, { storage : asyncSessionStorage })
|
||||
persistor.pause()
|
||||
persistor.resume()
|
||||
persistor.purge(["foo", "bar"])
|
||||
persistor.rehydrate(restoredState, rehydrateOptions)
|
||||
})
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
import { PersistStorage } from "redux-persist";
|
||||
|
||||
export const asyncLocalStorage: PersistStorage;
|
||||
export const asyncSessionStorage: PersistStorage;
|
||||
Reference in New Issue
Block a user