motia 0.17.1-beta.183-843379 → 0.17.1-beta.183-767430
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,142 +60,46 @@ 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
97
|
<br />
|
|
155
|
-
|
|
156
|
-
|
|
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>
|
|
98
|
+
<p>Take your time exploring these features. Click <b>Continue</b> when you're ready to move on.</p>
|
|
99
|
+
</div>
|
|
180
100
|
),
|
|
181
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
101
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') }],
|
|
182
102
|
},
|
|
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
|
-
<br />
|
|
190
|
-
You simply need to return an object that complies with one of the <b>responseSchema</b> definitions declared in
|
|
191
|
-
your Step configuration.
|
|
192
|
-
</p>
|
|
193
|
-
),
|
|
194
103
|
before: [{ type: 'click', selector: workbenchXPath.flows.feature('http-response') }],
|
|
195
104
|
},
|
|
196
105
|
|
|
@@ -220,77 +129,39 @@ export const steps: TutorialStep[] = [
|
|
|
220
129
|
},
|
|
221
130
|
{
|
|
222
131
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
223
|
-
title: 'Event Step',
|
|
132
|
+
title: 'Explore the Event Step',
|
|
224
133
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-event',
|
|
225
134
|
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 />
|
|
135
|
+
<div>
|
|
136
|
+
<p>
|
|
137
|
+
<b>Event</b> Steps are essential for Motia's event driven architecture. They subscribe to topics and perform
|
|
138
|
+
specific tasks.
|
|
139
|
+
</p>
|
|
274
140
|
<br />
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
141
|
+
<p>
|
|
142
|
+
<b>Click on the feature cards</b> to learn about:
|
|
143
|
+
</p>
|
|
144
|
+
<ul className="square-decoration">
|
|
145
|
+
<li>
|
|
146
|
+
<b>Step Configuration</b> - Common attributes for Event Steps
|
|
147
|
+
</li>
|
|
148
|
+
<li>
|
|
149
|
+
<b>Input Schema</b> - The data structure provided by the topic (defined as a zod schema)
|
|
150
|
+
</li>
|
|
151
|
+
<li>
|
|
152
|
+
<b>Event Step Handler</b> - The handler receives topic data as the first argument
|
|
153
|
+
</li>
|
|
154
|
+
<li>
|
|
155
|
+
<b>State Management</b> - How to persist data in state with group IDs
|
|
156
|
+
</li>
|
|
157
|
+
</ul>
|
|
287
158
|
<br />
|
|
159
|
+
<p>💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.</p>
|
|
288
160
|
<br />
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
</p>
|
|
161
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
162
|
+
</div>
|
|
292
163
|
),
|
|
293
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
164
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') }],
|
|
294
165
|
},
|
|
295
166
|
|
|
296
167
|
// Cron Steps
|
|
@@ -313,41 +184,34 @@ export const steps: TutorialStep[] = [
|
|
|
313
184
|
},
|
|
314
185
|
{
|
|
315
186
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
316
|
-
title: 'Cron
|
|
187
|
+
title: 'Explore the Cron Step',
|
|
317
188
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-cron',
|
|
318
189
|
description: () => (
|
|
319
|
-
<
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
define the cron schedule for your Step.
|
|
325
|
-
<br />
|
|
190
|
+
<div>
|
|
191
|
+
<p>
|
|
192
|
+
<b>CRON</b> Steps are similar to other Step types - they have a configuration and a handler. The key difference
|
|
193
|
+
is the <b>cron</b> attribute that defines the schedule.
|
|
194
|
+
</p>
|
|
326
195
|
<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.
|
|
196
|
+
<p>
|
|
197
|
+
<b>Click on the feature cards</b> to learn about:
|
|
198
|
+
</p>
|
|
199
|
+
<ul className="square-decoration">
|
|
200
|
+
<li>
|
|
201
|
+
<b>Cron Configuration</b> - How to define the cron schedule (e.g., every 5 minutes)
|
|
202
|
+
</li>
|
|
203
|
+
<li>
|
|
204
|
+
<b>Cron Step Handler</b> - Receives only the Motia context, giving access to emit topics, log, manage state,
|
|
205
|
+
and trace ID
|
|
206
|
+
</li>
|
|
207
|
+
</ul>
|
|
344
208
|
<br />
|
|
209
|
+
<p>In this example, the CRON Step evaluates orders in state and emits warnings for unprocessed orders.</p>
|
|
345
210
|
<br />
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</p>
|
|
211
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
212
|
+
</div>
|
|
349
213
|
),
|
|
350
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
214
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('stateauditjob') }],
|
|
351
215
|
},
|
|
352
216
|
|
|
353
217
|
// 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,142 +60,46 @@ 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
97
|
<br />
|
|
112
|
-
<
|
|
113
|
-
</
|
|
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>
|
|
98
|
+
<p>Take your time exploring these features. Click <b>Continue</b> when you're ready to move on.</p>
|
|
99
|
+
</div>
|
|
180
100
|
),
|
|
181
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
101
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('apitrigger') }],
|
|
182
102
|
},
|
|
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
|
-
<br />
|
|
190
|
-
You simply need to return an object that complies with one of the <b>responseSchema</b> definitions declared in
|
|
191
|
-
your Step configuration.
|
|
192
|
-
</p>
|
|
193
|
-
),
|
|
194
103
|
before: [{ type: 'click', selector: workbenchXPath.flows.feature('http-response') }],
|
|
195
104
|
},
|
|
196
105
|
|
|
@@ -220,77 +129,39 @@ export const steps: TutorialStep[] = [
|
|
|
220
129
|
},
|
|
221
130
|
{
|
|
222
131
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
223
|
-
title: 'Event Step',
|
|
132
|
+
title: 'Explore the Event Step',
|
|
224
133
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-event',
|
|
225
134
|
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 />
|
|
135
|
+
<div>
|
|
136
|
+
<p>
|
|
137
|
+
<b>Event</b> Steps are essential for Motia's event driven architecture. They subscribe to topics and perform
|
|
138
|
+
specific tasks.
|
|
139
|
+
</p>
|
|
274
140
|
<br />
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
141
|
+
<p>
|
|
142
|
+
<b>Click on the feature cards</b> to learn about:
|
|
143
|
+
</p>
|
|
144
|
+
<ul className="square-decoration">
|
|
145
|
+
<li>
|
|
146
|
+
<b>Step Configuration</b> - Common attributes for Event Steps
|
|
147
|
+
</li>
|
|
148
|
+
<li>
|
|
149
|
+
<b>Input Schema</b> - The data structure provided by the topic (defined as a zod schema)
|
|
150
|
+
</li>
|
|
151
|
+
<li>
|
|
152
|
+
<b>Event Step Handler</b> - The handler receives topic data as the first argument
|
|
153
|
+
</li>
|
|
154
|
+
<li>
|
|
155
|
+
<b>State Management</b> - How to persist data in state with group IDs
|
|
156
|
+
</li>
|
|
157
|
+
</ul>
|
|
287
158
|
<br />
|
|
159
|
+
<p>💡 <b>Event</b> Steps can only be triggered internally, through topic subscriptions.</p>
|
|
288
160
|
<br />
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
</p>
|
|
161
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
162
|
+
</div>
|
|
292
163
|
),
|
|
293
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
164
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('processfoodorder') }],
|
|
294
165
|
},
|
|
295
166
|
|
|
296
167
|
// Cron Steps
|
|
@@ -313,41 +184,34 @@ export const steps: TutorialStep[] = [
|
|
|
313
184
|
},
|
|
314
185
|
{
|
|
315
186
|
elementXpath: workbenchXPath.sidebarContainer,
|
|
316
|
-
title: 'Cron
|
|
187
|
+
title: 'Explore the Cron Step',
|
|
317
188
|
link: 'https://www.motia.dev/docs/concepts/steps#triggers-cron',
|
|
318
189
|
description: () => (
|
|
319
|
-
<
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
define the cron schedule for your Step.
|
|
325
|
-
<br />
|
|
190
|
+
<div>
|
|
191
|
+
<p>
|
|
192
|
+
<b>CRON</b> Steps are similar to other Step types - they have a configuration and a handler. The key difference
|
|
193
|
+
is the <b>cron</b> attribute that defines the schedule.
|
|
194
|
+
</p>
|
|
326
195
|
<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.
|
|
196
|
+
<p>
|
|
197
|
+
<b>Click on the feature cards</b> to learn about:
|
|
198
|
+
</p>
|
|
199
|
+
<ul className="square-decoration">
|
|
200
|
+
<li>
|
|
201
|
+
<b>Cron Configuration</b> - How to define the cron schedule (e.g., every 5 minutes)
|
|
202
|
+
</li>
|
|
203
|
+
<li>
|
|
204
|
+
<b>Cron Step Handler</b> - Receives only the Motia context, giving access to emit topics, log, manage state,
|
|
205
|
+
and trace ID
|
|
206
|
+
</li>
|
|
207
|
+
</ul>
|
|
344
208
|
<br />
|
|
209
|
+
<p>In this example, the CRON Step evaluates orders in state and emits warnings for unprocessed orders.</p>
|
|
345
210
|
<br />
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
</p>
|
|
211
|
+
<p>Click <b>Continue</b> when you're ready to move on.</p>
|
|
212
|
+
</div>
|
|
349
213
|
),
|
|
350
|
-
before: [{ type: 'click', selector: workbenchXPath.flows.
|
|
214
|
+
before: [{ type: 'click', selector: workbenchXPath.flows.previewButton('stateauditjob') }],
|
|
351
215
|
},
|
|
352
216
|
|
|
353
217
|
// 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.1-beta.183-
|
|
4
|
+
"version": "0.17.1-beta.183-767430",
|
|
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.1-beta.183-
|
|
50
|
-
"@motiadev/adapter-redis-
|
|
51
|
-
"@motiadev/adapter-redis-
|
|
52
|
-
"@motiadev/adapter-redis-
|
|
53
|
-
"@motiadev/core": "0.17.1-beta.183-
|
|
54
|
-
"@motiadev/stream-client-node": "0.17.1-beta.183-
|
|
55
|
-
"@motiadev/workbench": "0.17.1-beta.183-
|
|
49
|
+
"@motiadev/adapter-bullmq-events": "0.17.1-beta.183-767430",
|
|
50
|
+
"@motiadev/adapter-redis-cron": "0.17.1-beta.183-767430",
|
|
51
|
+
"@motiadev/adapter-redis-state": "0.17.1-beta.183-767430",
|
|
52
|
+
"@motiadev/adapter-redis-streams": "0.17.1-beta.183-767430",
|
|
53
|
+
"@motiadev/core": "0.17.1-beta.183-767430",
|
|
54
|
+
"@motiadev/stream-client-node": "0.17.1-beta.183-767430",
|
|
55
|
+
"@motiadev/workbench": "0.17.1-beta.183-767430"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@amplitude/analytics-types": "^2.9.2",
|