state-decorator 7.0.0-beta.9-dev → 7.0.0-rc2

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 (59) hide show
  1. package/README.md +55 -24
  2. package/development.d.ts +10 -0
  3. package/development.js +2 -0
  4. package/development.js.map +1 -0
  5. package/graph.d.ts +8 -0
  6. package/helpers.js +1 -174
  7. package/helpers.js.map +1 -1
  8. package/impl.d.ts +20 -32
  9. package/impl.js +1 -996
  10. package/impl.js.map +1 -1
  11. package/index.d.ts +10 -11
  12. package/index.js +1 -1044
  13. package/index.js.map +1 -1
  14. package/middlewares.d.ts +0 -23
  15. package/middlewares.js +1 -526
  16. package/middlewares.js.map +1 -1
  17. package/package.json +2 -2
  18. package/shallow.d.ts +0 -14
  19. package/test.d.ts +7 -21
  20. package/test.js +1 -358
  21. package/test.js.map +1 -1
  22. package/types.d.ts +73 -72
  23. package/v5.d.ts +5 -18
  24. package/v5.js +1 -322
  25. package/v5.js.map +1 -1
  26. package/v5_test.d.ts +4 -17
  27. package/v5_test.js +1 -416
  28. package/v5_test.js.map +1 -1
  29. package/v5_types.d.ts +15 -29
  30. package/v6.d.ts +7 -3
  31. package/v6.js +1 -120
  32. package/v6.js.map +1 -1
  33. package/es/helpers.d.ts +0 -66
  34. package/es/helpers.js +0 -163
  35. package/es/helpers.js.map +0 -1
  36. package/es/impl.d.ts +0 -209
  37. package/es/impl.js +0 -964
  38. package/es/impl.js.map +0 -1
  39. package/es/index.d.ts +0 -164
  40. package/es/index.js +0 -1014
  41. package/es/index.js.map +0 -1
  42. package/es/middlewares.d.ts +0 -26
  43. package/es/middlewares.js +0 -520
  44. package/es/middlewares.js.map +0 -1
  45. package/es/shallow.d.ts +0 -15
  46. package/es/test.d.ts +0 -136
  47. package/es/test.js +0 -350
  48. package/es/test.js.map +0 -1
  49. package/es/types.d.ts +0 -381
  50. package/es/v5.d.ts +0 -58
  51. package/es/v5.js +0 -302
  52. package/es/v5.js.map +0 -1
  53. package/es/v5_test.d.ts +0 -70
  54. package/es/v5_test.js +0 -393
  55. package/es/v5_test.js.map +0 -1
  56. package/es/v5_types.d.ts +0 -227
  57. package/es/v6.d.ts +0 -17
  58. package/es/v6.js +0 -97
  59. package/es/v6.js.map +0 -1
