@vicacha-devs/medusa-plugin-automations 0.1.0 → 0.2.0

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.
Files changed (2) hide show
  1. package/README.md +43 -10
  2. package/package.json +8 -3
package/README.md CHANGED
@@ -1,23 +1,34 @@
1
1
  # `@vicacha-devs/medusa-plugin-automations`
2
2
 
3
- Rule-based **trigger → condition → action** automation engine for **Medusa v2** (`>= 2.23.0`).
3
+ Rule-based **trigger → condition → action** automation engine for **Medusa v2** (`>= 2.23.0`), built as an ESM-only package with an optional zero-hard-dependency bridge to `@vicacha-devs/medusa-plugin-notifications`.
4
4
 
5
- - **Triggers**: Commerce events (`order.placed`, `order.completed`, `customer.created`, `inventory-level.updated`, etc.), scheduled rules, and manual triggers (`POST /admin/automations/:id/trigger`).
6
- - **Condition Engine**: Prototype-safe nested path evaluation (`eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `not_in`, `contains`, `not_contains`, `exists`, `not_exists`).
7
- - **Action Handlers**:
8
- - `notification`: Dispatches via Medusa's built-in `Modules.NOTIFICATION`.
9
- - `mpn-notification-studio`: Optional zero-hard-dependency integration with `@vicacha-devs/medusa-plugin-notifications`.
10
- - `webhook`: SSRF-guarded outgoing JSON webhook POST.
11
- - Extensible via `registerActionHandler()` or `options.actionHandlers`.
5
+ ---
12
6
 
13
- ## Installation
7
+ ## Key Features
8
+
9
+ - **Triggers**:
10
+ - **Commerce Events**: `order.placed`, `order.completed`, `order.canceled`, `customer.created`, `product.created`, `product.updated`, `inventory-level.updated` (via `src/subscribers/automation-events.ts`).
11
+ - **Scheduled & Manual Triggers**: Cron-ready rule definitions plus manual execution via `POST /admin/automations/:id/trigger`.
12
+ - **Prototype-Safe Condition Evaluator (`evaluateConditions`)**:
13
+ - Resolves nested dot/array paths (`order.total`, `order.items.0.sku`, `customer.tags`) while blocking `__proto__`, `constructor`, and `prototype`.
14
+ - Supports 12 operators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `in`, `not_in`, `contains`, `not_contains`, `exists`, `not_exists`.
15
+ - **Built-in & Extensible Action Handlers (`AutomationActionHandler`)**:
16
+ - `notification`: Dispatches via Medusa's built-in `Modules.NOTIFICATION` (`email`, `sms`, `whatsapp`, `telegram`, `slack`).
17
+ - `mpn-notification-studio`: Optional bridge to `@vicacha-devs/medusa-plugin-notifications` (falls back to `Modules.NOTIFICATION` when standalone).
18
+ - `webhook`: SSRF-guarded outgoing JSON `POST` (`https://` in production; loopback allowed in non-production).
19
+ - Register custom handlers via `service.registerActionHandler(handler)` or `options.actionHandlers`.
20
+
21
+ ---
22
+
23
+ ## Installation & Configuration
14
24
 
15
25
  ```bash
16
26
  pnpm add @vicacha-devs/medusa-plugin-automations
17
27
  ```
18
28
 
19
29
  ```ts
20
- // medusa-config.ts
30
+ import { defineConfig } from "@medusajs/framework/utils"
31
+
21
32
  export default defineConfig({
22
33
  plugins: [
23
34
  {
@@ -27,3 +38,25 @@ export default defineConfig({
27
38
  ],
28
39
  })
29
40
  ```
41
+
42
+ ---
43
+
44
+ ## Data Models & REST API
45
+
46
+ - **Models**: `automation_rule` (`AutomationRuleModel`) and `automation_execution_log` (`AutomationExecutionLogModel`).
47
+ - **Admin Endpoints**:
48
+ - `GET /admin/automations` · `POST /admin/automations`
49
+ - `GET /admin/automations/:id` · `PATCH /admin/automations/:id` · `DELETE /admin/automations/:id`
50
+ - `POST /admin/automations/:id/trigger`
51
+ - `GET /admin/automations/:id/logs`
52
+ - `GET /admin/automations/actions`
53
+ - **Admin UI**: `/app/automations` route for viewing, toggling, and manually triggering rules.
54
+
55
+ ---
56
+
57
+ ## Development & Testing
58
+
59
+ ```bash
60
+ pnpm --filter @vicacha-devs/medusa-plugin-automations test
61
+ pnpm --filter @vicacha-devs/medusa-plugin-automations typecheck
62
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicacha-devs/medusa-plugin-automations",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Automations plugin for Medusa v2 by Vicacha Devs.",
5
5
  "keywords": [
6
6
  "automations",
@@ -14,6 +14,11 @@
14
14
  ],
15
15
  "license": "MIT",
16
16
  "author": "Vicacha Devs",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Vicacha-Devs/medusa-plugins.git",
20
+ "directory": "packages/automations"
21
+ },
17
22
  "files": [
18
23
  ".medusa/server",
19
24
  "src",
@@ -60,9 +65,9 @@
60
65
  "tsc-alias": "^1.9.2",
61
66
  "typescript": "5.6.2",
62
67
  "vite": "^8.3.8",
68
+ "@vicacha-devs/medusa-eslint-config": "1.0.0",
63
69
  "@vicacha-devs/medusa-plugin-testing": "1.0.0",
64
- "@vicacha-devs/medusa-typescript-config": "1.0.0",
65
- "@vicacha-devs/medusa-eslint-config": "1.0.0"
70
+ "@vicacha-devs/medusa-typescript-config": "1.0.0"
66
71
  },
67
72
  "peerDependencies": {
68
73
  "@medusajs/admin-sdk": "2.23.0",