Skip to content

Commit acf9993

Browse files
committed
chore: wip
1 parent f33a529 commit acf9993

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

app/Actions/LogAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default new Action({
1212
description: 'This action is used to demo how to POST to a server and upon success, log a message.',
1313

1414
// the request object is optional, but if it is provided, it will be used for validation
15-
fields: {
15+
validations: {
1616
message: {
1717
rule: schema.string().minLength(3).maxLength(255),
1818
message: 'The message must be between 3 and 255 characters long.',

storage/framework/core/actions/src/action.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import type { JobOptions, Nullable } from '@stacksjs/types'
22
import type { ValidationBoolean, ValidationNumber, ValidationString } from '@stacksjs/validation'
33

4-
type FieldKey = string
5-
interface FieldValue {
4+
type ValidationKey = string
5+
interface ValidationValue {
66
rule: ValidationString | ValidationNumber | ValidationBoolean | Date | Nullable<any>
77
message: string
8-
factory?: any
9-
unique?: boolean
108
}
119

1210
// TODO: this is temporary and will get auto generated based on ./app/Actions/*
@@ -19,7 +17,7 @@ interface ActionOptions {
1917
name?: string
2018
description?: string
2119
apiResponse?: boolean
22-
fields?: Record<FieldKey, FieldValue>
20+
validations?: Record<ValidationKey, ValidationValue>
2321
path?: string
2422
rate?: JobOptions['rate']
2523
tries?: JobOptions['tries']
@@ -31,19 +29,19 @@ interface ActionOptions {
3129
export class Action {
3230
name?: string
3331
description?: string
34-
fields?: Record<FieldKey, FieldValue>
3532
rate?: JobOptions['rate']
3633
tries?: JobOptions['tries']
3734
backoff?: JobOptions['backoff']
3835
enabled?: boolean
36+
validations?: Record<ValidationKey, ValidationValue>
3937
handle: (request?: Request) => Promise<any> | object | string
4038

41-
constructor({ name, description, fields, handle, rate, tries, backoff, enabled }: ActionOptions) {
39+
constructor({ name, description, validations, handle, rate, tries, backoff, enabled }: ActionOptions) {
4240
// log.debug(`Action ${name} created`) // TODO: this does not yet work because the cloud does not yet have proper file system (efs) access
4341

4442
this.name = name
4543
this.description = description
46-
this.fields = fields
44+
this.validations = validations
4745
this.rate = rate
4846
this.tries = tries
4947
this.backoff = backoff

0 commit comments

Comments
 (0)