@docyrus/docyrus 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docyrus/docyrus",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "description": "Docyrus API CLI",
6
6
  "main": "./main.js",
@@ -2,29 +2,52 @@
2
2
 
3
3
  ## Automation Engine
4
4
 
5
- Define event-driven workflows with triggers and action chains:
6
-
7
- **Triggers:**
8
-
9
- - Record created, modified, or deleted
10
- - Time-based (after a period, recurring interval)
11
- - Webhook (external event)
12
- - Button activation (user action)
13
- - Previous action (chaining)
14
- - AI agent (agent-triggered)
15
-
16
- **Actions:**
17
-
18
- - Send email
19
- - Send notification
20
- - Create record
21
- - Update records
22
- - Request input
23
- - Request approval
24
- - Trigger HTTP request
25
- - AI prompt
26
- - AI agent execution
27
- - Data source query
28
- - Custom query execution
29
-
30
- Automations support conditional flows, action chains, and soft-delete (archiving).
5
+ Define event-driven workflows with triggers and action chains. Each automation belongs to a tenant app and combines one or more triggers with a graph of typed action nodes.
6
+
7
+ ## Trigger Types
8
+
9
+ The runtime supports ten trigger types. The dev API exposes each as a typed endpoint, and the CLI exposes the same set under `docyrus automation create-trigger --type <kebab-case>`.
10
+
11
+ - `record-created` fires when a record is inserted into the source data source
12
+ - `record-modified` fires when specific columns change (with `all` / `any` match mode)
13
+ - `record-deleted` fires when a record is removed from the source data source
14
+ - `recurrence` fires on a cron-like schedule (hour / day / week / month / year, with run-at time and weekday/month-day options)
15
+ - `app-event` — fires from a connector or core data-provider event (with optional webhook binding)
16
+ - `webhook` — fires when an external HTTP webhook is received
17
+ - `emailhook` — fires when a tenant-bound inbound email is received
18
+ - `webform` — fires when a public webform is submitted
19
+ - `button-activation` — fires when a user activates an in-UI button on a record
20
+ - `manual-activation` — fires when a record is manually activated via the UI
21
+
22
+ The platform also tracks `max_run_per_record` for record-* and recurrence triggers to prevent re-firing on the same record.
23
+
24
+ ## Action Node Types
25
+
26
+ Action nodes are the building blocks of an automation's execution graph. The dev API exposes each as a typed endpoint, and the CLI exposes the same set under `docyrus automation create-node --type <kebab-case>`.
27
+
28
+ - `external-action` invokes a registered `core_action` against a connector (requires `action_type_id`; backend validates payload against `core_action.input_json_schema` and provisions the `tenant_action` row)
29
+ - `send-email` — sends an email through a tenant email account or template
30
+ - `send-notification` pushes an in-app or device notification
31
+ - `create-record` — inserts a record into a target data source
32
+ - `update-records` — bulk-updates records in a target data source (optionally pivoted on a target field)
33
+ - `request-approval` — opens an approval cycle against an input data source
34
+ - `request-input` — collects ad-hoc input from a user via the input data source
35
+ - `http-request` — fires an HTTP request (supports batch mode, transformers, and connection auth)
36
+ - `data-source-query` — runs a data source query and emits the result into the chain
37
+ - `custom-query` — runs a saved custom SQL query
38
+ - `generate-document` — renders an HTML/PDF/DOCX template against a record
39
+ - `ai-prompt` — runs a stored prompt against an AI provider
40
+ - `ai-agent` — invokes a Docyrus AI agent
41
+ - `execute-script` — runs a sandboxed JavaScript snippet
42
+ - `wait-for` — bridge action that delays the next step. Does no work itself; forwards input data unchanged and queues the next step(s) with `tenant_job_queue.process_after = clock_timestamp() + delaySeconds` so the worker defers execution. Configure via `data.delaySeconds` (integer, ≤ 30 days) or the `data.delayValue` + `data.delayUnit` (`seconds`/`minutes`/`hours`/`days`) pair.
43
+
44
+ ## Composition Features
45
+
46
+ - Conditional branches via per-node `condition` payloads
47
+ - Action chains with parent/child wiring (`parent` node id)
48
+ - Field mappings (`field_mapping`, `dynamic_field_mapping`) for record-shaped nodes
49
+ - Request lifecycle hooks (`pre_action_request`, `post_action_request`) on external-action nodes
50
+ - Input/output transformers (`input_template`, `input_transformer`, `output_transformer`, `batch_transformer`, `error_transformer`) on http-request nodes
51
+ - Custom headers (`custom_headers`) for http-request nodes
52
+ - Target data source conditions (`target_data_source_condition`) on update-records and external-action nodes
53
+ - Soft-delete (archiving) for both automations and individual nodes
@@ -14,7 +14,7 @@
14
14
  ## CLI