package/es/impl.d.ts DELETED
@@ -1,209 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) GlobalSport SAS.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- import { AsyncAction, SimpleSyncAction, SyncAction, StoreAction, AsyncActionPromise, AsyncActionPromiseGet, PromiseProvider, DecoratedActions, InternalLoadingMap, StoreOptions, InvocationContextActions, OnMountInvocationContext, OnPropsChangeEffectsContext, ContextState, Middleware, MiddlewareFactory, ContextWithDerived, PromiseIdErrorMap, ErrorMap, ErrorParallelMap, OnUnMountInvocationContext, AbortedActions, ClearErrorFunc } from './types';
16
- export declare type SetStateFunc<S, A> = (newState: S, newLoadingMap: InternalLoadingMap<A>, actionName: keyof A | 'onPropsChange', actionType: 'preEffects' | 'effects' | 'errorEffects' | null, // FIXME
17
- isAsync: boolean, actionCtx: any, propsChanged: boolean, isInit?: boolean) => void;
18
- /** @internal */
19
- export declare type PromiseMap<A> = {
20
- [name in keyof A]?: {
21
- [promiseId: string]: {
22
- promise: Promise<any>;
23
- refArgs: any[];
24
- abortController: AbortController;
25
- };
26
- };
27
- };
28
- /** @internal */
29
- export declare type FutureActions = {
30
- args: any[];
31
- resolve: (...args: any[]) => void;
32
- reject: (...args: any[]) => void;
33
- timestamp?: number;
34
- };
35
- /** @internal */
36
- export declare type ConflictActionsMap<A> = {
37
- [name in keyof A]?: FutureActions[];
38
- };
39
- /** @internal */
40
- export declare type AsyncActionExecContext<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P> = {
41
- actionName: keyof A;
42
- action: AsyncActionPromise<S, F, A, P, DS>;
43
- stateRef: Ref<S>;
44
- derivedStateRef: Ref<DerivedState<DS>>;
45
- propsRef: Ref<P>;
46
- loadingParallelMapRef: Ref<InternalLoadingMap<A>>;
47
- errorMapRef: Ref<ErrorParallelMap<A>>;
48
- promisesRef: Ref<PromiseMap<A>>;
49
- conflictActionsRef: Ref<ConflictActionsMap<A>>;
50
- actionsRef: Ref<A>;
51
- initializedRef: Ref<boolean>;
52
- options: StoreOptions<S, A, P, any>;
53
- setState: SetStateFunc<S, A>;
54
- clearError: ClearErrorFunc<A>;
55
- };
56
- /** @internal */
57
- export declare type TimeoutMap<A> = {
58
- [name in keyof A]?: any;
59
- };
60
- export declare type NotifyFunc = (msg: string) => void;
61
- export declare type CloneFunction = <C>(obj: C) => C;
62
- export declare type ComparatorFunction = <C>(obj1: C, Obj2: C) => boolean;
63
- export declare type RetryOnErrorFunction = (error: any) => boolean;
64
- export declare type AsyncErrorHandler = (error: any, isHandled: boolean, state: any, props: any, actionName: string, args: any[]) => void;
65
- declare type DerivedStateMap<DS> = {
66
- [name in keyof DS]?: any[];
67
- };
68
- /** @internal */
69
- export declare type DerivedState<DS> = {
70
- state: DS;
71
- deps: DerivedStateMap<DS>;
72
- };
73
- export declare class EffectError extends Error {
74
- /**
75
- * The wrapped error
76
- */
77
- source: any;
78
- /**
79
- * If effects error occurred while processed an error, the initial error.
80
- */
81
- initialError: Error;
82
- constructor(source: any, initialError?: Error);
83
- }
84
- /**
85
- * Global configuration, shared with all stores.
86
- */
87
- export declare type GlobalConfig = {
88
- /**
89
- * Clone function.
90
- * Used to clone state and props when managing optimistic reducer and conflicting actions.
91
- * Default implementation is a very basic algorithm using JSON.stringify. To clone complex stats,
92
- * use a custom implementation like lodash/cloneDeep.
93
- * @default JSON.stringify
94
- */
95
- clone: CloneFunction;
96
- /**
97
- * Compare to objets and returns if they are equal.
98
- * Used to comparent previous and current state slice.
99
- * @default shallow
100
- */
101
- comparator: ComparatorFunction;
102
- /**
103
- * Global callback function to handle asychronous actions rejected promise.
104
- */
105
- asyncErrorHandler: AsyncErrorHandler;
106
- /**
107
- * Tests if the error will trigger a retry of the action or will fail directly.
108
- * Default implementation is returning true for TypeError instances only.
109
- * @see AsynchActionBase#retryCount
110
- */
111
- retryOnErrorFunction: RetryOnErrorFunction;
112
- /**
113
- * Global notification function that will called when an asynchronous action succeeded,
114
- * if and only if, an error message is specified for this action using
115
- * <code>getErrorMessage</code>.
116
- * If another function is set in the options, the function from the options will be used.
117
- */
118
- notifySuccess: NotifyFunc;
119
- /**
120
- * Global notification function that will called when an asynchronous action fails,
121
- * if and only if, an error message is specified for this action using
122
- * <code>getErrorMessage</code>.
123
- * If another function is set in the options, the function from the options will be used.
124
- */
125
- notifyError: NotifyFunc;
126
- /**
127
- * Global notification function that will injected in onDone and onFail of an asynchronous actions and onActionDone of a synchronous function,
128
- * If another function is set in the options, the function from the options will be used.
129
- */
130
- notifyWarning: NotifyFunc;
131
- /**
132
- * A default error message provider.
133
- * Used to return generic messages on generic HTTP errors
134
- */
135
- getErrorMessage: (error: Error) => string;
136
- /**
137
- * Default middlewares. Store middleware array will be concatenated with this one.
138
- * By default contains only the optimistic middleware.
139
- */
140
- defaultMiddlewares: MiddlewareFactory<any, any, any>[];
141
- };
142
- /** @internal */
143
- export declare const globalConfig: GlobalConfig;
144
- export declare function setGlobalConfig(overrideConfig: Partial<GlobalConfig>): void;
145
- /**
146
- * Type guard function to test if an action is a asynchronous action.
147
- */
148
- export declare function isAsyncAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncAction<S, F, A, P, DS, FxRes>;
149
- /**
150
- * Type guard function to test if an action is a synchronous action.
151
- */
152
- export declare function isSimpleSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is SimpleSyncAction<S, F, P, DS, FxRes>;
153
- /**
154
- * Type guard function to test if an action is a synchronous action.
155
- */
156
- export declare function isSyncAction<S, F extends (...args: any[]) => any, A, P, DS = {}, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is SyncAction<S, F, A, P, DS, FxRes>;
157
- export declare function isAsyncGetPromiseAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncActionPromise<S, F, A, P, DS, FxRes>;
158
- export declare function isAsyncGetPromiseGetAction<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: StoreAction<S, F, A, P, DS, FxRes>): action is AsyncActionPromiseGet<S, F, A, P, DS, FxRes>;
159
- /** @internal */
160
- export declare function computeAsyncActionInput<S, DS, F extends (...args: any[]) => any, A, P, FxRes = S>(action: AsyncAction<S, F, A, P, DS, FxRes>): AsyncActionPromise<S, F, A, P, DS, FxRes>;
161
- /** @internal */
162
- export declare function buildLoadingMap<A>(source: InternalLoadingMap<A>, actionName: keyof A, promiseId: string, loading: boolean): InternalLoadingMap<A>;
163
- /** @internal */
164
- export declare function updateErrorMap<A>(source: ErrorParallelMap<A>, actionName: keyof A, promiseId: string, error: Error): ErrorParallelMap<A>;
165
- export declare class ParallelActionError extends Error {
166
- promiseIds: PromiseIdErrorMap;
167
- constructor(promiseIds: PromiseIdErrorMap);
168
- }
169
- export declare function buildErrorMap<A>(map: ErrorParallelMap<A>): ErrorMap<A>;
170
- /** @internal */
171
- export declare function retryPromiseDecorator<S, DS, F extends (...args: any[]) => Promise<any>, A, P>(promiseProvider: PromiseProvider<S, DS, F, A, P>, maxCalls?: number, delay?: number, isRetryError?: (e: Error) => boolean): PromiseProvider<S, DS, F, A, P>;
172
- export declare type Ref<P> = {
173
- current: P;
174
- };
175
- /** @internal */
176
- export declare function createRef<U>(init?: U): Ref<U>;
177
- /** @internal */
178
- export declare function buildInvocationContextBase<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>): ContextWithDerived<S, DS, P>;
179
- /** @internal */
180
- export declare function buildOnMountInvocationContext<S, DS, A, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, actionsRef: Ref<A>): OnMountInvocationContext<S, A, P>;
181
- /** @internal */
182
- export declare function buildOnUnMountInvocationContext<S, DS, A, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, abortedActions: AbortedActions<A>): OnUnMountInvocationContext<S, A, P>;
183
- /** @internal */
184
- export declare function buildOnPropChangeEffects<S, DS, P>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, indices: number[], index: number, isInit: boolean, getInitialState: S | ((p: P) => S)): OnPropsChangeEffectsContext<S, DS, P>;
185
- /** @internal */
186
- export declare function addStateToContext<T, S>(ctx: T, stateRef: Ref<S>): T & ContextState<S>;
187
- /** @internal */
188
- export declare function addContextActions<T, A>(ctx: T, actionsRef: Ref<A>): T & InvocationContextActions<A>;
189
- /** @internal */
190
- export declare function decorateSimpleSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SimpleSyncAction<S, F, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, initializedRef: Ref<boolean>, setState: SetStateFunc<S, A>): (...args: Parameters<F>) => void;
191
- /** @internal */
192
- export declare function decorateSyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(actionName: keyof A, action: SyncAction<S, F, A, P, DS>, stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, actionsRef: Ref<A>, initializedRef: Ref<boolean>, timeoutMap: Ref<TimeoutMap<A>>, options: StoreOptions<S, A, P, any>, setState: SetStateFunc<S, A>, clearError: ClearErrorFunc<A>): (...args: Parameters<F>) => void;
193
- /** @internal */
194
- export declare function decorateAsyncAction<S, DS, F extends (...args: any[]) => any, A extends DecoratedActions, P>(context: AsyncActionExecContext<S, DS, F, A, P>): (...args: Parameters<F>) => Promise<any>;
195
- /** @internal */
196
- export declare function isLoadingImpl<A, K extends keyof A>(loadingMap: InternalLoadingMap<A>, ...props: (K | [K, string])[]): boolean;
197
- export declare const DEFAULT_PROMISE_ID = "__def__";
198
- /** @internal */
199
- export declare function areSameArgs(args1: any[], args2: any[]): boolean;
200
- /** @internal */
201
- export declare function computeDerivedValues<S, A, P, DS>(s: Ref<S>, p: Ref<P>, derivedStateRef: Ref<DerivedState<DS>>, options: StoreOptions<S, A, P, DS>): boolean;
202
- /** @internal */
203
- export declare function onPropChange<S, P, A, DS>(stateRef: Ref<S>, derivedStateRef: Ref<DerivedState<DS>>, propsRef: Ref<P>, oldProps: P, actionsRef: Ref<A>, options: StoreOptions<S, A, P, DS>, getInitialState: S | ((p: P) => S), setState: SetStateFunc<S, A>, isInit: boolean, isDeferred: boolean): void;
204
- /** @internal */
205
- export declare function runMiddlewares<S, A extends DecoratedActions, P>(middlewares: Middleware<S, A, P>[], oldState: S, newState: S, loading: boolean, actionName: keyof A, actionType: 'preEffects' | 'effects' | 'errorEffects' | null, isAsync: boolean, actionCtx: any): {
206
- newState: S;
207
- newLoading: boolean;
208
- };
209
- export {};