motia 0.6.4-beta.131-508662 → 0.6.4-beta.131-876960
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/cjs/cloud/build/builders/python/index.js +2 -2
- package/dist/cjs/cloud/build/builders/python/router_template.py +1 -3
- package/dist/cjs/generate-locked-data.js +21 -0
- package/dist/cjs/watcher.js +2 -2
- package/dist/esm/cloud/build/builders/python/index.js +2 -2
- package/dist/esm/cloud/build/builders/python/router_template.py +1 -3
- package/dist/esm/generate-locked-data.js +21 -0
- package/dist/esm/watcher.js +2 -2
- package/package.json +4 -4
|
@@ -112,13 +112,13 @@ class PythonBuilder {
|
|
|
112
112
|
}
|
|
113
113
|
createRouterTemplate(steps) {
|
|
114
114
|
const imports = steps
|
|
115
|
-
.map((step, index) => `from ${this.getModuleName(step)} import handler as route${index}
|
|
115
|
+
.map((step, index) => `from ${this.getModuleName(step)} import handler as route${index}_handler, config as route${index}_config`)
|
|
116
116
|
.join('\n');
|
|
117
117
|
const routerPaths = steps
|
|
118
118
|
.map((step, index) => {
|
|
119
119
|
const method = step.config.method.toUpperCase();
|
|
120
120
|
const path = step.config.path;
|
|
121
|
-
return ` '${method} ${path}': RouterPath('${step.config.name}', '${step.config.method.toLowerCase()}', route${index}
|
|
121
|
+
return ` '${method} ${path}': RouterPath('${step.config.name}', '${step.config.method.toLowerCase()}', route${index}_handler, route${index}_config)`;
|
|
122
122
|
})
|
|
123
123
|
.join(',\n');
|
|
124
124
|
return fs_1.default
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Dict, Callable, Any, Literal
|
|
2
|
+
# from steps.api_step import handler as route0_handler, config as route0_config
|
|
2
3
|
# {{imports}}
|
|
3
4
|
|
|
4
|
-
|
|
5
5
|
class RouterPath:
|
|
6
6
|
def __init__(self, step_name: str, method: Literal['get', 'post', 'put', 'delete', 'patch', 'options', 'head'], handler: Callable, config: Dict[str, Any]):
|
|
7
7
|
self.step_name = step_name
|
|
@@ -10,8 +10,6 @@ class RouterPath:
|
|
|
10
10
|
self.config = config
|
|
11
11
|
|
|
12
12
|
router_paths: Dict[str, RouterPath] = {
|
|
13
|
-
# Example:
|
|
14
13
|
# 'POST /api/parallel-merge/python': RouterPath('Parallel Merge Python', 'post', route0_handler, route0_config)
|
|
15
|
-
|
|
16
14
|
# {{router paths}}
|
|
17
15
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.generateLockedData = exports.collectFlows = exports.getStreamFiles = exports.getStepFiles = void 0;
|
|
7
7
|
const core_1 = require("@motiadev/core");
|
|
8
8
|
const printer_1 = require("@motiadev/core/dist/src/printer");
|
|
9
|
+
const colors_1 = __importDefault(require("colors"));
|
|
9
10
|
const crypto_1 = require("crypto");
|
|
10
11
|
const glob_1 = require("glob");
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
@@ -32,6 +33,7 @@ const collectFlows = async (projectDir, lockedData) => {
|
|
|
32
33
|
const invalidSteps = [];
|
|
33
34
|
const stepFiles = (0, exports.getStepFiles)(projectDir);
|
|
34
35
|
const streamFiles = (0, exports.getStreamFiles)(projectDir);
|
|
36
|
+
const deprecatedSteps = (0, glob_1.globSync)('**/*.step.py', { absolute: true, cwd: path_1.default.join(projectDir, 'steps') });
|
|
35
37
|
for (const filePath of stepFiles) {
|
|
36
38
|
try {
|
|
37
39
|
const config = await (0, core_1.getStepConfig)(filePath);
|
|
@@ -56,6 +58,25 @@ const collectFlows = async (projectDir, lockedData) => {
|
|
|
56
58
|
}
|
|
57
59
|
lockedData.createStream({ filePath, config }, { disableTypeCreation: true });
|
|
58
60
|
}
|
|
61
|
+
if (deprecatedSteps.length > 0) {
|
|
62
|
+
const warning = colors_1.default.yellow('! [WARNING]');
|
|
63
|
+
console.warn(colors_1.default.yellow([
|
|
64
|
+
'',
|
|
65
|
+
'========================================',
|
|
66
|
+
warning,
|
|
67
|
+
'',
|
|
68
|
+
`Python steps with ${colors_1.default.gray('.step.py')} extensions are no longer supported.`,
|
|
69
|
+
`Please rename them to ${colors_1.default.gray('_step.py')}.`,
|
|
70
|
+
'',
|
|
71
|
+
colors_1.default.bold('Steps:'),
|
|
72
|
+
...deprecatedSteps.map((step) => colors_1.default.reset(`- ${colors_1.default.cyan(colors_1.default.bold(step.replace(projectDir, '')))} rename to ${colors_1.default.gray(`${step.replace(projectDir, '').replace('.step.py', '_step.py')}`)}`)),
|
|
73
|
+
'',
|
|
74
|
+
'Make sure the step names are importable from Python:',
|
|
75
|
+
`- Don't use numbers, dots, dashes, commas, spaces, colons, or special characters`,
|
|
76
|
+
'========================================',
|
|
77
|
+
'',
|
|
78
|
+
].join('\n')));
|
|
79
|
+
}
|
|
59
80
|
return invalidSteps;
|
|
60
81
|
};
|
|
61
82
|
exports.collectFlows = collectFlows;
|
package/dist/cjs/watcher.js
CHANGED
|
@@ -137,10 +137,10 @@ class Watcher {
|
|
|
137
137
|
.on('unlink', (path) => this.onFileDelete(path));
|
|
138
138
|
}
|
|
139
139
|
isStepFile(path) {
|
|
140
|
-
return /[._]step\.[^.]+$/.test(path) && !/\.tsx$/.test(path);
|
|
140
|
+
return /[._]step\.[^.]+$/.test(path) && !/\.tsx$/.test(path) && !/\.step\.py$/.test(path);
|
|
141
141
|
}
|
|
142
142
|
isStreamFile(path) {
|
|
143
|
-
return /[._]stream\.[^.]+$/.test(path) && !/\.tsx$/.test(path);
|
|
143
|
+
return /[._]stream\.[^.]+$/.test(path) && !/\.tsx$/.test(path) && !/\.stream\.py$/.test(path);
|
|
144
144
|
}
|
|
145
145
|
async stop() {
|
|
146
146
|
if (this.watcher) {
|
|
@@ -106,13 +106,13 @@ export class PythonBuilder {
|
|
|
106
106
|
}
|
|
107
107
|
createRouterTemplate(steps) {
|
|
108
108
|
const imports = steps
|
|
109
|
-
.map((step, index) => `from ${this.getModuleName(step)} import handler as route${index}
|
|
109
|
+
.map((step, index) => `from ${this.getModuleName(step)} import handler as route${index}_handler, config as route${index}_config`)
|
|
110
110
|
.join('\n');
|
|
111
111
|
const routerPaths = steps
|
|
112
112
|
.map((step, index) => {
|
|
113
113
|
const method = step.config.method.toUpperCase();
|
|
114
114
|
const path = step.config.path;
|
|
115
|
-
return ` '${method} ${path}': RouterPath('${step.config.name}', '${step.config.method.toLowerCase()}', route${index}
|
|
115
|
+
return ` '${method} ${path}': RouterPath('${step.config.name}', '${step.config.method.toLowerCase()}', route${index}_handler, route${index}_config)`;
|
|
116
116
|
})
|
|
117
117
|
.join(',\n');
|
|
118
118
|
return fs
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Dict, Callable, Any, Literal
|
|
2
|
+
# from steps.api_step import handler as route0_handler, config as route0_config
|
|
2
3
|
# {{imports}}
|
|
3
4
|
|
|
4
|
-
|
|
5
5
|
class RouterPath:
|
|
6
6
|
def __init__(self, step_name: str, method: Literal['get', 'post', 'put', 'delete', 'patch', 'options', 'head'], handler: Callable, config: Dict[str, Any]):
|
|
7
7
|
self.step_name = step_name
|
|
@@ -10,8 +10,6 @@ class RouterPath:
|
|
|
10
10
|
self.config = config
|
|
11
11
|
|
|
12
12
|
router_paths: Dict[str, RouterPath] = {
|
|
13
|
-
# Example:
|
|
14
13
|
# 'POST /api/parallel-merge/python': RouterPath('Parallel Merge Python', 'post', route0_handler, route0_config)
|
|
15
|
-
|
|
16
14
|
# {{router paths}}
|
|
17
15
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LockedData, getStepConfig, getStreamConfig } from '@motiadev/core';
|
|
2
2
|
import { NoPrinter, Printer } from '@motiadev/core/dist/src/printer';
|
|
3
|
+
import colors from 'colors';
|
|
3
4
|
import { randomUUID } from 'crypto';
|
|
4
5
|
import { globSync } from 'glob';
|
|
5
6
|
import path from 'path';
|
|
@@ -24,6 +25,7 @@ export const collectFlows = async (projectDir, lockedData) => {
|
|
|
24
25
|
const invalidSteps = [];
|
|
25
26
|
const stepFiles = getStepFiles(projectDir);
|
|
26
27
|
const streamFiles = getStreamFiles(projectDir);
|
|
28
|
+
const deprecatedSteps = globSync('**/*.step.py', { absolute: true, cwd: path.join(projectDir, 'steps') });
|
|
27
29
|
for (const filePath of stepFiles) {
|
|
28
30
|
try {
|
|
29
31
|
const config = await getStepConfig(filePath);
|
|
@@ -48,6 +50,25 @@ export const collectFlows = async (projectDir, lockedData) => {
|
|
|
48
50
|
}
|
|
49
51
|
lockedData.createStream({ filePath, config }, { disableTypeCreation: true });
|
|
50
52
|
}
|
|
53
|
+
if (deprecatedSteps.length > 0) {
|
|
54
|
+
const warning = colors.yellow('! [WARNING]');
|
|
55
|
+
console.warn(colors.yellow([
|
|
56
|
+
'',
|
|
57
|
+
'========================================',
|
|
58
|
+
warning,
|
|
59
|
+
'',
|
|
60
|
+
`Python steps with ${colors.gray('.step.py')} extensions are no longer supported.`,
|
|
61
|
+
`Please rename them to ${colors.gray('_step.py')}.`,
|
|
62
|
+
'',
|
|
63
|
+
colors.bold('Steps:'),
|
|
64
|
+
...deprecatedSteps.map((step) => colors.reset(`- ${colors.cyan(colors.bold(step.replace(projectDir, '')))} rename to ${colors.gray(`${step.replace(projectDir, '').replace('.step.py', '_step.py')}`)}`)),
|
|
65
|
+
'',
|
|
66
|
+
'Make sure the step names are importable from Python:',
|
|
67
|
+
`- Don't use numbers, dots, dashes, commas, spaces, colons, or special characters`,
|
|
68
|
+
'========================================',
|
|
69
|
+
'',
|
|
70
|
+
].join('\n')));
|
|
71
|
+
}
|
|
51
72
|
return invalidSteps;
|
|
52
73
|
};
|
|
53
74
|
export const generateLockedData = async (projectDir, streamAdapter = 'file', printerType = 'default') => {
|
package/dist/esm/watcher.js
CHANGED
|
@@ -131,10 +131,10 @@ export class Watcher {
|
|
|
131
131
|
.on('unlink', (path) => this.onFileDelete(path));
|
|
132
132
|
}
|
|
133
133
|
isStepFile(path) {
|
|
134
|
-
return /[._]step\.[^.]+$/.test(path) && !/\.tsx$/.test(path);
|
|
134
|
+
return /[._]step\.[^.]+$/.test(path) && !/\.tsx$/.test(path) && !/\.step\.py$/.test(path);
|
|
135
135
|
}
|
|
136
136
|
isStreamFile(path) {
|
|
137
|
-
return /[._]stream\.[^.]+$/.test(path) && !/\.tsx$/.test(path);
|
|
137
|
+
return /[._]stream\.[^.]+$/.test(path) && !/\.tsx$/.test(path) && !/\.stream\.py$/.test(path);
|
|
138
138
|
}
|
|
139
139
|
async stop() {
|
|
140
140
|
if (this.watcher) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
3
|
"description": "A Modern Unified Backend Framework for APIs, Events and Agents",
|
|
4
|
-
"version": "0.6.4-beta.131-
|
|
4
|
+
"version": "0.6.4-beta.131-876960",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"python-ast": "^0.1.0",
|
|
47
47
|
"table": "^6.9.0",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
|
-
"@motiadev/
|
|
50
|
-
"@motiadev/
|
|
51
|
-
"@motiadev/workbench": "0.6.4-beta.131-
|
|
49
|
+
"@motiadev/stream-client-node": "0.6.4-beta.131-876960",
|
|
50
|
+
"@motiadev/core": "0.6.4-beta.131-876960",
|
|
51
|
+
"@motiadev/workbench": "0.6.4-beta.131-876960"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@amplitude/analytics-types": "^2.9.2",
|