1
1
import type { JobOptions , Nullable } from '@stacksjs/types'
2
2
import type { ValidationBoolean , ValidationNumber , ValidationString } from '@stacksjs/validation'
3
3
4
- type FieldKey = string
5
- interface FieldValue {
4
+ type ValidationKey = string
5
+ interface ValidationValue {
6
6
rule : ValidationString | ValidationNumber | ValidationBoolean | Date | Nullable < any >
7
7
message : string
8
- factory ?: any
9
- unique ?: boolean
10
8
}
11
9
12
10
// TODO: this is temporary and will get auto generated based on ./app/Actions/*
@@ -19,7 +17,7 @@ interface ActionOptions {
19
17
name ?: string
20
18
description ?: string
21
19
apiResponse ?: boolean
22
- fields ?: Record < FieldKey , FieldValue >
20
+ validations ?: Record < ValidationKey , ValidationValue >
23
21
path ?: string
24
22
rate ?: JobOptions [ 'rate' ]
25
23
tries ?: JobOptions [ 'tries' ]
@@ -31,19 +29,19 @@ interface ActionOptions {
31
29
export class Action {
32
30
name ?: string
33
31
description ?: string
34
- fields ?: Record < FieldKey , FieldValue >
35
32
rate ?: JobOptions [ 'rate' ]
36
33
tries ?: JobOptions [ 'tries' ]
37
34
backoff ?: JobOptions [ 'backoff' ]
38
35
enabled ?: boolean
36
+ validations ?: Record < ValidationKey , ValidationValue >
39
37
handle : ( request ?: Request ) => Promise < any > | object | string
40
38
41
- constructor ( { name, description, fields , handle, rate, tries, backoff, enabled } : ActionOptions ) {
39
+ constructor ( { name, description, validations , handle, rate, tries, backoff, enabled } : ActionOptions ) {
42
40
// log.debug(`Action ${name} created`) // TODO: this does not yet work because the cloud does not yet have proper file system (efs) access
43
41
44
42
this . name = name
45
43
this . description = description
46
- this . fields = fields
44
+ this . validations = validations
47
45
this . rate = rate
48
46
this . tries = tries
49
47
this . backoff = backoff
0 commit comments