@kellanjs/actioncraft 0.1.0 → 0.2.1

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 (64) hide show
  1. package/README.md +411 -302
  2. package/dist/classes/action-builder.d.ts +59 -0
  3. package/dist/classes/action-builder.js +95 -0
  4. package/dist/classes/action-builder.js.map +1 -0
  5. package/dist/classes/craft-builder.d.ts +66 -0
  6. package/dist/classes/craft-builder.js +129 -0
  7. package/dist/classes/craft-builder.js.map +1 -0
  8. package/dist/classes/error.d.ts +23 -0
  9. package/dist/classes/error.js +60 -0
  10. package/dist/classes/error.js.map +1 -0
  11. package/dist/classes/executor/callbacks.js.map +1 -0
  12. package/dist/{core → classes/executor}/errors.d.ts +8 -7
  13. package/dist/{core → classes/executor}/errors.js +23 -10
  14. package/dist/classes/executor/errors.js.map +1 -0
  15. package/dist/classes/executor/executor.d.ts +68 -0
  16. package/dist/{actioncraft.js → classes/executor/executor.js} +135 -131
  17. package/dist/classes/executor/executor.js.map +1 -0
  18. package/dist/classes/executor/logging.d.ts +2 -0
  19. package/dist/classes/executor/logging.js.map +1 -0
  20. package/dist/classes/executor/transformation.d.ts +17 -0
  21. package/dist/{core → classes/executor}/transformation.js +1 -1
  22. package/dist/classes/executor/transformation.js.map +1 -0
  23. package/dist/classes/executor/validation.d.ts +16 -0
  24. package/dist/{core → classes/executor}/validation.js +20 -20
  25. package/dist/classes/executor/validation.js.map +1 -0
  26. package/dist/classes/internal.d.ts +10 -0
  27. package/dist/classes/internal.js +5 -0
  28. package/dist/classes/internal.js.map +1 -0
  29. package/dist/index.d.ts +4 -3
  30. package/dist/index.js +4 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/types/actions.d.ts +67 -25
  33. package/dist/types/{config.d.ts → builder.d.ts} +18 -10
  34. package/dist/types/builder.js +2 -0
  35. package/dist/types/builder.js.map +1 -0
  36. package/dist/types/errors.d.ts +25 -17
  37. package/dist/types/inference.d.ts +41 -8
  38. package/dist/types/result.d.ts +8 -14
  39. package/dist/types/result.js +36 -4
  40. package/dist/types/result.js.map +1 -1
  41. package/dist/types/schemas.d.ts +7 -7
  42. package/dist/types/shared.d.ts +14 -6
  43. package/dist/utils.d.ts +30 -6
  44. package/dist/utils.js +68 -8
  45. package/dist/utils.js.map +1 -1
  46. package/package.json +11 -11
  47. package/dist/actioncraft.d.ts +0 -93
  48. package/dist/actioncraft.js.map +0 -1
  49. package/dist/core/callbacks.js.map +0 -1
  50. package/dist/core/errors.js.map +0 -1
  51. package/dist/core/logging.d.ts +0 -6
  52. package/dist/core/logging.js.map +0 -1
  53. package/dist/core/transformation.d.ts +0 -17
  54. package/dist/core/transformation.js.map +0 -1
  55. package/dist/core/validation.d.ts +0 -16
  56. package/dist/core/validation.js.map +0 -1
  57. package/dist/error.d.ts +0 -16
  58. package/dist/error.js +0 -22
  59. package/dist/error.js.map +0 -1
  60. package/dist/types/config.js +0 -2
  61. package/dist/types/config.js.map +0 -1
  62. /package/dist/{core → classes/executor}/callbacks.d.ts +0 -0
  63. /package/dist/{core → classes/executor}/callbacks.js +0 -0
  64. /package/dist/{core → classes/executor}/logging.js +0 -0
