@tramvai/module-common 2.7.1 → 2.10.2
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/lib/actions/actionExecution.d.ts +17 -12
- package/lib/actions/actionPageRunner.browser.d.ts +7 -4
- package/lib/actions/actionPageRunner.d.ts +16 -11
- package/lib/actions/constants.d.ts +6 -0
- package/lib/cache/CacheModule.d.ts +1 -1
- package/lib/child-app/command.d.ts +8 -8
- package/lib/command/commandLineRunner.d.ts +6 -2
- package/lib/command/defaultLines.d.ts +10 -10
- package/lib/createConsumerContext/createConsumerContext.d.ts +3 -3
- package/lib/executionContext/executionContextManager.d.ts +5 -0
- package/lib/index.browser.js +194 -53
- package/lib/index.d.ts +1 -0
- package/lib/index.es.js +227 -86
- package/lib/index.js +213 -71
- package/lib/providers/clientProviders.d.ts +3 -3
- package/package.json +19 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Action, ActionParameters, DI_TOKEN } from '@tramvai/core';
|
|
2
|
-
import type { CONTEXT_TOKEN, ActionCondition, STORE_TOKEN } from '@tramvai/tokens-common';
|
|
2
|
+
import type { CONTEXT_TOKEN, ActionCondition, STORE_TOKEN, ActionExecution as Interface, EXECUTION_CONTEXT_MANAGER_TOKEN, ExecutionContext } from '@tramvai/tokens-common';
|
|
3
|
+
import type { TramvaiAction } from '@tramvai/types-actions-state-context';
|
|
3
4
|
import type { ExtractDependencyType } from '@tinkoff/dippy';
|
|
4
|
-
import type { ActionType } from './constants';
|
|
5
5
|
export declare const getParameters: (action: Action) => ActionParameters<any, any>;
|
|
6
6
|
declare type ExecutionStatus = 'success' | 'failed' | 'pending' | 'forbidden';
|
|
7
7
|
export interface ExecutionState {
|
|
@@ -9,21 +9,26 @@ export interface ExecutionState {
|
|
|
9
9
|
state: Record<string, any>;
|
|
10
10
|
}
|
|
11
11
|
declare type TransformAction = <T>(action: T) => T;
|
|
12
|
-
export declare class ActionExecution {
|
|
13
|
-
actionConditionals: ActionCondition[];
|
|
12
|
+
export declare class ActionExecution implements Interface {
|
|
14
13
|
execution: Map<string, ExecutionState>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
private actionConditionals;
|
|
15
|
+
private context;
|
|
16
|
+
private store;
|
|
17
|
+
private executionContextManager;
|
|
18
|
+
private di;
|
|
19
|
+
private transformAction;
|
|
20
|
+
constructor({ store, context, di, executionContextManager, actionConditionals, transformAction, }: {
|
|
19
21
|
actionConditionals: ActionCondition[] | ActionCondition[][] | null;
|
|
20
|
-
store
|
|
21
|
-
context
|
|
22
|
-
di
|
|
22
|
+
store: ExtractDependencyType<typeof STORE_TOKEN>;
|
|
23
|
+
context: ExtractDependencyType<typeof CONTEXT_TOKEN>;
|
|
24
|
+
di: ExtractDependencyType<typeof DI_TOKEN>;
|
|
25
|
+
executionContextManager: ExtractDependencyType<typeof EXECUTION_CONTEXT_MANAGER_TOKEN>;
|
|
23
26
|
transformAction?: TransformAction;
|
|
24
27
|
});
|
|
25
|
-
|
|
28
|
+
runInContext(executionContext: ExecutionContext | null, action: Action | TramvaiAction<any, any, any>, ...params: any[]): Promise<any>;
|
|
29
|
+
run(action: Action | TramvaiAction<any, any, any>, ...params: any[]): Promise<any>;
|
|
26
30
|
private getExecutionState;
|
|
27
31
|
private canExecuteAction;
|
|
32
|
+
private createActionContext;
|
|
28
33
|
}
|
|
29
34
|
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type { Action } from '@tramvai/core';
|
|
1
|
+
import type { Action, TramvaiAction } from '@tramvai/core';
|
|
2
2
|
import type { LOGGER_TOKEN } from '@tramvai/module-log';
|
|
3
|
+
import type { COMMAND_LINE_EXECUTION_CONTEXT_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN } from '@tramvai/tokens-common';
|
|
3
4
|
import type { ActionExecution } from './actionExecution';
|
|
4
5
|
export declare class ActionPageRunner {
|
|
5
|
-
|
|
6
|
+
private deps;
|
|
6
7
|
log: ReturnType<typeof LOGGER_TOKEN>;
|
|
7
|
-
constructor(
|
|
8
|
+
constructor(deps: {
|
|
8
9
|
actionExecution: ActionExecution;
|
|
10
|
+
executionContextManager: typeof EXECUTION_CONTEXT_MANAGER_TOKEN;
|
|
11
|
+
commandLineExecutionContext: typeof COMMAND_LINE_EXECUTION_CONTEXT_TOKEN;
|
|
9
12
|
logger: typeof LOGGER_TOKEN;
|
|
10
13
|
});
|
|
11
|
-
runActions(actions: Action[], stopRunAtError?: (error: Error) => boolean): Promise<
|
|
14
|
+
runActions(actions: Array<Action | TramvaiAction<any[], any, any>>, stopRunAtError?: (error: Error) => boolean): Promise<void>;
|
|
12
15
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type { Action } from '@tramvai/core';
|
|
2
|
-
import type { ActionPageRunner as ActionPageRunnerInterface, STORE_TOKEN } from '@tramvai/tokens-common';
|
|
1
|
+
import type { Action, TramvaiAction } from '@tramvai/core';
|
|
2
|
+
import type { LOGGER_TOKEN, ActionPageRunner as ActionPageRunnerInterface, STORE_TOKEN, EXECUTION_CONTEXT_MANAGER_TOKEN, COMMAND_LINE_EXECUTION_CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
3
3
|
import type { ActionExecution } from './actionExecution';
|
|
4
|
+
declare module '@tramvai/tokens-common' {
|
|
5
|
+
interface ExecutionContextValues {
|
|
6
|
+
pageActions?: boolean;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
4
9
|
export declare class ActionPageRunner implements ActionPageRunnerInterface {
|
|
5
|
-
|
|
6
|
-
actionExecution: ActionExecution;
|
|
7
|
-
private limitTime;
|
|
10
|
+
private deps;
|
|
8
11
|
private log;
|
|
9
|
-
constructor(
|
|
10
|
-
store:
|
|
11
|
-
actionExecution:
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
constructor(deps: {
|
|
13
|
+
store: typeof STORE_TOKEN;
|
|
14
|
+
actionExecution: ActionExecution;
|
|
15
|
+
executionContextManager: typeof EXECUTION_CONTEXT_MANAGER_TOKEN;
|
|
16
|
+
commandLineExecutionContext: typeof COMMAND_LINE_EXECUTION_CONTEXT_TOKEN;
|
|
17
|
+
limitTime: number;
|
|
18
|
+
logger: typeof LOGGER_TOKEN;
|
|
14
19
|
});
|
|
15
|
-
runActions(actions: Action[], stopRunAtError?: (error: Error) => boolean): Promise<void>;
|
|
20
|
+
runActions(actions: Array<Action | TramvaiAction<any[], any, any>>, stopRunAtError?: (error: Error) => boolean): Promise<void>;
|
|
16
21
|
private syncStateActions;
|
|
17
22
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated only for compatibility with legacy createAction
|
|
3
|
+
*/
|
|
1
4
|
export declare const actionType: {
|
|
2
5
|
global: "global";
|
|
3
6
|
local: "local";
|
|
4
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated only for compatibility with legacy createAction
|
|
10
|
+
*/
|
|
5
11
|
export declare type ActionType = keyof typeof actionType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Cache } from '@tramvai/tokens-common';
|
|
2
|
-
export declare const cachesToken: import("@tinkoff/dippy
|
|
2
|
+
export declare const cachesToken: import("@tinkoff/dippy").BaseTokenInterface<Cache<any>[]>;
|
|
3
3
|
export declare class CacheModule {
|
|
4
4
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Provider } from '@tramvai/core';
|
|
2
2
|
export declare const lines: {
|
|
3
3
|
server: {
|
|
4
|
-
customer: import("@tinkoff/dippy
|
|
5
|
-
clear: import("@tinkoff/dippy
|
|
6
|
-
spa: import("@tinkoff/dippy
|
|
7
|
-
afterSpa: import("@tinkoff/dippy
|
|
4
|
+
customer: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
5
|
+
clear: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
6
|
+
spa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
7
|
+
afterSpa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
8
8
|
};
|
|
9
9
|
client: {
|
|
10
|
-
customer: import("@tinkoff/dippy
|
|
11
|
-
clear: import("@tinkoff/dippy
|
|
12
|
-
spa: import("@tinkoff/dippy
|
|
13
|
-
afterSpa: import("@tinkoff/dippy
|
|
10
|
+
customer: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
11
|
+
clear: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
12
|
+
spa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
13
|
+
afterSpa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export declare const commandProviders: Provider[];
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { CommandLineDescription, CommandLine, CommandLines } from '@tramvai/core';
|
|
2
2
|
import type { METRICS_MODULE_TOKEN } from '@tramvai/tokens-metrics';
|
|
3
3
|
import type { Container, Provider } from '@tinkoff/dippy';
|
|
4
|
-
import type { LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
4
|
+
import type { ExecutionContext, EXECUTION_CONTEXT_MANAGER_TOKEN, LOGGER_TOKEN } from '@tramvai/tokens-common';
|
|
5
5
|
export declare class CommandLineRunner implements CommandLine {
|
|
6
6
|
lines: CommandLines;
|
|
7
7
|
rootDi: Container;
|
|
8
8
|
log: ReturnType<typeof LOGGER_TOKEN>;
|
|
9
9
|
metrics: typeof METRICS_MODULE_TOKEN;
|
|
10
|
+
executionContextManager: typeof EXECUTION_CONTEXT_MANAGER_TOKEN;
|
|
10
11
|
private metricsInstance;
|
|
11
|
-
|
|
12
|
+
private executionContextByDi;
|
|
13
|
+
constructor({ lines, rootDi, logger, metrics, executionContextManager, }: {
|
|
12
14
|
lines: CommandLines;
|
|
13
15
|
rootDi: Container;
|
|
14
16
|
logger: typeof LOGGER_TOKEN;
|
|
15
17
|
metrics?: typeof METRICS_MODULE_TOKEN;
|
|
18
|
+
executionContextManager: typeof EXECUTION_CONTEXT_MANAGER_TOKEN;
|
|
16
19
|
});
|
|
17
20
|
run(type: keyof CommandLines, status: keyof CommandLineDescription, providers?: Provider[], customDi?: Container): Promise<Container>;
|
|
21
|
+
resolveExecutionContextFromDi(di: Container): ExecutionContext | null;
|
|
18
22
|
private createLineChain;
|
|
19
23
|
private instanceExecute;
|
|
20
24
|
private createDurationMetric;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export declare const lines: {
|
|
2
2
|
server: {
|
|
3
|
-
init: import("@tinkoff/dippy
|
|
4
|
-
close: import("@tinkoff/dippy
|
|
5
|
-
customer: import("@tinkoff/dippy
|
|
6
|
-
spa: import("@tinkoff/dippy
|
|
7
|
-
afterSpa: import("@tinkoff/dippy
|
|
3
|
+
init: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
4
|
+
close: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
5
|
+
customer: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
6
|
+
spa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
7
|
+
afterSpa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
8
8
|
};
|
|
9
9
|
client: {
|
|
10
|
-
init: import("@tinkoff/dippy
|
|
11
|
-
close: import("@tinkoff/dippy
|
|
12
|
-
customer: import("@tinkoff/dippy
|
|
13
|
-
spa: import("@tinkoff/dippy
|
|
14
|
-
afterSpa: import("@tinkoff/dippy
|
|
10
|
+
init: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
11
|
+
close: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
12
|
+
customer: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
13
|
+
spa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
14
|
+
afterSpa: import("@tinkoff/dippy").MultiTokenInterface<import("@tramvai/core").Command>[];
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Container } from '@tinkoff/dippy';
|
|
2
2
|
import type { Event, Reducer } from '@tramvai/state';
|
|
3
|
-
import type { Action } from '@tramvai/core';
|
|
3
|
+
import type { Action, TramvaiAction } from '@tramvai/core';
|
|
4
4
|
import type { PUBSUB_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
5
5
|
import type { PlatformAction } from './typings';
|
|
6
6
|
declare type ContextType = typeof CONTEXT_TOKEN;
|
|
@@ -9,7 +9,7 @@ export declare class ConsumerContext implements ContextType {
|
|
|
9
9
|
pubsub: typeof PUBSUB_TOKEN;
|
|
10
10
|
private dispatcher;
|
|
11
11
|
private store;
|
|
12
|
-
executeAction: <
|
|
12
|
+
executeAction: (action: PlatformAction<any, any> | Action<any, any, any> | TramvaiAction<any[], any, any>, payload?: any) => Promise<any>;
|
|
13
13
|
dispatch: <Payload>(actionOrNameEvent: string | Event<Payload>, payload?: Payload) => Promise<Payload>;
|
|
14
14
|
dispatchWith: (createActionOrType: (...args: unknown[]) => Event | Event, options?: any) => (...args: unknown[]) => Promise<any>;
|
|
15
15
|
/**
|
|
@@ -38,5 +38,5 @@ export declare function createConsumerContext({ di, dispatcherContext, pubsub, s
|
|
|
38
38
|
dispatcherContext: any;
|
|
39
39
|
pubsub: any;
|
|
40
40
|
store: any;
|
|
41
|
-
}):
|
|
41
|
+
}): ContextType;
|
|
42
42
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExecutionContext, ExecutionContextManager as Interface, ExecutionContextOptions } from '@tramvai/tokens-common';
|
|
2
|
+
import { AbortController } from 'node-abort-controller';
|
|
3
|
+
export declare class ExecutionContextManager implements Interface {
|
|
4
|
+
withContext<T>(parentContext: ExecutionContext | null, nameOrOptions: string | ExecutionContextOptions, cb: (context: ExecutionContext, abortController: AbortController) => Promise<T>): Promise<T>;
|
|
5
|
+
}
|