@kellanjs/actioncraft 0.1.0 → 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.
Files changed (87) hide show
  1. package/README.md +411 -302
  2. package/dist/actioncraft-error.d.ts +23 -0
  3. package/dist/actioncraft-error.js +60 -0
  4. package/dist/actioncraft-error.js.map +1 -0
  5. package/dist/actioncraft-prev.d.ts +93 -0
  6. package/dist/actioncraft-prev.js +387 -0
  7. package/dist/actioncraft-prev.js.map +1 -0
  8. package/dist/actioncraft.d.ts +94 -44
  9. package/dist/actioncraft.js +281 -55
  10. package/dist/actioncraft.js.map +1 -1
  11. package/dist/api.d.ts +49 -0
  12. package/dist/api.js +84 -0
  13. package/dist/api.js.map +1 -0
  14. package/dist/classes/action-builder.d.ts +59 -0
  15. package/dist/classes/action-builder.js +95 -0
  16. package/dist/classes/action-builder.js.map +1 -0
  17. package/dist/classes/craft-builder.d.ts +66 -0
  18. package/dist/classes/craft-builder.js +129 -0
  19. package/dist/classes/craft-builder.js.map +1 -0
  20. package/dist/classes/crafter.d.ts +66 -0
  21. package/dist/classes/crafter.js +129 -0
  22. package/dist/classes/crafter.js.map +1 -0
  23. package/dist/classes/error.d.ts +23 -0
  24. package/dist/classes/error.js +60 -0
  25. package/dist/classes/error.js.map +1 -0
  26. package/dist/classes/executor/callbacks.d.ts +6 -0
  27. package/dist/classes/executor/callbacks.js +20 -0
  28. package/dist/classes/executor/callbacks.js.map +1 -0
  29. package/dist/classes/executor/errors.d.ts +29 -0
  30. package/dist/classes/executor/errors.js +114 -0
  31. package/dist/classes/executor/errors.js.map +1 -0
  32. package/dist/classes/executor/executor.d.ts +68 -0
  33. package/dist/classes/executor/executor.js +391 -0
  34. package/dist/classes/executor/executor.js.map +1 -0
  35. package/dist/classes/executor/logging.d.ts +2 -0
  36. package/dist/classes/executor/logging.js +8 -0
  37. package/dist/classes/executor/logging.js.map +1 -0
  38. package/dist/classes/executor/transformation.d.ts +17 -0
  39. package/dist/classes/executor/transformation.js +43 -0
  40. package/dist/classes/executor/transformation.js.map +1 -0
  41. package/dist/classes/executor/validation.d.ts +16 -0
  42. package/dist/classes/executor/validation.js +70 -0
  43. package/dist/classes/executor/validation.js.map +1 -0
  44. package/dist/classes/executor.d.ts +64 -0
  45. package/dist/classes/executor.js +354 -0
  46. package/dist/classes/executor.js.map +1 -0
  47. package/dist/classes/internal.d.ts +10 -0
  48. package/dist/classes/internal.js +5 -0
  49. package/dist/classes/internal.js.map +1 -0
  50. package/dist/core/errors.d.ts +2 -2
  51. package/dist/core/errors.js +5 -5
  52. package/dist/core/errors.js.map +1 -1
  53. package/dist/core/logging.d.ts +1 -1
  54. package/dist/core/transformation.d.ts +2 -2
  55. package/dist/core/validation.d.ts +4 -4
  56. package/dist/core/validation.js +14 -14
  57. package/dist/core/validation.js.map +1 -1
  58. package/dist/craft.d.ts +29 -0
  59. package/dist/craft.js +62 -0
  60. package/dist/craft.js.map +1 -0
  61. package/dist/error.d.ts +21 -6
  62. package/dist/error.js +59 -10
  63. package/dist/error.js.map +1 -1
  64. package/dist/index.d.ts +4 -3
  65. package/dist/index.js +4 -3
  66. package/dist/index.js.map +1 -1
  67. package/dist/initial.d.ts +14 -0
  68. package/dist/initial.js +47 -0
  69. package/dist/initial.js.map +1 -0
  70. package/dist/types/actions.d.ts +67 -25
  71. package/dist/types/builder.d.ts +92 -0
  72. package/dist/types/builder.js +2 -0
  73. package/dist/types/builder.js.map +1 -0
  74. package/dist/types/crafter.d.ts +87 -0
  75. package/dist/types/crafter.js +2 -0
  76. package/dist/types/crafter.js.map +1 -0
  77. package/dist/types/errors.d.ts +25 -17
  78. package/dist/types/inference.d.ts +41 -8
  79. package/dist/types/result.d.ts +8 -14
  80. package/dist/types/result.js +36 -4
  81. package/dist/types/result.js.map +1 -1
  82. package/dist/types/schemas.d.ts +7 -7
  83. package/dist/types/shared.d.ts +14 -6
  84. package/dist/utils.d.ts +30 -6
  85. package/dist/utils.js +68 -8
  86. package/dist/utils.js.map +1 -1
  87. package/package.json +3 -3
