@nice-code/action 0.2.5 → 0.2.7

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.
@@ -1,5 +1,6 @@
1
1
  import type { IExecuteActionOptions } from "../../ActionRuntime/Handler/ActionHandler.types";
2
2
  import { ActionLocalHandler } from "../../ActionRuntime/Handler/Local/ActionLocalHandler";
3
+ import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
3
4
  import type { TAction_Any_JsonObject, TDistributeActionPayload_Request, TDistributeActionPayload_Result, TDistributedDomainActions, TNarrowActionJsonTypeToActionInstanceType } from "../Action/Action.combined.types";
4
5
  import { type IActionBase } from "../Action/ActionBase.types";
5
6
  import { ActionContext } from "../Action/Context/ActionContext";
@@ -21,6 +22,7 @@ export declare class ActionDomain<ACT_DOM extends IActionDomain = IActionDomain>
21
22
  rootDomain: ActionRootDomain<any>;
22
23
  });
23
24
  get rootDomain(): ActionRootDomain<any>;
25
+ _registerRuntime(runtime: ActionRuntime): void;
24
26
  createChildDomain<SUB_DOM extends IActionDomainChildOptions>(subDomainDef: SUB_DOM & {
25
27
  [K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;
26
28
  }): ActionDomain<TActionDomainChildDef<ACT_DOM, SUB_DOM>>;
@@ -17,7 +17,8 @@ export declare class ActionRootDomain<ROOT_DOM extends IActionRootDomain = IActi
17
17
  createChildDomain<SUB_DOM extends IActionDomainChildOptions>(subDomainDef: SUB_DOM & {
18
18
  [K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;
19
19
  }): ActionDomain<TActionDomainChildDef<ROOT_DOM, SUB_DOM>>;
20
- addActionRuntime(runtime: ActionRuntime): this;
20
+ _registerRuntime(runtime: ActionRuntime): void;
21
+ _hasRuntime(runtime: ActionRuntime): boolean;
21
22
  getRuntime(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined;
22
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>>;
23
24
  }
@@ -13,6 +13,7 @@ export declare class ActionRuntime {
13
13
  private readonly actionRouter;
14
14
  private readonly _pendingRunningActions;
15
15
  private readonly _registeredExternalHandlers;
16
+ private _applied;
16
17
  static getDefault(): ActionRuntime;
17
18
  constructor(coordinate: RuntimeCoordinate);
18
19
  get coordinate(): RuntimeCoordinate;
@@ -35,6 +36,13 @@ export declare class ActionRuntime {
35
36
  * Duplicate registrations (same handler cuid for the same key) are skipped.
36
37
  */
37
38
  addHandlers(handlers: TActionRuntimeHandler[]): this;
39
+ private applyRuntimeForDomain;
40
+ /**
41
+ * Register this runtime with all root domains covered by its currently-added handlers,
42
+ * making it eligible to execute actions dispatched from those domains.
43
+ * After apply() is called, any subsequent addHandlers() calls also auto-register.
44
+ */
45
+ apply(): this;
38
46
  /**
39
47
  * Find the best registered external handler that can reach `originClient` directly.
40
48
  * Used to locate the return-path channel for dispatching results back to the action origin.
@@ -15,5 +15,6 @@ export declare class ActionRuntimeManager {
15
15
  getPreferredRuntime(): ActionRuntime | undefined;
16
16
  getBestRuntimeForSpecifier(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined;
17
17
  getBestRuntime(clientSpecifier?: IRuntimeCoordinate): ActionRuntime | undefined;
18
+ hasRuntime(runtime: ActionRuntime): boolean;
18
19
  getBestRuntimeOrThrow(specifier?: IRuntimeCoordinate): ActionRuntime;
19
20
  }
@@ -13,7 +13,8 @@ export interface IRuntimeCoordinate {
13
13
  */
14
14
  insId?: string;
15
15
  }
16
- export type TRuntimeCoordinateStringId = `envId[${string}]perId[${string | "_"}]:insId[${string | "_"}]`;
16
+ export type TRuntimeCoordinateEnvId = `envId[${string}]`;
17
+ export type TRuntimeCoordinateStringId = `${TRuntimeCoordinateEnvId}perId[${string | "_"}]:insId[${string | "_"}]`;
17
18
  export interface IRuntimeFullCoordinates extends Required<IRuntimeCoordinate> {
18
19
  }
19
20
  export declare class RuntimeCoordinate implements IRuntimeCoordinate {
@@ -8,8 +8,10 @@ export declare function actionQueryKey<DOM extends IActionDomain, ID extends key
8
8
  DOM["domain"],
9
9
  DOM["allDomains"],
10
10
  ID,
11
- TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"],
12
- string | undefined
11
+ TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]
13
12
  ];
14
13
  export type TUseActionQueryOptions<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID] = DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]> = Omit<UseQueryOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TSelect, QueryKey>, "queryKey" | "queryFn">;
15
- export declare function useActionQuery<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<SCH>["Input"] | null | undefined, options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>): UseQueryResult<TSelect, TInferActionError<SCH>>;
14
+ export declare function useActionQuery<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]>(action: ActionCore<DOM, ID>, ...args: [TInferInputFromSchema<SCH>["Input"]] extends [never] ? [options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>] : [
15
+ input: TInferInputFromSchema<SCH>["Input"] | null | undefined,
16
+ options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>
17
+ ]): UseQueryResult<TSelect, TInferActionError<SCH>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {