@marktoflow/core 2.0.0-alpha.14 → 2.0.0-alpha.16
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/README.md +24 -365
- package/dist/built-in-operations.d.ts +10 -0
- package/dist/built-in-operations.d.ts.map +1 -1
- package/dist/built-in-operations.js +386 -1
- package/dist/built-in-operations.js.map +1 -1
- package/dist/credentials.d.ts +60 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +229 -4
- package/dist/credentials.js.map +1 -1
- package/dist/engine.d.ts +36 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +462 -21
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +399 -6
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +60 -1
- package/dist/models.js.map +1 -1
- package/dist/oauth-manager.d.ts +128 -0
- package/dist/oauth-manager.d.ts.map +1 -0
- package/dist/oauth-manager.js +291 -0
- package/dist/oauth-manager.js.map +1 -0
- package/dist/oauth-refresh.d.ts +37 -0
- package/dist/oauth-refresh.d.ts.map +1 -0
- package/dist/oauth-refresh.js +76 -0
- package/dist/oauth-refresh.js.map +1 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +19 -0
- package/dist/parser.js.map +1 -1
- package/dist/sdk-registry.d.ts +7 -1
- package/dist/sdk-registry.d.ts.map +1 -1
- package/dist/sdk-registry.js +38 -9
- package/dist/sdk-registry.js.map +1 -1
- package/dist/secret-providers/index.d.ts +12 -0
- package/dist/secret-providers/index.d.ts.map +1 -0
- package/dist/secret-providers/index.js +11 -0
- package/dist/secret-providers/index.js.map +1 -0
- package/dist/secret-providers/providers/aws.d.ts +32 -0
- package/dist/secret-providers/providers/aws.d.ts.map +1 -0
- package/dist/secret-providers/providers/aws.js +118 -0
- package/dist/secret-providers/providers/aws.js.map +1 -0
- package/dist/secret-providers/providers/azure.d.ts +40 -0
- package/dist/secret-providers/providers/azure.d.ts.map +1 -0
- package/dist/secret-providers/providers/azure.js +170 -0
- package/dist/secret-providers/providers/azure.js.map +1 -0
- package/dist/secret-providers/providers/env.d.ts +26 -0
- package/dist/secret-providers/providers/env.d.ts.map +1 -0
- package/dist/secret-providers/providers/env.js +59 -0
- package/dist/secret-providers/providers/env.js.map +1 -0
- package/dist/secret-providers/providers/vault.d.ts +39 -0
- package/dist/secret-providers/providers/vault.d.ts.map +1 -0
- package/dist/secret-providers/providers/vault.js +180 -0
- package/dist/secret-providers/providers/vault.js.map +1 -0
- package/dist/secret-providers/secret-manager.d.ts +72 -0
- package/dist/secret-providers/secret-manager.d.ts.map +1 -0
- package/dist/secret-providers/secret-manager.js +226 -0
- package/dist/secret-providers/secret-manager.js.map +1 -0
- package/dist/secret-providers/types.d.ts +105 -0
- package/dist/secret-providers/types.d.ts.map +1 -0
- package/dist/secret-providers/types.js +8 -0
- package/dist/secret-providers/types.js.map +1 -0
- package/dist/secrets/index.d.ts +12 -0
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +11 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/providers/aws.d.ts +32 -0
- package/dist/secrets/providers/aws.d.ts.map +1 -0
- package/dist/secrets/providers/aws.js +118 -0
- package/dist/secrets/providers/aws.js.map +1 -0
- package/dist/secrets/providers/azure.d.ts +40 -0
- package/dist/secrets/providers/azure.d.ts.map +1 -0
- package/dist/secrets/providers/azure.js +170 -0
- package/dist/secrets/providers/azure.js.map +1 -0
- package/dist/secrets/providers/env.d.ts +26 -0
- package/dist/secrets/providers/env.d.ts.map +1 -0
- package/dist/secrets/providers/env.js +59 -0
- package/dist/secrets/providers/env.js.map +1 -0
- package/dist/secrets/providers/vault.d.ts +39 -0
- package/dist/secrets/providers/vault.d.ts.map +1 -0
- package/dist/secrets/providers/vault.js +180 -0
- package/dist/secrets/providers/vault.js.map +1 -0
- package/dist/secrets/secret-manager.d.ts +72 -0
- package/dist/secrets/secret-manager.d.ts.map +1 -0
- package/dist/secrets/secret-manager.js +226 -0
- package/dist/secrets/secret-manager.js.map +1 -0
- package/dist/secrets/types.d.ts +105 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +8 -0
- package/dist/secrets/types.js.map +1 -0
- package/dist/tools/mcp-tool.js +9 -9
- package/dist/tools/mcp-tool.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,70 +1,51 @@
|
|
|
1
1
|
# @marktoflow/core
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Workflow engine for parsing, executing, and managing markdown-based automations.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@marktoflow/core)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Part of [marktoflow](../../README.md) — open-source markdown workflow automation.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Workflow Parser** - Parse markdown + YAML workflow definitions
|
|
14
|
-
- **Execution Engine** - Step-by-step workflow execution with retry and error handling
|
|
15
|
-
- **State Management** - SQLite-based persistent state tracking
|
|
16
|
-
- **Scheduling** - Cron-based workflow scheduling
|
|
17
|
-
- **Queue System** - Support for Redis, RabbitMQ, and in-memory queues
|
|
18
|
-
- **Webhooks** - HTTP webhook trigger support
|
|
19
|
-
- **File Watching** - Monitor files for changes and trigger workflows
|
|
20
|
-
- **Security** - RBAC, approval workflows, and audit logging
|
|
21
|
-
- **Cost Tracking** - Track and manage API usage costs
|
|
22
|
-
- **Plugin System** - Extensible plugin architecture with 17 hook types
|
|
23
|
-
- **Templates** - Reusable workflow templates with variables
|
|
24
|
-
- **Tool Registry** - Support for MCP, OpenAPI, and custom tools
|
|
25
|
-
- **Agent Routing** - Multi-agent workflow support with routing strategies
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
9
|
+
## Quick Start
|
|
28
10
|
|
|
29
11
|
```bash
|
|
30
12
|
npm install @marktoflow/core
|
|
31
13
|
```
|
|
32
14
|
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
### Basic Workflow Execution
|
|
36
|
-
|
|
37
15
|
```typescript
|
|
38
16
|
import { WorkflowParser, WorkflowEngine } from '@marktoflow/core';
|
|
39
17
|
|
|
40
|
-
// Parse workflow
|
|
41
18
|
const parser = new WorkflowParser();
|
|
42
19
|
const workflow = await parser.parseWorkflow('workflow.md');
|
|
43
20
|
|
|
44
|
-
// Execute workflow
|
|
45
21
|
const engine = new WorkflowEngine();
|
|
46
22
|
const result = await engine.execute(workflow, {
|
|
47
23
|
inputs: { message: 'Hello World' },
|
|
48
24
|
});
|
|
49
|
-
|
|
50
|
-
console.log(result);
|
|
51
25
|
```
|
|
52
26
|
|
|
53
|
-
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- **Workflow Parser** — Parse markdown + YAML workflow definitions
|
|
30
|
+
- **Execution Engine** — Step-by-step execution with retry, circuit breakers, and error handling
|
|
31
|
+
- **State Management** — SQLite-based persistent state tracking
|
|
32
|
+
- **Plugin System** — Extensible architecture with 17 hook types
|
|
33
|
+
- **Cost Tracking** — Monitor and budget API usage per workflow
|
|
34
|
+
- **Scheduling** — Cron-based workflow scheduling
|
|
35
|
+
- **Security** — RBAC, approval workflows, and audit logging
|
|
36
|
+
- **Queue System** — Distributed execution via Redis, RabbitMQ, or in-memory
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### State Management
|
|
54
41
|
|
|
55
42
|
```typescript
|
|
56
43
|
import { WorkflowEngine, StateManager } from '@marktoflow/core';
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
const stateManager = new StateManager({
|
|
60
|
-
dbPath: '.marktoflow/state.db',
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Execute workflow with state
|
|
45
|
+
const stateManager = new StateManager({ dbPath: '.marktoflow/state.db' });
|
|
64
46
|
const engine = new WorkflowEngine({ stateManager });
|
|
65
47
|
const result = await engine.execute(workflow);
|
|
66
48
|
|
|
67
|
-
// Query state
|
|
68
49
|
const history = await stateManager.getWorkflowHistory(workflow.id);
|
|
69
50
|
```
|
|
70
51
|
|
|
@@ -73,377 +54,55 @@ const history = await stateManager.getWorkflowHistory(workflow.id);
|
|
|
73
54
|
```typescript
|
|
74
55
|
import { Scheduler } from '@marktoflow/core';
|
|
75
56
|
|
|
76
|
-
// Create scheduler
|
|
77
57
|
const scheduler = new Scheduler();
|
|
78
|
-
|
|
79
|
-
// Schedule workflow (cron format)
|
|
80
58
|
await scheduler.schedule({
|
|
81
59
|
workflowId: 'daily-report',
|
|
82
|
-
cron: '0 9 * * 1-5',
|
|
60
|
+
cron: '0 9 * * 1-5',
|
|
83
61
|
workflowPath: './workflows/daily-report.md',
|
|
84
62
|
});
|
|
85
|
-
|
|
86
|
-
// Start scheduler
|
|
87
63
|
await scheduler.start();
|
|
88
64
|
```
|
|
89
65
|
|
|
90
|
-
### Webhooks
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { WebhookServer } from '@marktoflow/core';
|
|
94
|
-
|
|
95
|
-
// Create webhook server
|
|
96
|
-
const webhookServer = new WebhookServer({ port: 3000 });
|
|
97
|
-
|
|
98
|
-
// Register webhook
|
|
99
|
-
await webhookServer.registerWebhook({
|
|
100
|
-
path: '/github',
|
|
101
|
-
workflowPath: './workflows/github-pr.md',
|
|
102
|
-
secret: process.env.GITHUB_WEBHOOK_SECRET,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// Start server
|
|
106
|
-
await webhookServer.start();
|
|
107
|
-
```
|
|
108
|
-
|
|
109
66
|
### Plugin System
|
|
110
67
|
|
|
111
68
|
```typescript
|
|
112
69
|
import { PluginRegistry } from '@marktoflow/core';
|
|
113
70
|
|
|
114
|
-
// Register plugin
|
|
115
71
|
const registry = new PluginRegistry();
|
|
116
72
|
await registry.register({
|
|
117
73
|
name: 'my-plugin',
|
|
118
74
|
hooks: {
|
|
119
|
-
beforeWorkflowStart: async (
|
|
120
|
-
|
|
121
|
-
},
|
|
122
|
-
afterStepComplete: async (context) => {
|
|
123
|
-
console.log('Completed step:', context.step.action);
|
|
124
|
-
},
|
|
75
|
+
beforeWorkflowStart: async (ctx) => console.log('Starting:', ctx.workflow.id),
|
|
76
|
+
afterStepComplete: async (ctx) => console.log('Done:', ctx.step.action),
|
|
125
77
|
},
|
|
126
78
|
});
|
|
127
79
|
```
|
|
128
80
|
|
|
129
|
-
## Workflow Format
|
|
130
|
-
|
|
131
|
-
Workflows are written in markdown with YAML frontmatter. See the [examples/](https://github.com/marktoflow/marktoflow/tree/main/examples) directory for production-ready workflow templates.
|
|
132
|
-
|
|
133
|
-
### Basic Example
|
|
134
|
-
|
|
135
|
-
```markdown
|
|
136
|
-
---
|
|
137
|
-
workflow:
|
|
138
|
-
id: example
|
|
139
|
-
name: Example Workflow
|
|
140
|
-
|
|
141
|
-
tools:
|
|
142
|
-
slack:
|
|
143
|
-
sdk: '@slack/web-api'
|
|
144
|
-
auth:
|
|
145
|
-
token: '${SLACK_BOT_TOKEN}'
|
|
146
|
-
|
|
147
|
-
triggers:
|
|
148
|
-
- type: schedule
|
|
149
|
-
cron: '0 9 * * *'
|
|
150
|
-
|
|
151
|
-
inputs:
|
|
152
|
-
message:
|
|
153
|
-
type: string
|
|
154
|
-
required: true
|
|
155
|
-
|
|
156
|
-
outputs:
|
|
157
|
-
result:
|
|
158
|
-
type: string
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
# Example Workflow
|
|
162
|
-
|
|
163
|
-
This workflow posts a message to Slack.
|
|
164
|
-
|
|
165
|
-
## Step 1: Post Message
|
|
166
|
-
|
|
167
|
-
\`\`\`yaml
|
|
168
|
-
action: slack.chat.postMessage
|
|
169
|
-
inputs:
|
|
170
|
-
channel: '#general'
|
|
171
|
-
text: '{{ inputs.message }}'
|
|
172
|
-
output_variable: result
|
|
173
|
-
\`\`\`
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Real-World Examples
|
|
177
|
-
|
|
178
|
-
See these production workflows in the `examples/` directory:
|
|
179
|
-
|
|
180
|
-
- **[daily-standup](https://github.com/marktoflow/marktoflow/tree/main/examples/daily-standup)** - Jira + Slack integration with AI-generated summaries
|
|
181
|
-
- **[code-review](https://github.com/marktoflow/marktoflow/tree/main/examples/code-review)** - Automated GitHub PR reviews with security analysis
|
|
182
|
-
- **[incident-response](https://github.com/marktoflow/marktoflow/tree/main/examples/incident-response)** - PagerDuty + Slack + Jira coordination
|
|
183
|
-
- **[gmail-notification](https://github.com/marktoflow/marktoflow/tree/main/examples/gmail-notification)** - Email automation with Gmail API
|
|
184
|
-
- **[web-automation](https://github.com/marktoflow/marktoflow/tree/main/examples/web-automation)** - Browser automation with Playwright
|
|
185
|
-
|
|
186
|
-
### Advanced Features
|
|
187
|
-
|
|
188
|
-
The core engine supports sophisticated workflow patterns:
|
|
189
|
-
|
|
190
|
-
#### Control Flow
|
|
191
|
-
|
|
192
|
-
```yaml
|
|
193
|
-
# Conditional execution
|
|
194
|
-
- action: jira.issues.getIssue
|
|
195
|
-
inputs:
|
|
196
|
-
issueKey: 'PROJ-123'
|
|
197
|
-
output_variable: issue
|
|
198
|
-
|
|
199
|
-
- action: slack.chat.postMessage
|
|
200
|
-
condition: '{{ issue.fields.priority.name == "Critical" }}'
|
|
201
|
-
inputs:
|
|
202
|
-
channel: '#urgent'
|
|
203
|
-
text: 'Critical issue found!'
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
#### Loops and Iteration
|
|
207
|
-
|
|
208
|
-
```yaml
|
|
209
|
-
# Process multiple items
|
|
210
|
-
- action: github.pulls.list
|
|
211
|
-
inputs:
|
|
212
|
-
owner: marktoflow
|
|
213
|
-
repo: marktoflow
|
|
214
|
-
output_variable: prs
|
|
215
|
-
|
|
216
|
-
- action: code_review
|
|
217
|
-
for_each: '{{ prs.data }}'
|
|
218
|
-
inputs:
|
|
219
|
-
pr: '{{ item }}'
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
#### Error Handling and Retry
|
|
223
|
-
|
|
224
|
-
```yaml
|
|
225
|
-
- action: external_api.call
|
|
226
|
-
retry:
|
|
227
|
-
max_attempts: 3
|
|
228
|
-
backoff: exponential
|
|
229
|
-
initial_delay: 1000
|
|
230
|
-
on_error: continue
|
|
231
|
-
fallback:
|
|
232
|
-
- action: slack.chat.postMessage
|
|
233
|
-
inputs:
|
|
234
|
-
channel: '#alerts'
|
|
235
|
-
text: 'API call failed after retries'
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
#### Circuit Breaker Pattern
|
|
239
|
-
|
|
240
|
-
```yaml
|
|
241
|
-
tools:
|
|
242
|
-
external_api:
|
|
243
|
-
sdk: 'custom-api-client'
|
|
244
|
-
circuit_breaker:
|
|
245
|
-
failure_threshold: 5
|
|
246
|
-
timeout: 30000
|
|
247
|
-
reset_timeout: 60000
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
See [examples/tests/control-flow/](https://github.com/marktoflow/marktoflow/tree/main/examples/tests/control-flow) for more advanced patterns.
|
|
251
|
-
|
|
252
|
-
## Architecture
|
|
253
|
-
|
|
254
|
-
### Core Components
|
|
255
|
-
|
|
256
|
-
1. **Parser** (`parser.ts`) - Parse markdown + YAML workflow definitions
|
|
257
|
-
2. **Engine** (`engine.ts`) - Execute workflows with retry/circuit breaker
|
|
258
|
-
3. **State Manager** (`state.ts`) - SQLite-based state persistence
|
|
259
|
-
4. **Scheduler** (`scheduler.ts`) - Cron-based workflow scheduling
|
|
260
|
-
5. **Queue** (`queue.ts`) - Redis/RabbitMQ/InMemory queue support
|
|
261
|
-
6. **Webhook** (`webhook.ts`) - HTTP webhook triggers
|
|
262
|
-
7. **File Watcher** (`filewatcher.ts`) - File change monitoring
|
|
263
|
-
8. **Security** (`security.ts`) - RBAC and audit logging
|
|
264
|
-
9. **Cost Tracker** (`costs.ts`) - API usage cost management
|
|
265
|
-
10. **Plugin System** (`plugins.ts`) - Extensible hooks
|
|
266
|
-
11. **Templates** (`templates.ts`) - Reusable workflow patterns
|
|
267
|
-
12. **Tool Registry** (`tool-registry.ts`) - MCP/OpenAPI/Custom tools
|
|
268
|
-
13. **Agent Routing** (`routing.ts`) - Multi-agent coordination
|
|
269
|
-
|
|
270
|
-
### Execution Flow
|
|
271
|
-
|
|
272
|
-
```
|
|
273
|
-
Parser → Validate → Security Check → Execute Steps → Save State → Output
|
|
274
|
-
↓ ↓ ↓ ↓
|
|
275
|
-
Schema RBAC Retry/Failover Audit Log
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
## Configuration
|
|
279
|
-
|
|
280
|
-
### Environment Variables
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
# Database
|
|
284
|
-
MARKTOFLOW_DB_PATH=.marktoflow/state.db
|
|
285
|
-
|
|
286
|
-
# Queue (Redis)
|
|
287
|
-
REDIS_HOST=localhost
|
|
288
|
-
REDIS_PORT=6379
|
|
289
|
-
|
|
290
|
-
# Queue (RabbitMQ)
|
|
291
|
-
RABBITMQ_URL=amqp://localhost
|
|
292
|
-
|
|
293
|
-
# Security
|
|
294
|
-
MARKTOFLOW_SECRET_KEY=your-secret-key
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### Configuration File
|
|
298
|
-
|
|
299
|
-
Create `.marktoflow/config.yaml`:
|
|
300
|
-
|
|
301
|
-
```yaml
|
|
302
|
-
state:
|
|
303
|
-
dbPath: .marktoflow/state.db
|
|
304
|
-
|
|
305
|
-
queue:
|
|
306
|
-
type: redis # redis, rabbitmq, or memory
|
|
307
|
-
redis:
|
|
308
|
-
host: localhost
|
|
309
|
-
port: 6379
|
|
310
|
-
|
|
311
|
-
security:
|
|
312
|
-
rbac:
|
|
313
|
-
enabled: true
|
|
314
|
-
auditLog:
|
|
315
|
-
enabled: true
|
|
316
|
-
|
|
317
|
-
costs:
|
|
318
|
-
budget:
|
|
319
|
-
daily: 100
|
|
320
|
-
monthly: 3000
|
|
321
|
-
alerts:
|
|
322
|
-
- threshold: 50
|
|
323
|
-
emails: [admin@example.com]
|
|
324
|
-
```
|
|
325
|
-
|
|
326
81
|
## API Reference
|
|
327
82
|
|
|
328
|
-
### WorkflowParser
|
|
329
|
-
|
|
330
83
|
```typescript
|
|
331
84
|
class WorkflowParser {
|
|
332
85
|
parseWorkflow(filePath: string): Promise<Workflow>;
|
|
333
86
|
parseYAML(content: string): Workflow;
|
|
334
87
|
validate(workflow: Workflow): ValidationResult;
|
|
335
88
|
}
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
### WorkflowEngine
|
|
339
89
|
|
|
340
|
-
```typescript
|
|
341
90
|
class WorkflowEngine {
|
|
342
91
|
constructor(options?: EngineOptions);
|
|
343
92
|
execute(workflow: Workflow, context?: ExecutionContext): Promise<WorkflowResult>;
|
|
344
93
|
stop(): Promise<void>;
|
|
345
94
|
}
|
|
346
|
-
```
|
|
347
95
|
|
|
348
|
-
### StateManager
|
|
349
|
-
|
|
350
|
-
```typescript
|
|
351
96
|
class StateManager {
|
|
352
97
|
constructor(options: StateOptions);
|
|
353
98
|
getWorkflowHistory(workflowId: string): Promise<WorkflowRun[]>;
|
|
354
|
-
getWorkflowState(runId: string): Promise<WorkflowState>;
|
|
355
99
|
saveWorkflowState(state: WorkflowState): Promise<void>;
|
|
356
100
|
}
|
|
357
101
|
```
|
|
358
102
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
class Scheduler {
|
|
363
|
-
schedule(config: ScheduleConfig): Promise<void>;
|
|
364
|
-
unschedule(workflowId: string): Promise<void>;
|
|
365
|
-
start(): Promise<void>;
|
|
366
|
-
stop(): Promise<void>;
|
|
367
|
-
}
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
## Testing
|
|
371
|
-
|
|
372
|
-
The core package includes comprehensive unit and integration tests.
|
|
373
|
-
|
|
374
|
-
### Running Tests
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
# Run all tests (unit + integration)
|
|
378
|
-
pnpm test
|
|
379
|
-
|
|
380
|
-
# Run only unit tests
|
|
381
|
-
pnpm test:unit
|
|
382
|
-
|
|
383
|
-
# Run only integration tests
|
|
384
|
-
pnpm test:integration
|
|
385
|
-
|
|
386
|
-
# Run specific test file
|
|
387
|
-
pnpm test path/to/test.ts
|
|
388
|
-
|
|
389
|
-
# Run tests matching a pattern
|
|
390
|
-
pnpm test:integration -t "transform"
|
|
391
|
-
|
|
392
|
-
# Watch mode
|
|
393
|
-
pnpm test --watch
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### Test Structure
|
|
397
|
-
|
|
398
|
-
- **Unit Tests** (`tests/`) - Fast, isolated tests for individual functions and classes
|
|
399
|
-
- **Integration Tests** (`integration-tests/`) - End-to-end workflow execution tests organized by feature:
|
|
400
|
-
- `suites/built-in-operations.integration.test.ts` - Transform, filter, reduce, etc.
|
|
401
|
-
- `suites/control-flow.integration.test.ts` - If/else, loops, parallel execution
|
|
402
|
-
- `suites/error-handling.integration.test.ts` - Retry, circuit breaker, error recovery
|
|
403
|
-
- `suites/nunjucks-filters.integration.test.ts` - Template engine filters
|
|
404
|
-
- `suites/script-execution.integration.test.ts` - JavaScript script execution
|
|
405
|
-
- `suites/variable-resolution.integration.test.ts` - Template variables and context
|
|
406
|
-
|
|
407
|
-
### Writing Integration Tests
|
|
408
|
-
|
|
409
|
-
Integration tests use real workflow definitions and the full execution engine:
|
|
410
|
-
|
|
411
|
-
```typescript
|
|
412
|
-
import { loadInline, createSmartExecutor } from '../helpers/test-utils.js';
|
|
413
|
-
import { WorkflowEngine } from '../../src/engine.js';
|
|
414
|
-
|
|
415
|
-
const engine = new WorkflowEngine();
|
|
416
|
-
|
|
417
|
-
it('should execute workflow', async () => {
|
|
418
|
-
const { workflow } = loadInline(`
|
|
419
|
-
---
|
|
420
|
-
workflow:
|
|
421
|
-
id: test-workflow
|
|
422
|
-
name: Test Workflow
|
|
423
|
-
steps:
|
|
424
|
-
- id: step1
|
|
425
|
-
type: action
|
|
426
|
-
action: core.set
|
|
427
|
-
inputs:
|
|
428
|
-
value: "Hello"
|
|
429
|
-
output_variable: result
|
|
430
|
-
---
|
|
431
|
-
`);
|
|
432
|
-
|
|
433
|
-
const { executor, registry } = createSmartExecutor();
|
|
434
|
-
const result = await engine.execute(workflow, {}, registry, executor);
|
|
435
|
-
|
|
436
|
-
expect(result.status).toBe(WorkflowStatus.COMPLETED);
|
|
437
|
-
expect(result.output.result).toBe('Hello');
|
|
438
|
-
});
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
## Links
|
|
103
|
+
## Contributing
|
|
442
104
|
|
|
443
|
-
|
|
444
|
-
- [Documentation](https://github.com/marktoflow/marktoflow#readme)
|
|
445
|
-
- [CLI Package](@marktoflow/cli)
|
|
446
|
-
- [Integrations Package](@marktoflow/integrations)
|
|
105
|
+
See the [contributing guide](../../CONTRIBUTING.md).
|
|
447
106
|
|
|
448
107
|
## License
|
|
449
108
|
|
|
@@ -137,4 +137,14 @@ export declare function executeBuiltInOperation(action: string, rawInputs: Recor
|
|
|
137
137
|
* Check if an action is a built-in operation
|
|
138
138
|
*/
|
|
139
139
|
export declare function isBuiltInOperation(action: string): boolean;
|
|
140
|
+
export declare function executeAggregate(inputs: Record<string, unknown>, _context: ExecutionContext): unknown;
|
|
141
|
+
export declare function executeCompare(inputs: Record<string, unknown>, _context: ExecutionContext): unknown;
|
|
142
|
+
export declare function executeRenameKeys(inputs: Record<string, unknown>): unknown;
|
|
143
|
+
export declare function executeLimit(inputs: Record<string, unknown>): unknown;
|
|
144
|
+
export declare function executeSortOperation(inputs: Record<string, unknown>): unknown;
|
|
145
|
+
export declare function executeCrypto(inputs: Record<string, unknown>): unknown;
|
|
146
|
+
export declare function executeDatetime(inputs: Record<string, unknown>): unknown;
|
|
147
|
+
export declare function executeParse(inputs: Record<string, unknown>): unknown;
|
|
148
|
+
export declare function executeCompress(inputs: Record<string, unknown>): unknown;
|
|
149
|
+
export declare function executeDecompress(inputs: Record<string, unknown>): unknown;
|
|
140
150
|
//# sourceMappingURL=built-in-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-in-operations.d.ts","sourceRoot":"","sources":["../src/built-in-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAQ/C,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,gBAAgB,G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