@@ -0,0 +1,23 @@
1
+ import type { CraftedAction } from "../types/actions.js";
2
+ import type { BaseError } from "../types/errors.js";
3
+ import type { InferErrors } from "../types/inference.js";
4
+ /**
5
+ * Error wrapper that provides standard Error semantics while preserving
6
+ * the original Actioncraft error data in the cause property.
7
+ */
8
+ export declare class ActioncraftError<TErrorData extends BaseError = BaseError> extends Error {
9
+ readonly cause: TErrorData;
10
+ readonly actionId?: string;
11
+ constructor(errorData: TErrorData, actionId?: string);
12
+ }
13
+ /**
14
+ * Type guard to check if an error is an ActioncraftError.
15
+ *
16
+ * When called with just an error, performs basic structural validation.
17
+ * When called with an error and action, performs verified action ID checking.
18
+ *
19
+ * @param error - The unknown error to check
20
+ * @param action - Optional action for verified checking and type inference
21
+ * @returns Type predicate indicating if error is ActioncraftError
22
+ */
23
+ export declare function isActioncraftError<TAction extends CraftedAction<any, any, any, any>>(error: unknown, action?: TAction): error is ActioncraftError<TAction extends undefined ? BaseError : InferErrors<TAction>>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Error wrapper that provides standard Error semantics while preserving
3
+ * the original Actioncraft error data in the cause property.
4
+ */
5
+ export class ActioncraftError extends Error {
6
+ cause;
7
+ actionId;
8
+ constructor(errorData, actionId) {
9
+ super(`Actioncraft Error: ${errorData.type}${"message" in errorData ? ` - ${errorData.message}` : ""}`);
10
+ this.name = "ActioncraftError";
11
+ this.cause = errorData;
12
+ this.actionId = actionId;
13
+ // Ensure proper prototype chain for instanceof checks
14
+ Object.setPrototypeOf(this, ActioncraftError.prototype);
15
+ }
16
+ }
17
+ /**
18
+ * Type guard to check if an error is an ActioncraftError.
19
+ *
20
+ * When called with just an error, performs basic structural validation.
21
+ * When called with an error and action, performs verified action ID checking.
22
+ *
23
+ * @param error - The unknown error to check
24
+ * @param action - Optional action for verified checking and type inference
25
+ * @returns Type predicate indicating if error is ActioncraftError
26
+ */
27
+ export function isActioncraftError(error, action) {
28
+ if (!(error instanceof ActioncraftError)) {
29
+ return false;
30
+ }
31
+ // Verify the cause property exists and has the expected BaseError structure
32
+ const cause = error.cause;
33
+ if (!cause || typeof cause !== "object") {
34
+ return false;
35
+ }
36
+ // Verify the cause has a type property that's a string (required by BaseError)
37
+ if (!("type" in cause) || typeof cause.type !== "string") {
38
+ return false;
39
+ }
40
+ // If message exists, it should be a string (optional in BaseError)
41
+ if ("message" in cause &&
42
+ cause.message !== undefined &&
43
+ typeof cause.message !== "string") {
44
+ return false;
45
+ }
46
+ // If no action provided, just do structural validation
47
+ if (!action) {
48
+ return true;
49
+ }
50
+ // If action provided, verify the action ID matches
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ const actionId = action.__ac_id;
53
+ // Both action and error must have IDs for verification to be possible
54
+ if (!actionId || !error.actionId) {
55
+ return false;
56
+ }
57
+ // Check if the error's action ID matches the action's ID
58
+ return error.actionId === actionId;
59
+ }
60
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/classes/error.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,gBAEX,SAAQ,KAAK;IACY,KAAK,CAAa;IAC3B,QAAQ,CAAU;IAElC,YAAY,SAAqB,EAAE,QAAiB;QAClD,KAAK,CACH,sBAAsB,SAAS,CAAC,IAAI,GAClC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EACvD,EAAE,CACH,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,sDAAsD;QACtD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAIhC,KAAc,EACd,MAAgB;IAIhB,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4EAA4E;IAC5E,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,+EAA+E;IAC/E,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mEAAmE;IACnE,IACE,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,KAAK,SAAS;QAC3B,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EACjC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uDAAuD;IACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,mDAAmD;IACnD,8DAA8D;IAC9D,MAAM,QAAQ,GAAI,MAAc,CAAC,OAA6B,CAAC;IAE/D,sEAAsE;IACtE,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yDAAyD;IACzD,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACrC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Executes a callback function safely.
3
+ * Any error thrown by the callback is caught and logged (if a logFn is supplied)
4
+ * so that it never interrupts the main action flow.
5
+ */
6
+ export declare function safeExecuteCallback(callback: (() => Promise<void> | void) | undefined, callbackName: string, logFn?: (level: "error" | "warn", message: string, details?: unknown) => void): Promise<void>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Executes a callback function safely.
3
+ * Any error thrown by the callback is caught and logged (if a logFn is supplied)
4
+ * so that it never interrupts the main action flow.
5
+ */
6
+ export async function safeExecuteCallback(callback, callbackName,
7
+ // Logger accepts (level, message, details?)
8
+ logFn) {
9
+ if (!callback)
10
+ return;
11
+ try {
12
+ await callback();
13
+ }
14
+ catch (error) {
15
+ if (logFn) {
16
+ logFn("error", `Error in ${callbackName} callback`, error);
17
+ }
18
+ }
19
+ }
20
+ //# sourceMappingURL=callbacks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../../src/classes/executor/callbacks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAkD,EAClD,YAAoB;AACpB,4CAA4C;AAC5C,KAA6E;IAE7E,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,IAAI,CAAC;QACH,MAAM,QAAQ,EAAE,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,OAAO,EAAE,YAAY,YAAY,WAAW,EAAE,KAAK,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { StandardSchemaV1 } from "../../standard-schema.js";
2
+ import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES } from "../../types/errors.js";
3
+ import type { UnhandledError, ImplicitReturnError, InternalLogicError, ValidationErrorFormat, NoInputSchemaError } from "../../types/errors.js";
4
+ import type { Result } from "../../types/result.js";
5
+ export declare const UNHANDLED_ERROR: UnhandledError;
6
+ export declare const IMPLICIT_RETURN_ERROR: ImplicitReturnError;
7
+ export declare const NO_INPUT_SCHEMA_ERROR: NoInputSchemaError;
8
+ /**
9
+ * Creates internal logic errors with custom messages.
10
+ */
11
+ export declare const createInternalLogicError: (message: string) => InternalLogicError;
12
+ /**
13
+ * Creates Result objects for unhandled errors.
14
+ */
15
+ export declare function createUnhandledErrorResult<TData = never, TError = UnhandledError>(actionId: string, actionName?: string): Result<TData, TError>;
16
+ /**
17
+ * Creates Result objects for implicit return errors.
18
+ */
19
+ export declare function createImplicitReturnErrorResult<TData = never, TError = ImplicitReturnError>(actionId: string, actionName?: string): Result<TData, TError>;
20
+ /**
21
+ * Formats validation issues into structured error objects based on the configured format.
22
+ */
23
+ export declare function formatValidationIssues(issues: readonly StandardSchemaV1.Issue[], format: "flattened" | "nested"): ValidationErrorFormat;
24
+ type ValidationErrorType = typeof EXTERNAL_ERROR_TYPES.INPUT_VALIDATION | typeof EXTERNAL_ERROR_TYPES.BIND_ARGS_VALIDATION | typeof INTERNAL_ERROR_TYPES.OUTPUT_VALIDATION;
25
+ /**
26
+ * Creates validation error objects.
27
+ */
28
+ export declare function createValidationError<TError>(type: ValidationErrorType, message: string, errorStructure: ValidationErrorFormat, actionName?: string): TError;
29
+ export {};
@@ -0,0 +1,114 @@
1
+ import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES, } from "../../types/errors.js";
2
+ import { err } from "../../types/result.js";
3
+ // ===========================================================================
4
+ // CONSTANTS
5
+ // ===========================================================================
6
+ export const UNHANDLED_ERROR = {
7
+ type: EXTERNAL_ERROR_TYPES.UNHANDLED,
8
+ message: "An unhandled error occurred",
9
+ };
10
+ export const IMPLICIT_RETURN_ERROR = {
11
+ type: INTERNAL_ERROR_TYPES.IMPLICIT_RETURN,
12
+ message: "Action handler must return a value",
13
+ };
14
+ export const NO_INPUT_SCHEMA_ERROR = {
15
+ type: "NO_INPUT_SCHEMA",
16
+ message: "Cannot validate input: no input schema defined for this action",
17
+ };
18
+ // ===========================================================================
19
+ // FACTORY HELPERS
20
+ // ===========================================================================
21
+ /**
22
+ * Creates internal logic errors with custom messages.
23
+ */
24
+ export const createInternalLogicError = (message) => ({
25
+ type: INTERNAL_ERROR_TYPES.INTERNAL_LOGIC,
26
+ message,
27
+ });
28
+ /**
29
+ * Creates Result objects for unhandled errors.
30
+ */
31
+ export function createUnhandledErrorResult(actionId, actionName) {
32
+ const message = actionName
33
+ ? `An unhandled error occurred in action "${actionName}"`
34
+ : "An unhandled error occurred";
35
+ return err({ ...UNHANDLED_ERROR, message }, actionId);
36
+ }
37
+ /**
38
+ * Creates Result objects for implicit return errors.
39
+ */
40
+ export function createImplicitReturnErrorResult(actionId, actionName) {
41
+ const message = actionName
42
+ ? `Action handler "${actionName}" must return a value`
43
+ : "Action handler must return a value";
44
+ return err({ ...IMPLICIT_RETURN_ERROR, message }, actionId);
45
+ }
46
+ // ===========================================================================
47
+ // VALIDATION-ERROR STRUCTURING HELPERS
48
+ // ===========================================================================
49
+ /**
50
+ * Normalises Standard Schema path segments to string|number for serialization.
51
+ */
52
+ function _normalisePath(path) {
53
+ if (!path)
54
+ return [];
55
+ return path
56
+ .map((segment) => {
57
+ if (typeof segment === "symbol")
58
+ return undefined;
59
+ if (typeof segment === "object" && segment !== null && "key" in segment) {
60
+ const key = segment.key;
61
+ return typeof key === "symbol" ? undefined : key;
62
+ }
63
+ return segment;
64
+ })
65
+ .filter((p) => p !== undefined);
66
+ }
67
+ /**
68
+ * Formats validation issues into structured error objects based on the configured format.
69
+ */
70
+ export function formatValidationIssues(issues, format) {
71
+ if (format === "nested") {
72
+ const formErrors = [];
73
+ const fieldErrors = {};
74
+ for (const issue of issues) {
75
+ const currentPath = _normalisePath(issue.path);
76
+ if (currentPath.length === 0) {
77
+ formErrors.push(issue.message);
78
+ }
79
+ else {
80
+ const pathKey = currentPath.join(".");
81
+ if (!fieldErrors[pathKey])
82
+ fieldErrors[pathKey] = [];
83
+ fieldErrors[pathKey].push(issue.message);
84
+ }
85
+ }
86
+ return { formErrors, fieldErrors };
87
+ }
88
+ // Default to 'flattened'
89
+ return {
90
+ issues: issues.map(({ path, message }) => ({
91
+ path: _normalisePath(path),
92
+ message,
93
+ })),
94
+ };
95
+ }
96
+ function _buildFlattenedValidationError(type, message, issues) {
97
+ return { type, message, issues };
98
+ }
99
+ function _buildNestedValidationError(type, message, formErrors, fieldErrors) {
100
+ return { type, message, formErrors, fieldErrors };
101
+ }
102
+ /**
103
+ * Creates validation error objects.
104
+ */
105
+ export function createValidationError(type, message, errorStructure, actionName) {
106
+ const enhancedMessage = actionName
107
+ ? `${message} in action "${actionName}"`
108
+ : message;
109
+ if ("issues" in errorStructure) {
110
+ return _buildFlattenedValidationError(type, enhancedMessage, errorStructure.issues);
111
+ }
112
+ return _buildNestedValidationError(type, enhancedMessage, errorStructure.formErrors, errorStructure.fieldErrors);
113
+ }
114
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/classes/executor/errors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,IAAI,EAAE,oBAAoB,CAAC,SAAS;IACpC,OAAO,EAAE,6BAA6B;CAC9B,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAwB;IACxD,IAAI,EAAE,oBAAoB,CAAC,eAAe;IAC1C,OAAO,EAAE,oCAAoC;CACrC,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAuB;IACvD,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,gEAAgE;CACjE,CAAC;AAEX,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAAe,EACK,EAAE,CAAC,CAAC;IACxB,IAAI,EAAE,oBAAoB,CAAC,cAAc;IACzC,OAAO;CACR,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAGxC,Q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,EACf,cAAqC,EACrC,UAAmB;IAEnB,MAAM,eAAe,GAAG,UAAU;QAChC,CAAC,CAAC,GAAG,OAAO,eAAe,UAAU,GAAG;QACxC,CAAC,CAAC,OAAO,CAAC;IAEZ,IAAI,QAAQ,IAAI,cAAc,EAAE,CAAC;QAC/B,OAAO,8BAA8B,CACnC,IAAI,EACJ,eAAe,EACf,cAAc,CAAC,MAAM,CACtB,CAAC;IACJ,CAAC;IAED,OAAO,2BAA2B,CAChC,IAAI,EACJ,eAAe,EACf,cAAc,CAAC,UAAU,EACzB,cAAc,CAAC,WAAW,CAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { CraftedAction } from "../../types/actions.js";
2
+ import type { Config, Schemas, Errors, Callbacks } from "../../types/builder.js";
3
+ import type { CraftBuilder } from "../craft-builder.js";
4
+ export declare class Executor<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> {
5
+ private readonly _config;
6
+ private readonly _schemas;
7
+ private readonly _errors;
8
+ private readonly _callbacks;
9
+ private readonly _handler?;
10
+ private _actionId?;
11
+ constructor(builder: CraftBuilder<TConfig, TSchemas, TErrors, TCallbacks, TData>);
12
+ /**
13
+ * Builds and returns the final executable server action.
14
+ */
15
+ craft(): CraftedAction<TConfig, TSchemas, TErrors, TData>;
16
+ /**
17
+ * Generates a unique identifier for this action instance.
18
+ */
19
+ private _generateActionId;
20
+ /**
21
+ * Orchestrates action execution (validation, business logic, callbacks, and result formatting.)
22
+ */
23
+ private _runAction;
24
+ /**
25
+ * Extracts bind arguments, previous state, and input from raw action arguments.
26
+ */
27
+ private _extractActionArgs;
28
+ /**
29
+ * Transforms internal Result objects to client-facing action result format.
30
+ */
31
+ private _toActionResult;
32
+ /**
33
+ * Handles uncaught exceptions during action execution.
34
+ */
35
+ private _handleThrownError;
36
+ /**
37
+ * Validates input using the shared helper.
38
+ */
39
+ private _validateInput;
40
+ /**
41
+ * Validates bound arguments using the configured bind schemas.
42
+ */
43
+ private _validateBindArgs;
44
+ /**
45
+ * Validates output data using the configured output schema.
46
+ */
47
+ private _validateOutput;
48
+ /**
49
+ * Validates input data only (used by the $validate method).
50
+ */
51
+ private _validateInputOnly;
52
+ /**
53
+ * Executes the onStart callback if defined.
54
+ */
55
+ private _executeOnStartCallback;
56
+ /**
57
+ * Executes result-based lifecycle callbacks (onSuccess, onError, onSettled).
58
+ */
59
+ private _executeResultCallbacks;
60
+ /**
61
+ * Ensures a Result object has the correct action ID.
62
+ */
63
+ private _ensureResultActionId;
64
+ /**
65
+ * Creates error functions that return a Result object when called by the action handler.
66
+ */
67
+ private _buildErrorFunctions;
68
+ }