rez_core 4.0.184 → 4.0.187
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/dist/app.module.js +11 -0
- package/dist/app.module.js.map +1 -1
- package/dist/config/bull.config.d.ts +10 -0
- package/dist/config/bull.config.js +66 -0
- package/dist/config/bull.config.js.map +1 -0
- package/dist/config/database.config.js +1 -1
- package/dist/config/database.config.js.map +1 -1
- package/dist/module/entity_json/controller/entity_json.controller.d.ts +8 -0
- package/dist/module/entity_json/controller/entity_json.controller.js +43 -0
- package/dist/module/entity_json/controller/entity_json.controller.js.map +1 -0
- package/dist/module/entity_json/entity_json.module.d.ts +2 -0
- package/dist/module/entity_json/entity_json.module.js +26 -0
- package/dist/module/entity_json/entity_json.module.js.map +1 -0
- package/dist/module/entity_json/service/entity_json.service.d.ts +7 -0
- package/dist/module/entity_json/service/entity_json.service.js +116 -0
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -0
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/integration/service/wrapper.service.d.ts +3 -1
- package/dist/module/integration/service/wrapper.service.js +39 -36
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +5 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +29 -0
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -0
- package/dist/module/linked_attributes/entity/linked_attribute.entity.d.ts +9 -0
- package/dist/module/linked_attributes/entity/linked_attribute.entity.js +70 -0
- package/dist/module/linked_attributes/entity/linked_attribute.entity.js.map +1 -0
- package/dist/module/linked_attributes/linked_attributes.module.d.ts +2 -0
- package/dist/module/linked_attributes/linked_attributes.module.js +29 -0
- package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -0
- package/dist/module/linked_attributes/repository/linked_attribute.repository.d.ts +6 -0
- package/dist/module/linked_attributes/repository/linked_attribute.repository.js +31 -0
- package/dist/module/linked_attributes/repository/linked_attribute.repository.js.map +1 -0
- package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +5 -0
- package/dist/module/linked_attributes/service/linked_attributes.service.js +34 -0
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -0
- package/dist/module/mapper/service/field-mapper.service.js +2 -2
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
- package/dist/module/meta/controller/attribute-master.controller.d.ts +10 -1
- package/dist/module/meta/controller/attribute-master.controller.js +27 -2
- package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
- package/dist/module/meta/controller/entity-master.controller.d.ts +6 -0
- package/dist/module/meta/controller/entity-master.controller.js +13 -0
- package/dist/module/meta/controller/entity-master.controller.js.map +1 -1
- package/dist/module/meta/entity.module.js +7 -0
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/attribute-master.repository.d.ts +4 -0
- package/dist/module/meta/repository/attribute-master.repository.js +19 -0
- package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
- package/dist/module/meta/repository/entity-attribute-update.repository.d.ts +6 -0
- package/dist/module/meta/repository/entity-attribute-update.repository.js +44 -0
- package/dist/module/meta/repository/entity-attribute-update.repository.js.map +1 -0
- package/dist/module/meta/repository/entity-master.repository.d.ts +7 -1
- package/dist/module/meta/repository/entity-master.repository.js +24 -2
- package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +4 -0
- package/dist/module/meta/service/attribute-master.service.js +3 -0
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-attribute-update.service.d.ts +7 -0
- package/dist/module/meta/service/entity-attribute-update.service.js +35 -0
- package/dist/module/meta/service/entity-attribute-update.service.js.map +1 -0
- package/dist/module/meta/service/entity-master.service.d.ts +4 -0
- package/dist/module/meta/service/entity-master.service.js +3 -0
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.js +2 -2
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.js +1 -7
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/workflow/entity/action.entity.d.ts +1 -0
- package/dist/module/workflow/entity/action.entity.js +4 -0
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.js +1 -0
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
- package/dist/module/workflow/repository/task.repository.d.ts +3 -1
- package/dist/module/workflow/repository/task.repository.js +6 -1
- package/dist/module/workflow/repository/task.repository.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +41 -27
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +23 -21
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow-automation/controller/workflow-automation.controller.d.ts +6 -0
- package/dist/module/workflow-automation/controller/workflow-automation.controller.js +16 -0
- package/dist/module/workflow-automation/controller/workflow-automation.controller.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation.entity.d.ts +2 -0
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js +8 -0
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js.map +1 -1
- package/dist/module/workflow-automation/service/schedule-handler.service.d.ts +16 -0
- package/dist/module/workflow-automation/service/schedule-handler.service.js +109 -0
- package/dist/module/workflow-automation/service/schedule-handler.service.js.map +1 -0
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +13 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +111 -2
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/module/workflow-automation/workflow-automation.module.js +14 -1
- package/dist/module/workflow-automation/workflow-automation.module.js.map +1 -1
- package/dist/module/workflow-schedule/constants/schedule.constants.d.ts +27 -0
- package/dist/module/workflow-schedule/constants/schedule.constants.js +31 -0
- package/dist/module/workflow-schedule/constants/schedule.constants.js.map +1 -0
- package/dist/module/workflow-schedule/controller/workflow-schedule.controller.d.ts +83 -0
- package/dist/module/workflow-schedule/controller/workflow-schedule.controller.js +220 -0
- package/dist/module/workflow-schedule/controller/workflow-schedule.controller.js.map +1 -0
- package/dist/module/workflow-schedule/dto/create-schedule.dto.d.ts +32 -0
- package/dist/module/workflow-schedule/dto/create-schedule.dto.js +163 -0
- package/dist/module/workflow-schedule/dto/create-schedule.dto.js.map +1 -0
- package/dist/module/workflow-schedule/dto/get-execution-logs.dto.d.ts +35 -0
- package/dist/module/workflow-schedule/dto/get-execution-logs.dto.js +124 -0
- package/dist/module/workflow-schedule/dto/get-execution-logs.dto.js.map +1 -0
- package/dist/module/workflow-schedule/dto/update-schedule.dto.d.ts +19 -0
- package/dist/module/workflow-schedule/dto/update-schedule.dto.js +106 -0
- package/dist/module/workflow-schedule/dto/update-schedule.dto.js.map +1 -0
- package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.d.ts +30 -0
- package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.js +113 -0
- package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.js.map +1 -0
- package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.d.ts +34 -0
- package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.js +118 -0
- package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.js.map +1 -0
- package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.d.ts +44 -0
- package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.js +3 -0
- package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.js.map +1 -0
- package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.d.ts +3 -0
- package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.js +3 -0
- package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.js.map +1 -0
- package/dist/module/workflow-schedule/processors/schedule.processor.d.ts +31 -0
- package/dist/module/workflow-schedule/processors/schedule.processor.js +409 -0
- package/dist/module/workflow-schedule/processors/schedule.processor.js.map +1 -0
- package/dist/module/workflow-schedule/service/workflow-schedule.service.d.ts +44 -0
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js +434 -0
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -0
- package/dist/module/workflow-schedule/workflow-schedule.module.d.ts +5 -0
- package/dist/module/workflow-schedule/workflow-schedule.module.js +52 -0
- package/dist/module/workflow-schedule/workflow-schedule.module.js.map +1 -0
- package/dist/table.config.d.ts +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/loggingUtil.service.d.ts +9 -2
- package/dist/utils/service/loggingUtil.service.js +65 -14
- package/dist/utils/service/loggingUtil.service.js.map +1 -1
- package/dist/utils/utils.module.js +2 -0
- package/dist/utils/utils.module.js.map +1 -1
- package/package.json +9 -4
- package/src/app.module.ts +16 -2
- package/src/config/bull.config.ts +69 -0
- package/src/config/database.config.ts +1 -1
- package/src/module/entity_json/controller/entity_json.controller.ts +47 -0
- package/src/module/entity_json/entity_json.module.ts +13 -0
- package/src/module/entity_json/service/entity_json.service.ts +162 -0
- package/src/module/filter/service/filter.service.ts +0 -2
- package/src/module/integration/service/wrapper.service.ts +248 -41
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +10 -0
- package/src/module/linked_attributes/entity/linked_attribute.entity.ts +48 -0
- package/src/module/linked_attributes/linked_attributes.module.ts +16 -0
- package/src/module/linked_attributes/repository/linked_attribute.repository.ts +12 -0
- package/src/module/linked_attributes/service/linked_attributes.service.ts +22 -0
- package/src/module/mapper/service/field-mapper.service.ts +12 -7
- package/src/module/meta/controller/attribute-master.controller.ts +20 -0
- package/src/module/meta/controller/entity-master.controller.ts +13 -0
- package/src/module/meta/entity.module.ts +8 -0
- package/src/module/meta/repository/attribute-master.repository.ts +20 -0
- package/src/module/meta/repository/entity-attribute-update.repository.ts +44 -0
- package/src/module/meta/repository/entity-master.repository.ts +30 -0
- package/src/module/meta/service/attribute-master.service.ts +4 -0
- package/src/module/meta/service/entity-attribute-update.service.ts +29 -0
- package/src/module/meta/service/entity-master.service.ts +6 -0
- package/src/module/meta/service/resolver.service.ts +2 -2
- package/src/module/module/service/module-access.service.ts +3 -16
- package/src/module/workflow/entity/action.entity.ts +3 -0
- package/src/module/workflow/repository/action-data.repository.ts +1 -0
- package/src/module/workflow/repository/task.repository.ts +8 -0
- package/src/module/workflow/service/task.service.ts +47 -38
- package/src/module/workflow/service/workflow-meta.service.ts +47 -33
- package/src/module/workflow-automation/SCHEDULING_GUIDE.md +145 -0
- package/src/module/workflow-automation/controller/workflow-automation.controller.ts +22 -0
- package/src/module/workflow-automation/entity/workflow-automation.entity.ts +5 -0
- package/src/module/workflow-automation/service/schedule-handler.service.ts +149 -0
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +1 -1
- package/src/module/workflow-automation/service/workflow-automation.service.ts +163 -2
- package/src/module/workflow-automation/workflow-automation.module.ts +14 -1
- package/src/module/workflow-schedule/INSTALLATION.md +244 -0
- package/src/module/workflow-schedule/MULTI_PROJECT_GUIDE.md +196 -0
- package/src/module/workflow-schedule/README.md +422 -0
- package/src/module/workflow-schedule/constants/schedule.constants.ts +48 -0
- package/src/module/workflow-schedule/controller/workflow-schedule.controller.ts +255 -0
- package/src/module/workflow-schedule/docs/CLAUDE_CODE_GUIDE.md +510 -0
- package/src/module/workflow-schedule/docs/CLAUDE_CODE_PROMPT.md +362 -0
- package/src/module/workflow-schedule/docs/RUN_CLAUDE_CODE.sh +68 -0
- package/src/module/workflow-schedule/dto/create-schedule.dto.ts +147 -0
- package/src/module/workflow-schedule/dto/get-execution-logs.dto.ts +119 -0
- package/src/module/workflow-schedule/dto/update-schedule.dto.ts +96 -0
- package/src/module/workflow-schedule/entities/scheduled-workflow.entity.ts +148 -0
- package/src/module/workflow-schedule/entities/workflow-execution-log.entity.ts +154 -0
- package/src/module/workflow-schedule/interfaces/schedule-job-data.interface.ts +53 -0
- package/src/module/workflow-schedule/interfaces/workflow-schedule-options.interface.ts +12 -0
- package/src/module/workflow-schedule/processors/schedule.processor.ts +584 -0
- package/src/module/workflow-schedule/service/workflow-schedule.service.ts +600 -0
- package/src/module/workflow-schedule/workflow-schedule.module.ts +67 -0
- package/src/resources/dev.properties.yaml +1 -1
- package/src/utils/service/loggingUtil.service.ts +70 -16
- package/src/utils/utils.module.ts +2 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Workflow Schedule Module - Installation Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
### Step 1: Install Dependencies
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @nestjs/bull bull redis cron-parser
|
|
9
|
+
npm install --save-dev @types/bull
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**Note:** `cron-parser` includes its own TypeScript definitions, so no `@types` package is needed.
|
|
13
|
+
|
|
14
|
+
### Step 2: Setup Redis
|
|
15
|
+
|
|
16
|
+
#### Option A: Using Docker (Recommended)
|
|
17
|
+
```bash
|
|
18
|
+
docker run -d \
|
|
19
|
+
--name redis-workflow \
|
|
20
|
+
-p 6379:6379 \
|
|
21
|
+
redis:latest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Option B: Local Installation
|
|
25
|
+
**macOS:**
|
|
26
|
+
```bash
|
|
27
|
+
brew install redis
|
|
28
|
+
brew services start redis
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Ubuntu/Debian:**
|
|
32
|
+
```bash
|
|
33
|
+
sudo apt-get install redis-server
|
|
34
|
+
sudo systemctl start redis-server
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Windows:**
|
|
38
|
+
Download from: https://redis.io/download
|
|
39
|
+
|
|
40
|
+
### Step 3: Configure Environment Variables
|
|
41
|
+
|
|
42
|
+
Add to your `.env` file:
|
|
43
|
+
|
|
44
|
+
```env
|
|
45
|
+
# Redis Configuration
|
|
46
|
+
REDIS_HOST=localhost
|
|
47
|
+
REDIS_PORT=6379
|
|
48
|
+
REDIS_PASSWORD=
|
|
49
|
+
REDIS_DB=0
|
|
50
|
+
|
|
51
|
+
# Existing Database Configuration (verify these)
|
|
52
|
+
DB_HOST=13.234.25.234
|
|
53
|
+
DB_PORT=3306
|
|
54
|
+
DB_USER=root
|
|
55
|
+
DB_PASS=Rezolut@123
|
|
56
|
+
DB_NAME=core
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Step 4: Verify Redis Connection
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Test Redis connection
|
|
63
|
+
redis-cli ping
|
|
64
|
+
# Should respond: PONG
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Step 5: Run Database Migrations
|
|
68
|
+
|
|
69
|
+
The module requires three migrations to be run:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Using TypeORM CLI (recommended)
|
|
73
|
+
npx ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run -d src/config/database.config.ts
|
|
74
|
+
|
|
75
|
+
# Or create a migration script in package.json:
|
|
76
|
+
# "migration:run": "typeorm migration:run -d src/config/database.config.ts"
|
|
77
|
+
# Then run:
|
|
78
|
+
npm run migration:run
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Migrations will create:**
|
|
82
|
+
1. ✅ `workflow_type` column in `cr_wf_master` table
|
|
83
|
+
2. ✅ `cr_wf_scheduled_workflow` table with indexes
|
|
84
|
+
3. ✅ `cr_wf_execution_log` table with indexes
|
|
85
|
+
|
|
86
|
+
### Step 6: Start Your Application
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm run start:dev
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Step 7: Verify Installation
|
|
93
|
+
|
|
94
|
+
Check the console logs for:
|
|
95
|
+
```
|
|
96
|
+
[Nest] INFO [BullModule] Bull queues registered
|
|
97
|
+
[Nest] INFO [WorkflowScheduleModule] Workflow Schedule Module initialized
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quick Test
|
|
101
|
+
|
|
102
|
+
### Create Your First Schedule
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
curl -X POST http://localhost:3000/workflow-schedule/create \
|
|
106
|
+
-H "Content-Type: application/json" \
|
|
107
|
+
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
|
|
108
|
+
-d '{
|
|
109
|
+
"workflow_id": 1,
|
|
110
|
+
"name": "Test Schedule",
|
|
111
|
+
"cron_expression": "*/5 * * * *",
|
|
112
|
+
"timezone": "Asia/Kolkata",
|
|
113
|
+
"actions": []
|
|
114
|
+
}'
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### List All Schedules
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
curl -X GET http://localhost:3000/workflow-schedule/list \
|
|
121
|
+
-H "Authorization: Bearer YOUR_JWT_TOKEN"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Troubleshooting
|
|
125
|
+
|
|
126
|
+
### Issue: Cannot connect to Redis
|
|
127
|
+
|
|
128
|
+
**Solution:**
|
|
129
|
+
```bash
|
|
130
|
+
# Check if Redis is running
|
|
131
|
+
redis-cli ping
|
|
132
|
+
|
|
133
|
+
# If not running, start Redis
|
|
134
|
+
docker start redis-workflow
|
|
135
|
+
# or
|
|
136
|
+
brew services start redis
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Issue: Migration fails with "Table already exists"
|
|
140
|
+
|
|
141
|
+
**Solution:**
|
|
142
|
+
Migrations check if tables exist before creating them. If you see this message, the tables are already present. You can safely ignore it.
|
|
143
|
+
|
|
144
|
+
### Issue: Jobs are not processing
|
|
145
|
+
|
|
146
|
+
**Checklist:**
|
|
147
|
+
- [ ] Redis is running and accessible
|
|
148
|
+
- [ ] Schedule status is `ACTIVE`
|
|
149
|
+
- [ ] Schedule `is_enabled` is `true`
|
|
150
|
+
- [ ] Cron expression is valid
|
|
151
|
+
- [ ] Application has restarted after creating the schedule
|
|
152
|
+
|
|
153
|
+
**Verify:**
|
|
154
|
+
```bash
|
|
155
|
+
# Check Redis keys
|
|
156
|
+
redis-cli KEYS "bull:workflow-schedule:*"
|
|
157
|
+
|
|
158
|
+
# Should show keys if jobs are queued
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Issue: TypeScript errors after installation
|
|
162
|
+
|
|
163
|
+
**Solution:**
|
|
164
|
+
```bash
|
|
165
|
+
# Clear node_modules and reinstall
|
|
166
|
+
rm -rf node_modules package-lock.json
|
|
167
|
+
npm install
|
|
168
|
+
|
|
169
|
+
# Restart your IDE/editor
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Verify Bull Queue Dashboard (Optional)
|
|
173
|
+
|
|
174
|
+
Install Bull Board for visual queue monitoring:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npm install @bull-board/express @bull-board/api
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Add to your `main.ts`:
|
|
181
|
+
```typescript
|
|
182
|
+
import { createBullBoard } from '@bull-board/api';
|
|
183
|
+
import { BullAdapter } from '@bull-board/api/bullAdapter';
|
|
184
|
+
import { ExpressAdapter } from '@bull-board/express';
|
|
185
|
+
|
|
186
|
+
// Get queue from your app
|
|
187
|
+
const schedulerQueue = app.get('BullQueue_workflow-schedule');
|
|
188
|
+
|
|
189
|
+
const serverAdapter = new ExpressAdapter();
|
|
190
|
+
createBullBoard({
|
|
191
|
+
queues: [new BullAdapter(schedulerQueue)],
|
|
192
|
+
serverAdapter,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
serverAdapter.setBasePath('/admin/queues');
|
|
196
|
+
app.use('/admin/queues', serverAdapter.getRouter());
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Then access: `http://localhost:3000/admin/queues`
|
|
200
|
+
|
|
201
|
+
## Package Versions
|
|
202
|
+
|
|
203
|
+
Tested with:
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"@nestjs/bull": "^10.0.0",
|
|
207
|
+
"@nestjs/common": "^11.0.0",
|
|
208
|
+
"@nestjs/core": "^11.0.0",
|
|
209
|
+
"bull": "^4.12.0",
|
|
210
|
+
"redis": "^4.6.0",
|
|
211
|
+
"cron-parser": "^4.9.0"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Production Checklist
|
|
216
|
+
|
|
217
|
+
Before deploying to production:
|
|
218
|
+
|
|
219
|
+
- [ ] Configure Redis with persistence
|
|
220
|
+
- [ ] Set up Redis password authentication
|
|
221
|
+
- [ ] Configure appropriate retry strategies
|
|
222
|
+
- [ ] Set up monitoring and alerting
|
|
223
|
+
- [ ] Configure log retention policies
|
|
224
|
+
- [ ] Test failover scenarios
|
|
225
|
+
- [ ] Set up backup for scheduled workflow configurations
|
|
226
|
+
- [ ] Document schedule ownership and purpose
|
|
227
|
+
- [ ] Configure rate limiting if needed
|
|
228
|
+
- [ ] Set up Redis clustering for high availability
|
|
229
|
+
|
|
230
|
+
## Next Steps
|
|
231
|
+
|
|
232
|
+
1. Read the full [README.md](./README.md) for API documentation
|
|
233
|
+
2. Test the 9 API endpoints
|
|
234
|
+
3. Create your first scheduled workflow
|
|
235
|
+
4. Monitor execution logs
|
|
236
|
+
5. Set up Bull Board for visual monitoring
|
|
237
|
+
|
|
238
|
+
## Support
|
|
239
|
+
|
|
240
|
+
If you encounter issues:
|
|
241
|
+
1. Check application logs
|
|
242
|
+
2. Verify Redis connectivity
|
|
243
|
+
3. Ensure migrations ran successfully
|
|
244
|
+
4. Review the [README.md](./README.md) troubleshooting section
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Multi-Project Configuration Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This `workflow-schedule` module is designed to be used as a **shared package** across multiple NestJS projects. You can control whether the cron processor runs in each project independently.
|
|
5
|
+
|
|
6
|
+
## Problem Scenario
|
|
7
|
+
You have multiple servers importing this module:
|
|
8
|
+
- **Server 1 (Scheduler Server)** - Should run the cron processor ✅
|
|
9
|
+
- **Server 2 (API Server)** - Should NOT run cron, but can create/manage schedules ❌
|
|
10
|
+
- **Server 3 (Worker Server)** - Should NOT run cron, but can create/manage schedules ❌
|
|
11
|
+
|
|
12
|
+
## Solution
|
|
13
|
+
|
|
14
|
+
### Server 1: Enable Cron Processor (Scheduler Server)
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// app.module.ts
|
|
18
|
+
import { WorkflowScheduleModule } from './module/workflow-schedule/workflow-schedule.module';
|
|
19
|
+
|
|
20
|
+
@Module({
|
|
21
|
+
imports: [
|
|
22
|
+
BullModule.forRootAsync(bullConfigFactory),
|
|
23
|
+
// ✅ Enable processor - this server will execute scheduled workflows
|
|
24
|
+
WorkflowScheduleModule.forRoot({ enableProcessor: true }),
|
|
25
|
+
WorkflowAutomationModule,
|
|
26
|
+
// ... other modules
|
|
27
|
+
],
|
|
28
|
+
})
|
|
29
|
+
export class AppModule {}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Server 2 & 3: Disable Cron Processor (API/Worker Servers)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// app.module.ts
|
|
36
|
+
import { WorkflowScheduleModule } from './module/workflow-schedule/workflow-schedule.module';
|
|
37
|
+
|
|
38
|
+
@Module({
|
|
39
|
+
imports: [
|
|
40
|
+
BullModule.forRootAsync(bullConfigFactory),
|
|
41
|
+
// ❌ Disable processor - this server will NOT execute cron jobs
|
|
42
|
+
WorkflowScheduleModule.forRoot({ enableProcessor: false }),
|
|
43
|
+
WorkflowAutomationModule,
|
|
44
|
+
// ... other modules
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
export class AppModule {}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## What Each Configuration Does
|
|
51
|
+
|
|
52
|
+
### With `enableProcessor: true`
|
|
53
|
+
- ✅ `WorkflowScheduleService` is available (create/manage schedules)
|
|
54
|
+
- ✅ `ScheduleProcessor` is registered (listens to Bull queue)
|
|
55
|
+
- ✅ **Cron jobs WILL execute** on this server
|
|
56
|
+
- ✅ REST API endpoints are available
|
|
57
|
+
- ✅ Can trigger manual executions
|
|
58
|
+
|
|
59
|
+
### With `enableProcessor: false`
|
|
60
|
+
- ✅ `WorkflowScheduleService` is available (create/manage schedules)
|
|
61
|
+
- ❌ `ScheduleProcessor` is NOT registered
|
|
62
|
+
- ❌ **Cron jobs will NOT execute** on this server
|
|
63
|
+
- ✅ REST API endpoints are available
|
|
64
|
+
- ✅ Can trigger manual executions
|
|
65
|
+
- ⚠️ Scheduled workflows will be executed by the server with `enableProcessor: true`
|
|
66
|
+
|
|
67
|
+
## Environment-Based Configuration
|
|
68
|
+
|
|
69
|
+
For better control, use environment variables:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// app.module.ts
|
|
73
|
+
import { WorkflowScheduleModule } from './module/workflow-schedule/workflow-schedule.module';
|
|
74
|
+
|
|
75
|
+
@Module({
|
|
76
|
+
imports: [
|
|
77
|
+
BullModule.forRootAsync(bullConfigFactory),
|
|
78
|
+
WorkflowScheduleModule.forRoot({
|
|
79
|
+
enableProcessor: process.env.ENABLE_WORKFLOW_SCHEDULER === 'true',
|
|
80
|
+
}),
|
|
81
|
+
WorkflowAutomationModule,
|
|
82
|
+
],
|
|
83
|
+
})
|
|
84
|
+
export class AppModule {}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then in each project's `.env` file:
|
|
88
|
+
|
|
89
|
+
**Server 1 (Scheduler Server):**
|
|
90
|
+
```env
|
|
91
|
+
ENABLE_WORKFLOW_SCHEDULER=true
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Server 2 & 3:**
|
|
95
|
+
```env
|
|
96
|
+
ENABLE_WORKFLOW_SCHEDULER=false
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Default Behavior
|
|
100
|
+
|
|
101
|
+
If you call `WorkflowScheduleModule.forRoot()` without options, the processor is **ENABLED by default**:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// This is equivalent to { enableProcessor: true }
|
|
105
|
+
WorkflowScheduleModule.forRoot()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Architecture Considerations
|
|
109
|
+
|
|
110
|
+
### Recommended Setup for High Availability
|
|
111
|
+
|
|
112
|
+
1. **Dedicated Scheduler Server** (Server 1)
|
|
113
|
+
- `enableProcessor: true`
|
|
114
|
+
- Runs cron processor
|
|
115
|
+
- Handles scheduled workflow executions
|
|
116
|
+
- Monitor with PM2/Forever for auto-restart
|
|
117
|
+
|
|
118
|
+
2. **API Servers** (Server 2, 3, ...)
|
|
119
|
+
- `enableProcessor: false`
|
|
120
|
+
- Handle HTTP requests
|
|
121
|
+
- Create/update/delete schedules
|
|
122
|
+
- Schedules are executed by Server 1
|
|
123
|
+
|
|
124
|
+
### Redis Requirement
|
|
125
|
+
|
|
126
|
+
All servers must connect to the **same Redis instance**:
|
|
127
|
+
- Server 1 adds jobs to the queue
|
|
128
|
+
- Servers 2 & 3 can also add jobs (manual triggers)
|
|
129
|
+
- Only Server 1 (with processor enabled) will consume/execute jobs
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// bull.config.ts (same across all servers)
|
|
133
|
+
export const bullConfigFactory = {
|
|
134
|
+
useFactory: () => ({
|
|
135
|
+
redis: {
|
|
136
|
+
host: process.env.REDIS_HOST || 'localhost',
|
|
137
|
+
port: parseInt(process.env.REDIS_PORT) || 6379,
|
|
138
|
+
password: process.env.REDIS_PASSWORD,
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Testing
|
|
145
|
+
|
|
146
|
+
### Test Processor is Disabled
|
|
147
|
+
|
|
148
|
+
Start your server with `enableProcessor: false` and check logs. You should NOT see:
|
|
149
|
+
```
|
|
150
|
+
[ScheduleProcessor] Processing job {jobId}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Test Processor is Enabled
|
|
154
|
+
|
|
155
|
+
Start your server with `enableProcessor: true` and:
|
|
156
|
+
1. Create a schedule with `is_enabled: true`
|
|
157
|
+
2. Check logs for processor activity
|
|
158
|
+
3. Verify jobs execute on schedule
|
|
159
|
+
|
|
160
|
+
## Migration from Old Setup
|
|
161
|
+
|
|
162
|
+
If you previously imported the module directly:
|
|
163
|
+
|
|
164
|
+
**Before:**
|
|
165
|
+
```typescript
|
|
166
|
+
imports: [
|
|
167
|
+
WorkflowScheduleModule, // ❌ Old way
|
|
168
|
+
]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**After:**
|
|
172
|
+
```typescript
|
|
173
|
+
imports: [
|
|
174
|
+
WorkflowScheduleModule.forRoot({ enableProcessor: true }), // ✅ New way
|
|
175
|
+
]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Troubleshooting
|
|
179
|
+
|
|
180
|
+
### Issue: Cron runs on multiple servers
|
|
181
|
+
|
|
182
|
+
**Cause:** Multiple servers have `enableProcessor: true`
|
|
183
|
+
|
|
184
|
+
**Solution:** Set `enableProcessor: false` on all servers except one
|
|
185
|
+
|
|
186
|
+
### Issue: Cron doesn't run on any server
|
|
187
|
+
|
|
188
|
+
**Cause:** All servers have `enableProcessor: false`
|
|
189
|
+
|
|
190
|
+
**Solution:** Set `enableProcessor: true` on at least one server
|
|
191
|
+
|
|
192
|
+
### Issue: "Cannot find module WorkflowScheduleModule"
|
|
193
|
+
|
|
194
|
+
**Cause:** Wrong import after refactor
|
|
195
|
+
|
|
196
|
+
**Solution:** Ensure you're importing from the correct path and using `.forRoot()`
|