@motiadev/core 0.5.11-beta.120-433270 → 0.5.11-beta.120-110250
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StepConfig } from './types';
|
|
2
2
|
import { StreamConfig } from './types-stream';
|
|
3
|
-
export declare const getStepConfig: (
|
|
4
|
-
export declare const getStreamConfig: (
|
|
3
|
+
export declare const getStepConfig: (file: string) => Promise<StepConfig | null>;
|
|
4
|
+
export declare const getStreamConfig: (file: string) => Promise<StreamConfig | null>;
|
|
@@ -7,13 +7,13 @@ exports.getStreamConfig = exports.getStepConfig = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const logger_1 = require("./logger");
|
|
9
9
|
const process_manager_1 = require("./process-communication/process-manager");
|
|
10
|
-
const getLanguageBasedRunner = (
|
|
10
|
+
const getLanguageBasedRunner = (stepFilePath = '') => {
|
|
11
11
|
const isPython = stepFilePath.endsWith('.py');
|
|
12
12
|
const isRuby = stepFilePath.endsWith('.rb');
|
|
13
13
|
const isNode = stepFilePath.endsWith('.js') || stepFilePath.endsWith('.ts');
|
|
14
14
|
if (isPython) {
|
|
15
15
|
const pythonRunner = path_1.default.join(__dirname, 'python', 'get-config.py');
|
|
16
|
-
return { runner: pythonRunner, command: 'python', args: [
|
|
16
|
+
return { runner: pythonRunner, command: 'python', args: [] };
|
|
17
17
|
}
|
|
18
18
|
else if (isRuby) {
|
|
19
19
|
const rubyRunner = path_1.default.join(__dirname, 'ruby', 'get-config.rb');
|
|
@@ -29,13 +29,13 @@ const getLanguageBasedRunner = (baseDir, stepFilePath) => {
|
|
|
29
29
|
}
|
|
30
30
|
throw Error(`Unsupported file extension ${stepFilePath}`);
|
|
31
31
|
};
|
|
32
|
-
const getConfig = (
|
|
33
|
-
const { runner, command, args } = getLanguageBasedRunner(
|
|
32
|
+
const getConfig = (file) => {
|
|
33
|
+
const { runner, command, args } = getLanguageBasedRunner(file);
|
|
34
34
|
return new Promise((resolve, reject) => {
|
|
35
35
|
let config = null;
|
|
36
36
|
const processManager = new process_manager_1.ProcessManager({
|
|
37
37
|
command,
|
|
38
|
-
args: [
|
|
38
|
+
args: [...args, runner, file],
|
|
39
39
|
logger: logger_1.globalLogger,
|
|
40
40
|
context: 'Config',
|
|
41
41
|
});
|
|
@@ -78,11 +78,11 @@ const getConfig = (baseDir, file) => {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
const getStepConfig = (
|
|
82
|
-
return getConfig(
|
|
81
|
+
const getStepConfig = (file) => {
|
|
82
|
+
return getConfig(file);
|
|
83
83
|
};
|
|
84
84
|
exports.getStepConfig = getStepConfig;
|
|
85
|
-
const getStreamConfig = (
|
|
86
|
-
return getConfig(
|
|
85
|
+
const getStreamConfig = (file) => {
|
|
86
|
+
return getConfig(file);
|
|
87
87
|
};
|
|
88
88
|
exports.getStreamConfig = getStreamConfig;
|
|
@@ -19,13 +19,13 @@ def sendMessage(text):
|
|
|
19
19
|
NODEIPCFD = int(os.environ["NODE_CHANNEL_FD"])
|
|
20
20
|
os.write(NODEIPCFD, bytesMessage)
|
|
21
21
|
|
|
22
|
-
async def run_python_module(
|
|
22
|
+
async def run_python_module(file_path: str) -> None:
|
|
23
23
|
try:
|
|
24
|
-
module_dir = os.path.dirname(file_path)
|
|
24
|
+
module_dir = os.path.dirname(os.path.abspath(file_path))
|
|
25
25
|
|
|
26
|
-
if
|
|
27
|
-
sys.path.insert(0,
|
|
28
|
-
|
|
26
|
+
if module_dir not in sys.path:
|
|
27
|
+
sys.path.insert(0, module_dir)
|
|
28
|
+
|
|
29
29
|
flows_dir = os.path.dirname(module_dir)
|
|
30
30
|
if flows_dir not in sys.path:
|
|
31
31
|
sys.path.insert(0, flows_dir)
|
|
@@ -51,11 +51,10 @@ async def run_python_module(project_path: str, file_path: str) -> None:
|
|
|
51
51
|
sys.exit(1)
|
|
52
52
|
|
|
53
53
|
if __name__ == "__main__":
|
|
54
|
-
if len(sys.argv) <
|
|
54
|
+
if len(sys.argv) < 2:
|
|
55
55
|
sys.exit(1)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
file_path = sys.argv[2]
|
|
57
|
+
file_path = sys.argv[1]
|
|
59
58
|
|
|
60
59
|
import asyncio
|
|
61
|
-
asyncio.run(run_python_module(
|
|
60
|
+
asyncio.run(run_python_module(file_path))
|
|
@@ -6,23 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.stepEndpoint = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
8
|
const flows_helper_1 = require("./helper/flows-helper");
|
|
9
|
+
const getFeatures = async (filePath) => {
|
|
10
|
+
const stat = await promises_1.default.stat(filePath + '-features.json').catch(() => null);
|
|
11
|
+
if (!stat || stat.isDirectory()) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const content = await promises_1.default.readFile(filePath + '-features.json', 'utf8');
|
|
16
|
+
return JSON.parse(content);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
9
22
|
const stepEndpoint = (app, lockedData) => {
|
|
10
23
|
app.get('/step/:stepId', async (req, res) => {
|
|
11
|
-
const
|
|
24
|
+
const id = req.params.stepId;
|
|
12
25
|
const allSteps = [...lockedData.activeSteps, ...lockedData.devSteps];
|
|
13
|
-
const step = allSteps.find((step) => (0, flows_helper_1.generateStepId)(step.filePath) ===
|
|
26
|
+
const step = allSteps.find((step) => (0, flows_helper_1.generateStepId)(step.filePath) === id);
|
|
14
27
|
if (!step) {
|
|
15
|
-
res.status(404).send({
|
|
16
|
-
error: 'Step not found',
|
|
17
|
-
});
|
|
28
|
+
res.status(404).send({ error: 'Step not found' });
|
|
18
29
|
return;
|
|
19
30
|
}
|
|
20
31
|
try {
|
|
21
32
|
const content = await promises_1.default.readFile(step.filePath, 'utf8');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
content,
|
|
25
|
-
});
|
|
33
|
+
const features = await getFeatures(step.filePath);
|
|
34
|
+
res.status(200).send({ id, content, features });
|
|
26
35
|
}
|
|
27
36
|
catch (error) {
|
|
28
37
|
console.error('Error reading step file:', error);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.5.11-beta.120-
|
|
5
|
+
"version": "0.5.11-beta.120-110250",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"body-parser": "^1.20.3",
|