Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create record action #8460

Merged
merged 6 commits into from
Nov 13, 2024
Merged

Create record action #8460

merged 6 commits into from
Nov 13, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Nov 12, 2024

  • Add create record action
  • Migrate all step name => action in a common folder
  • Separate types

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces a new CreateRecord workflow action and reorganizes workflow-related code for better maintainability. Here's a concise summary of the key changes:

  • Added new CreateRecordWorkflowAction for creating database records through workflows using TwentyORMManager
  • Migrated all "step" terminology to "action" across the codebase for consistency
  • Reorganized workflow action types and modules into a common /workflow-actions directory structure
  • Added proper type definitions for the new create record action with WorkflowCreateRecordActionInput and settings types
  • Refactored workflow executor module to use more specific action modules (CodeActionModule, SendEmailActionModule, CreateRecordActionModule)

Note: The CreateRecordWorkflowAction implementation could benefit from additional error handling for invalid object names and failed record operations.

27 file(s) reviewed, 12 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -1,4 +1,4 @@
import { WorkflowActionResult } from 'src/modules/workflow/workflow-executor/types/workflow-action-result.type';
import { WorkflowActionResult } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-result.type';

export interface WorkflowAction {
execute(workflowStepInput: unknown): Promise<WorkflowActionResult>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding type safety by making workflowStepInput generic instead of unknown

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The WorkflowActionType enum only contained CODE and SEND_EMAIL, but the PR adds CREATE_RECORD. Make sure the new enum location includes all three action types.

@thomtrp thomtrp force-pushed the tt-create-record-action branch from 8435b54 to 4b72d8f Compare November 12, 2024 17:48
@thomtrp thomtrp force-pushed the tt-create-record-action branch from 4b72d8f to d2a070a Compare November 12, 2024 17:50
@@ -98,7 +98,7 @@ export class WorkflowVersionWorkspaceEntity extends BaseWorkspaceEntity {
icon: 'IconSettingsAutomation',
})
@WorkspaceIsNullable()
steps: WorkflowStep[] | null;
steps: WorkflowAction[] | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it worth renaming steps into actions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think branches, conditions, loops will be actions. There would be better as steps. Wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

Comment on lines 4 to 6
CREATE = 'Create',
UPDATE = 'Update',
DELETE = 'Delete',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CREATE = 'Create',
UPDATE = 'Update',
DELETE = 'Delete',
CREATE = 'create',
UPDATE = 'update',
DELETE = 'delete',

export enum WorkflowActionType {
CODE = 'CODE',
SEND_EMAIL = 'SEND_EMAIL',
RECORD_OPERATION = 'RECORD_OPERATION',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RECORD_OPERATION = 'RECORD_OPERATION',
CRUD_RECORD = 'CRUD_RECORD',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright renaming everything

input: object;
outputSchema: OutputSchema;
errorHandlingOptions: {
retryOnFailure: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems both bool are mutually exclusive, right?
If so, should we create a strategy enum instead? @thomtrp
If both are true, does that mean it will retry once and continue if still fails? If so you can ignore my comment. You could take example on queue system libraries such as bullmq, usually we want to provide the number of retry etc.
Up to you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If both are true, does that mean it will retry once and continue if still fails?
Yes, it will retry MAX_RETRIES_ON_FAILURE which is a repo constant for now, and then continue if it fails

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think renaming RECORD_OPERATION to CRUD_RECORD is missing, but rest of it LGTM

@thomtrp thomtrp merged commit faeea2b into main Nov 13, 2024
19 checks passed
@thomtrp thomtrp deleted the tt-create-record-action branch November 13, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants