motia 0.17.11-beta.194-563479 → 0.17.12-beta.194
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/create/templates/hello/.env +3 -0
- package/dist/create/templates/hello/README.md.txt +10 -60
- package/dist/create/templates/hello_js/.env +3 -0
- package/dist/create/templates/hello_js/README.md.txt +10 -60
- package/dist/create/templates/hello_multilang/.env +3 -0
- package/dist/create/templates/hello_multilang/README.md.txt +10 -83
- package/dist/create/templates/hello_python/.env +3 -0
- package/dist/create/templates/hello_python/README.md.txt +10 -61
- package/dist/create/templates/nodejs/.env +3 -0
- package/dist/create/templates/nodejs/README.md.txt +10 -69
- package/dist/create/templates/nodejs/src/petstore/api.step.ts.txt +1 -1
- package/dist/create/templates/nodejs/src/petstore/state-audit-cron.step.ts.txt +1 -1
- package/dist/create/templates/nodejs/src/services/pet-store.ts.txt +4 -2
- package/dist/create/templates/python/.env +3 -0
- package/dist/create/templates/python/README.md.txt +10 -70
- package/dist/create/templates/python/src/petstore/api_step.py.txt +2 -1
- package/dist/create/templates/python/src/petstore/state_audit_cron_step.py.txt +2 -1
- package/dist/create/templates/python/src/services/pet_store.py.txt +5 -2
- package/dist/create/templates/python/tutorial/petstore/api_step.py-features.json.txt +8 -8
- package/dist/create/templates/python/tutorial/petstore/state_audit_cron_step.py-features.json.txt +4 -10
- package/dist/cursor-rules/dot-files/.claude/agents/motia-developer.md +1 -1
- package/dist/cursor-rules/dot-files/.cursor/architecture/architecture.mdc +5 -26
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/api-steps.mdc +2 -2
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/cron-steps.mdc +2 -2
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/event-steps.mdc +2 -2
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/middlewares.mdc +1 -1
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/motia-config.mdc +1 -1
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/realtime-streaming.mdc +4 -4
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/state-management.mdc +1 -1
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/ui-steps.mdc +2 -2
- package/dist/cursor-rules/dot-files/.cursor/rules/motia/virtual-steps.mdc +2 -2
- package/dist/cursor-rules/dot-files/AGENTS.md +2 -15
- package/dist/cursor-rules/dot-files/CLAUDE.md +1 -1
- package/package.json +8 -8
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
8
6
|
|
|
9
7
|
## Quick Start
|
|
10
8
|
|
|
@@ -17,67 +15,19 @@ yarn dev
|
|
|
17
15
|
pnpm dev
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
This starts the Motia runtime and
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Test your first endpoint
|
|
24
|
-
curl http://localhost:3000/hello
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Step Types
|
|
28
|
-
|
|
29
|
-
Every Step has a `type` that defines how it triggers:
|
|
30
|
-
|
|
31
|
-
| Type | When it runs | Use case |
|
|
32
|
-
|------|--------------|----------|
|
|
33
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
34
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
35
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
36
|
-
|
|
37
|
-
## Development Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Start Workbench and development server
|
|
41
|
-
npm run dev
|
|
42
|
-
# or
|
|
43
|
-
yarn dev
|
|
44
|
-
# or
|
|
45
|
-
pnpm dev
|
|
46
|
-
|
|
47
|
-
# Start production server (without hot reload)
|
|
48
|
-
npm run start
|
|
49
|
-
# or
|
|
50
|
-
yarn start
|
|
51
|
-
# or
|
|
52
|
-
pnpm start
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
53
19
|
|
|
54
|
-
|
|
55
|
-
npm run generate-types
|
|
56
|
-
# or
|
|
57
|
-
yarn generate-types
|
|
58
|
-
# or
|
|
59
|
-
pnpm generate-types
|
|
20
|
+
You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
60
21
|
|
|
61
|
-
|
|
62
|
-
npm run build
|
|
63
|
-
# or
|
|
64
|
-
yarn build
|
|
65
|
-
# or
|
|
66
|
-
pnpm build
|
|
67
|
-
```
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
68
23
|
|
|
69
|
-
## Project
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
steps/ # Your Step definitions (or use src/)
|
|
73
|
-
motia.config.ts # Motia configuration
|
|
74
|
-
```
|
|
24
|
+
## Project Config
|
|
75
25
|
|
|
76
|
-
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
77
27
|
|
|
78
28
|
## Learn More
|
|
79
29
|
|
|
80
|
-
- [
|
|
81
|
-
- [Quick Start
|
|
82
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
83
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
8
6
|
|
|
9
7
|
## Quick Start
|
|
10
8
|
|
|
@@ -17,67 +15,19 @@ yarn dev
|
|
|
17
15
|
pnpm dev
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
This starts the Motia runtime and
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Test your first endpoint
|
|
24
|
-
curl http://localhost:3000/hello
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Step Types
|
|
28
|
-
|
|
29
|
-
Every Step has a `type` that defines how it triggers:
|
|
30
|
-
|
|
31
|
-
| Type | When it runs | Use case |
|
|
32
|
-
|------|--------------|----------|
|
|
33
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
34
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
35
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
36
|
-
|
|
37
|
-
## Development Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Start Workbench and development server
|
|
41
|
-
npm run dev
|
|
42
|
-
# or
|
|
43
|
-
yarn dev
|
|
44
|
-
# or
|
|
45
|
-
pnpm dev
|
|
46
|
-
|
|
47
|
-
# Start production server (without hot reload)
|
|
48
|
-
npm run start
|
|
49
|
-
# or
|
|
50
|
-
yarn start
|
|
51
|
-
# or
|
|
52
|
-
pnpm start
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
53
19
|
|
|
54
|
-
|
|
55
|
-
npm run generate-types
|
|
56
|
-
# or
|
|
57
|
-
yarn generate-types
|
|
58
|
-
# or
|
|
59
|
-
pnpm generate-types
|
|
20
|
+
You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
60
21
|
|
|
61
|
-
|
|
62
|
-
npm run build
|
|
63
|
-
# or
|
|
64
|
-
yarn build
|
|
65
|
-
# or
|
|
66
|
-
pnpm build
|
|
67
|
-
```
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
68
23
|
|
|
69
|
-
## Project
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
steps/ # Your Step definitions (or use src/)
|
|
73
|
-
motia.config.ts # Motia configuration
|
|
74
|
-
```
|
|
24
|
+
## Project Config
|
|
75
25
|
|
|
76
|
-
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
77
27
|
|
|
78
28
|
## Learn More
|
|
79
29
|
|
|
80
|
-
- [
|
|
81
|
-
- [Quick Start
|
|
82
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
83
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
8
|
-
|
|
9
|
-
## Polyglot Architecture
|
|
10
|
-
|
|
11
|
-
This template demonstrates Motia's polyglot capabilities by combining:
|
|
12
|
-
|
|
13
|
-
- **TypeScript**: API endpoint (`hello-api.step.ts`) - handles HTTP requests
|
|
14
|
-
- **Python**: Event processor (`process_greeting_step.py`) - handles background processing
|
|
15
|
-
- **JavaScript**: Logger (`log-greeting.step.js`) - handles workflow completion
|
|
16
|
-
|
|
17
|
-
This shows how you can use the best language for each task while keeping everything in a single unified system.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
18
6
|
|
|
19
7
|
## Quick Start
|
|
20
8
|
|
|
@@ -27,80 +15,19 @@ yarn dev
|
|
|
27
15
|
pnpm dev
|
|
28
16
|
```
|
|
29
17
|
|
|
30
|
-
This starts the Motia runtime and
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# Test your first endpoint
|
|
34
|
-
curl http://localhost:3000/hello
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## How It Works
|
|
38
|
-
|
|
39
|
-
1. **TypeScript API Step** receives the HTTP request at `/hello`
|
|
40
|
-
2. It emits a `process-greeting` event with the request data
|
|
41
|
-
3. **Python Event Step** picks up the event, processes it, and stores the result in state
|
|
42
|
-
4. Python emits a `greeting-processed` event
|
|
43
|
-
5. **JavaScript Event Step** logs the completed workflow
|
|
44
|
-
|
|
45
|
-
## Step Types
|
|
46
|
-
|
|
47
|
-
Every Step has a `type` that defines how it triggers:
|
|
48
|
-
|
|
49
|
-
| Type | When it runs | Use case |
|
|
50
|
-
|------|--------------|----------|
|
|
51
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
52
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
53
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
54
|
-
|
|
55
|
-
## Development Commands
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
# Start Workbench and development server
|
|
59
|
-
npm run dev
|
|
60
|
-
# or
|
|
61
|
-
yarn dev
|
|
62
|
-
# or
|
|
63
|
-
pnpm dev
|
|
64
|
-
|
|
65
|
-
# Start production server (without hot reload)
|
|
66
|
-
npm run start
|
|
67
|
-
# or
|
|
68
|
-
yarn start
|
|
69
|
-
# or
|
|
70
|
-
pnpm start
|
|
71
|
-
|
|
72
|
-
# Generate TypeScript types from Step configs
|
|
73
|
-
npm run generate-types
|
|
74
|
-
# or
|
|
75
|
-
yarn generate-types
|
|
76
|
-
# or
|
|
77
|
-
pnpm generate-types
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
78
19
|
|
|
79
|
-
|
|
80
|
-
npm run build
|
|
81
|
-
# or
|
|
82
|
-
yarn build
|
|
83
|
-
# or
|
|
84
|
-
pnpm build
|
|
85
|
-
```
|
|
20
|
+
You can start editing the project by making changes to `src/hello/hello-api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
86
21
|
|
|
87
|
-
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
88
23
|
|
|
89
|
-
|
|
90
|
-
steps/ # Your Step definitions
|
|
91
|
-
├── hello/
|
|
92
|
-
│ ├── hello-api.step.ts # TypeScript API endpoint
|
|
93
|
-
│ ├── process_greeting_step.py # Python event processor
|
|
94
|
-
│ └── log-greeting.step.js # JavaScript logger
|
|
95
|
-
motia.config.ts # Motia configuration
|
|
96
|
-
requirements.txt # Python dependencies
|
|
97
|
-
```
|
|
24
|
+
## Project Config
|
|
98
25
|
|
|
99
|
-
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
100
27
|
|
|
101
28
|
## Learn More
|
|
102
29
|
|
|
103
|
-
- [
|
|
104
|
-
- [Quick Start
|
|
105
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
106
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
8
6
|
|
|
9
7
|
## Quick Start
|
|
10
8
|
|
|
@@ -17,68 +15,19 @@ yarn dev
|
|
|
17
15
|
pnpm dev
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
This starts the Motia runtime and
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Test your first endpoint
|
|
24
|
-
curl http://localhost:3000/hello
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Step Types
|
|
28
|
-
|
|
29
|
-
Every Step has a `type` that defines how it triggers:
|
|
30
|
-
|
|
31
|
-
| Type | When it runs | Use case |
|
|
32
|
-
|------|--------------|----------|
|
|
33
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
34
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
35
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
36
|
-
|
|
37
|
-
## Development Commands
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# Start Workbench and development server
|
|
41
|
-
npm run dev
|
|
42
|
-
# or
|
|
43
|
-
yarn dev
|
|
44
|
-
# or
|
|
45
|
-
pnpm dev
|
|
46
|
-
|
|
47
|
-
# Start production server (without hot reload)
|
|
48
|
-
npm run start
|
|
49
|
-
# or
|
|
50
|
-
yarn start
|
|
51
|
-
# or
|
|
52
|
-
pnpm start
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
53
19
|
|
|
54
|
-
|
|
55
|
-
npm run generate-types
|
|
56
|
-
# or
|
|
57
|
-
yarn generate-types
|
|
58
|
-
# or
|
|
59
|
-
pnpm generate-types
|
|
20
|
+
You can start editing the project by making changes to `src/hello/hello_api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
60
21
|
|
|
61
|
-
|
|
62
|
-
npm run build
|
|
63
|
-
# or
|
|
64
|
-
yarn build
|
|
65
|
-
# or
|
|
66
|
-
pnpm build
|
|
67
|
-
```
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
68
23
|
|
|
69
|
-
## Project
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
steps/ # Your Step definitions (or use src/)
|
|
73
|
-
motia.config.ts # Motia configuration
|
|
74
|
-
requirements.txt # Python dependencies
|
|
75
|
-
```
|
|
24
|
+
## Project Config
|
|
76
25
|
|
|
77
|
-
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
78
27
|
|
|
79
28
|
## Learn More
|
|
80
29
|
|
|
81
|
-
- [
|
|
82
|
-
- [Quick Start
|
|
83
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
84
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
8
6
|
|
|
9
7
|
## Quick Start
|
|
10
8
|
|
|
@@ -17,76 +15,19 @@ yarn dev
|
|
|
17
15
|
pnpm dev
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
This starts the Motia runtime and
|
|
21
|
-
|
|
22
|
-
1. **Open the Workbench** in your browser at [`http://localhost:3000`](http://localhost:3000)
|
|
23
|
-
2. **Click the `Tutorial`** button on the top right of the workbench
|
|
24
|
-
3. **Complete the `Tutorial`** to get an understanding of the basics of Motia and using the Workbench
|
|
25
|
-
|
|
26
|
-
## Step Types
|
|
27
|
-
|
|
28
|
-
Every Step has a `type` that defines how it triggers:
|
|
29
|
-
|
|
30
|
-
| Type | When it runs | Use case |
|
|
31
|
-
|------|--------------|----------|
|
|
32
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
33
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
34
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
35
|
-
|
|
36
|
-
## Development Commands
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# Start Workbench and development server
|
|
40
|
-
npm run dev
|
|
41
|
-
# or
|
|
42
|
-
yarn dev
|
|
43
|
-
# or
|
|
44
|
-
pnpm dev
|
|
45
|
-
|
|
46
|
-
# Start production server (without hot reload)
|
|
47
|
-
npm run start
|
|
48
|
-
# or
|
|
49
|
-
yarn start
|
|
50
|
-
# or
|
|
51
|
-
pnpm start
|
|
52
|
-
|
|
53
|
-
# Generate TypeScript types from Step configs
|
|
54
|
-
npm run generate-types
|
|
55
|
-
# or
|
|
56
|
-
yarn generate-types
|
|
57
|
-
# or
|
|
58
|
-
pnpm generate-types
|
|
59
|
-
|
|
60
|
-
# Build project for deployment
|
|
61
|
-
npm run build
|
|
62
|
-
# or
|
|
63
|
-
yarn build
|
|
64
|
-
# or
|
|
65
|
-
pnpm build
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Project Structure
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
69
19
|
|
|
70
|
-
|
|
71
|
-
steps/ # Your Step definitions (or use src/)
|
|
72
|
-
src/ # Shared services and utilities
|
|
73
|
-
motia.config.ts # Motia configuration
|
|
74
|
-
```
|
|
20
|
+
You can start editing the project by making changes to `src/petstore/api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
75
21
|
|
|
76
|
-
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
77
23
|
|
|
78
|
-
##
|
|
24
|
+
## Project Config
|
|
79
25
|
|
|
80
|
-
|
|
81
|
-
- Understanding Steps and their types
|
|
82
|
-
- Creating API endpoints
|
|
83
|
-
- Building event-driven workflows
|
|
84
|
-
- Using state management
|
|
85
|
-
- Observing your flows in the Workbench
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
86
27
|
|
|
87
28
|
## Learn More
|
|
88
29
|
|
|
89
|
-
- [
|
|
90
|
-
- [Quick Start
|
|
91
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
92
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -38,7 +38,7 @@ export const handler: Handlers['ApiTrigger'] = async (req, { logger, traceId, em
|
|
|
38
38
|
topic: 'process-food-order',
|
|
39
39
|
data: {
|
|
40
40
|
quantity: foodOrder.quantity,
|
|
41
|
-
email: 'test@test.com',
|
|
41
|
+
email: process.env.SAMPLE_EMAIL || 'test@test.com',
|
|
42
42
|
petId: newPetRecord.id,
|
|
43
43
|
},
|
|
44
44
|
})
|
|
@@ -28,7 +28,7 @@ export const handler: Handlers['StateAuditJob'] = async ({ logger, state, emit }
|
|
|
28
28
|
await emit({
|
|
29
29
|
topic: 'notification',
|
|
30
30
|
data: {
|
|
31
|
-
email: 'test@test.com',
|
|
31
|
+
email: process.env.SAMPLE_EMAIL || 'test@test.com',
|
|
32
32
|
templateId: 'order-audit-warning',
|
|
33
33
|
templateData: {
|
|
34
34
|
orderId: item.id,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Order, Pet } from './types'
|
|
2
2
|
|
|
3
|
+
const API_URL = process.env.API_URL || 'https://xnigaj-xtnawg.motiahub.com'
|
|
4
|
+
|
|
3
5
|
export const petStoreService = {
|
|
4
6
|
createPet: async (pet: Omit<Pet, 'id'>): Promise<Pet> => {
|
|
5
|
-
const response = await fetch(
|
|
7
|
+
const response = await fetch(`${API_URL}/pet`, {
|
|
6
8
|
method: 'POST',
|
|
7
9
|
body: JSON.stringify({
|
|
8
10
|
name: pet?.name ?? '',
|
|
@@ -14,7 +16,7 @@ export const petStoreService = {
|
|
|
14
16
|
return response.json()
|
|
15
17
|
},
|
|
16
18
|
createOrder: async (order: Omit<Order, 'id' | 'complete'>): Promise<Order> => {
|
|
17
|
-
const response = await fetch(
|
|
19
|
+
const response = await fetch(`${API_URL}/store/order`, {
|
|
18
20
|
method: 'POST',
|
|
19
21
|
body: JSON.stringify({
|
|
20
22
|
quantity: order?.quantity ?? 1,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{PROJECT_NAME}}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is a **Motia** project bootstrapped with the Motia CLI.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
|
|
5
|
+
Motia lets you build APIs, background jobs, workflows, and event-driven systems in a single unified backend.
|
|
8
6
|
|
|
9
7
|
## Quick Start
|
|
10
8
|
|
|
@@ -17,77 +15,19 @@ yarn dev
|
|
|
17
15
|
pnpm dev
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
This starts the Motia runtime and
|
|
21
|
-
|
|
22
|
-
1. **Open the Workbench** in your browser at [`http://localhost:3000`](http://localhost:3000)
|
|
23
|
-
2. **Click the `Tutorial`** button on the top right of the workbench
|
|
24
|
-
3. **Complete the `Tutorial`** to get an understanding of the basics of Motia and using the Workbench
|
|
25
|
-
|
|
26
|
-
## Step Types
|
|
27
|
-
|
|
28
|
-
Every Step has a `type` that defines how it triggers:
|
|
29
|
-
|
|
30
|
-
| Type | When it runs | Use case |
|
|
31
|
-
|------|--------------|----------|
|
|
32
|
-
| **`api`** | HTTP request | REST APIs, webhooks |
|
|
33
|
-
| **`event`** | Event emitted | Background jobs, workflows |
|
|
34
|
-
| **`cron`** | Schedule | Cleanup, reports, reminders |
|
|
35
|
-
|
|
36
|
-
## Development Commands
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# Start Workbench and development server
|
|
40
|
-
npm run dev
|
|
41
|
-
# or
|
|
42
|
-
yarn dev
|
|
43
|
-
# or
|
|
44
|
-
pnpm dev
|
|
45
|
-
|
|
46
|
-
# Start production server (without hot reload)
|
|
47
|
-
npm run start
|
|
48
|
-
# or
|
|
49
|
-
yarn start
|
|
50
|
-
# or
|
|
51
|
-
pnpm start
|
|
52
|
-
|
|
53
|
-
# Generate TypeScript types from Step configs
|
|
54
|
-
npm run generate-types
|
|
55
|
-
# or
|
|
56
|
-
yarn generate-types
|
|
57
|
-
# or
|
|
58
|
-
pnpm generate-types
|
|
59
|
-
|
|
60
|
-
# Build project for deployment
|
|
61
|
-
npm run build
|
|
62
|
-
# or
|
|
63
|
-
yarn build
|
|
64
|
-
# or
|
|
65
|
-
pnpm build
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Project Structure
|
|
18
|
+
This starts the Motia runtime and **Workbench**. Workbench is a tool for visualizing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
|
|
69
19
|
|
|
70
|
-
|
|
71
|
-
steps/ # Your Step definitions (or use src/)
|
|
72
|
-
src/ # Shared services and utilities
|
|
73
|
-
motia.config.ts # Motia configuration
|
|
74
|
-
requirements.txt # Python dependencies
|
|
75
|
-
```
|
|
20
|
+
You can start editing the project by making changes to `src/petstore/api` as well as produce your own `.step.ts`, `.step.js`, or `_step.py` files within the `src/` directory.
|
|
76
21
|
|
|
77
|
-
|
|
22
|
+
Motia auto-discovers all step files and executes them as defined in each step's configuration. Learn more about the power and simplicity of steps in the [Step Docs](https://motia.dev/docs/concepts/steps).
|
|
78
23
|
|
|
79
|
-
##
|
|
24
|
+
## Project Config
|
|
80
25
|
|
|
81
|
-
|
|
82
|
-
- Understanding Steps and their types
|
|
83
|
-
- Creating API endpoints
|
|
84
|
-
- Building event-driven workflows
|
|
85
|
-
- Using state management
|
|
86
|
-
- Observing your flows in the Workbench
|
|
26
|
+
The `motia.config.ts` file is the central configuration for your Motia application. Here you can customize Express, configure Redis, add security middleware, handle file uploads, set up stream authentication, and more.
|
|
87
27
|
|
|
88
28
|
## Learn More
|
|
89
29
|
|
|
90
|
-
- [
|
|
91
|
-
- [Quick Start
|
|
92
|
-
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
|
|
30
|
+
- [Docs](https://motia.dev/docs) - Complete guides and API reference
|
|
31
|
+
- [Quick Start Tutorial](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
|
|
32
|
+
- [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia's architecture
|
|
93
33
|
- [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from pydantic import BaseModel
|
|
2
3
|
from typing import Optional
|
|
3
4
|
from src.services.pet_store import pet_store_service
|
|
@@ -42,7 +43,7 @@ async def handler(req, context):
|
|
|
42
43
|
"topic": "process-food-order",
|
|
43
44
|
"data": {
|
|
44
45
|
"quantity": food_order.get("quantity"),
|
|
45
|
-
"email": "test@test.com",
|
|
46
|
+
"email": os.environ.get("SAMPLE_EMAIL", "test@test.com"),
|
|
46
47
|
"pet_id": new_pet_record.get("id"),
|
|
47
48
|
},
|
|
48
49
|
})
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
from datetime import datetime, timezone
|
|
2
3
|
|
|
3
4
|
config = {
|
|
@@ -27,7 +28,7 @@ async def handler(context):
|
|
|
27
28
|
await context.emit({
|
|
28
29
|
"topic": "notification",
|
|
29
30
|
"data": {
|
|
30
|
-
"email": "test@test.com",
|
|
31
|
+
"email": os.environ.get("SAMPLE_EMAIL", "test@test.com"),
|
|
31
32
|
"template_id": "order-audit-warning",
|
|
32
33
|
"template_data": {
|
|
33
34
|
"order_id": item.get("id"),
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import httpx
|
|
2
3
|
from typing import Dict, Any
|
|
3
4
|
from .types import Order, Pet
|
|
4
5
|
|
|
6
|
+
api_url = os.environ.get("API_URL", "https://xnigaj-xtnawg.motiahub.com")
|
|
7
|
+
|
|
5
8
|
class PetStoreService:
|
|
6
9
|
async def create_pet(self, pet: Dict[str, Any]) -> Pet:
|
|
7
10
|
pet_data = {
|
|
@@ -12,7 +15,7 @@ class PetStoreService:
|
|
|
12
15
|
|
|
13
16
|
async with httpx.AsyncClient() as client:
|
|
14
17
|
response = await client.post(
|
|
15
|
-
|
|
18
|
+
f"{api_url}/pet",
|
|
16
19
|
json=pet_data,
|
|
17
20
|
headers={'Content-Type': 'application/json'}
|
|
18
21
|
)
|
|
@@ -28,7 +31,7 @@ class PetStoreService:
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
response = await client.post(
|
|
31
|
-
|
|
34
|
+
f"{api_url}/store/order",
|
|
32
35
|
json=order_data,
|
|
33
36
|
headers={'Content-Type': 'application/json'}
|
|
34
37
|
)
|
|
@@ -3,48 +3,48 @@
|
|
|
3
3
|
"id": "step-configuration",
|
|
4
4
|
"title": "Step Configuration",
|
|
5
5
|
"description": "All steps should have a defined configuration, this is how you define the step's behavior and how it will be triggered.",
|
|
6
|
-
"lines": ["
|
|
6
|
+
"lines": ["7-30"]
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
"id": "api-configuration",
|
|
10
10
|
"title": "API Step",
|
|
11
11
|
"description": "Definition of an API endpoint",
|
|
12
|
-
"lines": ["
|
|
12
|
+
"lines": ["19", "23-24"]
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"id": "request-body",
|
|
16
16
|
"title": "Request body",
|
|
17
17
|
"description": "Definition of the expected request body. Motia will automatically generate types based on this schema.",
|
|
18
|
-
"lines": ["
|
|
18
|
+
"lines": ["7-16", "25"]
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"id": "response-payload",
|
|
22
22
|
"title": "Response Payload",
|
|
23
23
|
"description": "Definition of the expected response payload, Motia will generate the types automatically based on this schema. This is also important to create the Open API spec later.",
|
|
24
|
-
"lines": ["
|
|
24
|
+
"lines": ["5", "26-28"]
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"id": "event-driven-architecture",
|
|
28
28
|
"title": "Emits",
|
|
29
29
|
"description": "We can define the events that this step will emit, this is how we can trigger other Motia Steps.",
|
|
30
|
-
"lines": ["
|
|
30
|
+
"lines": ["29", "42-49"]
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"id": "handler",
|
|
34
34
|
"title": "Handler",
|
|
35
35
|
"description": "The handler is the function that will be executed when the step is triggered. This one receives the request body and emits events.",
|
|
36
|
-
"lines": ["
|
|
36
|
+
"lines": ["32-51"]
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"id": "logger",
|
|
40
40
|
"title": "Logger",
|
|
41
41
|
"description": "The logger is a utility that allows you to log messages to the console. It is available in the handler function. We encourage you to use it instead of console.log. It will automatically be tied to the trace id of the request.",
|
|
42
|
-
"lines": ["
|
|
42
|
+
"lines": ["34"]
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"id": "http-response",
|
|
46
46
|
"title": "HTTP Response",
|
|
47
47
|
"description": "The handler can return a response to the client. This is how we can return a response to the client. It must comply with the responseSchema defined in the step configuration.",
|
|
48
|
-
"lines": ["
|
|
48
|
+
"lines": ["51"]
|
|
49
49
|
}
|
|
50
50
|
]
|
package/dist/create/templates/python/tutorial/petstore/state_audit_cron_step.py-features.json.txt
CHANGED
|
@@ -3,24 +3,18 @@
|
|
|
3
3
|
"id": "step-configuration",
|
|
4
4
|
"title": "Step Configuration",
|
|
5
5
|
"description": "All steps should have a defined configuration, this is how you define the step's behavior and how it will be triggered.",
|
|
6
|
-
"lines": [
|
|
7
|
-
"3-10"
|
|
8
|
-
]
|
|
6
|
+
"lines": ["4-11"]
|
|
9
7
|
},
|
|
10
8
|
{
|
|
11
9
|
"id": "cron-configuration",
|
|
12
10
|
"title": "Cron Configuration",
|
|
13
11
|
"description": "Cron steps require a specific configuration structure with the 'type' field set to 'cron' and a valid cron expression.",
|
|
14
|
-
"lines": [
|
|
15
|
-
"4-5"
|
|
16
|
-
]
|
|
12
|
+
"lines": ["5-6"]
|
|
17
13
|
},
|
|
18
14
|
{
|
|
19
15
|
"id": "handler",
|
|
20
16
|
"title": "Cron Step Handler",
|
|
21
17
|
"description": "The Cron step handler only receives one argument.",
|
|
22
|
-
"lines": [
|
|
23
|
-
"12-39"
|
|
24
|
-
]
|
|
18
|
+
"lines": ["13-40"]
|
|
25
19
|
}
|
|
26
|
-
]
|
|
20
|
+
]
|
|
@@ -86,7 +86,7 @@ Before writing ANY Motia code, you MUST read the relevant cursor rules from `.cu
|
|
|
86
86
|
## Key Principles
|
|
87
87
|
|
|
88
88
|
- **All guides have TypeScript, JavaScript, and Python examples**
|
|
89
|
-
- **Steps can live
|
|
89
|
+
- **Steps can live anywhere within `/src`** - Motia discovers them automatically
|
|
90
90
|
- **Always export `config` and `handler`**
|
|
91
91
|
- **List all emits in config before using them**
|
|
92
92
|
- **Follow naming conventions**: `*.step.ts` (TS), `*.step.js` (JS), `*_step.py` (Python)
|
|
@@ -10,17 +10,13 @@ alwaysApply: true
|
|
|
10
10
|
|
|
11
11
|
This guide covers the architecture and best practices for structuring Motia projects.
|
|
12
12
|
|
|
13
|
-
**Key Takeaway**: Motia automatically discovers steps from anywhere in
|
|
13
|
+
**Key Takeaway**: Motia automatically discovers steps from anywhere in the `/src` folder. Modern projects use `/src` for a familiar structure that works seamlessly with Domain-Driven Design.
|
|
14
14
|
|
|
15
15
|
## File Structure
|
|
16
16
|
|
|
17
|
-
Motia automatically discovers step files from your project.
|
|
17
|
+
Motia automatically discovers step files from your project.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
- **`/steps` folder** - Traditional Motia pattern
|
|
21
|
-
- Both folders simultaneously
|
|
22
|
-
|
|
23
|
-
### Recommended Structure (using `/src`)
|
|
19
|
+
### Recommended Structure
|
|
24
20
|
|
|
25
21
|
```
|
|
26
22
|
project/
|
|
@@ -39,24 +35,7 @@ project/
|
|
|
39
35
|
└── motia.config.ts
|
|
40
36
|
```
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
project/
|
|
46
|
-
├── steps/
|
|
47
|
-
│ ├── api/
|
|
48
|
-
│ │ └── users.step.ts
|
|
49
|
-
│ ├── events/
|
|
50
|
-
│ │ └── order-processing.step.ts
|
|
51
|
-
│ └── cron/
|
|
52
|
-
│ └── cleanup.step.ts
|
|
53
|
-
├── src/
|
|
54
|
-
│ ├── services/
|
|
55
|
-
│ └── utils/
|
|
56
|
-
└── motia.config.ts
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Create subfolders within your chosen directory to organize related steps into logical groups (domains, features, or flows).
|
|
38
|
+
Create subfolders within your `/src` directory to organize related steps into logical groups (domains, features, or flows).
|
|
60
39
|
|
|
61
40
|
**Why `/src` is recommended:**
|
|
62
41
|
- Familiar to developers from other frameworks (Next.js, NestJS, etc.)
|
|
@@ -109,7 +88,7 @@ Motia encourages Domain-Driven Design (DDD) principles for maintainable, scalabl
|
|
|
109
88
|
|
|
110
89
|
### Folder Structure for DDD
|
|
111
90
|
|
|
112
|
-
When using `/src` for steps
|
|
91
|
+
When using `/src` for steps, your structure naturally supports DDD:
|
|
113
92
|
|
|
114
93
|
```
|
|
115
94
|
src/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: How to create HTTP endpoints in Motia
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
# API Steps Guide
|
|
@@ -9,7 +9,7 @@ API Steps expose HTTP endpoints that can trigger workflows and emit events.
|
|
|
9
9
|
|
|
10
10
|
## Creating API Steps
|
|
11
11
|
|
|
12
|
-
Steps need to be created in the `
|
|
12
|
+
Steps need to be created in the `src` folder, it can be in subfolders.
|
|
13
13
|
|
|
14
14
|
- Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
|
|
15
15
|
- Steps in Python should end with `_step.py`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Cron Steps are scheduled tasks that run based on cron expressions.
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
# Cron Steps Guide
|
|
@@ -15,7 +15,7 @@ ultimately trigger an Event Step that will handle the logic.
|
|
|
15
15
|
|
|
16
16
|
## Creating Cron Steps
|
|
17
17
|
|
|
18
|
-
Steps need to be created in the `
|
|
18
|
+
Steps need to be created in the `src` folder, it can be in subfolders.
|
|
19
19
|
|
|
20
20
|
- Steps in TS and JS should end with `.step.ts` and `.step.js` respectively
|
|
21
21
|
- Steps in Python should end with `_step.py`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: How to create background tasks in Motia
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
# Event Steps Guide
|
|
@@ -19,7 +19,7 @@ Other applicable examples are tasks that are likely to fail, examples:
|
|
|
19
19
|
|
|
20
20
|
## Creating Event Steps
|
|
21
21
|
|
|
22
|
-
Steps need to be created in the `
|
|
22
|
+
Steps need to be created in the `src` folder, it can be in subfolders.
|
|
23
23
|
|
|
24
24
|
- Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
|
|
25
25
|
- Steps in Python should end with `_step.py`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Middlewares are used to execute code before and after the handler is called
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py,middlewares/**/*.middleware.ts,middlewares/**/*.middleware.js,middlewares/**/*_middleware.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
# Middlewares Guide
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Real-time streaming
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py,src/**/*.stream.ts,src/**/*.stream.js,src/**/*_stream.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
# Real-time Streaming
|
|
@@ -56,7 +56,7 @@ export interface StreamConfig {
|
|
|
56
56
|
### TypeScript Example
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
-
//
|
|
59
|
+
// src/streams/chat-messages.stream.ts
|
|
60
60
|
import { StreamConfig } from 'motia'
|
|
61
61
|
import { z } from 'zod'
|
|
62
62
|
|
|
@@ -81,7 +81,7 @@ export const config: StreamConfig = {
|
|
|
81
81
|
#### With Pydantic (Optional)
|
|
82
82
|
|
|
83
83
|
```python
|
|
84
|
-
#
|
|
84
|
+
# src/streams/chat_messages_stream.py
|
|
85
85
|
from pydantic import BaseModel
|
|
86
86
|
|
|
87
87
|
class ChatMessage(BaseModel):
|
|
@@ -100,7 +100,7 @@ config = {
|
|
|
100
100
|
#### Without Pydantic (Pure JSON Schema)
|
|
101
101
|
|
|
102
102
|
```python
|
|
103
|
-
#
|
|
103
|
+
# src/streams/chat_messages_stream.py
|
|
104
104
|
|
|
105
105
|
config = {
|
|
106
106
|
"name": "chatMessage",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Overriding the UI of Steps in Motia
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.tsx,src/**/*.step.jsx,src/**/*_step.tsx,src/**/*_step.jsx
|
|
4
4
|
alwaysApply: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ With UI Steps, you can enhance the user experience by designing intuitive, conte
|
|
|
15
15
|
To create a custom UI for a step, create a .tsx or .jsx file next to your step file with the same base name:
|
|
16
16
|
|
|
17
17
|
```
|
|
18
|
-
|
|
18
|
+
src/
|
|
19
19
|
└── myStep/
|
|
20
20
|
├── myStep.step.ts # Step definition
|
|
21
21
|
└── myStep.step.tsx # Visual override
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Connecting nodes virtually and creating a smooth flow in Workbench
|
|
3
|
-
globs:
|
|
3
|
+
globs: src/**/*.step.ts,src/**/*.step.js,src/**/*_step.py
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ or without NOOP Steps.
|
|
|
15
15
|
|
|
16
16
|
## Creating NOOP Steps
|
|
17
17
|
|
|
18
|
-
Steps need to be created in the `
|
|
18
|
+
Steps need to be created in the `src` folder, it can be in subfolders.
|
|
19
19
|
|
|
20
20
|
- Steps in TS and JS should end with `.step.ts` and `.step.js` respectively.
|
|
21
21
|
- Steps in Python should end with `_step.py`.
|
|
@@ -63,9 +63,9 @@ Architecture guides in `.cursor/architecture/`:
|
|
|
63
63
|
|
|
64
64
|
### Project Structure
|
|
65
65
|
|
|
66
|
-
Motia discovers steps from
|
|
66
|
+
Motia discovers steps from the `/src` folder:
|
|
67
67
|
|
|
68
|
-
**Recommended Structure
|
|
68
|
+
**Recommended Structure:**
|
|
69
69
|
```
|
|
70
70
|
project/
|
|
71
71
|
├── .cursor/rules/ # DETAILED GUIDES - Read these first!
|
|
@@ -88,19 +88,6 @@ project/
|
|
|
88
88
|
└── types.d.ts # Auto-generated types
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
**Alternative Structure (using `/steps`):**
|
|
92
|
-
```
|
|
93
|
-
project/
|
|
94
|
-
├── steps/ # Step definitions
|
|
95
|
-
│ ├── api/
|
|
96
|
-
│ ├── events/
|
|
97
|
-
│ └── cron/
|
|
98
|
-
├── src/
|
|
99
|
-
│ ├── services/
|
|
100
|
-
│ └── utils/
|
|
101
|
-
└── motia.config.ts
|
|
102
|
-
```
|
|
103
|
-
|
|
104
91
|
### Step Naming Conventions
|
|
105
92
|
|
|
106
93
|
**TypeScript/JavaScript:** `my-step.step.ts` (kebab-case)
|
|
@@ -48,7 +48,7 @@ All guides in `.cursor/rules/` with **TypeScript, JavaScript, and Python** examp
|
|
|
48
48
|
|
|
49
49
|
See `AGENTS.md` in this directory for a quick overview and links to specific guides.
|
|
50
50
|
|
|
51
|
-
**Important**: Motia discovers steps from
|
|
51
|
+
**Important**: Motia discovers steps from the `/src` folder.
|
|
52
52
|
|
|
53
53
|
## Key Commands
|
|
54
54
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
3
|
"description": "Build production-grade backends with a single primitive. APIs, background jobs, Queues, Workflows, and AI agents - unified in one system with built-in State management, Streaming, and Observability.",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.12-beta.194",
|
|
5
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"table": "^6.9.0",
|
|
47
47
|
"ts-node": "^10.9.2",
|
|
48
48
|
"zod": "^4.1.13",
|
|
49
|
-
"@motiadev/adapter-redis-cron": "0.17.
|
|
50
|
-
"@motiadev/adapter-
|
|
51
|
-
"@motiadev/adapter-
|
|
52
|
-
"@motiadev/
|
|
53
|
-
"@motiadev/
|
|
54
|
-
"@motiadev/
|
|
55
|
-
"@motiadev/
|
|
49
|
+
"@motiadev/adapter-redis-cron": "0.17.12-beta.194",
|
|
50
|
+
"@motiadev/adapter-bullmq-events": "0.17.12-beta.194",
|
|
51
|
+
"@motiadev/adapter-redis-streams": "0.17.12-beta.194",
|
|
52
|
+
"@motiadev/adapter-redis-state": "0.17.12-beta.194",
|
|
53
|
+
"@motiadev/stream-client-node": "0.17.12-beta.194",
|
|
54
|
+
"@motiadev/workbench": "0.17.12-beta.194",
|
|
55
|
+
"@motiadev/core": "0.17.12-beta.194"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@amplitude/analytics-types": "^2.9.2",
|