@@ -0,0 +1,59 @@
1
+ import type { Handler, CraftedAction, InferDataFromHandler, HandlerParams } from "../types/actions.js";
2
+ import type { Config, Schemas, Errors, Callbacks } from "../types/builder.js";
3
+ export declare class ActionBuilder<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> {
4
+ private readonly _config;
5
+ private readonly _schemas;
6
+ private readonly _errors;
7
+ private readonly _callbacks;
8
+ private readonly _handler?;
9
+ constructor(config: TConfig, schemas: TSchemas, errors: TErrors, callbacks: TCallbacks, handler?: Handler<TConfig, TSchemas, TErrors, TData>);
10
+ /**
11
+ * Defines configuration options for the action.
12
+ * Resets previously defined handler and callbacks.
13
+ */
14
+ config<TNewConfig extends Config>(config: TNewConfig): ActionBuilder<TNewConfig, TSchemas, TErrors, Record<string, never>, unknown>;
15
+ /**
16
+ * Defines validation schemas for input, output, and bind arguments.
17
+ * Resets previously defined handler and callbacks.
18
+ */
19
+ schemas<TNewSchemas extends Schemas>(schemas: TNewSchemas): ActionBuilder<TConfig, TNewSchemas, TErrors, Record<string, never>, unknown>;
20
+ /**
21
+ * Defines error functions for returning typed errors from the handler.
22
+ * Resets previously defined handler and callbacks.
23
+ */
24
+ errors<const TNewErrors extends Errors>(errors: TNewErrors): ActionBuilder<TConfig, TSchemas, TNewErrors, Record<string, never>, unknown>;
25
+ /**
26
+ * Defines the handler function containing the server action's business logic.
27
+ * Resets previously defined callbacks.
28
+ */
29
+ handler<TFn extends (params: HandlerParams<TConfig, TSchemas, TErrors, TData>) => Promise<unknown>>(fn: TFn): ActionBuilder<TConfig, TSchemas, TErrors, Record<string, never>, InferDataFromHandler<TFn>>;
30
+ /**
31
+ * Defines lifecycle callbacks to be triggered during the exection of an action.
32
+ * Must be called after handler() for correct type inference.
33
+ */
34
+ callbacks<TNewCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>>(callbacks: TNewCallbacks): ActionBuilder<TConfig, TSchemas, TErrors, TNewCallbacks, TData>;
35
+ /**
36
+ * Builds and returns the final executable server action.
37
+ * This is the terminal method for the ActionBuilder fluent API.
38
+ */
39
+ craft(): CraftedAction<TConfig, TSchemas, TErrors, TData>;
40
+ }
41
+ /**
42
+ * One of two entry points to the Actioncraft system.
43
+ * Creates a new ActionBuilder instance for the fluent API that ends with craft().
44
+ * This provides an alternative syntax for building your server actions.
45
+ *
46
+ * Example Usage:
47
+ * ```ts
48
+ * const myAction = action()
49
+ * .config(...)
50
+ * .schemas(...)
51
+ * .errors(...)
52
+ * .handler(...)
53
+ * .callbacks(...)
54
+ * .craft();
55
+ * ```
56
+ *
57
+ * @returns A new ActionBuilder instance to start building your action.
58
+ */
59
+ export declare function action(): ActionBuilder<Record<string, never>, Record<string, never>, Record<string, never>, Record<string, never>, unknown>;
@@ -0,0 +1,95 @@
1
+ import { CraftBuilder } from "./craft-builder.js";
2
+ import { Executor } from "./executor/executor.js";
3
+ // ============================================================================
4
+ // ACTION BUILDER CLASS - Alternative fluent API syntax ending with craft()
5
+ // ============================================================================
6
+ export class ActionBuilder {
7
+ _config;
8
+ _schemas;
9
+ _errors;
10
+ _callbacks;
11
+ _handler;
12
+ constructor(config, schemas, errors, callbacks, handler) {
13
+ this._config = config;
14
+ this._schemas = schemas;
15
+ this._errors = errors;
16
+ this._callbacks = callbacks;
17
+ this._handler = handler;
18
+ }
19
+ // --------------------------------------------------------------------------
20
+ // FLUENT API METHODS (same as CraftBuilder)
21
+ // --------------------------------------------------------------------------
22
+ /**
23
+ * Defines configuration options for the action.
24
+ * Resets previously defined handler and callbacks.
25
+ */
26
+ config(config) {
27
+ return new ActionBuilder(config, this._schemas, this._errors, {}, undefined);
28
+ }
29
+ /**
30
+ * Defines validation schemas for input, output, and bind arguments.
31
+ * Resets previously defined handler and callbacks.
32
+ */
33
+ schemas(schemas) {
34
+ return new ActionBuilder(this._config, schemas, this._errors, {}, undefined);
35
+ }
36
+ /**
37
+ * Defines error functions for returning typed errors from the handler.
38
+ * Resets previously defined handler and callbacks.
39
+ */
40
+ errors(errors) {
41
+ return new ActionBuilder(this._config, this._schemas, errors, {}, undefined);
42
+ }
43
+ /**
44
+ * Defines the handler function containing the server action's business logic.
45
+ * Resets previously defined callbacks.
46
+ */
47
+ handler(fn) {
48
+ return new ActionBuilder(this._config, this._schemas, this._errors, {}, fn);
49
+ }
50
+ /**
51
+ * Defines lifecycle callbacks to be triggered during the exection of an action.
52
+ * Must be called after handler() for correct type inference.
53
+ */
54
+ callbacks(callbacks) {
55
+ return new ActionBuilder(this._config, this._schemas, this._errors, callbacks, this._handler);
56
+ }
57
+ // --------------------------------------------------------------------------
58
+ // CRAFT METHOD - Final step to create the action
59
+ // --------------------------------------------------------------------------
60
+ /**
61
+ * Builds and returns the final executable server action.
62
+ * This is the terminal method for the ActionBuilder fluent API.
63
+ */
64
+ craft() {
65
+ // Convert ActionBuilder to CraftBuilder and use existing Executor logic
66
+ const builder = new CraftBuilder(this._config, this._schemas, this._errors, this._callbacks, this._handler);
67
+ const executor = new Executor(builder);
68
+ return executor.craft();
69
+ }
70
+ }
71
+ // ============================================================================
72
+ // PUBLIC API FUNCTION
73
+ // ============================================================================
74
+ /**
75
+ * One of two entry points to the Actioncraft system.
76
+ * Creates a new ActionBuilder instance for the fluent API that ends with craft().
77
+ * This provides an alternative syntax for building your server actions.
78
+ *
79
+ * Example Usage:
80
+ * ```ts
81
+ * const myAction = action()
82
+ * .config(...)
83
+ * .schemas(...)
84
+ * .errors(...)
85
+ * .handler(...)
86
+ * .callbacks(...)
87
+ * .craft();
88
+ * ```
89
+ *
90
+ * @returns A new ActionBuilder instance to start building your action.
91
+ */
92
+ export function action() {
93
+ return new ActionBuilder({}, {}, {}, {}, undefined);
94
+ }
95
+ //# sourceMappingURL=action-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-builder.js","sourceRoot":"","sources":["../../src/classes/action-builder.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAE/E,MAAM,OAAO,aAAa;IAOP,OAAO,CAAU;IACjB,QAAQ,CAAW;IACnB,OAAO,CAAU;IACjB,UAAU,CAAa;IACvB,QAAQ,CAA8C;IAEvE,YACE,MAAe,EACf,OAAiB,EACjB,MAAe,EACf,SAAqB,EACrB,OAAoD;QAEpD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,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AC,OAAO,CAAC,CAAC;QACvC,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF;AAED,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,MAAM;IAOpB,OAAO,IAAI,aAAa,CACtB,EAA2B,EAC3B,EAA2B,EAC3B,EAA2B,EAC3B,EAA2B,EAC3B,SAAS,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { Handler, InferDataFromHandler, HandlerParams, CraftedAction } from "../types/actions.js";
2
+ import type { Config, Schemas, Errors, Callbacks } from "../types/builder.js";
3
+ import { INTERNAL, type CrafterInternals } from "./internal.js";
4
+ export declare class CraftBuilder<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
+ constructor(config: TConfig, schemas: TSchemas, errors: TErrors, callbacks: TCallbacks, handler?: Handler<TConfig, TSchemas, TErrors, TData>);
11
+ /**
12
+ * Defines configuration options for the action.
13
+ * Resets previously defined handler and callbacks.
14
+ */
15
+ config<TNewConfig extends Config>(config: TNewConfig): CraftBuilder<TNewConfig, TSchemas, TErrors, Record<string, never>, unknown>;
16
+ /**
17
+ * Defines validation schemas for input, output, and bind arguments.
18
+ * Resets previously defined handler and callbacks.
19
+ */
20
+ schemas<TNewSchemas extends Schemas>(schemas: TNewSchemas): CraftBuilder<TConfig, TNewSchemas, TErrors, Record<string, never>, unknown>;
21
+ /**
22
+ * Defines error functions for returning typed errors from the handler.
23
+ * Resets previously defined handler and callbacks.
24
+ */
25
+ errors<const TNewErrors extends Errors>(errors: TNewErrors): CraftBuilder<TConfig, TSchemas, TNewErrors, Record<string, never>, unknown>;
26
+ /**
27
+ * Defines the handler function containing the server action's business logic.
28
+ * Resets previously defined callbacks.
29
+ */
30
+ handler<TFn extends (params: HandlerParams<TConfig, TSchemas, TErrors, TData>) => Promise<unknown>>(fn: TFn): CraftBuilder<TConfig, TSchemas, TErrors, Record<string, never>, InferDataFromHandler<TFn>>;
31
+ /**
32
+ * Defines lifecycle callbacks to be triggered during the exection of an action.
33
+ * Must be called after handler() for correct type inference.
34
+ */
35
+ callbacks<TNewCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>>(callbacks: TNewCallbacks): CraftBuilder<TConfig, TSchemas, TErrors, TNewCallbacks, TData>;
36
+ /**
37
+ * @returns Internal properties of the CraftBuilder instance
38
+ */
39
+ [INTERNAL](): CrafterInternals<TConfig, TSchemas, TErrors, TCallbacks, TData>;
40
+ }
41
+ /**
42
+ * Represents the function that the user passes to `craft()` in order to build an action.
43
+ */
44
+ type CraftFn<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> = (builder: CraftBuilder<Config, Record<string, never>, Record<string, never>, Record<string, never>, unknown>) => CraftBuilder<TConfig, TSchemas, TErrors, TCallbacks, TData> | Promise<CraftBuilder<TConfig, TSchemas, TErrors, TCallbacks, TData>>;
45
+ /**
46
+ * One of two entry points to the Actioncraft system.
47
+ * It provides you with an empty CraftBuilder instance on which you can call any of the fluent
48
+ * CraftBuilder methods to configure and define your action.
49
+ *
50
+ * Example Usage:
51
+ * ```ts
52
+ * const myAction = craft(async (action) => {
53
+ * return action
54
+ * .config(...)
55
+ * .schemas(...)
56
+ * .errors(...)
57
+ * .handler(...)
58
+ * .callbacks(...)
59
+ * });
60
+ * ```
61
+ *
62
+ * @param craftFn - The function that the user passes to `craft()` in order to build an action.
63
+ * @returns The fully-typed server action function that can be used in your app.
64
+ */
65
+ export declare function craft<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData>(craftFn: CraftFn<TConfig, TSchemas, TErrors, TCallbacks, TData>): CraftedAction<TConfig, TSchemas, TErrors, TData>;
66
+ export {};
@@ -0,0 +1,129 @@
1
+ import { Executor } from "./executor/executor.js";
2
+ import { INTERNAL } from "./internal.js";
3
+ // ============================================================================
4
+ // CRAFT BUILDER CLASS - Configure and define your action
5
+ // ============================================================================
6
+ export class CraftBuilder {
7
+ _config;
8
+ _schemas;
9
+ _errors;
10
+ _callbacks;
11
+ _handler;
12
+ constructor(config, schemas, errors, callbacks, handler) {
13
+ this._config = config;
14
+ this._schemas = schemas;
15
+ this._errors = errors;
16
+ this._callbacks = callbacks;
17
+ this._handler = handler;
18
+ }
19
+ // --------------------------------------------------------------------------
20
+ // FLUENT API METHODS
21
+ // --------------------------------------------------------------------------
22
+ /**
23
+ * Defines configuration options for the action.
24
+ * Resets previously defined handler and callbacks.
25
+ */
26
+ config(config) {
27
+ return new CraftBuilder(config, this._schemas, this._errors, {}, undefined);
28
+ }
29
+ /**
30
+ * Defines validation schemas for input, output, and bind arguments.
31
+ * Resets previously defined handler and callbacks.
32
+ */
33
+ schemas(schemas) {
34
+ return new CraftBuilder(this._config, schemas, this._errors, {}, undefined);
35
+ }
36
+ /**
37
+ * Defines error functions for returning typed errors from the handler.
38
+ * Resets previously defined handler and callbacks.
39
+ */
40
+ errors(errors) {
41
+ return new CraftBuilder(this._config, this._schemas, errors, {}, undefined);
42
+ }
43
+ /**
44
+ * Defines the handler function containing the server action's business logic.
45
+ * Resets previously defined callbacks.
46
+ */
47
+ handler(fn) {
48
+ return new CraftBuilder(this._config, this._schemas, this._errors, {}, fn);
49
+ }
50
+ /**
51
+ * Defines lifecycle callbacks to be triggered during the exection of an action.
52
+ * Must be called after handler() for correct type inference.
53
+ */
54
+ callbacks(callbacks) {
55
+ return new CraftBuilder(this._config, this._schemas, this._errors, callbacks, this._handler);
56
+ }
57
+ /**
58
+ * @returns Internal properties of the CraftBuilder instance
59
+ */
60
+ [INTERNAL]() {
61
+ return {
62
+ config: this._config,
63
+ schemas: this._schemas,
64
+ errors: this._errors,
65
+ callbacks: this._callbacks,
66
+ handler: this._handler,
67
+ };
68
+ }
69
+ }
70
+ /**
71
+ * One of two entry points to the Actioncraft system.
72
+ * It provides you with an empty CraftBuilder instance on which you can call any of the fluent
73
+ * CraftBuilder methods to configure and define your action.
74
+ *
75
+ * Example Usage:
76
+ * ```ts
77
+ * const myAction = craft(async (action) => {
78
+ * return action
79
+ * .config(...)
80
+ * .schemas(...)
81
+ * .errors(...)
82
+ * .handler(...)
83
+ * .callbacks(...)
84
+ * });
85
+ * ```
86
+ *
87
+ * @param craftFn - The function that the user passes to `craft()` in order to build an action.
88
+ * @returns The fully-typed server action function that can be used in your app.
89
+ */
90
+ export function craft(craftFn) {
91
+ const builder = craftFn(new CraftBuilder({}, {}, {}, {}, undefined));
92
+ // Handle async builder functions
93
+ if (builder instanceof Promise) {
94
+ return _craftAsync(builder);
95
+ }
96
+ // Handle sync builder functions
97
+ const executor = new Executor(builder);
98
+ const craftedAction = executor.craft();
99
+ return craftedAction;
100
+ }
101
+ /**
102
+ * Internal helper function to handle async craft functions.
103
+ * Encapsulates the logic for creating async actions and preserving metadata.
104
+ */
105
+ function _craftAsync(builderPromise) {
106
+ // Resolve the builder once and cache the resulting action to ensure consistent IDs
107
+ const actionPromise = builderPromise.then((resolvedBuilder) => {
108
+ const executor = new Executor(resolvedBuilder);
109
+ return executor.craft();
110
+ });
111
+ // For async craft functions, we need to return an async action
112
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+ const asyncAction = (async (...args) => {
114
+ // Wait for the cached action to be ready
115
+ const craftedAction = await actionPromise;
116
+ // Call the action with the user's arguments
117
+ return craftedAction(...args);
118
+ });
119
+ // We need to preserve the config and ID for the initial() function to work
120
+ // We'll use the same cached action to ensure consistent metadata
121
+ actionPromise.then((craftedAction) => {
122
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
+ asyncAction.__ac_config = craftedAction.__ac_config;
124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
+ asyncAction.__ac_id = craftedAction.__ac_id;
126
+ });
127
+ return asyncAction;
128
+ }
129
+ //# sourceMappingURL=craft-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"craft-builder.js","sourceRoot":"","sources":["../../src/classes/craft-builder.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAEhE,+EAA+E;AAC/E,yDAAyD;AACzD,+EAA+E;AAE/E,MAAM,OAAO,YAAY;IAON,OAAO,CAAU;IACjB,QAAQ,CAAW;IACnB,OAAO,CAAU;IACjB,UAAU,CAAa;IACvB,QAAQ,CAA8C;IAEvE,YACE,MAAe,EACf,OAAiB,EACjB,MAAe,EACf,SAAqB,EACrB,OAAoD;QAEpD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,6EAA6E;IAC7E,qBAAqB;IACrB,6EAA6E;IAE7E;;;OAGG;IACH,MAAM,CACJ,MAAkB;QAQlB,OAAO,IAAI,YAAY,CACrB,MAAM,EACN,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,EACZ,EAA2B,EAC3B,SAAS,CACV,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,OAAO,CACL,OAAoB;QAQpB,OAAO,IAAI,YAAY,CACrB,IAAI,CAAC,OAAO,EACZ,OAAO,EACP,IAAI,CAAC,OAAO,EACZ,EAA2B,EAC3B,SAAS,CACV,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,MAAM,CACJ,MAAkB;QAQlB,OAAO,IAAI,YAAY,CACrB,IAAI,CAAC,OAAO,EACZ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AOlB,cAEC;IAED,mFAAmF;IACnF,MAAM,aAAa,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;QAC5D,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,8DAA8D;IAC9D,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;QAC5C,yCAAyC;QACzC,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC;QAE1C,4CAA4C;QAC5C,OAAO,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;IAChC,CAAC,CAAqD,CAAC;IAEvD,2EAA2E;IAC3E,iEAAiE;IACjE,aAAa,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE;QACnC,8DAA8D;QAC7D,WAAmB,CAAC,WAAW,GAAI,aAAqB,CAAC,WAAW,CAAC;QACtE,8DAA8D;QAC7D,WAAmB,CAAC,OAAO,GAAI,aAAqB,CAAC,OAAO,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -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 @@
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"}
@@ -1,9 +1,10 @@
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 } from "../types/errors.js";
4
- import type { Result } from "../types/result.js";
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
5
  export declare const UNHANDLED_ERROR: UnhandledError;
