Commit Graph

300 Commits

Author SHA1 Message Date
Jan Jakes
0e32a215f3 Add MailPoet subscriber subject
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
832ad3a898 Add MailPoet segment subject
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
87a8538912 Add basic MailPoet automation integration with segment subscribed trigger
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
716050b7de Save subject data in workflow runs
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
50b889a1bd Add workflow data subject & field interfaces
A subject contains multiple fields. Each field has a type and they
can be filtered and used later on.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
d9d7df0b84 Add column for workflow data subjects
Data subjects will carry the data through a workflow.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
b62bc21849 Enqueue next step or complete workflow in step runner
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
ac04ade359 Implement action step runner
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
a7cd2b74b4 Fetch workflow, workflow run, and step in workflow step runner
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
66eaf555b5 Catch all errors in step runner
Action Scheduler handles only exceptions, not other errors.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
0c8c86c0a8 Add basic workflow step runner service
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
4a8f37172a Enqueue next workflow step in trigger handler
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
6d040571aa Add simple Action Scheduler wrapper service
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
e4b09ab6de Create new workflow run in trigger handler
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
b88e310f7e Add storage service for workflow runs & create workflow run method
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
a191c691f5 Add hook and basic handler for automation triggers
For now trigger keys are stored in the workflow as a JSON array.
This is not optimal in case someone has many workflows but as
workflows are user-created it's unlinkely someone will have thousands
of them. We can consider adding a workflow_triggers table as well.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
933ee0c8c8 Call "registerHooks" method for all triggers of all active workflows
This is needed so the triggers actually work – their hooks need to be
registered when the triggers are in some active workflows.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
55a25427fc Add initialize hook to register automation integrations
Those need to be registered after Automation engine is initialized.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
634cd11af9 Add automation integration interface
An integration is a set of triggers, actions, subjects, etc.
(E.g. "MailPoet integration".)

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
db21cfa8a5 Add registry service for workflow triggers and actions
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
c97476e8c3 Add controller to create workflows via REST API
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
41cb2c4034 Add storage service for workflows & create workflow method
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
97ad4cffb5 Add interface for workflow actions
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
ee6cdeceab Add interface for workflow triggers
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
bc1b27a53b Add workflow run data object
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
37b2c29eab Add workflow run table
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
b742a394b2 Add workflow step data definition
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
3e6a4fd557 Add workflow data object and an empty step object
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
020309e916 Add status and trigger keys workflow columns
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
5a5c11cbbe Rename workflow data column to steps
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
a08aaabc55 Fix 'deleted_at' column not being nullable
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
a3198a6a87 Fix passing args to WordPress hook
[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
da2621230d Move automation engine code under "Engine" namespace
This is to separate the engine itself from "integrations" that will be
built on top of the engine.

[MAILPOET-4136]
2022-03-14 09:36:21 +01:00
Jan Jakes
ec0f490397 Restrict automation API only for admins
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
4c61236d9a Add readme for automation
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
7153f6f0b5 Register action scheduler in automation
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
58dd80e647 Make strings translatable
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
de3227c6d6 Add endpoint to (re)create and delete automation DB schema
These are just "system" testing endpoints that we'll use in prototyping
phases. We should remove them eventually.

[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
d3e4d2c9d8 Construct method-not-allowed exception using exception factory
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
7c503a3517 Add basic migrator to create/delete automation tables for prototyping
This is a simple service used only for prototyping that will allow us
to simply change and recreate database schemas. Eventually, we'll need
to replace it with database migration logic.

[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
9e8e3a37bb Add basic workflow endpoint with hello world message
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
51d6b541e5 Add check that JSON request body exists when required
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
8c7516eaba Expose 5xx errors in PHP error log
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
b40f344a51 Add API exception handling and error response
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
b2a9053fa8 Add static factory class for easier exception creation
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
79350b4282 Add basic set of exceptions compatible with WP REST API
This means the exception need to have string error code, HTTP status code, and a message,
as the WP REST API errors look as foolows:

{"code":"rest_invalid_json","message":"Invalid JSON body passed.","data":{"status":400,"json_error_code":4,"json_error_message":"Syntax error"}}

[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
99a8ee3a46 Add basic API route handling wrapper for WP REST API
Each endpoint will be a class that can implement get/post/put/delete methods.
The routes are registered to WP REST API automatically based on the existence
of implemented methods. The endpoint classes are handled standard services and
therefore can leverage full powers of the DI container.

[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
ebfddb73bd Add endpoint-class factory based on PSR-11 container interface
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
18d722cd51 Add basic request, response, and endpoint definitions for API
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00
Jan Jakes
ddb04feef4 Add empty automation initializer
[MAILPOET-4135]
2022-02-21 09:56:26 +01:00