motia 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/src/builder/build-printer.d.ts +9 -0
- package/dist/src/builder/build.d.ts +1 -0
- package/dist/src/builder/cli-output-manager.d.ts +6 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/create/index.d.ts +6 -0
- package/dist/src/create/templates/default/generate.d.ts +4 -0
- package/dist/src/create/templates/index.d.ts +1 -0
- package/dist/src/create-step/getAnswers.d.ts +2 -0
- package/dist/src/create-step/index.d.ts +3 -0
- package/dist/src/create-step/teamplateUtils.d.ts +5 -0
- package/dist/src/create-step/templates/ui/overrides.d.ts +5 -0
- package/dist/src/create-step/types.d.ts +21 -0
- package/dist/src/create-step/utils.d.ts +2 -0
- package/dist/src/dev/state-endpoints.d.ts +2 -0
- package/dist/src/dev/workflow-config-endpoints.d.ts +2 -0
- package/dist/src/dev-watchers.d.ts +3 -0
- package/dist/src/dev.d.ts +1 -0
- package/dist/src/generate-locked-data.d.ts +3 -0
- package/dist/src/watcher.d.ts +24 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,18 +1,91 @@
|
|
|
1
|
-
# Motia
|
|
1
|
+
# Motia
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/motiajs/motia/main/assets/logo.png" alt="Motia Logo" width="200" />
|
|
5
|
+
</p>
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>A modern, declarative workflow framework for multiple programming languages</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/motia"><img src="https://img.shields.io/npm/v/motia.svg" alt="npm version"></a>
|
|
13
|
+
<a href="https://github.com/motiajs/motia/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license"></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## What is Motia?
|
|
17
|
+
|
|
18
|
+
Motia is a lightweight, flexible framework for building complex workflows and business processes across multiple programming languages. It allows you to define, visualize, and execute workflows with a clean, declarative API in JavaScript, TypeScript, Ruby, Python, and more languages coming soon.
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
Key features:
|
|
21
|
+
- 🔄 **Declarative Workflows**: Define complex processes with a simple, readable syntax
|
|
22
|
+
- 🛠️ **Type-Safe**: Built with strong typing support for all supported languages
|
|
23
|
+
- 🔍 **Visualizable**: Inspect and debug your workflows with Motia Workbench
|
|
24
|
+
- 🧩 **Composable**: Build complex workflows from reusable components
|
|
25
|
+
- 🚀 **Multi-Language Support**: Works with JavaScript, TypeScript, Ruby, Python, with more languages coming soon
|
|
26
|
+
- 🌐 **Framework Agnostic**: Integrates with any framework in your language of choice
|
|
8
27
|
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### JavaScript/TypeScript
|
|
9
31
|
```sh
|
|
10
|
-
npm install
|
|
32
|
+
npm install motia
|
|
33
|
+
# or
|
|
34
|
+
yarn add motia
|
|
35
|
+
# or
|
|
36
|
+
pnpm add motia
|
|
11
37
|
```
|
|
12
38
|
|
|
13
|
-
## Usage
|
|
14
39
|
|
|
15
|
-
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### Email Auto-Reply with Sentiment Analysis
|
|
45
|
+
|
|
46
|
+
Here's a real-world example of using Motia to create an automated email reply system with sentiment analysis:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { OpenAI } from 'openai';
|
|
50
|
+
import { z } from 'zod';
|
|
51
|
+
import type { EventConfig, StepHandler } from 'motia';
|
|
52
|
+
|
|
53
|
+
const openai = new OpenAI({
|
|
54
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const config: EventConfig = {
|
|
58
|
+
type: 'event',
|
|
59
|
+
name: 'Auto-Reply to Support Emails',
|
|
60
|
+
subscribes: ['email.received'],
|
|
61
|
+
emits: ['email.send'],
|
|
62
|
+
flows: ['email-support'],
|
|
63
|
+
input: z.object({ subject: z.string(), body: z.string(), from: z.string() }),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const handler: StepHandler<typeof config> = async (inputData, context) => {
|
|
67
|
+
const { subject, body, from } = inputData;
|
|
68
|
+
const { emit, logger } = context;
|
|
69
|
+
|
|
70
|
+
const sentimentResponse = await openai.chat.completions.create({
|
|
71
|
+
model: "gpt-4o",
|
|
72
|
+
messages: [{ role: "user", content: `Analyze the sentiment of the following email: ${body}` }]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const sentiment = sentimentResponse.choices[0].message.content;
|
|
76
|
+
|
|
77
|
+
logger.info('[EmailAutoReply] Sentiment analysis', { sentiment });
|
|
78
|
+
|
|
79
|
+
emit({
|
|
80
|
+
type: 'email.send',
|
|
81
|
+
data: { from, subject, body, sentiment },
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## CLI Commands
|
|
87
|
+
|
|
88
|
+
Motia comes with a powerful CLI to help you manage your projects:
|
|
16
89
|
|
|
17
90
|
### `motia init`
|
|
18
91
|
|
|
@@ -38,6 +111,26 @@ Initiates a dev environment for your project allowing you to use Motia Workbench
|
|
|
38
111
|
motia dev
|
|
39
112
|
```
|
|
40
113
|
|
|
114
|
+
## Visualizing Workflows
|
|
115
|
+
|
|
116
|
+
Motia Workbench provides a visual interface to inspect and debug your workflows:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
motia dev
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Then open your browser at `http://localhost:3000` to see your workflows in action.
|
|
123
|
+
|
|
124
|
+
## Language Support
|
|
125
|
+
|
|
126
|
+
Motia currently supports:
|
|
127
|
+
- JavaScript
|
|
128
|
+
- TypeScript
|
|
129
|
+
- Ruby
|
|
130
|
+
- Python
|
|
131
|
+
|
|
132
|
+
With more languages coming soon!
|
|
133
|
+
|
|
41
134
|
## Help
|
|
42
135
|
|
|
43
136
|
For more information on a specific command, you can use the `--help` flag:
|
|
@@ -46,6 +139,14 @@ For more information on a specific command, you can use the `--help` flag:
|
|
|
46
139
|
motia <command> --help
|
|
47
140
|
```
|
|
48
141
|
|
|
142
|
+
## Documentation
|
|
143
|
+
|
|
144
|
+
For full documentation, visit [https://motia.dev/docs](https://motia.dev/docs)
|
|
145
|
+
|
|
146
|
+
## Contributing
|
|
147
|
+
|
|
148
|
+
We welcome contributions! Please see our [Contributing Guide](https://github.com/motiajs/motia/blob/main/CONTRIBUTING.md) for details.
|
|
149
|
+
|
|
49
150
|
## License
|
|
50
151
|
|
|
51
152
|
This project is licensed under the MIT License.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("@motiadev/core"), exports);
|
|
18
|
+
__exportStar(require("@motiadev/workbench"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Step } from '@motiadev/core/dist/src/types';
|
|
2
|
+
export declare class BuildPrinter {
|
|
3
|
+
private readonly printer;
|
|
4
|
+
private readonly output;
|
|
5
|
+
printStepBuilding(step: Step): void;
|
|
6
|
+
printStepBuilt(step: Step): void;
|
|
7
|
+
printStepFailed(step: Step, error: Error): void;
|
|
8
|
+
printStepSkipped(step: Step, reason: string): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const build: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const templates: Record<string, (dir: string) => Promise<void>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const STEP_TYPES: readonly ["api", "event", "cron", "noop"];
|
|
2
|
+
export declare const LANGUAGES: readonly ["typescript", "javascript", "python", "ruby"];
|
|
3
|
+
export declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "DELETE"];
|
|
4
|
+
export type StepType = (typeof STEP_TYPES)[number];
|
|
5
|
+
export type Language = (typeof LANGUAGES)[number];
|
|
6
|
+
export type HttpMethod = (typeof HTTP_METHODS)[number];
|
|
7
|
+
export type StepAnswers = {
|
|
8
|
+
name: string;
|
|
9
|
+
language: Language;
|
|
10
|
+
type: StepType;
|
|
11
|
+
description?: string;
|
|
12
|
+
method?: HttpMethod;
|
|
13
|
+
path?: string;
|
|
14
|
+
subscriptions?: string[];
|
|
15
|
+
cronExpression?: string;
|
|
16
|
+
virtualEmits?: string[];
|
|
17
|
+
virtualSubscribes?: string[];
|
|
18
|
+
emits: string[];
|
|
19
|
+
flows: string[];
|
|
20
|
+
createOverride: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { LockedData, MotiaServer, MotiaEventManager, CronManager } from '@motiadev/core';
|
|
2
|
+
import { Watcher } from './watcher';
|
|
3
|
+
export declare const createDevWatchers: (lockedData: LockedData, server: MotiaServer, eventHandler: MotiaEventManager, cronManager: CronManager) => Watcher;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const dev: (port: number, isVerbose: boolean) => Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LockedData, Step } from '@motiadev/core';
|
|
2
|
+
type StepChangeHandler = (oldStep: Step, newStep: Step) => void;
|
|
3
|
+
type StepCreateHandler = (step: Step) => void;
|
|
4
|
+
type StepDeleteHandler = (step: Step) => void;
|
|
5
|
+
export declare class Watcher {
|
|
6
|
+
private readonly dir;
|
|
7
|
+
private lockedData;
|
|
8
|
+
private watcher?;
|
|
9
|
+
private stepChangeHandler?;
|
|
10
|
+
private stepCreateHandler?;
|
|
11
|
+
private stepDeleteHandler?;
|
|
12
|
+
constructor(dir: string, lockedData: LockedData);
|
|
13
|
+
onStepChange(handler: StepChangeHandler): void;
|
|
14
|
+
onStepCreate(handler: StepCreateHandler): void;
|
|
15
|
+
onStepDelete(handler: StepDeleteHandler): void;
|
|
16
|
+
private findStep;
|
|
17
|
+
private onFileAdd;
|
|
18
|
+
private onFileChange;
|
|
19
|
+
private onFileDelete;
|
|
20
|
+
init(): void;
|
|
21
|
+
private isStepFile;
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"motia": "dist/src/cli.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"inquirer": "^12.4.1",
|
|
17
17
|
"ts-node": "^10.9.2",
|
|
18
18
|
"yaml": "^2.7.0",
|
|
19
|
-
"@motiadev/core": "0.0.
|
|
20
|
-
"@motiadev/workbench": "0.0.
|
|
19
|
+
"@motiadev/core": "0.0.34",
|
|
20
|
+
"@motiadev/workbench": "0.0.34"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/archiver": "^6.0.3",
|