6
6
  export declare const IMPLICIT_RETURN_ERROR: ImplicitReturnError;
7
+ export declare const NO_INPUT_SCHEMA_ERROR: NoInputSchemaError;
7
8
  /**
8
9
  * Creates internal logic errors with custom messages.
9
10
  */
@@ -11,11 +12,11 @@ export declare const createInternalLogicError: (message: string) => InternalLogi
11
12
  /**
12
13
  * Creates Result objects for unhandled errors.
13
14
  */
14
- export declare function createUnhandledErrorResult<TData = never, TError = UnhandledError>(): Result<TData, TError>;
15
+ export declare function createUnhandledErrorResult<TData = never, TError = UnhandledError>(actionId: string, actionName?: string): Result<TData, TError>;
15
16
  /**
16
17
  * Creates Result objects for implicit return errors.
17
18
  */
18
- export declare function createImplicitReturnErrorResult<TData = never, TError = ImplicitReturnError>(): Result<TData, TError>;
19
+ export declare function createImplicitReturnErrorResult<TData = never, TError = ImplicitReturnError>(actionId: string, actionName?: string): Result<TData, TError>;
19
20
  /**
20
21
  * Formats validation issues into structured error objects based on the configured format.
21
22
  */
@@ -24,5 +25,5 @@ type ValidationErrorType = typeof EXTERNAL_ERROR_TYPES.INPUT_VALIDATION | typeof
24
25
  /**
25
26
  * Creates validation error objects.
26
27
  */
