@nice-code/action 0.8.0 → 0.9.0
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/build/ActionDevtoolsCore-B4s6aGvI.d.ts +79 -0
- package/build/ActionDevtoolsCore-BLeY_N-3.js +159 -0
- package/build/ActionDevtoolsCore-BLeY_N-3.js.map +1 -0
- package/build/ActionDevtoolsCore-Pg7ERO3L.d.ts +79 -0
- package/build/ActionDevtoolsCore-yfJ9tkvl.js +154 -0
- package/build/ActionDevtoolsCore-yfJ9tkvl.js.map +1 -0
- package/build/ActionPayload.types-BN-rXFBK.d.ts +2328 -0
- package/build/ActionPayload.types-D28ELKXC.d.ts +2328 -0
- package/build/RunningAction.types-C176rqHG.js +22 -0
- package/build/RunningAction.types-C176rqHG.js.map +1 -0
- package/build/RunningAction.types-DjCX1xp5.js +39 -0
- package/build/RunningAction.types-DjCX1xp5.js.map +1 -0
- package/build/devtools/browser/index.d.ts +17 -0
- package/build/devtools/browser/index.js +3762 -5145
- package/build/devtools/browser/index.js.map +1 -0
- package/build/devtools/server/index.d.ts +35 -0
- package/build/devtools/server/index.js +97 -261
- package/build/devtools/server/index.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +3872 -3870
- package/build/index.js.map +1 -0
- package/build/react-query/index.d.ts +17 -0
- package/build/react-query/index.js +60 -60
- package/build/react-query/index.js.map +1 -0
- package/package.json +11 -10
- package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +0 -37
- package/build/types/ActionDefinition/Action/ActionBase.d.ts +0 -14
- package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +0 -24
- package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +0 -25
- package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +0 -35
- package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +0 -19
- package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +0 -10
- package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +0 -14
- package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +0 -110
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +0 -15
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +0 -26
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +0 -19
- package/build/types/ActionDefinition/Action/RunningAction.d.ts +0 -36
- package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +0 -73
- package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +0 -42
- package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +0 -43
- package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +0 -14
- package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +0 -24
- package/build/types/ActionDefinition/Domain/helpers/createRootActionDomain.d.ts +0 -5
- package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +0 -68
- package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +0 -28
- package/build/types/ActionRuntime/ActionDomainManager.d.ts +0 -13
- package/build/types/ActionRuntime/ActionRuntime.d.ts +0 -78
- package/build/types/ActionRuntime/ActionRuntime.types.d.ts +0 -22
- package/build/types/ActionRuntime/ActionRuntimeManager.d.ts +0 -20
- package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +0 -16
- package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +0 -65
- package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +0 -45
- package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +0 -7
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +0 -16
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomConnection.d.ts +0 -7
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.d.ts +0 -43
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.types.d.ts +0 -11
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpConnection.d.ts +0 -8
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.d.ts +0 -26
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +0 -16
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +0 -27
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +0 -131
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.d.ts +0 -27
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +0 -41
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +0 -34
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +0 -60
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto.d.ts +0 -31
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWireCodec.d.ts +0 -41
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake.d.ts +0 -187
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter.d.ts +0 -20
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory.d.ts +0 -31
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel.d.ts +0 -63
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/ws_util.d.ts +0 -11
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport.d.ts +0 -36
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.d.ts +0 -18
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.d.ts +0 -2
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.d.ts +0 -2
- package/build/types/ActionRuntime/Handler/ExternalClient/err_nice_external_client.d.ts +0 -5
- package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +0 -55
- package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +0 -7
- package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +0 -254
- package/build/types/ActionRuntime/Handler/Server/WsConnectionStateStore.d.ts +0 -61
- package/build/types/ActionRuntime/Handler/Server/createActionFetchHandler.d.ts +0 -40
- package/build/types/ActionRuntime/Handler/Server/createSecureActionServer.d.ts +0 -71
- package/build/types/ActionRuntime/HandlerCallStack.d.ts +0 -3
- package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +0 -55
- package/build/types/ActionRuntime/Routing/ActionRouter.types.d.ts +0 -20
- package/build/types/ActionRuntime/RuntimeCoordinate.d.ts +0 -58
- package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +0 -207
- package/build/types/ActionRuntime/utils/runtimeCoordinateToStringIds.d.ts +0 -2
- package/build/types/devtools/browser/NiceActionDevtools.d.ts +0 -14
- package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +0 -5
- package/build/types/devtools/browser/components/CallStackSection.d.ts +0 -8
- package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +0 -6
- package/build/types/devtools/browser/components/Chip.d.ts +0 -22
- package/build/types/devtools/browser/components/DetailSection.d.ts +0 -5
- package/build/types/devtools/browser/components/DomainChip.d.ts +0 -8
- package/build/types/devtools/browser/components/HandlerChips.d.ts +0 -21
- package/build/types/devtools/browser/components/Icon.d.ts +0 -16
- package/build/types/devtools/browser/components/MetaSection.d.ts +0 -4
- package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +0 -19
- package/build/types/devtools/browser/components/OriginChip.d.ts +0 -15
- package/build/types/devtools/browser/components/RoutingSection.d.ts +0 -5
- package/build/types/devtools/browser/components/RunningTimer.d.ts +0 -7
- package/build/types/devtools/browser/components/SectionLabel.d.ts +0 -1
- package/build/types/devtools/browser/components/StackTraceSection.d.ts +0 -9
- package/build/types/devtools/browser/components/Tooltip.d.ts +0 -1
- package/build/types/devtools/browser/components/action_detail/ActionDetailPanel.d.ts +0 -7
- package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +0 -14
- package/build/types/devtools/browser/components/action_list/ActionInputAndOutputChip.d.ts +0 -11
- package/build/types/devtools/browser/components/action_list/ActionList.d.ts +0 -10
- package/build/types/devtools/browser/components/action_list/IoTooltipContent.d.ts +0 -3
- package/build/types/devtools/browser/components/action_list/action_list.types.d.ts +0 -4
- package/build/types/devtools/browser/components/sourceMapResolver.d.ts +0 -6
- package/build/types/devtools/browser/components/utils.d.ts +0 -20
- package/build/types/devtools/browser/devtools_storage.d.ts +0 -6
- package/build/types/devtools/browser/index.d.ts +0 -3
- package/build/types/devtools/browser/ui_util/size.d.ts +0 -6
- package/build/types/devtools/core/ActionDevtools.types.d.ts +0 -55
- package/build/types/devtools/core/ActionDevtoolsCore.d.ts +0 -17
- package/build/types/devtools/core/devtools_colors.d.ts +0 -38
- package/build/types/devtools/server/NiceActionServerDevtools.d.ts +0 -30
- package/build/types/devtools/server/index.d.ts +0 -3
- package/build/types/errors/err_nice_action.d.ts +0 -96
- package/build/types/index.d.ts +0 -43
- package/build/types/nice_action.static.d.ts +0 -3
- package/build/types/react-query/hooks/useActionMutation.d.ts +0 -10
- package/build/types/react-query/hooks/useActionQuery.d.ts +0 -17
- package/build/types/react-query/index.d.ts +0 -2
- package/build/types/utils/assertIsActionJson.d.ts +0 -2
- package/build/types/utils/decodeActionFrame.d.ts +0 -17
- package/build/types/utils/getAssumedRuntimeEnvironment.d.ts +0 -2
- package/build/types/utils/hashPayloadData.d.ts +0 -5
- package/build/types/utils/isActionPayload_Any_JsonObject.d.ts +0 -2
- package/build/types/utils/isActionPayload_Progress_JsonObject.d.ts +0 -2
- package/build/types/utils/isActionPayload_Request_JsonObject.d.ts +0 -2
- package/build/types/utils/isActionPayload_Result_JsonObject.d.ts +0 -2
- package/build/types/utils/isAction_Any_Instance.d.ts +0 -3
- package/build/types/utils/isAction_Any_JsonObject.d.ts +0 -2
- package/build/types/utils/isAction_Base_JsonObject.d.ts +0 -2
- package/build/types/utils/isAction_Context_JsonObject.d.ts +0 -2
- package/build/types/utils/isAction_Core_JsonObject.d.ts +0 -2
- package/build/types/utils/typescript/MaybePromise.d.ts +0 -1
- package/build/types/utils/wait.utils.d.ts +0 -13
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ActionDomain } from "../..";
|
|
2
|
-
import type { IActionDomain } from "../Domain/ActionDomain.types";
|
|
3
|
-
import type { ActionContext } from "./Context/ActionContext";
|
|
4
|
-
import { type IActionPayload_Result_JsonObject } from "./Payload/ActionPayload.types";
|
|
5
|
-
import type { ActionPayload_Progress } from "./Payload/ActionPayload_Progress";
|
|
6
|
-
import type { ActionPayload_Result } from "./Payload/ActionPayload_Result";
|
|
7
|
-
import { type IRunningActionState, type IRunningActionState_ConstructorParams, type IRunningActionUserMethods, type TRunningActionUpdate, type TRunningActionUpdateListener } from "./RunningAction.types";
|
|
8
|
-
export declare class RunningAction<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> implements IRunningActionUserMethods<DOM, ID> {
|
|
9
|
-
protected _state: IRunningActionState<DOM, ID>;
|
|
10
|
-
readonly context: ActionContext<DOM, ID>;
|
|
11
|
-
readonly cuid: string;
|
|
12
|
-
readonly id: ID;
|
|
13
|
-
readonly _domain: ActionDomain<DOM>;
|
|
14
|
-
readonly domain: DOM["domain"];
|
|
15
|
-
readonly allDomains: DOM["allDomains"];
|
|
16
|
-
readonly parentCuid?: string;
|
|
17
|
-
readonly callSite?: string;
|
|
18
|
-
private readonly _resultPayloadPromise;
|
|
19
|
-
private _resolveResult;
|
|
20
|
-
private _rejectResult;
|
|
21
|
-
private _isAborted;
|
|
22
|
-
private readonly _updates;
|
|
23
|
-
private readonly _updateListeners;
|
|
24
|
-
constructor(initialState: IRunningActionState_ConstructorParams<DOM, ID>);
|
|
25
|
-
get state(): IRunningActionState<DOM, ID>;
|
|
26
|
-
abort(reason?: unknown): void;
|
|
27
|
-
addUpdateListeners(listeners: TRunningActionUpdateListener<DOM, ID>[]): () => void;
|
|
28
|
-
iterateUpdates(): AsyncIterable<TRunningActionUpdate<DOM, ID>>;
|
|
29
|
-
_sendUpdate(update: TRunningActionUpdate<DOM, ID>): void;
|
|
30
|
-
_completeWithResult(result: ActionPayload_Result<DOM, ID>): boolean;
|
|
31
|
-
_abort(reason?: unknown): boolean;
|
|
32
|
-
_failWithError(error: unknown): boolean;
|
|
33
|
-
_updateProgress(progress: ActionPayload_Progress<DOM, ID>): void;
|
|
34
|
-
waitForResultPayload(): Promise<ActionPayload_Result<DOM, ID>>;
|
|
35
|
-
_resolveFromJson(resultJson: IActionPayload_Result_JsonObject<DOM, ID>): boolean;
|
|
36
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { IActionDomain } from "../Domain/ActionDomain.types";
|
|
2
|
-
import type { TInferActionError } from "../Schema/ActionSchema";
|
|
3
|
-
import type { ActionContext } from "./Context/ActionContext";
|
|
4
|
-
import type { TActionProgress } from "./Payload/ActionPayload.types";
|
|
5
|
-
import type { ActionPayload_Progress } from "./Payload/ActionPayload_Progress";
|
|
6
|
-
import type { ActionPayload_Request } from "./Payload/ActionPayload_Request";
|
|
7
|
-
import type { ActionPayload_Result } from "./Payload/ActionPayload_Result";
|
|
8
|
-
import type { RunningAction } from "./RunningAction";
|
|
9
|
-
export declare enum ERunningActionState {
|
|
10
|
-
running = "running",
|
|
11
|
-
completed = "completed"
|
|
12
|
-
}
|
|
13
|
-
export interface IRunningActionState<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> {
|
|
14
|
-
request: ActionPayload_Request<DOM, ID>;
|
|
15
|
-
progress: ActionPayload_Progress<DOM, ID>[];
|
|
16
|
-
result?: ActionPayload_Result<DOM, ID>;
|
|
17
|
-
}
|
|
18
|
-
export interface IRunningActionState_ConstructorParams<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> {
|
|
19
|
-
context: ActionContext<DOM, ID>;
|
|
20
|
-
request: ActionPayload_Request<DOM, ID>;
|
|
21
|
-
progress?: ActionPayload_Progress<DOM, ID>[];
|
|
22
|
-
result?: ActionPayload_Result<DOM, ID>;
|
|
23
|
-
parentCuid?: string;
|
|
24
|
-
callSite?: string;
|
|
25
|
-
}
|
|
26
|
-
export declare enum ERunningActionUpdateType {
|
|
27
|
-
started = "started",
|
|
28
|
-
progress = "progress",
|
|
29
|
-
finished = "finished"
|
|
30
|
-
}
|
|
31
|
-
export interface IRunningActionEvent_Base<T extends ERunningActionUpdateType, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> {
|
|
32
|
-
type: T;
|
|
33
|
-
runningAction: RunningAction<DOM, ID>;
|
|
34
|
-
time: number;
|
|
35
|
-
}
|
|
36
|
-
export interface IRunningActionUpdate_Started<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionEvent_Base<ERunningActionUpdateType.started, DOM, ID> {
|
|
37
|
-
}
|
|
38
|
-
export interface IRunningActionUpdate_Progress<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionEvent_Base<ERunningActionUpdateType.progress, DOM, ID> {
|
|
39
|
-
progress: TActionProgress;
|
|
40
|
-
}
|
|
41
|
-
export declare enum ERunningActionFinishedType {
|
|
42
|
-
aborted = "aborted",
|
|
43
|
-
failed = "failed",
|
|
44
|
-
success = "success"
|
|
45
|
-
}
|
|
46
|
-
export interface IRunningActionUpdate_Finished<FT extends ERunningActionFinishedType, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionEvent_Base<ERunningActionUpdateType.finished, DOM, ID> {
|
|
47
|
-
finishType: FT;
|
|
48
|
-
reason?: unknown;
|
|
49
|
-
}
|
|
50
|
-
export interface IRunningActionUpdate_Abort<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionUpdate_Finished<ERunningActionFinishedType.aborted, DOM, ID> {
|
|
51
|
-
reason?: unknown;
|
|
52
|
-
}
|
|
53
|
-
export interface IRunningActionUpdate_Failed<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionUpdate_Finished<ERunningActionFinishedType.failed, DOM, ID> {
|
|
54
|
-
error: TInferActionError<DOM["actionSchema"][ID]>;
|
|
55
|
-
}
|
|
56
|
-
export interface IRunningActionUpdate_Success<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IRunningActionUpdate_Finished<ERunningActionFinishedType.success, DOM, ID> {
|
|
57
|
-
response: ActionPayload_Result<DOM, ID>;
|
|
58
|
-
}
|
|
59
|
-
export type TRunningActionUpdateFinished<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = IRunningActionUpdate_Abort<DOM, ID> | IRunningActionUpdate_Failed<DOM, ID> | IRunningActionUpdate_Success<DOM, ID>;
|
|
60
|
-
export type TRunningActionUpdate<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = IRunningActionUpdate_Started<DOM, ID> | IRunningActionUpdate_Progress<DOM, ID> | TRunningActionUpdateFinished<DOM, ID>;
|
|
61
|
-
export type TRunningActionUpdateListener<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = (update: TRunningActionUpdate<DOM, ID>) => void;
|
|
62
|
-
/**
|
|
63
|
-
* Distributes a union ID into a proper discriminated union of RunningAction update events,
|
|
64
|
-
* so that narrowing on `update.runningAction.id` also narrows `update.runningAction`'s input/output types.
|
|
65
|
-
*/
|
|
66
|
-
export type TDistributeRunningActionUpdate<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = ID extends keyof DOM["actionSchema"] & string ? TRunningActionUpdate<DOM, ID> : never;
|
|
67
|
-
export type TDistributeRunningActionUpdateListener<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = (update: TDistributeRunningActionUpdate<DOM, ID>) => void;
|
|
68
|
-
export interface IRunningActionUserMethods<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> {
|
|
69
|
-
waitForResultPayload(): Promise<ActionPayload_Result<DOM, ID>>;
|
|
70
|
-
addUpdateListeners(listeners: TRunningActionUpdateListener<DOM, ID>[]): () => void;
|
|
71
|
-
iterateUpdates(): AsyncIterable<TRunningActionUpdate<DOM, ID>>;
|
|
72
|
-
abort(reason?: unknown): void;
|
|
73
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
|
|
2
|
-
import type { IExecuteActionOptions } from "../../ActionRuntime/Handler/ActionHandler.types";
|
|
3
|
-
import { ActionLocalHandler } from "../../ActionRuntime/Handler/Local/ActionLocalHandler";
|
|
4
|
-
import type { TAction_Any_JsonObject, TDistributeActionPayload_Request, TDistributeActionPayload_Result, TDistributedDomainActions, TNarrowActionJsonTypeToActionInstanceType } from "../Action/Action.combined.types";
|
|
5
|
-
import { type IActionBase } from "../Action/ActionBase.types";
|
|
6
|
-
import { ActionContext } from "../Action/Context/ActionContext";
|
|
7
|
-
import type { IActionContext_Data_JsonObject } from "../Action/Context/ActionContext.types";
|
|
8
|
-
import { ActionCore } from "../Action/Core/ActionCore";
|
|
9
|
-
import { type IActionPayload_Request_JsonObject, type IActionPayload_Result_JsonObject } from "../Action/Payload/ActionPayload.types";
|
|
10
|
-
import { ActionPayload_Request } from "../Action/Payload/ActionPayload_Request";
|
|
11
|
-
import type { RunningAction } from "../Action/RunningAction";
|
|
12
|
-
import type { IActionDomain, IActionDomainChildOptions, TActionDomainChildDef, TWrappableDomainActionHandler } from "./ActionDomain.types";
|
|
13
|
-
import { ActionDomainBase } from "./ActionDomainBase";
|
|
14
|
-
import { type ActionRootDomain } from "./ActionRootDomain";
|
|
15
|
-
type TActionMap<ACT_DOM extends IActionDomain> = {
|
|
16
|
-
[K in keyof ACT_DOM["actionSchema"] & string]: ActionCore<ACT_DOM, K>;
|
|
17
|
-
};
|
|
18
|
-
export declare class ActionDomain<ACT_DOM extends IActionDomain = IActionDomain> extends ActionDomainBase<ACT_DOM> {
|
|
19
|
-
private _rootDomain;
|
|
20
|
-
private readonly _actionMap;
|
|
21
|
-
constructor(definition: ACT_DOM, { rootDomain, }: {
|
|
22
|
-
rootDomain: ActionRootDomain<any>;
|
|
23
|
-
});
|
|
24
|
-
get rootDomain(): ActionRootDomain<any>;
|
|
25
|
-
_registerRuntime(runtime: ActionRuntime): void;
|
|
26
|
-
createChildDomain<SUB_DOM extends IActionDomainChildOptions>(subDomainDef: SUB_DOM & {
|
|
27
|
-
[K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;
|
|
28
|
-
}): ActionDomain<TActionDomainChildDef<ACT_DOM, SUB_DOM>>;
|
|
29
|
-
get action(): TActionMap<ACT_DOM>;
|
|
30
|
-
actionsMap(): TActionMap<ACT_DOM>;
|
|
31
|
-
actionForId<ID extends keyof ACT_DOM["actionSchema"] & string>(id: ID): ActionCore<ACT_DOM, ID>;
|
|
32
|
-
wrapAsPartialLocalHandler(wrappedActionExecutor: Partial<TWrappableDomainActionHandler<ACT_DOM>>): ActionLocalHandler;
|
|
33
|
-
wrapAsLocalHandler(wrappedActionExecutor: TWrappableDomainActionHandler<ACT_DOM>): ActionLocalHandler;
|
|
34
|
-
hydrateContext<ID extends keyof ACT_DOM["actionSchema"] & string>(id: ID, contextData: IActionContext_Data_JsonObject): ActionContext<ACT_DOM, ID>;
|
|
35
|
-
isDomainAction<ACT extends IActionBase<any, ACT_DOM, any>>(action: ACT | unknown | null | undefined): action is TDistributedDomainActions<ACT_DOM, ACT>;
|
|
36
|
-
hydrateRequestPayload<ID extends keyof ACT_DOM["actionSchema"] & string, P extends IActionPayload_Request_JsonObject<ACT_DOM, ID>>(serialized: P): TDistributeActionPayload_Request<ACT_DOM, ID>;
|
|
37
|
-
hydrateResultPayload<ID extends keyof ACT_DOM["actionSchema"] & string, R extends IActionPayload_Result_JsonObject<ACT_DOM, ID>>(serialized: R): TDistributeActionPayload_Result<ACT_DOM, ID>;
|
|
38
|
-
hydrateAnyAction<ID extends keyof ACT_DOM["actionSchema"] & string, AJ extends TAction_Any_JsonObject<ACT_DOM, ID>>(actionJson: AJ): TNarrowActionJsonTypeToActionInstanceType<ACT_DOM, AJ, ID>;
|
|
39
|
-
runAction<ID extends keyof ACT_DOM["actionSchema"] & string, ACT extends ActionPayload_Request<ACT_DOM, ID>>(request: ACT, options?: IExecuteActionOptions<ACT_DOM, ID>): Promise<RunningAction<ACT_DOM, ID>>;
|
|
40
|
-
private createActionMap;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ActionSchema } from "../Schema/ActionSchema";
|
|
2
|
-
import type { IActionErrorDeclaration, TTransportedValue } from "../Schema/ActionSchema.types";
|
|
3
|
-
export type TPossibleDomainId = string;
|
|
4
|
-
export type TPossibleDomainIdList = [...TPossibleDomainId[], TPossibleDomainId];
|
|
5
|
-
export type TActionDomainSchema = Record<string, ActionSchema<TTransportedValue<any, any>, TTransportedValue<any, any>, readonly IActionErrorDeclaration<any, any>[]>>;
|
|
6
|
-
/**
|
|
7
|
-
* Data shape for a domain — used for construction and as the type-level schema carrier.
|
|
8
|
-
* Does NOT include class methods.
|
|
9
|
-
*/
|
|
10
|
-
export interface IActionDomain<IDS extends TPossibleDomainIdList = TPossibleDomainIdList, SCH extends TActionDomainSchema = TActionDomainSchema> {
|
|
11
|
-
domain: IDS[0] & string;
|
|
12
|
-
allDomains: IDS;
|
|
13
|
-
actionSchema: SCH;
|
|
14
|
-
}
|
|
15
|
-
export interface IActionRootDomain<ID extends TPossibleDomainId = TPossibleDomainId> extends IActionDomain<[ID], {}> {
|
|
16
|
-
domain: ID;
|
|
17
|
-
allDomains: [ID];
|
|
18
|
-
actionSchema: {};
|
|
19
|
-
}
|
|
20
|
-
export interface IActionDomainChildOptions<ERR_DOMAIN extends string = string, SCHEMA extends TActionDomainSchema = TActionDomainSchema> {
|
|
21
|
-
domain: ERR_DOMAIN;
|
|
22
|
-
actions: SCHEMA;
|
|
23
|
-
}
|
|
24
|
-
export type TActionDomainChildDef<PARENT_DEF extends IActionDomain, SUB extends IActionDomainChildOptions> = {
|
|
25
|
-
domain: SUB["domain"];
|
|
26
|
-
allDomains: [...PARENT_DEF["allDomains"], SUB["domain"]];
|
|
27
|
-
actionSchema: SUB["actions"];
|
|
28
|
-
};
|
|
29
|
-
export type TDomainActionId<DOM extends IActionDomain> = keyof DOM["actionSchema"] & string;
|
|
30
|
-
export type TInferInputFromSchema<SCH extends ActionSchema<any, any, any>> = SCH extends ActionSchema<infer IN, any, any> ? {
|
|
31
|
-
Input: IN[0];
|
|
32
|
-
SerdeInput: IN[1];
|
|
33
|
-
} : {
|
|
34
|
-
Input: never;
|
|
35
|
-
SerdeInput: never;
|
|
36
|
-
};
|
|
37
|
-
export type TInferOutputFromSchema<SCH extends ActionSchema<any, any, any>> = SCH extends ActionSchema<any, infer OUT, any> ? {
|
|
38
|
-
Output: OUT[0];
|
|
39
|
-
SerdeOutput: OUT[1];
|
|
40
|
-
} : never;
|
|
41
|
-
export type TWrappableDomainActionHandler<DOM extends IActionDomain> = {
|
|
42
|
-
[K in TDomainActionId<DOM>]: (...args: [TInferInputFromSchema<DOM["actionSchema"][K]>["Input"]] extends [never] ? [] : [input: TInferInputFromSchema<DOM["actionSchema"][K]>["Input"]]) => [TInferOutputFromSchema<DOM["actionSchema"][K]>["Output"]] extends [never] ? Promise<void> | void : Promise<TInferOutputFromSchema<DOM["actionSchema"][K]>["Output"]>;
|
|
43
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TDistributeRunningActionUpdateListener, TRunningActionUpdateListener } from "../Action/RunningAction.types";
|
|
2
|
-
import type { IActionDomain } from "./ActionDomain.types";
|
|
3
|
-
export declare abstract class ActionDomainBase<ACT_DOM extends IActionDomain = IActionDomain> implements IActionDomain<ACT_DOM["allDomains"], ACT_DOM["actionSchema"]> {
|
|
4
|
-
readonly domain: ACT_DOM["domain"];
|
|
5
|
-
readonly allDomains: ACT_DOM["allDomains"];
|
|
6
|
-
readonly actionSchema: ACT_DOM["actionSchema"];
|
|
7
|
-
protected _listeners: TRunningActionUpdateListener<any, any>[];
|
|
8
|
-
constructor(definition: ACT_DOM);
|
|
9
|
-
/**
|
|
10
|
-
* Add an observer that is called after every action dispatched through this domain.
|
|
11
|
-
* Returns an unsubscribe function — call it to remove the listener.
|
|
12
|
-
*/
|
|
13
|
-
addActionListener(listener: TDistributeRunningActionUpdateListener<ACT_DOM, keyof ACT_DOM["actionSchema"] & string>): () => void;
|
|
14
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
|
|
2
|
-
import type { IExecuteActionOptions } from "../../ActionRuntime/Handler/ActionHandler.types";
|
|
3
|
-
import type { IRuntimeCoordinate } from "../../ActionRuntime/RuntimeCoordinate";
|
|
4
|
-
import type { ActionPayload_Request } from "../Action/Payload/ActionPayload_Request";
|
|
5
|
-
import { RunningAction } from "../Action/RunningAction";
|
|
6
|
-
import { ActionDomain } from "./ActionDomain";
|
|
7
|
-
import type { IActionDomain, IActionDomainChildOptions, IActionRootDomain, TActionDomainChildDef } from "./ActionDomain.types";
|
|
8
|
-
import { ActionDomainBase } from "./ActionDomainBase";
|
|
9
|
-
export declare class ActionRootDomain<ROOT_DOM extends IActionRootDomain = IActionRootDomain> extends ActionDomainBase<ROOT_DOM> {
|
|
10
|
-
readonly domainDefinition: {
|
|
11
|
-
domain: ROOT_DOM["domain"];
|
|
12
|
-
};
|
|
13
|
-
private _actionRuntimeManager;
|
|
14
|
-
constructor(domainDefinition: {
|
|
15
|
-
domain: ROOT_DOM["domain"];
|
|
16
|
-
});
|
|
17
|
-
createChildDomain<SUB_DOM extends IActionDomainChildOptions>(subDomainDef: SUB_DOM & {
|
|
18
|
-
[K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;
|
|
19
|
-
}): ActionDomain<TActionDomainChildDef<ROOT_DOM, SUB_DOM>>;
|
|
20
|
-
_registerRuntime(runtime: ActionRuntime): void;
|
|
21
|
-
_hasRuntime(runtime: ActionRuntime): boolean;
|
|
22
|
-
getRuntime(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined;
|
|
23
|
-
_runAction<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string, ACT extends ActionPayload_Request<DOM, ID> = ActionPayload_Request<DOM, ID>>(actionPayload: ACT, options?: IExecuteActionOptions<DOM, ID>): Promise<RunningAction<DOM, ID>>;
|
|
24
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { err_cast_not_nice, type INiceErrorDomainProps, type InferNiceError, type NiceErrorDomain } from "@nice-code/error";
|
|
2
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
import type { IActionErrorDeclaration, TActionSchemaOptions, TInferDeclaredErrors, TTransportedValue } from "./ActionSchema.types";
|
|
4
|
-
export declare class ActionSchema<INPUT extends TTransportedValue<any, any> = never, OUTPUT extends TTransportedValue<any, any> = never, ERRORS extends readonly IActionErrorDeclaration<any, any>[] = readonly []> {
|
|
5
|
-
private _errorDeclarations;
|
|
6
|
-
private inputOptions;
|
|
7
|
-
private outputOptions;
|
|
8
|
-
get inputSchema(): StandardSchemaV1 | undefined;
|
|
9
|
-
get outputSchema(): StandardSchemaV1 | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Declare the input schema (JSON-native or with explicit SERDE type param).
|
|
12
|
-
* For non-JSON-native inputs, prefer the 3-argument form below to avoid
|
|
13
|
-
* needing explicit type parameters.
|
|
14
|
-
*/
|
|
15
|
-
input<VS extends StandardSchemaV1 = StandardSchemaV1, SERDE_IN = any>(options: TActionSchemaOptions<VS, SERDE_IN>): ActionSchema<TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_IN>, OUTPUT, ERRORS>;
|
|
16
|
-
/**
|
|
17
|
-
* Declare the output schema (JSON-native or with explicit SERDE type param).
|
|
18
|
-
* For non-JSON-native outputs, prefer the 3-argument form below to avoid
|
|
19
|
-
* needing explicit type parameters.
|
|
20
|
-
*/
|
|
21
|
-
output<VS extends StandardSchemaV1 = StandardSchemaV1, SERDE_OUT = any>(options: TActionSchemaOptions<VS, SERDE_OUT>): ActionSchema<INPUT, TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_OUT>, ERRORS>;
|
|
22
|
-
/**
|
|
23
|
-
* Declare that this action may throw any error from `domain`.
|
|
24
|
-
* `TInferActionError` will include `NiceError<DEF, keyof schema>` in its union.
|
|
25
|
-
*/
|
|
26
|
-
throws<ERR_DEF extends INiceErrorDomainProps>(domain: NiceErrorDomain<ERR_DEF>): ActionSchema<INPUT, OUTPUT, readonly [...ERRORS, IActionErrorDeclaration<ERR_DEF, keyof ERR_DEF["schema"] & string>]>;
|
|
27
|
-
/**
|
|
28
|
-
* Declare that this action may throw only the listed `ids` from `domain`.
|
|
29
|
-
* `TInferActionError` will include `NiceError<DEF, IDS[number]>` narrowed to those IDs.
|
|
30
|
-
*/
|
|
31
|
-
throws<ERR_DEF extends INiceErrorDomainProps, IDS extends ReadonlyArray<keyof ERR_DEF["schema"] & string>>(domain: NiceErrorDomain<ERR_DEF>, ids: IDS): ActionSchema<INPUT, OUTPUT, readonly [...ERRORS, IActionErrorDeclaration<ERR_DEF, IDS[number] & string>]>;
|
|
32
|
-
/**
|
|
33
|
-
* Serialize raw input to a JSON-serializable form.
|
|
34
|
-
* Uses the schema's serialization.serialize if defined; otherwise the input
|
|
35
|
-
* is already JSON-native and is returned as-is.
|
|
36
|
-
*/
|
|
37
|
-
serializeInput(rawInput: INPUT[0]): INPUT[1];
|
|
38
|
-
/**
|
|
39
|
-
* Deserialize a JSON value back into the raw input type.
|
|
40
|
-
* Uses serialization.deserialize if defined; otherwise the value is cast
|
|
41
|
-
* directly (it's already in the correct shape).
|
|
42
|
-
*/
|
|
43
|
-
deserializeInput(serialized: INPUT[1]): INPUT[0];
|
|
44
|
-
/**
|
|
45
|
-
* Validate raw input against the schema defined via `.input({ schema })`.
|
|
46
|
-
* Throws `action_input_validation_failed` if validation fails.
|
|
47
|
-
* Returns the validated (and possibly coerced) value on success.
|
|
48
|
-
* If no input schema was declared, the value is passed through as-is.
|
|
49
|
-
*/
|
|
50
|
-
validateInput(value: unknown, meta: {
|
|
51
|
-
domain: string;
|
|
52
|
-
actionId: string;
|
|
53
|
-
}): INPUT[0];
|
|
54
|
-
validateOutput(value: unknown, meta: {
|
|
55
|
-
domain: string;
|
|
56
|
-
actionId: string;
|
|
57
|
-
}): OUTPUT[0];
|
|
58
|
-
/**
|
|
59
|
-
* Serialize raw output to a JSON-serializable form.
|
|
60
|
-
*/
|
|
61
|
-
serializeOutput(rawOutput: OUTPUT[0]): OUTPUT[1];
|
|
62
|
-
/**
|
|
63
|
-
* Deserialize a JSON value back into the raw output type.
|
|
64
|
-
*/
|
|
65
|
-
deserializeOutput(serialized: OUTPUT[1]): OUTPUT[0];
|
|
66
|
-
}
|
|
67
|
-
export type TInferActionError<SCH> = SCH extends ActionSchema<any, any, infer DECLS> ? DECLS extends readonly IActionErrorDeclaration[] ? TInferDeclaredErrors<DECLS> | InferNiceError<typeof err_cast_not_nice> : InferNiceError<typeof err_cast_not_nice> : never;
|
|
68
|
-
export declare const actionSchema: () => ActionSchema;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type INiceErrorDomainProps, type NiceErrorDomain } from "@nice-code/error";
|
|
2
|
-
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
export type TTransportedValue<RAW_VAL, SERDE_VAL> = [RAW_VAL] | [RAW_VAL, SERDE_VAL];
|
|
4
|
-
export type TActionSerializationDefinition<RAW_VAL = any, SERDE_VAL = any> = {
|
|
5
|
-
serialize: (value: RAW_VAL) => SERDE_VAL;
|
|
6
|
-
deserialize: (value: SERDE_VAL) => RAW_VAL;
|
|
7
|
-
};
|
|
8
|
-
export type TActionSchemaOptions<VS extends StandardSchemaV1 = StandardSchemaV1, SERDE_IN = any> = {
|
|
9
|
-
schema: VS;
|
|
10
|
-
serialization?: TActionSerializationDefinition<StandardSchemaV1.InferInput<VS>, SERDE_IN>;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* One error declaration on an action schema.
|
|
14
|
-
* `IDS` is the subset of error IDs that may be thrown. When the full
|
|
15
|
-
* `keyof schema` union is used it means any ID from the domain can be thrown.
|
|
16
|
-
*
|
|
17
|
-
* Build via `action().throws(domain)` or `action().throws(domain, ids)`.
|
|
18
|
-
*/
|
|
19
|
-
export interface IActionErrorDeclaration<ERR_DEF extends INiceErrorDomainProps = INiceErrorDomainProps, IDS extends keyof ERR_DEF["schema"] & string = keyof ERR_DEF["schema"] & string> {
|
|
20
|
-
readonly _domain: NiceErrorDomain<ERR_DEF>;
|
|
21
|
-
/** The specific IDs constrained for this declaration, or `undefined` meaning the full domain. */
|
|
22
|
-
readonly _ids: ReadonlyArray<IDS & string> | undefined;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Union of all `NiceError` types that can be thrown from a tuple of error declarations.
|
|
26
|
-
* Distributes over each declaration and unions the results.
|
|
27
|
-
*/
|
|
28
|
-
export type TInferDeclaredErrors<DECLS extends readonly IActionErrorDeclaration[]> = TInferErrorFromDeclaration<DECLS[number]>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TAction_Any_JsonObject, TNarrowActionJsonTypeToActionInstanceType } from "../ActionDefinition/Action/Action.combined.types";
|
|
2
|
-
import type { INiceActionIdAndDomain } from "../ActionDefinition/Action/ActionBase.types";
|
|
3
|
-
import type { ActionDomain } from "../ActionDefinition/Domain/ActionDomain";
|
|
4
|
-
import type { IActionDomain } from "../ActionDefinition/Domain/ActionDomain.types";
|
|
5
|
-
export declare class ActionDomainManager {
|
|
6
|
-
private _domains;
|
|
7
|
-
addDomain(domain: ActionDomain<any>): void;
|
|
8
|
-
getDomains(): ActionDomain<any>[];
|
|
9
|
-
verifyIsActionJson(action: INiceActionIdAndDomain<any>): void;
|
|
10
|
-
getActionDomain<DOM extends IActionDomain, ACT extends INiceActionIdAndDomain<DOM>>(action: ACT): ActionDomain<DOM> | undefined;
|
|
11
|
-
getActionDomainOrThrow<DOM extends IActionDomain, ACT extends INiceActionIdAndDomain<DOM>>(action: ACT): ActionDomain<DOM>;
|
|
12
|
-
hydrateActionPayload<D extends IActionDomain, ID extends keyof D["actionSchema"] & string, A extends TAction_Any_JsonObject<D, ID>>(actionJson: A): TNarrowActionJsonTypeToActionInstanceType<D, A, ID>;
|
|
13
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { ActionCore } from "../ActionDefinition/Action/Core/ActionCore";
|
|
2
|
-
import type { TActionPayload_Any_Instance } from "../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
3
|
-
import { type TActionPayload_Any_JsonObject } from "../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
4
|
-
import { RunningAction } from "../ActionDefinition/Action/RunningAction";
|
|
5
|
-
import type { ActionDomain } from "../ActionDefinition/Domain/ActionDomain";
|
|
6
|
-
import type { IActionDomain } from "../ActionDefinition/Domain/ActionDomain.types";
|
|
7
|
-
import type { IRuntimeMeta, TActionRuntimeHandler } from "./ActionRuntime.types";
|
|
8
|
-
import { type IHandleActionOptions, type TActionHandler } from "./Handler/ActionHandler.types";
|
|
9
|
-
import { ActionExternalClientHandler } from "./Handler/ExternalClient/ActionExternalClientHandler";
|
|
10
|
-
import type { Transport } from "./Handler/ExternalClient/Transport/Transport";
|
|
11
|
-
import { type IRuntimeCoordinateSpecifics, RuntimeCoordinate } from "./RuntimeCoordinate";
|
|
12
|
-
export declare class ActionRuntime {
|
|
13
|
-
private _coordinate;
|
|
14
|
-
readonly timeCreated: number;
|
|
15
|
-
readonly runtimeInfo: IRuntimeMeta;
|
|
16
|
-
private readonly actionRouter;
|
|
17
|
-
private readonly _pendingRunningActions;
|
|
18
|
-
private readonly _registeredExternalHandlers;
|
|
19
|
-
private _applied;
|
|
20
|
-
static getDefault(): ActionRuntime;
|
|
21
|
-
constructor(coordinate: RuntimeCoordinate);
|
|
22
|
-
get coordinate(): RuntimeCoordinate;
|
|
23
|
-
specifyRuntimeCoordinate(specifics: IRuntimeCoordinateSpecifics & {
|
|
24
|
-
envId?: string;
|
|
25
|
-
}): void;
|
|
26
|
-
registerRunningAction(ra: RunningAction<any, any>): void;
|
|
27
|
-
resolveIncomingActionPayload(json: TActionPayload_Any_JsonObject<any, any>): void;
|
|
28
|
-
/**
|
|
29
|
-
* Handle an incoming action wire (e.g. from a transport layer), route it to
|
|
30
|
-
* the correct handler, and return the response. The most specific handler
|
|
31
|
-
* match is chosen (action-ID-specific beats domain-wildcard).
|
|
32
|
-
*/
|
|
33
|
-
handleActionPayloadWire<D extends IActionDomain, ID extends keyof D["actionSchema"] & string>(wire: TActionPayload_Any_JsonObject<D, ID>): Promise<RunningAction<D, ID>>;
|
|
34
|
-
handleActionPayloadWire(wire: unknown): Promise<RunningAction<any, any>>;
|
|
35
|
-
handleActionPayload<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: TActionPayload_Any_Instance<DOM, ID>, options?: Omit<IHandleActionOptions, "targetLocalRuntime">): Promise<RunningAction<DOM, ID>>;
|
|
36
|
-
getHandlerForActionOrThrow<ACT extends TActionPayload_Any_Instance<any, any>>(action: ACT, options?: Omit<IHandleActionOptions, "localRuntime">): TActionHandler;
|
|
37
|
-
/**
|
|
38
|
-
* Register one or more handlers. Each handler's own `actionRouter` defines
|
|
39
|
-
* which domains/actions it handles — those routing keys are mirrored into
|
|
40
|
-
* this runtime's router so the same action can be served by multiple handlers.
|
|
41
|
-
* Duplicate registrations (same handler cuid for the same key) are skipped.
|
|
42
|
-
*/
|
|
43
|
-
addHandlers(handlers: TActionRuntimeHandler[]): this;
|
|
44
|
-
/**
|
|
45
|
-
* Declare an external "backend client" in one call: build an
|
|
46
|
-
* {@link ActionExternalClientHandler} for `externalCoordinate` carrying the given
|
|
47
|
-
* `transports`, route the listed `domains`/`actions` to it, register it (plus any
|
|
48
|
-
* `localHandlers` — e.g. server→client push handlers that share the same channel)
|
|
49
|
-
* on this runtime, and `apply()`. Returns the external handler so the caller can
|
|
50
|
-
* later `clearTransportCache()` it.
|
|
51
|
-
*
|
|
52
|
-
* Sugar over `new ActionExternalClientHandler(...).forDomain(...)` + `addHandlers([...])`,
|
|
53
|
-
* so a single runtime can host one handler per backend target with its transports
|
|
54
|
-
* declared once and reused across every action routed to that backend.
|
|
55
|
-
*/
|
|
56
|
-
connectTo(externalCoordinate: RuntimeCoordinate, options: {
|
|
57
|
-
transports: Transport[];
|
|
58
|
-
domains?: ActionDomain<any>[];
|
|
59
|
-
actions?: ActionCore<any, any>[];
|
|
60
|
-
localHandlers?: TActionRuntimeHandler[];
|
|
61
|
-
defaultTimeout?: number;
|
|
62
|
-
}): ActionExternalClientHandler;
|
|
63
|
-
private applyRuntimeForDomain;
|
|
64
|
-
/**
|
|
65
|
-
* Register this runtime with all root domains covered by its currently-added handlers,
|
|
66
|
-
* making it eligible to execute actions dispatched from those domains.
|
|
67
|
-
* After apply() is called, any subsequent addHandlers() calls also auto-register.
|
|
68
|
-
*/
|
|
69
|
-
apply(): this;
|
|
70
|
-
/**
|
|
71
|
-
* Find the best registered external handler that can reach `originClient` directly.
|
|
72
|
-
* Used to locate the return-path channel for dispatching results back to the action origin.
|
|
73
|
-
* Returns `undefined` if no handler matches (score > 0 required, i.e. at least id must match).
|
|
74
|
-
*/
|
|
75
|
-
getReturnHandlerForOrigin(originClient: RuntimeCoordinate): ActionExternalClientHandler | undefined;
|
|
76
|
-
resetRuntime(): void;
|
|
77
|
-
private _trySetupReturnDispatch;
|
|
78
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RuntimeName } from "std-env";
|
|
2
|
-
import type { ActionRuntime } from "./ActionRuntime";
|
|
3
|
-
import type { TActionHandler } from "./Handler/ActionHandler.types";
|
|
4
|
-
import type { ActionExternalClientHandler } from "./Handler/ExternalClient/ActionExternalClientHandler";
|
|
5
|
-
import type { ActionLocalHandler } from "./Handler/Local/ActionLocalHandler";
|
|
6
|
-
import type { RuntimeCoordinate } from "./RuntimeCoordinate";
|
|
7
|
-
export interface IRuntimeMeta {
|
|
8
|
-
assumed: boolean;
|
|
9
|
-
runtimeName: RuntimeName;
|
|
10
|
-
}
|
|
11
|
-
export interface IRuntimeEnvironmentMeta {
|
|
12
|
-
client: RuntimeCoordinate;
|
|
13
|
-
runtimeInfo: IRuntimeMeta;
|
|
14
|
-
}
|
|
15
|
-
export interface IActionRuntimeManagerContext {
|
|
16
|
-
domain?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface IActionHandlerAndRuntime {
|
|
19
|
-
handler: TActionHandler;
|
|
20
|
-
runtime: ActionRuntime;
|
|
21
|
-
}
|
|
22
|
-
export type TActionRuntimeHandler = ActionLocalHandler | ActionExternalClientHandler;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { TActionPayload_Any_Instance } from "../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
2
|
-
import type { ActionRuntime } from "./ActionRuntime";
|
|
3
|
-
import type { IActionHandlerAndRuntime, IActionRuntimeManagerContext } from "./ActionRuntime.types";
|
|
4
|
-
import type { IHandleActionOptions } from "./Handler/ActionHandler.types";
|
|
5
|
-
import { type IRuntimeCoordinate } from "./RuntimeCoordinate";
|
|
6
|
-
export declare class ActionRuntimeManager {
|
|
7
|
-
private _runtimes;
|
|
8
|
-
private _preferredRuntimeClientId;
|
|
9
|
-
private _context;
|
|
10
|
-
constructor(context?: IActionRuntimeManagerContext);
|
|
11
|
-
registerRuntime(runtime: ActionRuntime): void;
|
|
12
|
-
getRuntimeAndHandlerForAction(action: TActionPayload_Any_Instance<any, any>, options?: IHandleActionOptions, throwOnIssue?: boolean): IActionHandlerAndRuntime | undefined;
|
|
13
|
-
getRuntimeAndHandlerForActionOrThrow(action: TActionPayload_Any_Instance<any, any>, options?: IHandleActionOptions): IActionHandlerAndRuntime;
|
|
14
|
-
setPreferredRuntime(runtime: ActionRuntime): void;
|
|
15
|
-
getPreferredRuntime(): ActionRuntime | undefined;
|
|
16
|
-
getBestRuntimeForSpecifier(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined;
|
|
17
|
-
getBestRuntime(clientSpecifier?: IRuntimeCoordinate): ActionRuntime | undefined;
|
|
18
|
-
hasRuntime(runtime: ActionRuntime): boolean;
|
|
19
|
-
getBestRuntimeOrThrow(specifier?: IRuntimeCoordinate): ActionRuntime;
|
|
20
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IActionRouteItemHandler } from "../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
2
|
-
import type { ActionPayload_Request } from "../../ActionDefinition/Action/Payload/ActionPayload_Request";
|
|
3
|
-
import type { RunningAction } from "../../ActionDefinition/Action/RunningAction";
|
|
4
|
-
import type { IActionDomain } from "../../ActionDefinition/Domain/ActionDomain.types";
|
|
5
|
-
import { ActionRouter } from "../Routing/ActionRouter";
|
|
6
|
-
import type { EActionHandlerType, IActionHandler_Base, IHandleActionOptions, TActionHandler_Json } from "./ActionHandler.types";
|
|
7
|
-
export declare abstract class ActionHandler<T extends EActionHandlerType> implements IActionHandler_Base<T> {
|
|
8
|
-
abstract readonly handlerType: T;
|
|
9
|
-
readonly cuid: string;
|
|
10
|
-
abstract readonly actionRouter: ActionRouter<any>;
|
|
11
|
-
constructor();
|
|
12
|
-
getActionRouter(): ActionRouter<any>;
|
|
13
|
-
abstract handleActionRequest<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions): Promise<RunningAction<DOM, ID>>;
|
|
14
|
-
abstract toJsonObject(): TActionHandler_Json;
|
|
15
|
-
abstract toHandlerRouteItem(...args: any[]): IActionRouteItemHandler;
|
|
16
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { TActionPayload_Any_JsonObject } from "../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
2
|
-
import type { ActionPayload_Request } from "../../ActionDefinition/Action/Payload/ActionPayload_Request";
|
|
3
|
-
import type { RunningAction } from "../../ActionDefinition/Action/RunningAction";
|
|
4
|
-
import type { TRunningActionUpdateListener } from "../../ActionDefinition/Action/RunningAction.types";
|
|
5
|
-
import type { IActionDomain } from "../../ActionDefinition/Domain/ActionDomain.types";
|
|
6
|
-
import type { ActionRuntime } from "../ActionRuntime";
|
|
7
|
-
import type { ActionRouter } from "../Routing/ActionRouter";
|
|
8
|
-
import type { IRuntimeCoordinate, RuntimeCoordinate } from "../RuntimeCoordinate";
|
|
9
|
-
export declare enum EActionHandlerType {
|
|
10
|
-
external = "external",
|
|
11
|
-
local = "local"
|
|
12
|
-
}
|
|
13
|
-
export interface IActionHandler_Json<T extends EActionHandlerType> {
|
|
14
|
-
type: T;
|
|
15
|
-
}
|
|
16
|
-
export interface IActionHandler_ExternalClient_Json extends IActionHandler_Json<EActionHandlerType.external> {
|
|
17
|
-
client: IRuntimeCoordinate;
|
|
18
|
-
}
|
|
19
|
-
export interface IActionHandler_Local_Json extends IActionHandler_Json<EActionHandlerType.local> {
|
|
20
|
-
}
|
|
21
|
-
export type TActionHandler_Json = IActionHandler_Local_Json | IActionHandler_ExternalClient_Json;
|
|
22
|
-
export interface IHandleActionOptions {
|
|
23
|
-
timeout?: number;
|
|
24
|
-
targetExternalClient?: RuntimeCoordinate;
|
|
25
|
-
targetLocalRuntime?: ActionRuntime;
|
|
26
|
-
}
|
|
27
|
-
export interface IExecuteActionOptions<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IHandleActionOptions {
|
|
28
|
-
listeners?: TRunningActionUpdateListener<DOM, ID>[];
|
|
29
|
-
}
|
|
30
|
-
export type TAtLeastOne<T extends object> = {
|
|
31
|
-
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Omit<T, K>>;
|
|
32
|
-
}[keyof T];
|
|
33
|
-
export interface IActionHandler_Base<T extends EActionHandlerType> {
|
|
34
|
-
cuid: string;
|
|
35
|
-
handlerType: T;
|
|
36
|
-
getActionRouter: () => ActionRouter<any>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* LOCAL ACTION HANDLER
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
export interface IHandleActionOptions_Local extends IHandleActionOptions {
|
|
44
|
-
}
|
|
45
|
-
export interface IActionHandler_Local extends IActionHandler_Base<EActionHandlerType.local> {
|
|
46
|
-
handleActionRequest: <DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions_Local) => Promise<RunningAction<DOM, ID>>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* EXTERNAL CLIENT ACTION HANDLER
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export interface IHandleActionOptions_External extends IHandleActionOptions {
|
|
54
|
-
}
|
|
55
|
-
export interface IActionHandler_ExternalClient extends IActionHandler_Base<EActionHandlerType.external> {
|
|
56
|
-
externalClient: RuntimeCoordinate;
|
|
57
|
-
handleActionRequest: <DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions_External) => Promise<RunningAction<DOM, ID>>;
|
|
58
|
-
_setIncomingActionDataListener(listener: (json: TActionPayload_Any_JsonObject<any>) => void): void;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* COMBINED
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
export type TActionHandler = IActionHandler_Local | IActionHandler_ExternalClient;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ActionCore } from "../../../ActionDefinition/Action/Core/ActionCore";
|
|
2
|
-
import type { IActionRouteItemHandler, TActionPayload_Any_Instance, TActionPayload_Any_JsonObject } from "../../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
3
|
-
import type { ActionPayload_Request } from "../../../ActionDefinition/Action/Payload/ActionPayload_Request";
|
|
4
|
-
import { RunningAction } from "../../../ActionDefinition/Action/RunningAction";
|
|
5
|
-
import type { ActionDomain } from "../../../ActionDefinition/Domain/ActionDomain";
|
|
6
|
-
import type { IActionDomain } from "../../../ActionDefinition/Domain/ActionDomain.types";
|
|
7
|
-
import { ActionRuntime } from "../../ActionRuntime";
|
|
8
|
-
import { ActionRouter } from "../../Routing/ActionRouter";
|
|
9
|
-
import { RuntimeCoordinate } from "../../RuntimeCoordinate";
|
|
10
|
-
import { ActionHandler } from "../ActionHandler";
|
|
11
|
-
import { EActionHandlerType, type IActionHandler_ExternalClient, type IActionHandler_ExternalClient_Json, type IHandleActionOptions } from "../ActionHandler.types";
|
|
12
|
-
import type { IActionExternalClientRequestHandlerConfig } from "./ActionExternalClientHandler.types";
|
|
13
|
-
import { type ITransportRouteActionParams } from "./Transport/Transport.types";
|
|
14
|
-
import type { TransportConnection } from "./Transport/TransportConnection";
|
|
15
|
-
export declare class ActionExternalClientHandler extends ActionHandler<EActionHandlerType.external> implements IActionHandler_ExternalClient {
|
|
16
|
-
readonly externalClient: RuntimeCoordinate;
|
|
17
|
-
readonly handlerType = EActionHandlerType.external;
|
|
18
|
-
readonly cuid: string;
|
|
19
|
-
private _defaultTimeout;
|
|
20
|
-
private _transportCache;
|
|
21
|
-
private transportManager;
|
|
22
|
-
private _incomingActionDataListeners;
|
|
23
|
-
readonly actionRouter: ActionRouter<true>;
|
|
24
|
-
constructor({ runtimeCoordinate: externalClientSpecifier, transports, defaultTimeout, }: IActionExternalClientRequestHandlerConfig);
|
|
25
|
-
forDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>): this;
|
|
26
|
-
forAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actionSchema"] & string>(action: ActionCore<ACT_DOM, ID>): this;
|
|
27
|
-
forActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actionSchema"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS): this;
|
|
28
|
-
_setIncomingActionDataListener(listener: (json: TActionPayload_Any_JsonObject<any, any>) => void): void;
|
|
29
|
-
handleActionRequest<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions): Promise<RunningAction<DOM, ID>>;
|
|
30
|
-
private _dispatchWhenTransportReady;
|
|
31
|
-
/**
|
|
32
|
-
* Dispatch a result or progress payload directly back to the external client via the best
|
|
33
|
-
* available bidirectional transport (WebSocket / Custom). Used for return-path routing when the
|
|
34
|
-
* local runtime recognises that it has a direct channel to the action's originClient.
|
|
35
|
-
*
|
|
36
|
-
* Returns `true` if the payload was sent, `false` if no suitable transport was available.
|
|
37
|
-
*/
|
|
38
|
-
sendReturnPayload(payload: TActionPayload_Any_Instance<any, any>, config: {
|
|
39
|
-
targetLocalRuntime: ActionRuntime;
|
|
40
|
-
}): Promise<boolean>;
|
|
41
|
-
toJsonObject(): IActionHandler_ExternalClient_Json;
|
|
42
|
-
toHandlerRouteItem(transport: TransportConnection, input: ITransportRouteActionParams): IActionRouteItemHandler;
|
|
43
|
-
clearTransportCache(): void;
|
|
44
|
-
}
|
|
45
|
-
export declare const createExternalClientHandler: (config: IActionExternalClientRequestHandlerConfig) => ActionExternalClientHandler;
|
package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RuntimeCoordinate } from "../../RuntimeCoordinate";
|
|
2
|
-
import type { Transport } from "./Transport/Transport";
|
|
3
|
-
export interface IActionExternalClientRequestHandlerConfig {
|
|
4
|
-
defaultTimeout?: number;
|
|
5
|
-
runtimeCoordinate: RuntimeCoordinate;
|
|
6
|
-
transports: Transport[];
|
|
7
|
-
}
|