@kellanjs/actioncraft 0.2.1 → 0.3.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 +47 -68
- package/dist/classes/{action-builder.d.ts → builder.d.ts} +20 -16
- package/dist/classes/{action-builder.js → builder.js} +34 -25
- package/dist/classes/builder.js.map +1 -0
- package/dist/classes/executor/executor.d.ts +3 -3
- package/dist/classes/executor/executor.js +1 -1
- package/dist/classes/executor/executor.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/standard-schema.js +2 -1
- package/dist/standard-schema.js.map +1 -1
- package/package.json +14 -11
- package/dist/classes/action-builder.js.map +0 -1
- package/dist/classes/craft-builder.d.ts +0 -66
- package/dist/classes/craft-builder.js +0 -129
- package/dist/classes/craft-builder.js.map +0 -1
package/README.md
CHANGED
|
@@ -53,38 +53,17 @@ npm install @kellanjs/actioncraft
|
|
|
53
53
|
|
|
54
54
|
Actioncraft makes it easy to create type-safe server actions with first-class error-handling support.
|
|
55
55
|
|
|
56
|
-
The library supports two different syntax patterns, aptly referred to as the `action() api` and the `craft() api`. Both are functionally the same, so use whichever you prefer!
|
|
57
|
-
|
|
58
|
-
For the sake of simplicity, this document will use the same pattern (the `action() api`) for all usage examples, but either pattern would produce the exact same result.
|
|
59
|
-
|
|
60
|
-
#### action() api
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
export const example = action() // We call action() first to create a builder to use
|
|
64
|
-
.config(...)
|
|
65
|
-
.schemas(...)
|
|
66
|
-
.errors(...)
|
|
67
|
-
.handler(...)
|
|
68
|
-
.callbacks(...)
|
|
69
|
-
.craft(); // And we call craft() last to build and return your type-safe server action
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
#### craft() api
|
|
73
|
-
|
|
74
56
|
```typescript
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.callbacks(...)
|
|
83
|
-
// No craft() needed here, because it's already wrapping everything!
|
|
84
|
-
);
|
|
57
|
+
export const example = actioncraft() // Start with actioncraft() to create a builder
|
|
58
|
+
.config(...) // Configure your action
|
|
59
|
+
.schemas(...) // Add validation schemas
|
|
60
|
+
.errors(...) // Define custom errors
|
|
61
|
+
.handler(...) // Implement business logic
|
|
62
|
+
.callbacks(...) // Add lifecycle hooks
|
|
63
|
+
.build(); // Call build() to return your type-safe server action
|
|
85
64
|
```
|
|
86
65
|
|
|
87
|
-
Actioncraft uses a fluent builder design, making it simple to chain one method after the next to create a full-featured server action.
|
|
66
|
+
Actioncraft uses a fluent builder design, making it simple to chain one method after the next to create a full-featured server action. The order in which the methods are defined is important for type inference to work properly, so you'll see the same structure repeated often throughout the documentation. Always make sure to chain your methods together like this for the best experience!
|
|
88
67
|
|
|
89
68
|
### Example
|
|
90
69
|
|
|
@@ -93,7 +72,7 @@ With this basic structure in mind, let's see what a more detailed example looks
|
|
|
93
72
|
```typescript
|
|
94
73
|
"use server";
|
|
95
74
|
|
|
96
|
-
import {
|
|
75
|
+
import { actioncraft } from "@kellanjs/actioncraft";
|
|
97
76
|
import { z } from "zod";
|
|
98
77
|
|
|
99
78
|
const newUserInputSchema = z.object({
|
|
@@ -102,7 +81,7 @@ const newUserInputSchema = z.object({
|
|
|
102
81
|
age: z.number(),
|
|
103
82
|
});
|
|
104
83
|
|
|
105
|
-
export const createNewUser =
|
|
84
|
+
export const createNewUser = actioncraft()
|
|
106
85
|
// Define configuration settings
|
|
107
86
|
.config({
|
|
108
87
|
validationErrorFormat: "nested",
|
|
@@ -145,7 +124,7 @@ export const createNewUser = action()
|
|
|
145
124
|
// Log what happened if you want
|
|
146
125
|
},
|
|
147
126
|
})
|
|
148
|
-
.
|
|
127
|
+
.build();
|
|
149
128
|
```
|
|
150
129
|
|
|
151
130
|
### Result Format
|
|
@@ -195,7 +174,7 @@ Now that we've covered the basic structure of an action and looked at a simple e
|
|
|
195
174
|
Actioncraft provides several configuration options to customize your action. Sensible defaults are provided, so you only need to define the `config` if you specifically want to override something. When you want to customize a certain behavior, just pass a configuration object:
|
|
196
175
|
|
|
197
176
|
```typescript
|
|
198
|
-
export const getUser =
|
|
177
|
+
export const getUser = actioncraft()
|
|
199
178
|
.config({
|
|
200
179
|
name: "getUser",
|
|
201
180
|
useActionState: true,
|
|
@@ -210,7 +189,7 @@ export const getUser = action()
|
|
|
210
189
|
.errors(...)
|
|
211
190
|
.handler(...)
|
|
212
191
|
.callbacks(...)
|
|
213
|
-
.
|
|
192
|
+
.build();
|
|
214
193
|
```
|
|
215
194
|
|
|
216
195
|
#### `name: string`
|
|
@@ -220,13 +199,13 @@ export const getUser = action()
|
|
|
220
199
|
An optional identifier for your action that will be included in error messages to help with debugging:
|
|
221
200
|
|
|
222
201
|
```typescript
|
|
223
|
-
export const updateUserProfile =
|
|
202
|
+
export const updateUserProfile = actioncraft()
|
|
224
203
|
.config({ name: "updateUserProfile" })
|
|
225
204
|
.schemas({ inputSchema: userSchema })
|
|
226
205
|
.handler(async ({ input }) => {
|
|
227
206
|
// Your handler logic
|
|
228
207
|
})
|
|
229
|
-
.
|
|
208
|
+
.build();
|
|
230
209
|
|
|
231
210
|
// If validation fails, the error message will be:
|
|
232
211
|
// "Input validation failed in action \"updateUserProfile\""
|
|
@@ -241,13 +220,13 @@ export const updateUserProfile = action()
|
|
|
241
220
|
Set to `true` to make your action compatible with React's `useActionState` hook:
|
|
242
221
|
|
|
243
222
|
```typescript
|
|
244
|
-
export const getUser =
|
|
223
|
+
export const getUser = actioncraft()
|
|
245
224
|
.config({ useActionState: true })
|
|
246
225
|
.schemas(...)
|
|
247
226
|
.errors(...)
|
|
248
227
|
.handler(...)
|
|
249
228
|
.callbacks(...)
|
|
250
|
-
.
|
|
229
|
+
.build();
|
|
251
230
|
|
|
252
231
|
// Now you can use it with useActionState in your client components like this:
|
|
253
232
|
const [state, action] = useActionState(getUser, initial(getUser));
|
|
@@ -276,7 +255,7 @@ Controls how validation errors are structured:
|
|
|
276
255
|
By default, Actioncraft catches thrown errors and returns a structured error with type `"UNHANDLED"`. You can customize this behavior by passing an error handler function of your own:
|
|
277
256
|
|
|
278
257
|
```typescript
|
|
279
|
-
export const getUser =
|
|
258
|
+
export const getUser = actioncraft()
|
|
280
259
|
.config({
|
|
281
260
|
handleThrownError: (error) =>
|
|
282
261
|
({
|
|
@@ -290,7 +269,7 @@ export const getUser = action()
|
|
|
290
269
|
.errors(...)
|
|
291
270
|
.handler(...)
|
|
292
271
|
.callbacks(...)
|
|
293
|
-
.
|
|
272
|
+
.build();
|
|
294
273
|
```
|
|
295
274
|
|
|
296
275
|
You can even implement more complex logic if you want:
|
|
@@ -355,7 +334,7 @@ Pretty cool!
|
|
|
355
334
|
With our action configured, let's add validation using schemas. Actioncraft supports any library that implements the **Standard Schema V1** interface. Validation is handled automatically - you just need to provide the schemas:
|
|
356
335
|
|
|
357
336
|
```typescript
|
|
358
|
-
export const getUser =
|
|
337
|
+
export const getUser = actioncraft()
|
|
359
338
|
.config(...)
|
|
360
339
|
.schemas({
|
|
361
340
|
inputSchema,
|
|
@@ -365,7 +344,7 @@ export const getUser = action()
|
|
|
365
344
|
.errors(...)
|
|
366
345
|
.handler(...)
|
|
367
346
|
.callbacks(...)
|
|
368
|
-
.
|
|
347
|
+
.build();
|
|
369
348
|
```
|
|
370
349
|
|
|
371
350
|
#### Schema Options
|
|
@@ -387,7 +366,7 @@ Validates arguments bound to the action with `.bind()`. If validation fails, a "
|
|
|
387
366
|
Now that we have validation set up, let's define custom errors that our action can return. Actioncraft makes error handling really easy by letting you define structured error types:
|
|
388
367
|
|
|
389
368
|
```typescript
|
|
390
|
-
export const errorExamples =
|
|
369
|
+
export const errorExamples = actioncraft()
|
|
391
370
|
.config(...)
|
|
392
371
|
.schemas(...)
|
|
393
372
|
.errors({
|
|
@@ -411,7 +390,7 @@ export const errorExamples = action()
|
|
|
411
390
|
})
|
|
412
391
|
.handler(...)
|
|
413
392
|
.callbacks(...)
|
|
414
|
-
.
|
|
393
|
+
.build();
|
|
415
394
|
```
|
|
416
395
|
|
|
417
396
|
#### Error Structure
|
|
@@ -468,7 +447,7 @@ export const notFound = (resource: string, id: string) =>
|
|
|
468
447
|
|
|
469
448
|
```typescript
|
|
470
449
|
// get-user.ts
|
|
471
|
-
export const getUser =
|
|
450
|
+
export const getUser = actioncraft()
|
|
472
451
|
.config(...)
|
|
473
452
|
.schemas(...)
|
|
474
453
|
.errors({
|
|
@@ -482,7 +461,7 @@ export const getUser = action()
|
|
|
482
461
|
})
|
|
483
462
|
.handler(...)
|
|
484
463
|
.callbacks(...)
|
|
485
|
-
.
|
|
464
|
+
.build();
|
|
486
465
|
```
|
|
487
466
|
|
|
488
467
|
#### Using Errors in Your Action Handler
|
|
@@ -490,7 +469,7 @@ export const getUser = action()
|
|
|
490
469
|
Once defined, you can use these errors in your handler logic. When an error occurs, just call and return that particular error function:
|
|
491
470
|
|
|
492
471
|
```typescript
|
|
493
|
-
export const getUser =
|
|
472
|
+
export const getUser = actioncraft()
|
|
494
473
|
.config(...)
|
|
495
474
|
.schemas(...)
|
|
496
475
|
.errors(...)
|
|
@@ -510,7 +489,7 @@ export const getUser = action()
|
|
|
510
489
|
return { user };
|
|
511
490
|
})
|
|
512
491
|
.callbacks(...)
|
|
513
|
-
.
|
|
492
|
+
.build();
|
|
514
493
|
```
|
|
515
494
|
|
|
516
495
|
### .handler()
|
|
@@ -518,7 +497,7 @@ export const getUser = action()
|
|
|
518
497
|
The `handler` method is where you implement the core functionality of your server action. Actioncraft provides several helpful parameters to make things quick and easy for you:
|
|
519
498
|
|
|
520
499
|
```typescript
|
|
521
|
-
export const getUser =
|
|
500
|
+
export const getUser = actioncraft()
|
|
522
501
|
.config(...)
|
|
523
502
|
.schemas(...)
|
|
524
503
|
.errors(...)
|
|
@@ -526,7 +505,7 @@ export const getUser = action()
|
|
|
526
505
|
// Server action logic here
|
|
527
506
|
})
|
|
528
507
|
.callbacks(...)
|
|
529
|
-
.
|
|
508
|
+
.build();
|
|
530
509
|
```
|
|
531
510
|
|
|
532
511
|
#### Handler Parameters
|
|
@@ -557,7 +536,7 @@ Contains additional request information:
|
|
|
557
536
|
Sometimes you need to hook into the action lifecycle for logging, analytics, or other side effects. The `callbacks` method lets you define functions that run at key moments:
|
|
558
537
|
|
|
559
538
|
```typescript
|
|
560
|
-
export const getUser =
|
|
539
|
+
export const getUser = actioncraft()
|
|
561
540
|
.config(...)
|
|
562
541
|
.schemas(...)
|
|
563
542
|
.errors(...)
|
|
@@ -568,7 +547,7 @@ export const getUser = action()
|
|
|
568
547
|
onError: ({error}) => { ... },
|
|
569
548
|
onSettled: ({ result }) => { ... },
|
|
570
549
|
})
|
|
571
|
-
.
|
|
550
|
+
.build();
|
|
572
551
|
```
|
|
573
552
|
|
|
574
553
|
#### Callback Types
|
|
@@ -649,13 +628,13 @@ if (!result.success) {
|
|
|
649
628
|
For React forms, you can use actions configured for `useActionState`:
|
|
650
629
|
|
|
651
630
|
```typescript
|
|
652
|
-
export const updateUser =
|
|
631
|
+
export const updateUser = actioncraft()
|
|
653
632
|
.config({ useActionState: true })
|
|
654
633
|
.schemas(...)
|
|
655
634
|
.errors(...)
|
|
656
635
|
.handler(...)
|
|
657
636
|
.callbacks(...)
|
|
658
|
-
.
|
|
637
|
+
.build();
|
|
659
638
|
```
|
|
660
639
|
|
|
661
640
|
When `useActionState: true` is set, your action's return type changes to include a `values` field. This field contains the raw input values that were last passed to the action. However, on successful executions where an input schema is defined, it contains the validated input values instead.
|
|
@@ -693,7 +672,7 @@ By providing a schema which supports FormData, your action can work with or with
|
|
|
693
672
|
|
|
694
673
|
```typescript
|
|
695
674
|
// This action handles FormData from server-side form submissions
|
|
696
|
-
export const createNewUser =
|
|
675
|
+
export const createNewUser = actioncraft()
|
|
697
676
|
.config({ useActionState: true })
|
|
698
677
|
.schemas({
|
|
699
678
|
inputSchema: zfd.formData({
|
|
@@ -715,7 +694,7 @@ export const createNewUser = action()
|
|
|
715
694
|
|
|
716
695
|
return { user };
|
|
717
696
|
})
|
|
718
|
-
.
|
|
697
|
+
.build();
|
|
719
698
|
```
|
|
720
699
|
|
|
721
700
|
## Complete Example
|
|
@@ -725,7 +704,7 @@ Now that we've gone over how to create actions and how to use them on the client
|
|
|
725
704
|
```typescript
|
|
726
705
|
"use server";
|
|
727
706
|
|
|
728
|
-
import {
|
|
707
|
+
import { actioncraft } from "@kellanjs/actioncraft";
|
|
729
708
|
import { revalidatePath } from "next/cache";
|
|
730
709
|
import { z } from "zod";
|
|
731
710
|
|
|
@@ -735,7 +714,7 @@ const updateProfileSchema = z.object({
|
|
|
735
714
|
bio: z.string().max(500, "Bio must be under 500 characters"),
|
|
736
715
|
});
|
|
737
716
|
|
|
738
|
-
export const updateProfile =
|
|
717
|
+
export const updateProfile = actioncraft()
|
|
739
718
|
.config({ useActionState: true })
|
|
740
719
|
.schemas({ inputSchema: updateProfileSchema })
|
|
741
720
|
.errors({
|
|
@@ -799,7 +778,7 @@ export const updateProfile = action()
|
|
|
799
778
|
});
|
|
800
779
|
},
|
|
801
780
|
})
|
|
802
|
-
.
|
|
781
|
+
.build();
|
|
803
782
|
```
|
|
804
783
|
|
|
805
784
|
```typescript
|
|
@@ -877,7 +856,7 @@ If validation fails, an error with type `BIND_ARGS_VALIDATION` is returned to th
|
|
|
877
856
|
#### Example: Multi-Tenant Action
|
|
878
857
|
|
|
879
858
|
```typescript
|
|
880
|
-
export const createPost =
|
|
859
|
+
export const createPost = actioncraft()
|
|
881
860
|
.schemas({
|
|
882
861
|
bindSchemas: [z.string()], // Organization ID
|
|
883
862
|
inputSchema: z.object({
|
|
@@ -897,7 +876,7 @@ export const createPost = action()
|
|
|
897
876
|
|
|
898
877
|
return { post };
|
|
899
878
|
})
|
|
900
|
-
.
|
|
879
|
+
.build();
|
|
901
880
|
|
|
902
881
|
// Create organization-specific actions
|
|
903
882
|
const createPostForOrgA = createPost.bind(null, "org-a-id");
|
|
@@ -913,7 +892,7 @@ const result = await createPostForOrgA({
|
|
|
913
892
|
#### Example: Configuration Binding
|
|
914
893
|
|
|
915
894
|
```typescript
|
|
916
|
-
export const sendEmail =
|
|
895
|
+
export const sendEmail = actioncraft()
|
|
917
896
|
.schemas({
|
|
918
897
|
bindSchemas: [
|
|
919
898
|
z.object({
|
|
@@ -941,7 +920,7 @@ export const sendEmail = action()
|
|
|
941
920
|
|
|
942
921
|
return { messageId: result.id };
|
|
943
922
|
})
|
|
944
|
-
.
|
|
923
|
+
.build();
|
|
945
924
|
|
|
946
925
|
// Create environment-specific email actions
|
|
947
926
|
const sendProductionEmail = sendEmail.bind(null, {
|
|
@@ -975,10 +954,10 @@ Every crafted action includes an `$Infer` property that provides direct access t
|
|
|
975
954
|
#### Type Extraction Example
|
|
976
955
|
|
|
977
956
|
```typescript
|
|
978
|
-
import {
|
|
957
|
+
import { actioncraft } from "@kellanjs/actioncraft";
|
|
979
958
|
import { z } from "zod";
|
|
980
959
|
|
|
981
|
-
export const updateUser =
|
|
960
|
+
export const updateUser = actioncraft()
|
|
982
961
|
.schemas({
|
|
983
962
|
inputSchema: z.object({
|
|
984
963
|
id: z.string(),
|
|
@@ -994,7 +973,7 @@ export const updateUser = action()
|
|
|
994
973
|
// ... implementation
|
|
995
974
|
return { user: input, updatedAt: new Date() };
|
|
996
975
|
})
|
|
997
|
-
.
|
|
976
|
+
.build();
|
|
998
977
|
|
|
999
978
|
// Extracted types using $Infer:
|
|
1000
979
|
type ActionInput = typeof updateUser.$Infer.Input;
|
|
@@ -1040,10 +1019,10 @@ Actioncraft provides a utility to help you easily validate data against a partic
|
|
|
1040
1019
|
|
|
1041
1020
|
```typescript
|
|
1042
1021
|
// On the server...
|
|
1043
|
-
export const createUser =
|
|
1022
|
+
export const createUser = actioncraft()
|
|
1044
1023
|
.schemas({ inputSchema: userSchema })
|
|
1045
1024
|
.handler(async ({ input }) => ({ user: input }))
|
|
1046
|
-
.
|
|
1025
|
+
.build();
|
|
1047
1026
|
|
|
1048
1027
|
// On the client...
|
|
1049
1028
|
// Validate input without executing the action
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Handler,
|
|
1
|
+
import type { Handler, InferDataFromHandler, HandlerParams, CraftedAction } from "../types/actions.js";
|
|
2
2
|
import type { Config, Schemas, Errors, Callbacks } from "../types/builder.js";
|
|
3
|
-
|
|
3
|
+
import { INTERNAL, type CrafterInternals } from "./internal.js";
|
|
4
|
+
export declare class ActioncraftBuilder<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> {
|
|
4
5
|
private readonly _config;
|
|
5
6
|
private readonly _schemas;
|
|
6
7
|
private readonly _errors;
|
|
@@ -11,49 +12,52 @@ export declare class ActionBuilder<TConfig extends Config, TSchemas extends Sche
|
|
|
11
12
|
* Defines configuration options for the action.
|
|
12
13
|
* Resets previously defined handler and callbacks.
|
|
13
14
|
*/
|
|
14
|
-
config<TNewConfig extends Config>(config: TNewConfig):
|
|
15
|
+
config<TNewConfig extends Config>(config: TNewConfig): ActioncraftBuilder<TNewConfig, TSchemas, TErrors, Record<string, never>, unknown>;
|
|
15
16
|
/**
|
|
16
17
|
* Defines validation schemas for input, output, and bind arguments.
|
|
17
18
|
* Resets previously defined handler and callbacks.
|
|
18
19
|
*/
|
|
19
|
-
schemas<TNewSchemas extends Schemas>(schemas: TNewSchemas):
|
|
20
|
+
schemas<TNewSchemas extends Schemas>(schemas: TNewSchemas): ActioncraftBuilder<TConfig, TNewSchemas, TErrors, Record<string, never>, unknown>;
|
|
20
21
|
/**
|
|
21
22
|
* Defines error functions for returning typed errors from the handler.
|
|
22
23
|
* Resets previously defined handler and callbacks.
|
|
23
24
|
*/
|
|
24
|
-
errors<const TNewErrors extends Errors>(errors: TNewErrors):
|
|
25
|
+
errors<const TNewErrors extends Errors>(errors: TNewErrors): ActioncraftBuilder<TConfig, TSchemas, TNewErrors, Record<string, never>, unknown>;
|
|
25
26
|
/**
|
|
26
27
|
* Defines the handler function containing the server action's business logic.
|
|
27
28
|
* Resets previously defined callbacks.
|
|
28
29
|
*/
|
|
29
|
-
handler<TFn extends (params: HandlerParams<TConfig, TSchemas, TErrors, TData>) => Promise<unknown>>(fn: TFn):
|
|
30
|
+
handler<TFn extends (params: HandlerParams<TConfig, TSchemas, TErrors, TData>) => Promise<unknown>>(fn: TFn): ActioncraftBuilder<TConfig, TSchemas, TErrors, Record<string, never>, InferDataFromHandler<TFn>>;
|
|
30
31
|
/**
|
|
31
32
|
* Defines lifecycle callbacks to be triggered during the exection of an action.
|
|
32
33
|
* Must be called after handler() for correct type inference.
|
|
33
34
|
*/
|
|
34
|
-
callbacks<TNewCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>>(callbacks: TNewCallbacks):
|
|
35
|
+
callbacks<TNewCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>>(callbacks: TNewCallbacks): ActioncraftBuilder<TConfig, TSchemas, TErrors, TNewCallbacks, TData>;
|
|
35
36
|
/**
|
|
36
37
|
* Builds and returns the final executable server action.
|
|
37
|
-
* This is the terminal method for the
|
|
38
|
+
* This is the terminal method for the ActioncraftBuilder fluent API.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
build(): CraftedAction<TConfig, TSchemas, TErrors, TData>;
|
|
41
|
+
/**
|
|
42
|
+
* @returns Internal properties of the ActioncraftBuilder instance
|
|
43
|
+
*/
|
|
44
|
+
[INTERNAL](): CrafterInternals<TConfig, TSchemas, TErrors, TCallbacks, TData>;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
* Creates a new
|
|
44
|
-
* This provides an alternative syntax for building your server actions.
|
|
47
|
+
* Entry point to the Actioncraft system.
|
|
48
|
+
* Creates a new ActioncraftBuilder instance for building type-safe server actions.
|
|
45
49
|
*
|
|
46
50
|
* Example Usage:
|
|
47
51
|
* ```ts
|
|
48
|
-
* const myAction =
|
|
52
|
+
* const myAction = actioncraft()
|
|
49
53
|
* .config(...)
|
|
50
54
|
* .schemas(...)
|
|
51
55
|
* .errors(...)
|
|
52
56
|
* .handler(...)
|
|
53
57
|
* .callbacks(...)
|
|
54
|
-
* .
|
|
58
|
+
* .build();
|
|
55
59
|
* ```
|
|
56
60
|
*
|
|
57
|
-
* @returns A new
|
|
61
|
+
* @returns A new ActioncraftBuilder instance to start building your action.
|
|
58
62
|
*/
|
|
59
|
-
export declare function
|
|
63
|
+
export declare function actioncraft(): ActioncraftBuilder<Record<string, never>, Record<string, never>, Record<string, never>, Record<string, never>, unknown>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CraftBuilder } from "./craft-builder.js";
|
|
2
1
|
import { Executor } from "./executor/executor.js";
|
|
2
|
+
import { INTERNAL } from "./internal.js";
|
|
3
3
|
// ============================================================================
|
|
4
|
-
//
|
|
4
|
+
// ACTIONCRAFT BUILDER CLASS - Configure and define your action
|
|
5
5
|
// ============================================================================
|
|
6
|
-
export class
|
|
6
|
+
export class ActioncraftBuilder {
|
|
7
7
|
_config;
|
|
8
8
|
_schemas;
|
|
9
9
|
_errors;
|
|
@@ -17,79 +17,88 @@ export class ActionBuilder {
|
|
|
17
17
|
this._handler = handler;
|
|
18
18
|
}
|
|
19
19
|
// --------------------------------------------------------------------------
|
|
20
|
-
// FLUENT API METHODS
|
|
20
|
+
// FLUENT API METHODS
|
|
21
21
|
// --------------------------------------------------------------------------
|
|
22
22
|
/**
|
|
23
23
|
* Defines configuration options for the action.
|
|
24
24
|
* Resets previously defined handler and callbacks.
|
|
25
25
|
*/
|
|
26
26
|
config(config) {
|
|
27
|
-
return new
|
|
27
|
+
return new ActioncraftBuilder(config, this._schemas, this._errors, {}, undefined);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Defines validation schemas for input, output, and bind arguments.
|
|
31
31
|
* Resets previously defined handler and callbacks.
|
|
32
32
|
*/
|
|
33
33
|
schemas(schemas) {
|
|
34
|
-
return new
|
|
34
|
+
return new ActioncraftBuilder(this._config, schemas, this._errors, {}, undefined);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Defines error functions for returning typed errors from the handler.
|
|
38
38
|
* Resets previously defined handler and callbacks.
|
|
39
39
|
*/
|
|
40
40
|
errors(errors) {
|
|
41
|
-
return new
|
|
41
|
+
return new ActioncraftBuilder(this._config, this._schemas, errors, {}, undefined);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Defines the handler function containing the server action's business logic.
|
|
45
45
|
* Resets previously defined callbacks.
|
|
46
46
|
*/
|
|
47
47
|
handler(fn) {
|
|
48
|
-
return new
|
|
48
|
+
return new ActioncraftBuilder(this._config, this._schemas, this._errors, {}, fn);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Defines lifecycle callbacks to be triggered during the exection of an action.
|
|
52
52
|
* Must be called after handler() for correct type inference.
|
|
53
53
|
*/
|
|
54
54
|
callbacks(callbacks) {
|
|
55
|
-
return new
|
|
55
|
+
return new ActioncraftBuilder(this._config, this._schemas, this._errors, callbacks, this._handler);
|
|
56
56
|
}
|
|
57
57
|
// --------------------------------------------------------------------------
|
|
58
|
-
//
|
|
58
|
+
// BUILD METHOD - Final step to create the action
|
|
59
59
|
// --------------------------------------------------------------------------
|
|
60
60
|
/**
|
|
61
61
|
* Builds and returns the final executable server action.
|
|
62
|
-
* This is the terminal method for the
|
|
62
|
+
* This is the terminal method for the ActioncraftBuilder fluent API.
|
|
63
63
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
build() {
|
|
65
|
+
const executor = new Executor(this);
|
|
66
|
+
return executor.build();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @returns Internal properties of the ActioncraftBuilder instance
|
|
70
|
+
*/
|
|
71
|
+
[INTERNAL]() {
|
|
72
|
+
return {
|
|
73
|
+
config: this._config,
|
|
74
|
+
schemas: this._schemas,
|
|
75
|
+
errors: this._errors,
|
|
76
|
+
callbacks: this._callbacks,
|
|
77
|
+
handler: this._handler,
|
|
78
|
+
};
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
// ============================================================================
|
|
72
82
|
// PUBLIC API FUNCTION
|
|
73
83
|
// ============================================================================
|
|
74
84
|
/**
|
|
75
|
-
*
|
|
76
|
-
* Creates a new
|
|
77
|
-
* This provides an alternative syntax for building your server actions.
|
|
85
|
+
* Entry point to the Actioncraft system.
|
|
86
|
+
* Creates a new ActioncraftBuilder instance for building type-safe server actions.
|
|
78
87
|
*
|
|
79
88
|
* Example Usage:
|
|
80
89
|
* ```ts
|
|
81
|
-
* const myAction =
|
|
90
|
+
* const myAction = actioncraft()
|
|
82
91
|
* .config(...)
|
|
83
92
|
* .schemas(...)
|
|
84
93
|
* .errors(...)
|
|
85
94
|
* .handler(...)
|
|
86
95
|
* .callbacks(...)
|
|
87
|
-
* .
|
|
96
|
+
* .build();
|
|
88
97
|
* ```
|
|
89
98
|
*
|
|
90
|
-
* @returns A new
|
|
99
|
+
* @returns A new ActioncraftBuilder instance to start building your action.
|
|
91
100
|
*/
|
|
92
|
-
export function
|
|
93
|
-
return new
|
|
101
|
+
export function actioncraft() {
|
|
102
|
+
return new ActioncraftBuilder({}, {}, {}, {}, undefined);
|
|
94
103
|
}
|
|
95
|
-
//# sourceMappingURL=
|
|
104
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/classes/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,+DAA+D;AAC/D,+EAA+E;AAE/E,MAAM,OAAO,kBAAkB;IAOZ,OAAO,CAAU;IACjB,QAAQ,CAAW;IACnB,OAAO,CAAU;IACjB,UAAU,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AAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;IAED,6EAA6E;IAC7E,iDAAiD;IACjD,6EAA6E;IAE7E;;;OAGG;IACH,KAAK;QACH,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,CAAC,QAAQ,CAAC;QAOR,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;CACF;AAED,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW;IAOzB,OAAO,IAAI,kBAAkB,CAC3B,EAA2B,EAC3B,EAA2B,EAC3B,EAA2B,EAC3B,EAA2B,EAC3B,SAAS,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CraftedAction } from "../../types/actions.js";
|
|
2
2
|
import type { Config, Schemas, Errors, Callbacks } from "../../types/builder.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ActioncraftBuilder } from "../builder.js";
|
|
4
4
|
export declare class Executor<TConfig extends Config, TSchemas extends Schemas, TErrors extends Errors, TCallbacks extends Callbacks<TConfig, TSchemas, TErrors, TData>, TData> {
|
|
5
5
|
private readonly _config;
|
|
6
6
|
private readonly _schemas;
|
|
@@ -8,11 +8,11 @@ export declare class Executor<TConfig extends Config, TSchemas extends Schemas,
|
|
|
8
8
|
private readonly _callbacks;
|
|
9
9
|
private readonly _handler?;
|
|
10
10
|
private _actionId?;
|
|
11
|
-
constructor(builder:
|
|
11
|
+
constructor(builder: ActioncraftBuilder<TConfig, TSchemas, TErrors, TCallbacks, TData>);
|
|
12
12
|
/**
|
|
13
13
|
* Builds and returns the final executable server action.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
build(): CraftedAction<TConfig, TSchemas, TErrors, TData>;
|
|
16
16
|
/**
|
|
17
17
|
* Generates a unique identifier for this action instance.
|
|
18
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/classes/executor/executor.ts"],"names":[],"mappings":"AAeA,OAAO,EAIN,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,KAAK,GACN,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,+EAA+E;AAC/E,iDAAiD;AACjD,+EAA+E;AAE/E,MAAM,OAAO,QAAQ;IAOF,OAAO,CAAU;IACjB,QAAQ,CAAW;IACnB,OAAO,CAAU;IACjB,UAAU,CAAa;IACvB,QAAQ,CAA8C;IAC/D,SAAS,CAAU;IAE3B,YACE,OAAoE;QAEpE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC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D,QAAQ,CAAC,GAAoB,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,CAC5C,GAAG,CACD,UAAU,CAAC,GAAG,IAAI,CAAC,EACnB,IAAI,CAAC,SAAU,CAChB,CAA2C,CAAC;QACjD,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { action } from "./classes/action-builder.js";
|
|
1
|
+
export { actioncraft } from "./classes/builder.js";
|
|
3
2
|
export { unwrap, throwable, initial, getActionId } from "./utils.js";
|
|
4
3
|
export { ActioncraftError, isActioncraftError } from "./classes/error.js";
|
|
5
4
|
export type { Result, Ok, Err } from "./types/result.js";
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// PUBLIC API EXPORTS
|
|
3
3
|
// ============================================================================
|
|
4
4
|
// Core Functions
|
|
5
|
-
export {
|
|
6
|
-
export { action } from "./classes/action-builder.js";
|
|
5
|
+
export { actioncraft } from "./classes/builder.js";
|
|
7
6
|
export { unwrap, throwable, initial, getActionId } from "./utils.js";
|
|
8
7
|
export { ActioncraftError, isActioncraftError } from "./classes/error.js";
|
|
9
8
|
export { isOk, isErr, ok, err } from "./types/result.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,iBAAiB;AACjB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,iBAAiB;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAI1E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/standard-schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
|
-
// RUNTIME HELPERS
|
|
2
|
+
// CUSTOM RUNTIME HELPERS
|
|
3
3
|
// ============================================================================
|
|
4
4
|
/** Helper function to validate input using a Standard Schema. */
|
|
5
5
|
export async function standardParse(schema, value) {
|
|
@@ -11,6 +11,7 @@ export function isStandardSchema(value) {
|
|
|
11
11
|
value !== null &&
|
|
12
12
|
"~standard" in value &&
|
|
13
13
|
typeof value["~standard"] === "object" &&
|
|
14
|
+
value["~standard"] !== null &&
|
|
14
15
|
value["~standard"].version === 1);
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=standard-schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAkGA,+EAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"standard-schema.js","sourceRoot":"","sources":["../src/standard-schema.ts"],"names":[],"mappings":"AAkGA,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,iEAAiE;AACjE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAyC,EACzC,KAAc;IAEd,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,WAAW,IAAI,KAAK;QACpB,OAAQ,KAA0B,CAAC,WAAW,CAAC,KAAK,QAAQ;QAC3D,KAA0B,CAAC,WAAW,CAAC,KAAK,IAAI;QAChD,KAA0B,CAAC,WAAW,CAAC,CAAC,OAAO,KAAK,CAAC,CACvD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kellanjs/actioncraft",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fluent, type-safe builder for Next.js server actions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"next.js",
|
|
@@ -42,11 +42,13 @@
|
|
|
42
42
|
"dev": "vitest",
|
|
43
43
|
"build": "tsc",
|
|
44
44
|
"lint": "eslint .",
|
|
45
|
+
"type": "tsc --noEmit",
|
|
45
46
|
"test": "vitest run",
|
|
47
|
+
"test:coverage": "vitest run --coverage",
|
|
46
48
|
"format": "prettier --write .",
|
|
47
49
|
"check-format": "prettier --check .",
|
|
48
50
|
"check-exports": "attw --pack . --ignore-rules=cjs-resolves-to-esm",
|
|
49
|
-
"ci": "npm run lint && npm run build && npm run check-format && npm run check-exports && npm run test"
|
|
51
|
+
"ci": "npm run lint && npm run type && npm run build && npm run check-format && npm run check-exports && npm run test"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"next": "^15.0.0 || ^16.0.0",
|
|
@@ -59,16 +61,17 @@
|
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
62
|
-
"@eslint/js": "^9.39.
|
|
63
|
-
"@trivago/prettier-plugin-sort-imports": "^
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
64
|
+
"@eslint/js": "^9.39.2",
|
|
65
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
66
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
67
|
+
"eslint": "^9.39.2",
|
|
68
|
+
"next": "^16.1.1",
|
|
69
|
+
"prettier": "^3.7.4",
|
|
70
|
+
"react": "^19.2.3",
|
|
68
71
|
"typescript": "^5.9.3",
|
|
69
|
-
"typescript-eslint": "^8.
|
|
70
|
-
"vitest": "^4.0.
|
|
71
|
-
"zod": "^4.
|
|
72
|
+
"typescript-eslint": "^8.53.0",
|
|
73
|
+
"vitest": "^4.0.17",
|
|
74
|
+
"zod": "^4.3.5",
|
|
72
75
|
"zod-form-data": "^3.0.1"
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;IAED,6EAA6E;IAC7E,4CAA4C;IAC5C,6EAA6E;IAE7E;;;OAGG;IACH,MAAM,CACJ,MAAkB;QAQlB,OAAO,IAAI,aAAa,CACtB,MAAM,EACN,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,EACZ,EAA2B,EAC3B,SAAS,CACV,CAAC;IACJ,CAAC;IA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B,EAA2B,EAC3B,EAA2B,EAC3B,EAA2B,EAC3B,SAAS,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,129 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,I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