@nice-code/action 0.1.2 → 0.2.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/README.md +1 -410
- package/build/index.js +5176 -1970
- package/build/react-query/index.js +7 -7
- package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +27 -0
- package/build/types/ActionDefinition/Action/ActionBase.d.ts +14 -0
- package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +24 -0
- package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +26 -0
- package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +35 -0
- package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +20 -0
- package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +10 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +14 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +106 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +15 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +24 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +18 -0
- package/build/types/ActionDefinition/Action/RunningAction.d.ts +33 -0
- package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +65 -0
- package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +30 -0
- package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +37 -0
- package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +14 -0
- package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +23 -0
- package/build/types/ActionDefinition/Domain/helpers/createRootActionDomain.d.ts +5 -0
- package/build/types/{ActionSchema/NiceActionSchema.d.ts → ActionDefinition/Schema/ActionSchema.d.ts} +10 -29
- package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +32 -0
- package/build/types/ActionRuntime/ActionDomainManager.d.ts +13 -0
- package/build/types/ActionRuntime/ActionRuntime.d.ts +48 -0
- package/build/types/ActionRuntime/ActionRuntime.types.d.ts +22 -0
- package/build/types/ActionRuntime/ActionRuntimeManager.d.ts +19 -0
- package/build/types/ActionRuntime/Client/ActionClientSpecifier.d.ts +47 -0
- package/build/types/ActionRuntime/Client/utils/clientSpecifierToStringIds.d.ts +2 -0
- package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +16 -0
- package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +68 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +42 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +7 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +9 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.d.ts +7 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.types.d.ts +11 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.d.ts +8 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +17 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.combined.types.d.ts +4 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +13 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +106 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.d.ts +13 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +13 -0
- package/build/types/{ActionRuntimeEnvironment/ActionConnect → ActionRuntime/Handler/ExternalClient}/Transport/err_nice_transport.d.ts +5 -7
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.d.ts +2 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.d.ts +2 -0
- package/build/types/ActionRuntime/Handler/ExternalClient/err_nice_external_client.d.ts +5 -0
- package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +55 -0
- package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +6 -0
- package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +55 -0
- package/build/types/ActionRuntime/Routing/ActionRouter.types.d.ts +20 -0
- package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +301 -0
- package/build/types/errors/err_nice_action.d.ts +22 -12
- package/build/types/index.d.ts +31 -32
- package/build/types/nice_action.static.d.ts +3 -0
- package/build/types/react-query/index.d.ts +9 -10
- package/build/types/utils/assertIsActionJson.d.ts +2 -0
- package/build/types/utils/getAssumedRuntimeEnvironment.d.ts +2 -0
- package/build/types/utils/isActionPayload_Any_JsonObject.d.ts +2 -0
- package/build/types/utils/isActionPayload_Progress_JsonObject.d.ts +2 -0
- package/build/types/utils/isActionPayload_Request_JsonObject.d.ts +2 -0
- package/build/types/utils/isActionPayload_Result_JsonObject.d.ts +2 -0
- package/build/types/utils/isAction_Any_Instance.d.ts +3 -0
- package/build/types/utils/isAction_Any_JsonObject.d.ts +2 -0
- package/build/types/utils/isAction_Base_JsonObject.d.ts +2 -0
- package/build/types/utils/isAction_Context_JsonObject.d.ts +2 -0
- package/build/types/utils/isAction_Core_JsonObject.d.ts +2 -0
- package/build/types/utils/wait.utils.d.ts +13 -0
- package/package.json +3 -3
- package/build/types/ActionDomain/NiceActionDomain.d.ts +0 -40
- package/build/types/ActionDomain/NiceActionDomain.types.d.ts +0 -37
- package/build/types/ActionDomain/NiceActionDomainBase.d.ts +0 -14
- package/build/types/ActionDomain/RootDomain/NiceActionRootDomain.d.ts +0 -22
- package/build/types/ActionDomain/helpers/createRootActionDomain.d.ts +0 -5
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ActionConnect.d.ts +0 -24
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ActionConnect.types.d.ts +0 -15
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ConnectionConfig/ConnectionConfig.d.ts +0 -12
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ConnectionConfig/ConnectionConfig.types.d.ts +0 -6
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/Transport.d.ts +0 -19
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/Transport.types.d.ts +0 -70
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/TransportCustom.d.ts +0 -12
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/TransportHttp.d.ts +0 -9
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/TransportWebSocket.d.ts +0 -17
- package/build/types/ActionRuntimeEnvironment/ActionConnect/err_nice_connect.d.ts +0 -5
- package/build/types/ActionRuntimeEnvironment/ActionHandler/ActionHandler.d.ts +0 -80
- package/build/types/ActionRuntimeEnvironment/ActionHandler/ActionHandler.types.d.ts +0 -69
- package/build/types/ActionRuntimeEnvironment/ActionRuntimeEnvironment.d.ts +0 -32
- package/build/types/ActionRuntimeEnvironment/ActionRuntimeEnvironment.types.d.ts +0 -15
- package/build/types/ActionRuntimeEnvironment/utils/getAssumedRuntimeEnvironment.d.ts +0 -2
- package/build/types/ActionSchema/NiceActionSchema.types.d.ts +0 -32
- package/build/types/ActionSchema/action.d.ts +0 -2
- package/build/types/NiceAction/MatchAction/MatchAction.d.ts +0 -27
- package/build/types/NiceAction/NiceAction.d.ts +0 -64
- package/build/types/NiceAction/NiceAction.enums.d.ts +0 -5
- package/build/types/NiceAction/NiceAction.types.d.ts +0 -78
- package/build/types/NiceAction/NiceActionCombined.types.d.ts +0 -10
- package/build/types/NiceAction/NiceActionPrimed.d.ts +0 -43
- package/build/types/NiceAction/NiceActionResponse.d.ts +0 -42
- package/build/types/NiceAction/utils/isNiceActionInstance.d.ts +0 -3
- package/build/types/utils/isActionResponseJsonObject.d.ts +0 -2
- package/build/types/utils/isPrimedActionJsonObject.d.ts +0 -2
- /package/build/types/{ActionRuntimeEnvironment/ActionConnect → ActionRuntime/Handler/ExternalClient}/Transport/err_nice_transport_ws.d.ts +0 -0
- /package/build/types/utils/{maybePromise.d.ts → typescript/MaybePromise.d.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IActionPayload_Request_JsonObject, IActionPayload_Result_JsonObject } from "../../../../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
2
|
+
import type { ETransportType, IActionTransportDef, IActionTransportInitialized, IActionTransportReadyData_Base, ITransportRouteActionParams } from "../Transport.types";
|
|
3
|
+
export interface IActionTransportReadyData_Ws extends IActionTransportReadyData_Base {
|
|
4
|
+
formatMessage?: {
|
|
5
|
+
outgoing: (input: ITransportRouteActionParams) => string;
|
|
6
|
+
incoming?: (input: string) => IActionPayload_Result_JsonObject<any> | IActionPayload_Request_JsonObject<any> | undefined;
|
|
7
|
+
};
|
|
8
|
+
ws: WebSocket;
|
|
9
|
+
}
|
|
10
|
+
export interface IActionTransportInitialized_Ws extends IActionTransportInitialized<ITransportRouteActionParams, IActionTransportReadyData_Ws> {
|
|
11
|
+
}
|
|
12
|
+
export interface IActionTransportDef_Ws extends IActionTransportDef<ETransportType.ws, IActionTransportInitialized_Ws> {
|
|
13
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ETransportType } from "./Transport.types";
|
|
1
2
|
export declare enum EErrId_NiceTransport {
|
|
2
3
|
timeout = "timeout",
|
|
3
4
|
not_found = "not_found",
|
|
4
|
-
|
|
5
|
+
unsupported = "unsupported",
|
|
5
6
|
initialization_failed = "initialization_failed",
|
|
6
7
|
send_failed = "send_failed",
|
|
7
8
|
invalid_action_response = "invalid_action_response"
|
|
@@ -15,18 +16,15 @@ export declare const err_nice_transport: import("@nice-code/error").NiceErrorDom
|
|
|
15
16
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
16
17
|
not_found: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
17
18
|
actionId: string;
|
|
18
|
-
routeKey?: string;
|
|
19
|
-
tag?: string;
|
|
20
19
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
unsupported: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
21
|
+
transportTypes: ETransportType[];
|
|
23
22
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
24
23
|
initialization_failed: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
25
24
|
actionId: string;
|
|
26
|
-
routeKey?: string;
|
|
27
|
-
tag?: string;
|
|
28
25
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
29
26
|
send_failed: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
27
|
+
actionState: string;
|
|
30
28
|
actionId: string;
|
|
31
29
|
httpStatusCode?: number;
|
|
32
30
|
message?: string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { type IActionTransportReadyData_Base, type TTransportStatusInfo, type TTransportStatusInfo_GetTransport_Output } from "../Transport.types";
|
|
2
|
+
export declare function addTransportStatusMetadata<READY extends IActionTransportReadyData_Base>(transportStatus: TTransportStatusInfo_GetTransport_Output<READY>): TTransportStatusInfo<READY>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ActionCore } from "../../../ActionDefinition/Action/Core/ActionCore";
|
|
2
|
+
import type { IActionRouteItemHandler } from "../../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
3
|
+
import { 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 { ActionRouter } from "../../Routing/ActionRouter";
|
|
8
|
+
import { ActionHandler } from "../ActionHandler";
|
|
9
|
+
import { EActionHandlerType, type IActionHandler_Local, type IActionHandler_Local_Json, type IHandleActionOptions } from "../ActionHandler.types";
|
|
10
|
+
import type { THandleActionExecutionFn } from "./ActionLocalHandler.types";
|
|
11
|
+
export declare class ActionLocalHandler extends ActionHandler<EActionHandlerType.local> implements IActionHandler_Local {
|
|
12
|
+
readonly handlerType = EActionHandlerType.local;
|
|
13
|
+
readonly actionRouter: ActionRouter<THandleActionExecutionFn<any, any>>;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Register a handler for all actions in a domain.
|
|
17
|
+
* Receives the full primed action — use `matchAction()` to narrow to a specific action id.
|
|
18
|
+
* Useful for forwarding all domain actions to a remote endpoint.
|
|
19
|
+
* Lower priority than `forAction`.
|
|
20
|
+
*/
|
|
21
|
+
forDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, handler: THandleActionExecutionFn<FOR_DOM>): this;
|
|
22
|
+
/**
|
|
23
|
+
* Register a handler for a base action instance. Takes priority over domain-wide handlers.
|
|
24
|
+
* Receives the full primed action with narrowed input type.
|
|
25
|
+
* Useful for handling specific actions locally while forwarding the rest of the domain. For example, a local "ping" action that checks connectivity without needing a round trip.
|
|
26
|
+
*/
|
|
27
|
+
forAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actions"] & string>(action: ActionCore<ACT_DOM, ID>, handler: THandleActionExecutionFn<ACT_DOM, ID>): this;
|
|
28
|
+
/**
|
|
29
|
+
* Register a handler for multiple action IDs (first-match-wins among cases).
|
|
30
|
+
* Receives the full primed action narrowed to the union of those IDs.
|
|
31
|
+
* Use `act.coreAction.id` to branch on which action was dispatched.
|
|
32
|
+
*/
|
|
33
|
+
forActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actions"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS, handler: THandleActionExecutionFn<ACT_DOM, IDS[number]>): this;
|
|
34
|
+
/**
|
|
35
|
+
* Register per-action handlers for a domain using a single map, without needing
|
|
36
|
+
* separate `forAction` calls. Unregistered action IDs are unaffected.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* handler.forDomainActionCases(userDomain, {
|
|
41
|
+
* getUser: (primed) => db.getUser(primed.input.userId),
|
|
42
|
+
* deleteUser: (primed) => db.deleteUser(primed.input.userId),
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
forDomainActionCases<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, cases: {
|
|
47
|
+
[ID in keyof FOR_DOM["actions"] & string]?: THandleActionExecutionFn<FOR_DOM, ID>;
|
|
48
|
+
}): this;
|
|
49
|
+
handleActionRequest<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string>(action: ActionPayload_Request<DOM, ID>, config?: IHandleActionOptions): Promise<RunningAction<DOM, ID>>;
|
|
50
|
+
private _handleRunningAction;
|
|
51
|
+
handlePayloadWireOrThrow(wire: unknown, config?: IHandleActionOptions): Promise<RunningAction<any, any>>;
|
|
52
|
+
toJsonObject(): IActionHandler_Local_Json;
|
|
53
|
+
toHandlerRouteItem(): IActionRouteItemHandler;
|
|
54
|
+
}
|
|
55
|
+
export declare const createLocalHandler: () => ActionLocalHandler;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MaybePromise } from "bun";
|
|
2
|
+
import type { IActionPayload_Result_JsonObject } from "../../../ActionDefinition/Action/Payload/ActionPayload.types";
|
|
3
|
+
import type { ActionPayload_Request } from "../../../ActionDefinition/Action/Payload/ActionPayload_Request";
|
|
4
|
+
import type { ActionPayload_Result } from "../../../ActionDefinition/Action/Payload/ActionPayload_Result";
|
|
5
|
+
import type { IActionDomain, TInferOutputFromSchema } from "../../../ActionDefinition/Domain/ActionDomain.types";
|
|
6
|
+
export type THandleActionExecutionFn<DOM extends IActionDomain, ID extends keyof DOM["actions"] & string = keyof DOM["actions"] & string> = (action: ActionPayload_Request<DOM, ID>) => MaybePromise<ActionPayload_Result<DOM, ID> | IActionPayload_Result_JsonObject<DOM, ID> | TInferOutputFromSchema<DOM["actions"][ID]>["Output"] | undefined>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { INiceActionIdAndDomain } from "../../ActionDefinition/Action/ActionBase.types";
|
|
2
|
+
import type { ActionCore } from "../../ActionDefinition/Action/Core/ActionCore";
|
|
3
|
+
import type { ActionDomain } from "../../ActionDefinition/Domain/ActionDomain";
|
|
4
|
+
import type { IActionDomain } from "../../ActionDefinition/Domain/ActionDomain.types";
|
|
5
|
+
import { ActionDomainManager } from "../ActionDomainManager";
|
|
6
|
+
import type { IHandleActionOptions } from "../Handler/ActionHandler.types";
|
|
7
|
+
import { type IActionRouterContext, type TMatchHandlerKey } from "./ActionRouter.types";
|
|
8
|
+
export declare class ActionRouter<DATA> {
|
|
9
|
+
readonly domainManager: ActionDomainManager;
|
|
10
|
+
private actionRouteData;
|
|
11
|
+
private _context;
|
|
12
|
+
constructor(context: IActionRouterContext);
|
|
13
|
+
/** Copy all routes from another router into this one, replacing any overlapping keys. */
|
|
14
|
+
mergeRouter(actionRouter: ActionRouter<DATA>): void;
|
|
15
|
+
addDomainsFromOther(actionRouter: ActionRouter<DATA>): void;
|
|
16
|
+
/** All FNs registered for an action, ID-specific entries first then domain wildcard. */
|
|
17
|
+
getRouteDataEntriesForAction(action: {
|
|
18
|
+
domain: string;
|
|
19
|
+
id: string;
|
|
20
|
+
}): DATA[];
|
|
21
|
+
/** First FN registered for an action (ID-specific beats domain wildcard). */
|
|
22
|
+
getRouteDataForAction(action: INiceActionIdAndDomain): DATA | undefined;
|
|
23
|
+
private throwNoHandlerForAction;
|
|
24
|
+
getRouteDataEntriesForActionOrThrow(action: INiceActionIdAndDomain, context: IHandleActionOptions): DATA[];
|
|
25
|
+
getRouteDataForActionOrThrow(action: INiceActionIdAndDomain, context: IHandleActionOptions): DATA;
|
|
26
|
+
/** All FNs stored under an exact match key. */
|
|
27
|
+
getForKey(key: TMatchHandlerKey): readonly DATA[];
|
|
28
|
+
/** Every match key that has at least one registered FN. */
|
|
29
|
+
getRegisteredKeys(): TMatchHandlerKey[];
|
|
30
|
+
getDomains(): ActionDomain[];
|
|
31
|
+
/** Register a handler for all actions in a domain, replacing any existing one. */
|
|
32
|
+
forDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, routeData: DATA): this;
|
|
33
|
+
forAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actions"] & string>(action: ActionCore<ACT_DOM, ID>, routeData: DATA): this;
|
|
34
|
+
/** Register a handler for a specific action, replacing any existing one. */
|
|
35
|
+
forActionId<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actions"] & string>(domain: ActionDomain<ACT_DOM>, id: ID, routeData: DATA): this;
|
|
36
|
+
/** Register one handler for several action IDs, replacing any existing ones. */
|
|
37
|
+
forActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actions"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS, routeData: DATA): this;
|
|
38
|
+
/** Register per-action handlers from a cases map, replacing any existing ones. */
|
|
39
|
+
forDomainActionCases<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, cases: {
|
|
40
|
+
[ID in keyof FOR_DOM["actions"] & string]?: DATA;
|
|
41
|
+
}): this;
|
|
42
|
+
/** Append a handler for all actions in a domain (accumulates alongside existing). */
|
|
43
|
+
addForDomain<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, routeData: DATA): this;
|
|
44
|
+
/** Append a handler for a specific action (accumulates alongside existing). */
|
|
45
|
+
addForAction<ACT_DOM extends IActionDomain, ID extends keyof ACT_DOM["actions"] & string>(domain: ActionDomain<ACT_DOM>, id: ID, routeData: DATA): this;
|
|
46
|
+
/** Append one handler for several action IDs (accumulates alongside existing). */
|
|
47
|
+
addForActionIds<ACT_DOM extends IActionDomain, IDS extends ReadonlyArray<keyof ACT_DOM["actions"] & string>>(domain: ActionDomain<ACT_DOM>, ids: IDS, routeData: DATA): this;
|
|
48
|
+
/** Append per-action handlers from a cases map (accumulates alongside existing). */
|
|
49
|
+
addForDomainActionCases<FOR_DOM extends IActionDomain>(domain: ActionDomain<FOR_DOM>, cases: {
|
|
50
|
+
[ID in keyof FOR_DOM["actions"] & string]?: DATA;
|
|
51
|
+
}): this;
|
|
52
|
+
/** Append a handler directly by its raw match key (used when the key is known ahead of time). */
|
|
53
|
+
addForKey(key: TMatchHandlerKey, routeData: DATA): this;
|
|
54
|
+
private _push;
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ActionRuntime } from "../ActionRuntime";
|
|
2
|
+
import type { TActionHandler } from "../Handler/ActionHandler.types";
|
|
3
|
+
/**
|
|
4
|
+
* Format: `dom[${domainName}]id[${actionId | "_"}]`
|
|
5
|
+
* The wildcard `_` matches any action ID within a domain.
|
|
6
|
+
*/
|
|
7
|
+
export type TMatchHandlerKey = `${"dom"}[${string}]id[${string | "_"}]`;
|
|
8
|
+
export declare enum EActionRouterContextType {
|
|
9
|
+
runtime_to_handler = "runtime_to_handler",
|
|
10
|
+
handler_route = "handler_route"
|
|
11
|
+
}
|
|
12
|
+
export interface IActionRouterContext_HandlerRoute {
|
|
13
|
+
contextType: EActionRouterContextType.handler_route;
|
|
14
|
+
handler: TActionHandler;
|
|
15
|
+
}
|
|
16
|
+
export interface IActionRouterContext_RuntimeToHandler {
|
|
17
|
+
contextType: EActionRouterContextType.runtime_to_handler;
|
|
18
|
+
runtime: ActionRuntime;
|
|
19
|
+
}
|
|
20
|
+
export type IActionRouterContext = IActionRouterContext_HandlerRoute | IActionRouterContext_RuntimeToHandler;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { ActionRuntime } from "../../ActionRuntime";
|
|
2
|
+
import { type ActionExternalClientHandler } from "../../Handler/ExternalClient/ActionExternalClientHandler";
|
|
3
|
+
import type { IActionTransportDef_Custom } from "../../Handler/ExternalClient/Transport/Custom/TransportCustom.types";
|
|
4
|
+
import { type ActionLocalHandler } from "../../Handler/Local/ActionLocalHandler";
|
|
5
|
+
export declare function _test_initializeCustomTransport(externalClientRuntime: ActionRuntime): IActionTransportDef_Custom["initialize"];
|
|
6
|
+
export declare function _test_createActions(): {
|
|
7
|
+
domains: {
|
|
8
|
+
root: import("../../..").ActionRootDomain<import("../../..").IActionRootDomain<"test_root">>;
|
|
9
|
+
test_dom_user: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
10
|
+
domain: string;
|
|
11
|
+
actions: {
|
|
12
|
+
sign_in: import("../../..").ActionSchema<[{
|
|
13
|
+
username: string;
|
|
14
|
+
password: string;
|
|
15
|
+
}] | [{
|
|
16
|
+
username: string;
|
|
17
|
+
password: string;
|
|
18
|
+
}, never], [{
|
|
19
|
+
success: boolean;
|
|
20
|
+
}] | [{
|
|
21
|
+
success: boolean;
|
|
22
|
+
}, any], readonly []>;
|
|
23
|
+
};
|
|
24
|
+
}>>;
|
|
25
|
+
test_dom_edit_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
26
|
+
domain: string;
|
|
27
|
+
actions: {
|
|
28
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
29
|
+
docId: string;
|
|
30
|
+
newContent: string;
|
|
31
|
+
}] | [{
|
|
32
|
+
docId: string;
|
|
33
|
+
newContent: string;
|
|
34
|
+
}, never], [{
|
|
35
|
+
success: boolean;
|
|
36
|
+
}] | [{
|
|
37
|
+
success: boolean;
|
|
38
|
+
}, any], readonly []>;
|
|
39
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
40
|
+
docId: string;
|
|
41
|
+
}] | [{
|
|
42
|
+
docId: string;
|
|
43
|
+
}, never], [{
|
|
44
|
+
content: string;
|
|
45
|
+
}] | [{
|
|
46
|
+
content: string;
|
|
47
|
+
}, any], readonly []>;
|
|
48
|
+
};
|
|
49
|
+
}>>;
|
|
50
|
+
test_dom_push_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
51
|
+
domain: string;
|
|
52
|
+
actions: {
|
|
53
|
+
push_doc_update: import("../../..").ActionSchema<[{
|
|
54
|
+
docId: string;
|
|
55
|
+
updateContent: string;
|
|
56
|
+
}] | [{
|
|
57
|
+
docId: string;
|
|
58
|
+
updateContent: string;
|
|
59
|
+
}, never], [{
|
|
60
|
+
updated: boolean;
|
|
61
|
+
}] | [{
|
|
62
|
+
updated: boolean;
|
|
63
|
+
}, any], readonly []>;
|
|
64
|
+
};
|
|
65
|
+
}>>;
|
|
66
|
+
};
|
|
67
|
+
actions: {
|
|
68
|
+
action_user_sign_in: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
69
|
+
domain: string;
|
|
70
|
+
actions: {
|
|
71
|
+
sign_in: import("../../..").ActionSchema<[{
|
|
72
|
+
username: string;
|
|
73
|
+
password: string;
|
|
74
|
+
}] | [{
|
|
75
|
+
username: string;
|
|
76
|
+
password: string;
|
|
77
|
+
}, never], [{
|
|
78
|
+
success: boolean;
|
|
79
|
+
}] | [{
|
|
80
|
+
success: boolean;
|
|
81
|
+
}, any], readonly []>;
|
|
82
|
+
};
|
|
83
|
+
}>, "sign_in">;
|
|
84
|
+
action_edit_doc_edit: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
85
|
+
domain: string;
|
|
86
|
+
actions: {
|
|
87
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
88
|
+
docId: string;
|
|
89
|
+
newContent: string;
|
|
90
|
+
}] | [{
|
|
91
|
+
docId: string;
|
|
92
|
+
newContent: string;
|
|
93
|
+
}, never], [{
|
|
94
|
+
success: boolean;
|
|
95
|
+
}] | [{
|
|
96
|
+
success: boolean;
|
|
97
|
+
}, any], readonly []>;
|
|
98
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
99
|
+
docId: string;
|
|
100
|
+
}] | [{
|
|
101
|
+
docId: string;
|
|
102
|
+
}, never], [{
|
|
103
|
+
content: string;
|
|
104
|
+
}] | [{
|
|
105
|
+
content: string;
|
|
106
|
+
}, any], readonly []>;
|
|
107
|
+
};
|
|
108
|
+
}>, "edit_doc">;
|
|
109
|
+
action_edit_doc_get: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
110
|
+
domain: string;
|
|
111
|
+
actions: {
|
|
112
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
113
|
+
docId: string;
|
|
114
|
+
newContent: string;
|
|
115
|
+
}] | [{
|
|
116
|
+
docId: string;
|
|
117
|
+
newContent: string;
|
|
118
|
+
}, never], [{
|
|
119
|
+
success: boolean;
|
|
120
|
+
}] | [{
|
|
121
|
+
success: boolean;
|
|
122
|
+
}, any], readonly []>;
|
|
123
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
124
|
+
docId: string;
|
|
125
|
+
}] | [{
|
|
126
|
+
docId: string;
|
|
127
|
+
}, never], [{
|
|
128
|
+
content: string;
|
|
129
|
+
}] | [{
|
|
130
|
+
content: string;
|
|
131
|
+
}, any], readonly []>;
|
|
132
|
+
};
|
|
133
|
+
}>, "get_doc">;
|
|
134
|
+
action_push_doc_update: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
135
|
+
domain: string;
|
|
136
|
+
actions: {
|
|
137
|
+
push_doc_update: import("../../..").ActionSchema<[{
|
|
138
|
+
docId: string;
|
|
139
|
+
updateContent: string;
|
|
140
|
+
}] | [{
|
|
141
|
+
docId: string;
|
|
142
|
+
updateContent: string;
|
|
143
|
+
}, never], [{
|
|
144
|
+
updated: boolean;
|
|
145
|
+
}] | [{
|
|
146
|
+
updated: boolean;
|
|
147
|
+
}, any], readonly []>;
|
|
148
|
+
};
|
|
149
|
+
}>, "push_doc_update">;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export declare const _test_createTestActionRuntimeData: () => {
|
|
153
|
+
domains: {
|
|
154
|
+
root: import("../../..").ActionRootDomain<import("../../..").IActionRootDomain<"test_root">>;
|
|
155
|
+
test_dom_user: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
156
|
+
domain: string;
|
|
157
|
+
actions: {
|
|
158
|
+
sign_in: import("../../..").ActionSchema<[{
|
|
159
|
+
username: string;
|
|
160
|
+
password: string;
|
|
161
|
+
}] | [{
|
|
162
|
+
username: string;
|
|
163
|
+
password: string;
|
|
164
|
+
}, never], [{
|
|
165
|
+
success: boolean;
|
|
166
|
+
}] | [{
|
|
167
|
+
success: boolean;
|
|
168
|
+
}, any], readonly []>;
|
|
169
|
+
};
|
|
170
|
+
}>>;
|
|
171
|
+
test_dom_edit_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
172
|
+
domain: string;
|
|
173
|
+
actions: {
|
|
174
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
175
|
+
docId: string;
|
|
176
|
+
newContent: string;
|
|
177
|
+
}] | [{
|
|
178
|
+
docId: string;
|
|
179
|
+
newContent: string;
|
|
180
|
+
}, never], [{
|
|
181
|
+
success: boolean;
|
|
182
|
+
}] | [{
|
|
183
|
+
success: boolean;
|
|
184
|
+
}, any], readonly []>;
|
|
185
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
186
|
+
docId: string;
|
|
187
|
+
}] | [{
|
|
188
|
+
docId: string;
|
|
189
|
+
}, never], [{
|
|
190
|
+
content: string;
|
|
191
|
+
}] | [{
|
|
192
|
+
content: string;
|
|
193
|
+
}, any], readonly []>;
|
|
194
|
+
};
|
|
195
|
+
}>>;
|
|
196
|
+
test_dom_push_doc: import("../../..").ActionDomain<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
197
|
+
domain: string;
|
|
198
|
+
actions: {
|
|
199
|
+
push_doc_update: import("../../..").ActionSchema<[{
|
|
200
|
+
docId: string;
|
|
201
|
+
updateContent: string;
|
|
202
|
+
}] | [{
|
|
203
|
+
docId: string;
|
|
204
|
+
updateContent: string;
|
|
205
|
+
}, never], [{
|
|
206
|
+
updated: boolean;
|
|
207
|
+
}] | [{
|
|
208
|
+
updated: boolean;
|
|
209
|
+
}, any], readonly []>;
|
|
210
|
+
};
|
|
211
|
+
}>>;
|
|
212
|
+
};
|
|
213
|
+
actions: {
|
|
214
|
+
action_user_sign_in: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
215
|
+
domain: string;
|
|
216
|
+
actions: {
|
|
217
|
+
sign_in: import("../../..").ActionSchema<[{
|
|
218
|
+
username: string;
|
|
219
|
+
password: string;
|
|
220
|
+
}] | [{
|
|
221
|
+
username: string;
|
|
222
|
+
password: string;
|
|
223
|
+
}, never], [{
|
|
224
|
+
success: boolean;
|
|
225
|
+
}] | [{
|
|
226
|
+
success: boolean;
|
|
227
|
+
}, any], readonly []>;
|
|
228
|
+
};
|
|
229
|
+
}>, "sign_in">;
|
|
230
|
+
action_edit_doc_edit: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
231
|
+
domain: string;
|
|
232
|
+
actions: {
|
|
233
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
234
|
+
docId: string;
|
|
235
|
+
newContent: string;
|
|
236
|
+
}] | [{
|
|
237
|
+
docId: string;
|
|
238
|
+
newContent: string;
|
|
239
|
+
}, never], [{
|
|
240
|
+
success: boolean;
|
|
241
|
+
}] | [{
|
|
242
|
+
success: boolean;
|
|
243
|
+
}, any], readonly []>;
|
|
244
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
245
|
+
docId: string;
|
|
246
|
+
}] | [{
|
|
247
|
+
docId: string;
|
|
248
|
+
}, never], [{
|
|
249
|
+
content: string;
|
|
250
|
+
}] | [{
|
|
251
|
+
content: string;
|
|
252
|
+
}, any], readonly []>;
|
|
253
|
+
};
|
|
254
|
+
}>, "edit_doc">;
|
|
255
|
+
action_edit_doc_get: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
256
|
+
domain: string;
|
|
257
|
+
actions: {
|
|
258
|
+
edit_doc: import("../../..").ActionSchema<[{
|
|
259
|
+
docId: string;
|
|
260
|
+
newContent: string;
|
|
261
|
+
}] | [{
|
|
262
|
+
docId: string;
|
|
263
|
+
newContent: string;
|
|
264
|
+
}, never], [{
|
|
265
|
+
success: boolean;
|
|
266
|
+
}] | [{
|
|
267
|
+
success: boolean;
|
|
268
|
+
}, any], readonly []>;
|
|
269
|
+
get_doc: import("../../..").ActionSchema<[{
|
|
270
|
+
docId: string;
|
|
271
|
+
}] | [{
|
|
272
|
+
docId: string;
|
|
273
|
+
}, never], [{
|
|
274
|
+
content: string;
|
|
275
|
+
}] | [{
|
|
276
|
+
content: string;
|
|
277
|
+
}, any], readonly []>;
|
|
278
|
+
};
|
|
279
|
+
}>, "get_doc">;
|
|
280
|
+
action_push_doc_update: import("../../..").ActionCore<import("../../..").TActionDomainChildDef<import("../../..").IActionRootDomain<"test_root">, {
|
|
281
|
+
domain: string;
|
|
282
|
+
actions: {
|
|
283
|
+
push_doc_update: import("../../..").ActionSchema<[{
|
|
284
|
+
docId: string;
|
|
285
|
+
updateContent: string;
|
|
286
|
+
}] | [{
|
|
287
|
+
docId: string;
|
|
288
|
+
updateContent: string;
|
|
289
|
+
}, never], [{
|
|
290
|
+
updated: boolean;
|
|
291
|
+
}] | [{
|
|
292
|
+
updated: boolean;
|
|
293
|
+
}, any], readonly []>;
|
|
294
|
+
};
|
|
295
|
+
}>, "push_doc_update">;
|
|
296
|
+
};
|
|
297
|
+
web_app_to_server_handler: ActionExternalClientHandler;
|
|
298
|
+
web_app_runtime: ActionRuntime;
|
|
299
|
+
server_runtime: ActionRuntime;
|
|
300
|
+
server_action_handler: ActionLocalHandler;
|
|
301
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IActionRuntimeManagerContext } from "../ActionRuntime/ActionRuntime.types";
|
|
2
|
+
import type { ActionClientSpecifier, TClientSpecifierStringId } from "../ActionRuntime/Client/ActionClientSpecifier";
|
|
2
3
|
export declare enum EErrId_NiceAction {
|
|
4
|
+
not_implemented = "not_implemented",
|
|
3
5
|
action_id_not_in_domain = "action_id_not_in_domain",
|
|
4
6
|
domain_already_exists_in_hierarchy = "domain_already_exists_in_hierarchy",
|
|
5
7
|
domain_no_handler = "domain_no_handler",
|
|
@@ -9,8 +11,9 @@ export declare enum EErrId_NiceAction {
|
|
|
9
11
|
no_action_execution_handler = "no_action_execution_handler",
|
|
10
12
|
wire_action_not_primed_or_response = "wire_action_not_primed_or_response",
|
|
11
13
|
wire_not_action_data = "wire_not_action_data",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
client_runtime_already_registered = "client_runtime_already_registered",
|
|
15
|
+
client_runtime_not_registered = "client_runtime_not_registered",
|
|
16
|
+
no_client_runtimes_registered = "no_client_runtimes_registered",
|
|
14
17
|
action_input_validation_failed = "action_input_validation_failed",
|
|
15
18
|
action_input_validation_promise = "action_input_validation_promise",
|
|
16
19
|
action_output_validation_failed = "action_output_validation_failed",
|
|
@@ -20,6 +23,9 @@ export declare const err_nice_action: import("@nice-code/error").NiceErrorDomain
|
|
|
20
23
|
domain: string;
|
|
21
24
|
allDomains: [string, "err_nice"];
|
|
22
25
|
schema: {
|
|
26
|
+
not_implemented: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
27
|
+
label: string;
|
|
28
|
+
}, import("@nice-code/error").JSONSerializableValue>;
|
|
23
29
|
action_id_not_in_domain: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
24
30
|
domain: string;
|
|
25
31
|
actionId: string;
|
|
@@ -37,8 +43,8 @@ export declare const err_nice_action: import("@nice-code/error").NiceErrorDomain
|
|
|
37
43
|
received: string;
|
|
38
44
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
39
45
|
hydration_action_state_mismatch: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
40
|
-
expected:
|
|
41
|
-
received:
|
|
46
|
+
expected: string;
|
|
47
|
+
received: string;
|
|
42
48
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
43
49
|
hydration_action_id_not_found: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
44
50
|
domain: string;
|
|
@@ -47,20 +53,24 @@ export declare const err_nice_action: import("@nice-code/error").NiceErrorDomain
|
|
|
47
53
|
no_action_execution_handler: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
48
54
|
domain: string;
|
|
49
55
|
actionId: string;
|
|
56
|
+
specifiedClient?: ActionClientSpecifier;
|
|
50
57
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
51
58
|
wire_action_not_primed_or_response: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
52
59
|
domain: string;
|
|
53
60
|
actionId: string;
|
|
54
|
-
actionState:
|
|
61
|
+
actionState: string | undefined;
|
|
55
62
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
56
63
|
wire_not_action_data: import("@nice-code/error").INiceErrorIdMetadata<any, import("@nice-code/error").JSONSerializableValue>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
client_runtime_already_registered: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
65
|
+
context?: IActionRuntimeManagerContext;
|
|
66
|
+
client: ActionClientSpecifier;
|
|
60
67
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
client_runtime_not_registered: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
69
|
+
context?: IActionRuntimeManagerContext;
|
|
70
|
+
clientStringId: TClientSpecifierStringId;
|
|
71
|
+
}, import("@nice-code/error").JSONSerializableValue>;
|
|
72
|
+
no_client_runtimes_registered: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
73
|
+
context?: IActionRuntimeManagerContext;
|
|
64
74
|
}, import("@nice-code/error").JSONSerializableValue>;
|
|
65
75
|
action_input_validation_failed: import("@nice-code/error").INiceErrorIdMetadata<{
|
|
66
76
|
domain: string;
|