motia 0.17.4-beta.185 → 0.17.4-beta.186-859040
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.
|
@@ -44,7 +44,12 @@ export const steps: TutorialStep[] = [
|
|
|
44
44
|
{
|
|
45
45
|
elementXpath: workbenchXPath.flows.previewButton('apitrigger'),
|
|
46
46
|
title: 'Code Preview',
|
|
47
|
-
description: () =>
|
|
47
|
+
description: () => (
|
|
48
|
+
<p>
|
|
49
|
+
Clicking on this icon will allow you to visualize the source code for a given Step. This opens a code viewer
|
|
50
|
+
with interactive feature cards that explain different parts of the code.
|
|
51
|
+
</p>
|
|
52
|
+
),
|
|
48
53
|
before: [
|
|
49
54
|
{
|
|
50
55
|
type: 'click',
|
|
@@ -55,143 +60,45 @@ export const steps: TutorialStep[] = [
|
|
|
55
60
|
},
|
|
56
61
|
{
|
|
57
62
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
58
|
-
title: '
|
|
63
|
+
title: 'Explore the Code',
|
|
59
64
|
description: () => (
|
|
60
65
|
<div>
|
|
61
66
|
<p>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<br />
|
|
65
|
-
Let's start with the configuration, the common config attributes are
|
|
66
|
-
<i> type, name, description, and flows</i>.
|
|
67
|
-
<br />
|
|
68
|
-
<br />
|
|
67
|
+
The code viewer shows the Step's source code on the right. On the left, you'll find <b>feature cards</b> that
|
|
68
|
+
explain different parts of the code.
|
|
69
69
|
</p>
|
|
70
|
-
<
|
|
70
|
+
<br />
|
|
71
|
+
<p>
|
|
72
|
+
<b>Click on the feature cards</b> to learn about:
|
|
73
|
+
</p>
|
|
74
|
+
<ul className="square-decoration">
|
|
75
|
+
<li>
|
|
76
|
+
<b>Step Configuration</b> - Common attributes like type, name, description, and flows
|
|
77
|
+
</li>
|
|
78
|
+
<li>
|
|
79
|
+
<b>API Step Configuration</b> - HTTP method and path attributes
|
|
80
|
+
</li>
|
|
71
81
|
<li>
|
|
72
|
-
|
|
82
|
+
<b>Request Body & Response Payload</b> - Zod schemas for request/response validation
|
|
73
83
|
</li>
|
|
74
84
|
<li>
|
|
75
|
-
|
|
85
|
+
<b>Event Driven Architecture</b> - How Steps communicate via emits and subscribes
|
|
76
86
|
</li>
|
|
77
87
|
<li>
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
<b>Step Handler</b> - The function that executes when the Step is triggered
|
|
89
|
+
</li>
|
|
90
|
+
<li>
|
|
91
|
+
<b>Logger</b> - Enhanced logging utilities for observability
|
|
92
|
+
</li>
|
|
93
|
+
<li>
|
|
94
|
+
<b>HTTP Response</b> - Returning responses that match your responseSchema
|
|
80
95
|
</li>
|
|
81
96
|
</ul>
|
|
82
|
-
</div>
|
|
83
|
-
),
|
|
84
|
-
before: [
|
|
85
|
-
{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') },
|
|
86
|
-
{ type: 'click', selector: workbenchXPath.flows.feature('step-configuration') },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
91
|
-
title: 'API Step Configuration',
|
|
92
|
-
description: () => (
|
|
93
|
-
<p>
|
|
94
|
-
There are specific configuration attributes for an API Step. Let's start with the <b>method</b> attribute. This
|
|
95
|
-
will declare the type of HTTP method used to talk to your API Step.
|
|
96
|
-
<br />
|
|
97
|
-
<br />
|
|
98
|
-
Through the <b>path</b> attribute you'll declare the url path used to trigger your API Step
|
|
99
|
-
</p>
|
|
100
|
-
),
|
|
101
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('api-configuration') }],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
105
|
-
title: 'Request Body',
|
|
106
|
-
link: 'https://zod.dev/api',
|
|
107
|
-
description: () => (
|
|
108
|
-
<p>
|
|
109
|
-
The <b>bodySchema</b> attribute will define the shape of the request body.
|
|
110
|
-
<br />
|
|
111
|
-
<br />
|
|
112
|
-
<i>💡 Both the request body and response payload are defined by zod schemas</i>
|
|
113
|
-
</p>
|
|
114
|
-
),
|
|
115
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('request-body') }],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
119
|
-
title: 'Response Payload',
|
|
120
|
-
link: 'https://zod.dev/api',
|
|
121
|
-
description: () => (
|
|
122
|
-
<p>
|
|
123
|
-
Through the <b>responseSchema</b> attribute you can declare the different type of http responses based on the
|
|
124
|
-
http status code.
|
|
125
|
-
<br />
|
|
126
|
-
<br />
|
|
127
|
-
<i>💡 Both the request body and response payload are defined by zod schemas</i>
|
|
128
|
-
</p>
|
|
129
|
-
),
|
|
130
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('response-payload') }],
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
134
|
-
title: 'Event Driven Architecture',
|
|
135
|
-
description: () => (
|
|
136
|
-
<p>
|
|
137
|
-
Motia allows you to interact between Steps or flows through an event driven architecture.
|
|
138
|
-
<br />
|
|
139
|
-
<br />
|
|
140
|
-
In order to connect your Steps during runtime you will use the <b>emits</b> and <b>subscribes</b> attributes.
|
|
141
|
-
<br />
|
|
142
|
-
<br />
|
|
143
|
-
Through the <b>emits</b>, you can specify a list of topics that your Step emits for others to <i>subscribe</i>.
|
|
144
|
-
</p>
|
|
145
|
-
),
|
|
146
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('event-driven-architecture') }],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
150
|
-
title: 'Step Handler',
|
|
151
|
-
description: () => (
|
|
152
|
-
<p>
|
|
153
|
-
Now that we've covered how to declare a Step, let's dive into the <b>Step Handler</b>.<br />
|
|
154
|
-
<br />
|
|
155
|
-
Handlers are essential for the execution of your Step. For API Steps, the handler will receive the request
|
|
156
|
-
object as the first argument, followed by a second argument that provides access to the <b>logger</b>,{' '}
|
|
157
|
-
<b>event emitter</b>, <b>state manager</b>, and <b>trace id</b>.<br />
|
|
158
|
-
<br />
|
|
159
|
-
💡 We will cover these in depth further down the tutorial.
|
|
160
|
-
</p>
|
|
161
|
-
),
|
|
162
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('handler') }],
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
166
|
-
title: 'Logger',
|
|
167
|
-
description: () => (
|
|
168
|
-
<p>
|
|
169
|
-
We recommend using the provided <b>logger</b> util in order to guarantee observability through Motia's
|
|
170
|
-
ecosystem.
|
|
171
|
-
<br />
|
|
172
|
-
<br />
|
|
173
|
-
You can use logger similar to <i>console.log</i> for js or <i>print</i> for python, but with enhanced utilities,
|
|
174
|
-
such as being able to provide additional context.
|
|
175
|
-
<br />
|
|
176
|
-
<br />
|
|
177
|
-
Motia will take care of the rest to provide the best experience to visualize your logs and tie them through
|
|
178
|
-
tracing.
|
|
179
|
-
</p>
|
|
180
|
-
),
|
|
181
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('logger') }],
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
185
|
-
title: 'HTTP Response',
|
|
186
|
-
description: () => (
|
|
187
|
-
<p>
|
|
188
|
-
Now let's wrap our API Step and return a response.
|
|
189
97
|
<br />
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
</p>
|
|
98
|
+
<p>Take your time exploring these features. Click <b>Continue</b> when you're ready to move on.</p>
|
|
99
|
+
</div>
|
|
193
100
|
),
|
|
194
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
101
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') }],
|
|
195
102
|
},
|
|
196
103
|
|
|
197
104
|
// Event Steps
|
|
@@ -220,77 +127,39 @@ export const steps: TutorialStep[] = [
|
|
|
220
127
|
},
|
|
221
128
|
{
|
|
222
129
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
223
|
-
title: 'Event Step',
|
|
130
|
+
title: 'Explore the Event Step',
|
|
224
131
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-event',
|
|
225
132
|
description: () => (
|
|
226
|
-
<
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
<br /> <br />
|
|
232
|
-
<b> Event</b> Steps are essential for Motia's event driven architecture. Let's dive deeper into the anatomy of
|
|
233
|
-
an Event Step by taking a look at the code visualization tool.
|
|
234
|
-
<br /> <br />
|
|
235
|
-
💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.
|
|
236
|
-
</p>
|
|
237
|
-
),
|
|
238
|
-
before: [
|
|
239
|
-
{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') },
|
|
240
|
-
{ type: 'click', selector: workbenchXPath.flows.feature('step-configuration') },
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
245
|
-
title: 'Event Step Input',
|
|
246
|
-
description: () => (
|
|
247
|
-
<p>
|
|
248
|
-
<b>Event</b> Steps, like other Steps types, are composed of a configuration and a handler.
|
|
249
|
-
<br />
|
|
250
|
-
<br />
|
|
251
|
-
<b>Event</b> Steps have a specific attribute from their config, the <b>input</b> attribute, which declares the
|
|
252
|
-
data structure provided by the topic it is subscribed to.
|
|
253
|
-
<br />
|
|
254
|
-
<br />
|
|
255
|
-
The <b>input</b> attributes is defined as a zod schema, think of the <b>input</b> attributes as a contract for
|
|
256
|
-
other Steps that emit the topics that your Step subscribes to.
|
|
257
|
-
<br />
|
|
258
|
-
<br /> 💡 <b>Multiple Steps can subscribe to the same topic, but their input schema must be the same.</b>
|
|
259
|
-
</p>
|
|
260
|
-
),
|
|
261
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('input-schema') }],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
265
|
-
title: 'Event Step Handler',
|
|
266
|
-
description: () => (
|
|
267
|
-
<p>
|
|
268
|
-
Let's take a look at the <b>Event</b> Step Handler.
|
|
269
|
-
<br />
|
|
270
|
-
<br />
|
|
271
|
-
The handler will seem familiar to other Step handlers, but notice that the first argument holds the data
|
|
272
|
-
provided for the topic or topics your Step subscribes to.
|
|
273
|
-
<br />
|
|
133
|
+
<div>
|
|
134
|
+
<p>
|
|
135
|
+
<b>Event</b> Steps are essential for Motia's event driven architecture. They subscribe to topics and perform
|
|
136
|
+
specific tasks.
|
|
137
|
+
</p>
|
|
274
138
|
<br />
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
139
|
+
<p>
|
|
140
|
+
<b>Click on the feature cards</b> to learn about:
|
|
141
|
+
</p>
|
|
142
|
+
<ul className="square-decoration">
|
|
143
|
+
<li>
|
|
144
|
+
<b>Step Configuration</b> - Common attributes for Event Steps
|
|
145
|
+
</li>
|
|
146
|
+
<li>
|
|
147
|
+
<b>Input Schema</b> - The data structure provided by the topic (defined as a zod schema)
|
|
148
|
+
</li>
|
|
149
|
+
<li>
|
|
150
|
+
<b>Event Step Handler</b> - The handler receives topic data as the first argument
|
|
151
|
+
</li>
|
|
152
|
+
<li>
|
|
153
|
+
<b>State Management</b> - How to persist data in state with group IDs
|
|
154
|
+
</li>
|
|
155
|
+
</ul>
|
|
287
156
|
<br />
|
|
157
|
+
<p>💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.</p>
|
|
288
158
|
<br />
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
</p>
|
|
159
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
160
|
+
</div>
|
|
292
161
|
),
|
|
293
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
162
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') }],
|
|
294
163
|
},
|
|
295
164
|
|
|
296
165
|
// Cron Steps
|
|
@@ -301,53 +170,46 @@ export const steps: TutorialStep[] = [
|
|
|
301
170
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-cron',
|
|
302
171
|
description: () => (
|
|
303
172
|
<p>
|
|
304
|
-
Let's do a recap of what you've learned
|
|
173
|
+
Let's do a recap of what you've learned. Thus far, you've become familiar with two Step types: <b>API</b>{' '}
|
|
305
174
|
and <b>Event</b> Steps.
|
|
306
175
|
<br />
|
|
307
176
|
<br />
|
|
308
177
|
You've also started to learn how to navigate around Workbench. Let's wrap up Motia's Step types with the last
|
|
309
|
-
one the <b>CRON</b> Step. Let's take a deeper look at its definition.
|
|
178
|
+
one: the <b>CRON</b> Step. Let's take a deeper look at its definition.
|
|
310
179
|
</p>
|
|
311
180
|
),
|
|
312
181
|
before: [{ type: 'click', selector: workbenchXPath.closePanelButton }],
|
|
313
182
|
},
|
|
314
183
|
{
|
|
315
184
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
316
|
-
title: 'Cron
|
|
185
|
+
title: 'Explore the Cron Step',
|
|
317
186
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-cron',
|
|
318
187
|
description: () => (
|
|
319
|
-
<
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
define the cron schedule for your Step.
|
|
325
|
-
<br />
|
|
188
|
+
<div>
|
|
189
|
+
<p>
|
|
190
|
+
<b>CRON</b> Steps are similar to other Step types - they have a configuration and a handler. The key difference
|
|
191
|
+
is the <b>cron</b> attribute that defines the schedule.
|
|
192
|
+
</p>
|
|
326
193
|
<br />
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
description: () => (
|
|
340
|
-
<p>
|
|
341
|
-
The <b>CRON</b> Step handler only receives one argument, which is the Motia context, if you recall the Motia
|
|
342
|
-
context gives you access to utilities to emit <i>topics</i>, <i>log</i>, <i>manage state</i>, and it provides
|
|
343
|
-
the <i>trace id</i> associated to your Step's execution.
|
|
194
|
+
<p>
|
|
195
|
+
<b>Click on the feature cards</b> to learn about:
|
|
196
|
+
</p>
|
|
197
|
+
<ul className="square-decoration">
|
|
198
|
+
<li>
|
|
199
|
+
<b>Cron Configuration</b> - How to define the cron schedule (e.g., every 5 minutes)
|
|
200
|
+
</li>
|
|
201
|
+
<li>
|
|
202
|
+
<b>Cron Step Handler</b> - Receives only the Motia context, giving access to emit topics, log, manage state,
|
|
203
|
+
and trace ID
|
|
204
|
+
</li>
|
|
205
|
+
</ul>
|
|
344
206
|
<br />
|
|
207
|
+
<p>In this example, the CRON Step evaluates orders in state and emits warnings for unprocessed orders.</p>
|
|
345
208
|
<br />
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</p>
|
|
209
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
210
|
+
</div>
|
|
349
211
|
),
|
|
350
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
212
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('stateauditjob') }],
|
|
351
213
|
},
|
|
352
214
|
|
|
353
215
|
// Endpoints
|
|
@@ -44,7 +44,12 @@ export const steps: TutorialStep[] = [
|
|
|
44
44
|
{
|
|
45
45
|
elementXpath: workbenchXPath.flows.previewButton('apitrigger'),
|
|
46
46
|
title: 'Code Preview',
|
|
47
|
-
description: () =>
|
|
47
|
+
description: () => (
|
|
48
|
+
<p>
|
|
49
|
+
Clicking on this icon will allow you to visualize the source code for a given Step. This opens a code viewer
|
|
50
|
+
with interactive feature cards that explain different parts of the code.
|
|
51
|
+
</p>
|
|
52
|
+
),
|
|
48
53
|
before: [
|
|
49
54
|
{
|
|
50
55
|
type: 'click',
|
|
@@ -55,143 +60,45 @@ export const steps: TutorialStep[] = [
|
|
|
55
60
|
},
|
|
56
61
|
{
|
|
57
62
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
58
|
-
title: '
|
|
63
|
+
title: 'Explore the Code',
|
|
59
64
|
description: () => (
|
|
60
65
|
<div>
|
|
61
66
|
<p>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<br />
|
|
65
|
-
Let's start with the configuration, the common config attributes are
|
|
66
|
-
<i> type, name, description, and flows</i>.
|
|
67
|
-
<br />
|
|
68
|
-
<br />
|
|
67
|
+
The code viewer shows the Step's source code on the right. On the left, you'll find <b>feature cards</b> that
|
|
68
|
+
explain different parts of the code.
|
|
69
69
|
</p>
|
|
70
|
-
<
|
|
70
|
+
<br />
|
|
71
|
+
<p>
|
|
72
|
+
<b>Click on the feature cards</b> to learn about:
|
|
73
|
+
</p>
|
|
74
|
+
<ul className="square-decoration">
|
|
75
|
+
<li>
|
|
76
|
+
<b>Step Configuration</b> - Common attributes like type, name, description, and flows
|
|
77
|
+
</li>
|
|
78
|
+
<li>
|
|
79
|
+
<b>API Step Configuration</b> - HTTP method and path attributes
|
|
80
|
+
</li>
|
|
71
81
|
<li>
|
|
72
|
-
|
|
82
|
+
<b>Request Body & Response Payload</b> - Zod schemas for request/response validation
|
|
73
83
|
</li>
|
|
74
84
|
<li>
|
|
75
|
-
|
|
85
|
+
<b>Event Driven Architecture</b> - How Steps communicate via emits and subscribes
|
|
76
86
|
</li>
|
|
77
87
|
<li>
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
<b>Step Handler</b> - The function that executes when the Step is triggered
|
|
89
|
+
</li>
|
|
90
|
+
<li>
|
|
91
|
+
<b>Logger</b> - Enhanced logging utilities for observability
|
|
92
|
+
</li>
|
|
93
|
+
<li>
|
|
94
|
+
<b>HTTP Response</b> - Returning responses that match your responseSchema
|
|
80
95
|
</li>
|
|
81
96
|
</ul>
|
|
82
|
-
</div>
|
|
83
|
-
),
|
|
84
|
-
before: [
|
|
85
|
-
{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') },
|
|
86
|
-
{ type: 'click', selector: workbenchXPath.flows.feature('step-configuration') },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
91
|
-
title: 'API Step Configuration',
|
|
92
|
-
description: () => (
|
|
93
|
-
<p>
|
|
94
|
-
There are specific configuration attributes for an API Step. Let's start with the <b>method</b> attribute. This
|
|
95
|
-
will declare the type of HTTP method used to talk to your API Step.
|
|
96
|
-
<br />
|
|
97
|
-
<br />
|
|
98
|
-
Through the <b>path</b> attribute you'll declare the url path used to trigger your API Step
|
|
99
|
-
</p>
|
|
100
|
-
),
|
|
101
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('api-configuration') }],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
105
|
-
title: 'Request Body',
|
|
106
|
-
link: 'https://zod.dev/api',
|
|
107
|
-
description: () => (
|
|
108
|
-
<p>
|
|
109
|
-
The <b>bodySchema</b> attribute will define the shape of the request body.
|
|
110
|
-
<br />
|
|
111
|
-
<br />
|
|
112
|
-
<i>💡 Both the request body and response payload are defined by zod schemas</i>
|
|
113
|
-
</p>
|
|
114
|
-
),
|
|
115
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('request-body') }],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
119
|
-
title: 'Response Payload',
|
|
120
|
-
link: 'https://zod.dev/api',
|
|
121
|
-
description: () => (
|
|
122
|
-
<p>
|
|
123
|
-
Through the <b>responseSchema</b> attribute you can declare the different type of http responses based on the
|
|
124
|
-
http status code.
|
|
125
|
-
<br />
|
|
126
|
-
<br />
|
|
127
|
-
<i>💡 Both the request body and response payload are defined by zod schemas</i>
|
|
128
|
-
</p>
|
|
129
|
-
),
|
|
130
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('response-payload') }],
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
134
|
-
title: 'Event Driven Architecture',
|
|
135
|
-
description: () => (
|
|
136
|
-
<p>
|
|
137
|
-
Motia allows you to interact between Steps or flows through an event driven architecture.
|
|
138
|
-
<br />
|
|
139
|
-
<br />
|
|
140
|
-
In order to connect your Steps during runtime you will use the <b>emits</b> and <b>subscribes</b> attributes.
|
|
141
|
-
<br />
|
|
142
|
-
<br />
|
|
143
|
-
Through the <b>emits</b>, you can specify a list of topics that your Step emits for others to <i>subscribe</i>.
|
|
144
|
-
</p>
|
|
145
|
-
),
|
|
146
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('event-driven-architecture') }],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
150
|
-
title: 'Step Handler',
|
|
151
|
-
description: () => (
|
|
152
|
-
<p>
|
|
153
|
-
Now that we've covered how to declare a Step, let's dive into the <b>Step Handler</b>.<br />
|
|
154
|
-
<br />
|
|
155
|
-
Handlers are essential for the execution of your Step. For API Steps, the handler will receive the request
|
|
156
|
-
object as the first argument, followed by a second argument that provides access to the <b>logger</b>,{' '}
|
|
157
|
-
<b>event emitter</b>, <b>state manager</b>, and <b>trace id</b>.<br />
|
|
158
|
-
<br />
|
|
159
|
-
💡 We will cover these in depth further down the tutorial.
|
|
160
|
-
</p>
|
|
161
|
-
),
|
|
162
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('handler') }],
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
166
|
-
title: 'Logger',
|
|
167
|
-
description: () => (
|
|
168
|
-
<p>
|
|
169
|
-
We recommend using the provided <b>logger</b> util in order to guarantee observability through Motia's
|
|
170
|
-
ecosystem.
|
|
171
|
-
<br />
|
|
172
|
-
<br />
|
|
173
|
-
You can use logger similar to <i>console.log</i> for js or <i>print</i> for python, but with enhanced utilities,
|
|
174
|
-
such as being able to provide additional context.
|
|
175
|
-
<br />
|
|
176
|
-
<br />
|
|
177
|
-
Motia will take care of the rest to provide the best experience to visualize your logs and tie them through
|
|
178
|
-
tracing.
|
|
179
|
-
</p>
|
|
180
|
-
),
|
|
181
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('logger') }],
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
185
|
-
title: 'HTTP Response',
|
|
186
|
-
description: () => (
|
|
187
|
-
<p>
|
|
188
|
-
Now let's wrap our API Step and return a response.
|
|
189
97
|
<br />
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
</p>
|
|
98
|
+
<p>Take your time exploring these features. Click <b>Continue</b> when you're ready to move on.</p>
|
|
99
|
+
</div>
|
|
193
100
|
),
|
|
194
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
101
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') }],
|
|
195
102
|
},
|
|
196
103
|
|
|
197
104
|
// Event Steps
|
|
@@ -220,77 +127,39 @@ export const steps: TutorialStep[] = [
|
|
|
220
127
|
},
|
|
221
128
|
{
|
|
222
129
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
223
|
-
title: 'Event Step',
|
|
130
|
+
title: 'Explore the Event Step',
|
|
224
131
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-event',
|
|
225
132
|
description: () => (
|
|
226
|
-
<
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
<br /> <br />
|
|
232
|
-
<b> Event</b> Steps are essential for Motia's event driven architecture. Let's dive deeper into the
|
|
233
|
-
anatomy of an Event Step by taking a look at the code visualization tool.
|
|
234
|
-
<br /> <br />
|
|
235
|
-
💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.
|
|
236
|
-
</p>
|
|
237
|
-
),
|
|
238
|
-
before: [
|
|
239
|
-
{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') },
|
|
240
|
-
{ type: 'click', selector: workbenchXPath.flows.feature('step-configuration') },
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
245
|
-
title: 'Event Step Input',
|
|
246
|
-
description: () => (
|
|
247
|
-
<p>
|
|
248
|
-
<b> Event</b> Steps, like other Step types, are composed of a configuration and a handler.
|
|
249
|
-
<br />
|
|
250
|
-
<br />
|
|
251
|
-
<b>Event</b> Steps have a specific attribute from their config, the <b>input</b> attribute, which declares the
|
|
252
|
-
data structure provided by the topic it is subscribed to.
|
|
253
|
-
<br />
|
|
254
|
-
<br />
|
|
255
|
-
The <b>input</b> attributes is defined as a zod schema, think of the <b>input</b> attributes as a contract for
|
|
256
|
-
other Steps that emit the topics that your Step subscribes to.
|
|
257
|
-
<br />
|
|
258
|
-
<br /> 💡 <b>Multiple Steps can subscribe to the same topic, but their input schema must be the same.</b>
|
|
259
|
-
</p>
|
|
260
|
-
),
|
|
261
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.feature('input-schema') }],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
elementXpath: workbenchXPath.sidebarContainer,
|
|
265
|
-
title: 'Event Step Handler',
|
|
266
|
-
description: () => (
|
|
267
|
-
<p>
|
|
268
|
-
Let's take a look at the <b>Event</b> Step Handler.
|
|
269
|
-
<br />
|
|
270
|
-
<br />
|
|
271
|
-
The handler will seem familiar to other Step handlers, but notice that the first argument holds the data
|
|
272
|
-
provided for the topic or topics your Step subscribes to.
|
|
273
|
-
<br />
|
|
133
|
+
<div>
|
|
134
|
+
<p>
|
|
135
|
+
<b>Event</b> Steps are essential for Motia's event driven architecture. They subscribe to topics and perform
|
|
136
|
+
specific tasks.
|
|
137
|
+
</p>
|
|
274
138
|
<br />
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
139
|
+
<p>
|
|
140
|
+
<b>Click on the feature cards</b> to learn about:
|
|
141
|
+
</p>
|
|
142
|
+
<ul className="square-decoration">
|
|
143
|
+
<li>
|
|
144
|
+
<b>Step Configuration</b> - Common attributes for Event Steps
|
|
145
|
+
</li>
|
|
146
|
+
<li>
|
|
147
|
+
<b>Input Schema</b> - The data structure provided by the topic (defined as a zod schema)
|
|
148
|
+
</li>
|
|
149
|
+
<li>
|
|
150
|
+
<b>Event Step Handler</b> - The handler receives topic data as the first argument
|
|
151
|
+
</li>
|
|
152
|
+
<li>
|
|
153
|
+
<b>State Management</b> - How to persist data in state with group IDs
|
|
154
|
+
</li>
|
|
155
|
+
</ul>
|
|
287
156
|
<br />
|
|
157
|
+
<p>💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.</p>
|
|
288
158
|
<br />
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
</p>
|
|
159
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
160
|
+
</div>
|
|
292
161
|
),
|
|
293
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
162
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') }],
|
|
294
163
|
},
|
|
295
164
|
|
|
296
165
|
// Cron Steps
|
|
@@ -313,41 +182,34 @@ export const steps: TutorialStep[] = [
|
|
|
313
182
|
},
|
|
314
183
|
{
|
|
315
184
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
316
|
-
title: 'Cron
|
|
185
|
+
title: 'Explore the Cron Step',
|
|
317
186
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-cron',
|
|
318
187
|
description: () => (
|
|
319
|
-
<
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
define the cron schedule for your Step.
|
|
325
|
-
<br />
|
|
188
|
+
<div>
|
|
189
|
+
<p>
|
|
190
|
+
<b>CRON</b> Steps are similar to other Step types - they have a configuration and a handler. The key difference
|
|
191
|
+
is the <b>cron</b> attribute that defines the schedule.
|
|
192
|
+
</p>
|
|
326
193
|
<br />
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
description: () => (
|
|
340
|
-
<p>
|
|
341
|
-
The <b>CRON</b> Step handler only receives one argument, which is the Motia context, if you recall the Motia
|
|
342
|
-
context gives you access to utilities to emit <i>topics</i>, <i>log</i>, <i>manage state</i>, and it provides
|
|
343
|
-
the <i>trace id</i> associated to your Step's execution.
|
|
194
|
+
<p>
|
|
195
|
+
<b>Click on the feature cards</b> to learn about:
|
|
196
|
+
</p>
|
|
197
|
+
<ul className="square-decoration">
|
|
198
|
+
<li>
|
|
199
|
+
<b>Cron Configuration</b> - How to define the cron schedule (e.g., every 5 minutes)
|
|
200
|
+
</li>
|
|
201
|
+
<li>
|
|
202
|
+
<b>Cron Step Handler</b> - Receives only the Motia context, giving access to emit topics, log, manage state,
|
|
203
|
+
and trace ID
|
|
204
|
+
</li>
|
|
205
|
+
</ul>
|
|
344
206
|
<br />
|
|
207
|
+
<p>In this example, the CRON Step evaluates orders in state and emits warnings for unprocessed orders.</p>
|
|
345
208
|
<br />
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</p>
|
|
209
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
210
|
+
</div>
|
|
349
211
|
),
|
|
350
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
212
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('stateauditjob') }],
|
|
351
213
|
},
|
|
352
214
|
|
|
353
215
|
// Endpoints
|
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-beta.
|
|
4
|
+
"version": "0.17.4-beta.186-859040",
|
|
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.12",
|
|
49
|
-
"@motiadev/adapter-bullmq-events": "0.17.4-beta.
|
|
50
|
-
"@motiadev/adapter-redis-cron": "0.17.4-beta.
|
|
51
|
-
"@motiadev/adapter-redis-state": "0.17.4-beta.
|
|
52
|
-
"@motiadev/core": "0.17.4-beta.
|
|
53
|
-
"@motiadev/
|
|
54
|
-
"@motiadev/
|
|
55
|
-
"@motiadev/
|
|
49
|
+
"@motiadev/adapter-bullmq-events": "0.17.4-beta.186-859040",
|
|
50
|
+
"@motiadev/adapter-redis-cron": "0.17.4-beta.186-859040",
|
|
51
|
+
"@motiadev/adapter-redis-state": "0.17.4-beta.186-859040",
|
|
52
|
+
"@motiadev/core": "0.17.4-beta.186-859040",
|
|
53
|
+
"@motiadev/stream-client-node": "0.17.4-beta.186-859040",
|
|
54
|
+
"@motiadev/adapter-redis-streams": "0.17.4-beta.186-859040",
|
|
55
|
+
"@motiadev/workbench": "0.17.4-beta.186-859040"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@amplitude/analytics-types": "^2.9.2",
|