27
- export declare function createValidationError<TError>(type: ValidationErrorType, message: string, errorStructure: ValidationErrorFormat): TError;
28
+ export declare function createValidationError<TError>(type: ValidationErrorType, message: string, errorStructure: ValidationErrorFormat, actionName?: string): TError;
28
29
  export {};
@@ -1,5 +1,5 @@
1
- import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES } from "../types/errors.js";
2
- import { err } from "../types/result.js";
1
+ import { EXTERNAL_ERROR_TYPES, INTERNAL_ERROR_TYPES, } from "../../types/errors.js";
2
+ import { err } from "../../types/result.js";
3
3
  // ===========================================================================
4
4
  // CONSTANTS
5
5
  // ===========================================================================
@@ -9,7 +9,11 @@ export const UNHANDLED_ERROR = {
9
9
  };
10
10
  export const IMPLICIT_RETURN_ERROR = {
11
11
  type: INTERNAL_ERROR_TYPES.IMPLICIT_RETURN,
12
- message: "Action implementation must return a value",
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",
13
17
  };
14
18
  // ===========================================================================
15
19
  // FACTORY HELPERS
@@ -24,14 +28,20 @@ export const createInternalLogicError = (message) => ({
24
28
  /**
25
29
  * Creates Result objects for unhandled errors.
26
30
  */
27
- export function createUnhandledErrorResult() {
28
- return err({ ...UNHANDLED_ERROR });
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);
29
36
  }
30
37
  /**
31
38
  * Creates Result objects for implicit return errors.
32
39
  */
33
- export function createImplicitReturnErrorResult() {
34
- return err({ ...IMPLICIT_RETURN_ERROR });
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);
35
45
  }
