diff --git a/packages/agent/src/utils/forest-schema/action-values.ts b/packages/agent/src/utils/forest-schema/action-values.ts index e387b195f8..fb2d9749b4 100644 --- a/packages/agent/src/utils/forest-schema/action-values.ts +++ b/packages/agent/src/utils/forest-schema/action-values.ts @@ -35,6 +35,8 @@ export default class ForestValueConverter { data[key] = value; } } + + data[field.name] = data[key]; } return data; diff --git a/packages/datasource-customizer/src/decorators/actions/types/fields.ts b/packages/datasource-customizer/src/decorators/actions/types/fields.ts index 36eb4e97c8..1c5b1b1d40 100644 --- a/packages/datasource-customizer/src/decorators/actions/types/fields.ts +++ b/packages/datasource-customizer/src/decorators/actions/types/fields.ts @@ -23,6 +23,21 @@ export type ValueOrHandler = type BaseDynamicField = { type: Type; label: string; + /** + * the name used to access your value from the context. + * different from the label as it is not shown to the user + * @example + * //in your action field definition: + * { + * label: "Discount percentage" + * name: "percentage" + * ... + * } + * + * //in your execution + * await context.collection.update(context.filter, { percentage: context.formValues.percentage }); + */ + name: string; description?: ValueOrHandler; isRequired?: ValueOrHandler; isReadOnly?: ValueOrHandler; diff --git a/packages/datasource-toolkit/src/interfaces/action.ts b/packages/datasource-toolkit/src/interfaces/action.ts index 7c6adf4a1d..5c59186641 100644 --- a/packages/datasource-toolkit/src/interfaces/action.ts +++ b/packages/datasource-toolkit/src/interfaces/action.ts @@ -22,6 +22,7 @@ export type File = { export type ActionFieldBase = { type: ActionFieldType; label: string; + name: string; description?: string; isRequired?: boolean; isReadOnly?: boolean;