15
15
 
16
16
  - Full-featured CLI (`@docyrus/docyrus`) for terminal and AI agent use
17
- - Commands: environment management, authentication, data operations, record comments, record file attachments, schema management (studio), app management, API discovery, AI chat, and direct API requests
17
+ - Commands: environment management, authentication, data operations, record comments, record file attachments, schema management (studio: data sources, fields, enums, data views, forms, webforms, HTML/PDF/DOCX export templates, email templates), automation management (automation, trigger, and action node CRUD), tenant email account discovery and transactional email send (messaging), app management, API discovery, connector discovery and provider-auth requests, AI chat, and direct API requests
18
18
  - Multi-account, multi-tenant session management
19
19
  - OpenAPI discovery with caching and fallback generation
20
20
  - Interactive TUI mode
@@ -871,6 +871,229 @@ Same options as `create-email-template`, plus `--templateId` (required).
871
871
 
872
872
  ---
873
873
 
874
+ ## automation — Automations, Triggers, and Action Nodes
875
+
876
+ Manage automations, their triggers, and their action nodes for a tenant app. All commands route through `/v1/dev/apps/:appId/automations`.
877
+
878
+ **Common selector rules:**
879
+ - App: exactly one of `--appId` or `--appSlug`
880
+ - Automation: `--automationId` (no slug — automations and nodes are ID-only)
881
+ - Trigger `--type` (URL kebab-case): `record-created`, `record-modified`, `record-deleted`, `recurrence`, `app-event`, `webhook`, `emailhook`, `webform`, `button-activation`, `manual-activation`
882
+ - Node `--type` (URL kebab-case): `external-action`, `send-email`, `send-notification`, `create-record`, `update-records`, `request-approval`, `request-input`, `http-request`, `data-source-query`, `custom-query`, `generate-document`, `ai-prompt`, `ai-agent`, `execute-script`, `wait-for`
883
+
884
+ **Write payload rules:**
885
+ - Write commands accept `--data '<json>'` or `--from-file ./payload.json` (JSON only)
886
+ - Convenience flags are camelCase and are converted to `snake_case` in the request body
887
+ - Nested objects (trigger `data`; node `data`, `field_mapping`, `dynamic_field_mapping`, `condition`, `input_template`, `input_transformer`, `custom_headers`, `pre_action_request`, `post_action_request`, `target_data_source_condition`) must be supplied via `--data` / `--from-file` — the CLI does not flatten them
888
+ - `delete`, `delete-trigger`, and `delete-node` return `{ deleted: true, id }` (API itself returns 204)
889
+
890
+ ### Automation CRUD
891
+
892
+ #### `docyrus automation list`
893
+
894
+ | Option | Type | Description |
895
+ |---|---|---|
896
+ | `--appId / --appSlug` | string | App selector |
897
+
898
+ #### `docyrus automation get`
899
+
900
+ | Option | Type | Description |
901
+ |---|---|---|
902
+ | `--appId / --appSlug` | string | App selector |
903
+ | `--automationId` | string | Automation ID (required) |
904
+
905
+ #### `docyrus automation create`
906
+
907
+ Creates an automation together with its first trigger. `--triggerType` uses camelCase (`recordCreated`, `recordModified`, `recordDeleted`, `recurrence`, `appEvent`, `webhook`, `emailhook`, `webform`, `buttonActivation`, `manualActivation`) to match `CreateAutomationDto.trigger_type`.
908
+
909
+ | Option | Type | Description |
910
+ |---|---|---|
911
+ | `--appId / --appSlug` | string | App selector |
912
+ | `--data` | string | JSON payload |
913
+ | `--fromFile` | string | Path to JSON file |
914
+ | `--name` | string | Automation name |
915
+ | `--triggerType` | string | Initial trigger type (camelCase) |
916
+ | `--status` | number | Automation status |
917
+ | `--sourceDataSourceId` | string | Source data source ID |
918
+ | `--triggerDataSourceId` | string | Trigger data source ID |
919
+ | `--triggerDataProviderId` | string | Trigger data provider ID |
920
+ | `--triggerWebhookId` | string | Trigger webhook ID |
921
+
922
+ #### `docyrus automation update`
923
+
924
+ | Option | Type | Description |
925
+ |---|---|---|
926
+ | `--appId / --appSlug` | string | App selector |
927
+ | `--automationId` | string | Automation ID (required) |
928
+ | `--data / --fromFile` | string | JSON payload / file |
929
+ | `--name` | string | Automation name |
930
+ | `--status` | number | Automation status |
931
+ | `--sourceDataSourceId` | string | Source data source ID |
932
+
933
+ #### `docyrus automation delete`
934
+
935
+ | Option | Type | Description |
936
+ |---|---|---|
937
+ | `--appId / --appSlug` | string | App selector |
938
+ | `--automationId` | string | Automation ID (required) |
939
+
940
+ ### Trigger CRUD
941
+
942
+ #### `docyrus automation list-triggers`
943
+
944
+ Derived from the automation GET response.
945
+
946
+ #### `docyrus automation get-trigger`
947
+
948
+ Same options as `list-triggers`, plus `--triggerId` (required).
949
+
950
+ #### `docyrus automation create-trigger`
951
+
952
+ Routes through `POST .../triggers/:type`.
953
+
954
+ | Option | Type | Description |
955
+ |---|---|---|
956
+ | `--appId / --appSlug` | string | App selector |
957
+ | `--automationId` | string | Automation ID (required) |
958
+ | `--type` | string | Trigger type (kebab-case, required) |
959
+ | `--data / --fromFile` | string | JSON payload / file |
960
+ | `--active` | boolean | Whether the trigger is active |
961
+ | `--sourceDataSourceId` | string | Source data source (record-*, recurrence, button/manual) |
962
+ | `--maxRunPerRecord` | number | Max runs per record (record-*, recurrence) |
963
+ | `--modifiedColumns` | string | Comma-separated columns (record-modified) |
964
+ | `--modifiedColumnsCondition` | string | `all` or `any` (record-modified) |
965
+ | `--recurrenceFrequency` | string | `hour`, `day`, `week`, `month`, `year` (recurrence) |
966
+ | `--recurrenceInterval` | number | Recurrence interval (recurrence) |
967
+ | `--recurrenceMinutes` | number | Minutes `0\|15\|30\|45` (recurrence) |
968
+ | `--recurrenceWeekDays` | string | Comma-separated week days `MON,TUE,...` (recurrence) |
969
+ | `--recurrenceMonthDays` | string | `DAY_OF_MONTH` or `DAY_OF_WEEK` (recurrence) |
970
+ | `--recurrenceStartDate` | string | ISO date (recurrence) |
971
+ | `--recurrenceEndDate` | string | ISO date (recurrence) |
972
+ | `--recurrenceRunAt` | string | `HH:mm` (recurrence) |
973
+ | `--coreDataProviderId` | string | Core data provider ID (app-event) |
974
+ | `--coreDataProviderWebhookId` | string | Core data provider webhook ID (app-event) |
975
+ | `--webhookId` | string | Webhook ID (webhook, emailhook) |
976
+ | `--webhookName` | string | Name for auto-created webhook (webhook, emailhook) |
977
+ | `--tenantWebformId` | string | Tenant webform ID (webform) |
978
+
979
+ #### `docyrus automation update-trigger`
980
+
981
+ Routes through `PATCH .../triggers/:type/:triggerId`. Same flags as `create-trigger`, plus `--triggerId` (required).
982
+
983
+ #### `docyrus automation delete-trigger`
984
+
985
+ Routes through `DELETE .../triggers/:triggerId` (type-independent).
986
+
987
+ | Option | Type | Description |
988
+ |---|---|---|
989
+ | `--appId / --appSlug` | string | App selector |
990
+ | `--automationId` | string | Automation ID (required) |
991
+ | `--triggerId` | string | Trigger ID (required) |
992
+
993
+ ### Action Node CRUD
994
+
995
+ #### `docyrus automation list-nodes`
996
+
997
+ `GET .../nodes`
998
+
999
+ #### `docyrus automation get-node`
1000
+
1001
+ `GET .../nodes/:nodeId`
1002
+
1003
+ #### `docyrus automation create-node`
1004
+
1005
+ Routes through `POST .../nodes/:type`. `external-action` create requires `--actionTypeId`; the backend validates `data` against `core_action.input_json_schema` and provisions the `tenant_action` row in the same transaction.
1006
+
1007
+ | Option | Type | Description |
1008
+ |---|---|---|
1009
+ | `--appId / --appSlug` | string | App selector |
1010
+ | `--automationId` | string | Automation ID (required) |
1011
+ | `--type` | string | Node type (kebab-case, required) |
1012
+ | `--data / --fromFile` | string | JSON payload / file |
1013
+ | `--name` | string | Node name |
1014
+ | `--description` | string | Node description |
1015
+ | `--subType` | string | Sub type discriminator |
1016
+ | `--parent` | string | Parent node ID |
1017
+ | `--active` | boolean | Whether the node is active |
1018
+ | `--actionTypeId` | string | Action type ID (required for external-action create; maps to `core_action.id`) |
1019
+ | `--sourceDataSourceId` | string | Source data source ID (external-action) |
1020
+ | `--targetDataSourceId` | string | Target data source ID (create-record, update-records, http-request, data-source-query, external-action) |
1021
+ | `--targetDataSourceFieldId` | string | Target data source field ID (update-records) |
1022
+ | `--connectionId` | string | Connection ID (http-request, external-action) |
1023
+ | `--connectionAccountId` | string | Connection account ID (http-request, external-action) |
1024
+ | `--webhookId` | string | Webhook ID (external-action) |
1025
+ | `--inputDataSourceId` | string | Input data source ID (request-approval, request-input) |
1026
+ | `--requestMethod` | string | HTTP method (http-request): `GET`, `POST`, `PUT`, `PATCH`, `DELETE` |
1027
+ | `--contentType` | string | HTTP content type (http-request) |
1028
+ | `--customEndpoint` | string | HTTP endpoint (http-request) |
1029
+ | `--relativeEndpoint` | boolean | Whether the endpoint is relative to the connection base URL (http-request) |
1030
+ | `--batch` | boolean | Whether to send the HTTP request in batches (http-request) |
1031
+ | `--batchSize` | number | HTTP batch size 1..10000 (http-request) |
1032
+ | `--outputTransformer` | string | Output transformer expression (http-request) |
1033
+ | `--batchTransformer` | string | Batch transformer expression (http-request) |
1034
+ | `--errorTransformer` | string | Error transformer expression (http-request) |
1035
+
1036
+ `wait-for` nodes accept no flat convenience flags beyond the common base — supply `data.delaySeconds` (integer ≤ 30 days) or the `data.delayValue` + `data.delayUnit` pair (`seconds` / `minutes` / `hours` / `days`) via `--data` / `--from-file`. The action forwards input through unchanged and queues the next step(s) with a deferred `tenant_job_queue.process_after`.
1037
+
1038
+ ```sh
1039
+ docyrus automation create-node \
1040
+ --appSlug crm \
1041
+ --automationId 9c4f… \
1042
+ --type wait-for \
1043
+ --name "Wait 2 hours" \
1044
+ --parent <previous-node-id> \
1045
+ --data '{"data":{"delayValue":2,"delayUnit":"hours"}}'
1046
+ ```
1047
+
1048
+ #### `docyrus automation update-node`
1049
+
1050
+ Routes through `PATCH .../nodes/:type/:nodeId`. Same flags as `create-node`, plus `--nodeId` (required).
1051
+
1052
+ #### `docyrus automation delete-node`
1053
+
1054
+ Routes through `DELETE .../nodes/:nodeId` (type-independent).
1055
+
1056
+ | Option | Type | Description |
1057
+ |---|---|---|
1058
+ | `--appId / --appSlug` | string | App selector |
1059
+ | `--automationId` | string | Automation ID (required) |
1060
+ | `--nodeId` | string | Node ID (required) |
1061
+
1062
+ ---
1063
+
1064
+ ## messaging — Tenant Email Accounts and Send
1065
+
1066
+ List tenant email accounts and send transactional emails. Routes through `/v1/messaging/email/*` and requires the `Messaging.Email.Send` OAuth2 scope. Credentials are never returned.
1067
+
1068
+ ### `docyrus messaging accounts`
1069
+
1070
+ `GET /messaging/email/accounts`
1071
+
1072
+ Returns active tenant email accounts. Each item exposes `id`, `name`, `provider`, `senderEmail`, `senderName`, `isUserAccessible`, `allowOverrideName`, `allowOverrideEmail`, `createdOn`.
1073
+
1074
+ ### `docyrus messaging email send`
1075
+
1076
+ `POST /messaging/email/accounts/:accountId/send`
1077
+
1078
+ | Option | Type | Description |
1079
+ |---|---|---|
1080
+ | `--accountId` | string | Tenant email account UUID (required) |
1081
+ | `--to` | string | Comma-separated recipient addresses |
1082
+ | `--cc` | string | Comma-separated CC addresses |
1083
+ | `--bcc` | string | Comma-separated BCC addresses |
1084
+ | `--replyTo` | string | Comma-separated reply-to addresses |
1085
+ | `--subject` | string | Subject (max 998 chars) |
1086
+ | `--body` | string | HTML or text body (max 1 000 000 chars) |
1087
+ | `--sendAsUser` | boolean | Send using the authenticated user's identity when the account allows the override |
1088
+ | `--data` | string | Full JSON payload; overrides individual flags when set |
1089
+ | `--fromFile` | string | Read full JSON payload from a JSON file |
1090
+
1091
+ Limits: up to 50 addresses per recipient list, up to 10 attachments. Attachments are `{ filePath, fileName?, mimeType? }` with `filePath` referencing a tenant-scoped storage path.
1092
+
1093
+ Response payload: `{ messageId, provider, accepted, rejected }`.
1094
+
1095
+ ---
1096
+
874
1097
  ## curl — Direct API Requests
875
1098
 
876
1099
  ### `docyrus curl <path>`
@@ -58,3 +58,6 @@
58
58
  - Custom HTML email templates with dynamic content
59
59
  - Email configuration management
60
60
  - Delivery tracking and webhook integration
61
+ - Tenant email accounts with per-provider credentials, optional user-level identity override, and send-as-user enforcement
62
+ - Send endpoint `POST /v1/messaging/email/accounts/{accountId}/send` (scope `Messaging.Email.Send`) with multi-recipient `to`/`cc`/`bcc`/`replyTo`, HTML or text body, and up to 10 storage-backed attachments
63
+ - Account discovery via `GET /v1/messaging/email/accounts` (credentials are never returned; the response exposes provider, sender identity, and override flags)