36
46
  // ===========================================================================
37
47
  // VALIDATION-ERROR STRUCTURING HELPERS
@@ -92,10 +102,13 @@ function _buildNestedValidationError(type, message, formErrors, fieldErrors) {
92
102
  /**
93
103
  * Creates validation error objects.
94
104
  */
95
- export function createValidationError(type, message, errorStructure) {
105
+ export function createValidationError(type, message, errorStructure, actionName) {
106
+ const enhancedMessage = actionName
107
+ ? `${message} in action "${actionName}"`
108
+ : message;
96
109
  if ("issues" in errorStructure) {
97
- return _buildFlattenedValidationError(type, message, errorStructure.issues);
110
+ return _buildFlattenedValidationError(type, enhancedMessage, errorStructure.issues);
98
111
  }
99
- return _buildNestedValidationError(type, message, errorStructure.formErrors, errorStructure.fieldErrors);
112
+ return _buildNestedValidationError(type, enhancedMessage, errorStructure.formErrors, errorStructure.fieldErrors);
100
113
  }
101
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,QAAgB,EAAE,UAAmB;IACrC,MAAM,OAAO,GAAG,UAAU;QACxB,CAAC,CAAC,0CAA0C,UAAU,GAAG;QACzD,CAAC,CAAC,6BAA6B,CAAC;IAElC,OAAO,GAAG,CAAC,EAAE,GAAG,eAAe,EAAE,OAAO,EAAE,EAAE,QAAQ,CAGnD,CAAC;AACJ,CAAC;AA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AAe,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
+ }