@motiadev/core 0.5.2-beta.102-571342 → 0.5.2-beta.103
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/src/analytics/utils.js +5 -3
- package/dist/src/call-step-file.js +6 -1
- package/dist/src/helper/flows-helper.d.ts +0 -2
- package/dist/src/helper/flows-helper.js +3 -8
- package/dist/src/server.js +1 -2
- package/package.json +1 -2
- package/dist/src/step-endpoint.d.ts +0 -3
- package/dist/src/step-endpoint.js +0 -35
|
@@ -39,9 +39,11 @@ exports.isAnalyticsEnabled = isAnalyticsEnabled;
|
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
40
|
const trackEvent = (eventName, properties = {}) => {
|
|
41
41
|
try {
|
|
42
|
-
(0,
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if ((0, exports.isAnalyticsEnabled)()) {
|
|
43
|
+
(0, analytics_node_1.track)(eventName, properties, {
|
|
44
|
+
user_id: (0, exports.getUserIdentifier)() || 'unknown',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
47
49
|
// Silently fail to not disrupt dev server
|
|
@@ -45,7 +45,12 @@ const callStepFile = (options, motia) => {
|
|
|
45
45
|
logger,
|
|
46
46
|
context: 'StepExecution',
|
|
47
47
|
});
|
|
48
|
-
(0, utils_1.trackEvent)('step_execution_started', {
|
|
48
|
+
(0, utils_1.trackEvent)('step_execution_started', {
|
|
49
|
+
stepName: step.config.name,
|
|
50
|
+
language: command,
|
|
51
|
+
type: step.config.type,
|
|
52
|
+
streams: streams.length,
|
|
53
|
+
});
|
|
49
54
|
processManager
|
|
50
55
|
.spawn()
|
|
51
56
|
.then(() => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Step } from 'src/types';
|
|
2
2
|
import { FlowResponse } from '../types/flows-types';
|
|
3
|
-
export declare const STEP_NAMESPACE = "7f1c3ff2-9b00-4d0a-bdd7-efb8bca49d4f";
|
|
4
|
-
export declare const generateStepId: (filePath: string) => string;
|
|
5
3
|
export declare const generateFlow: (flowId: string, flowSteps: Step[]) => FlowResponse;
|
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateFlow =
|
|
6
|
+
exports.generateFlow = void 0;
|
|
7
7
|
const guards_1 = require("../guards");
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
8
9
|
const get_step_language_1 = require("../get-step-language");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
10
11
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const uuid_1 = require("uuid");
|
|
12
12
|
const getNodeComponentPath = (filePath) => {
|
|
13
13
|
const filePathWithoutExtension = filePath.replace(/\.[^/.]+$/, '');
|
|
14
14
|
const tsxPath = filePathWithoutExtension + '.tsx';
|
|
@@ -107,13 +107,8 @@ const createCronStepResponse = (step, id) => {
|
|
|
107
107
|
cronExpression: step.config.cron,
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
|
-
exports.STEP_NAMESPACE = '7f1c3ff2-9b00-4d0a-bdd7-efb8bca49d4f';
|
|
111
|
-
const generateStepId = (filePath) => {
|
|
112
|
-
return (0, uuid_1.v5)(filePath, exports.STEP_NAMESPACE);
|
|
113
|
-
};
|
|
114
|
-
exports.generateStepId = generateStepId;
|
|
115
110
|
const createStepResponse = (step) => {
|
|
116
|
-
const id = (0,
|
|
111
|
+
const id = (0, crypto_1.randomUUID)();
|
|
117
112
|
if ((0, guards_1.isApiStep)(step))
|
|
118
113
|
return createApiStepResponse(step, id);
|
|
119
114
|
if ((0, guards_1.isEventStep)(step))
|
package/dist/src/server.js
CHANGED
|
@@ -25,7 +25,6 @@ const api_endpoints_1 = require("./streams/api-endpoints");
|
|
|
25
25
|
const logs_stream_1 = require("./streams/logs-stream");
|
|
26
26
|
const logger_1 = require("./logger");
|
|
27
27
|
const printer_1 = require("./printer");
|
|
28
|
-
const step_endpoint_1 = require("./step-endpoint");
|
|
29
28
|
const createServer = (lockedData, eventManager, state, config) => {
|
|
30
29
|
const printer = config.printer ?? new printer_1.Printer(process.cwd());
|
|
31
30
|
const app = (0, express_1.default)();
|
|
@@ -129,6 +128,7 @@ const createServer = (lockedData, eventManager, state, config) => {
|
|
|
129
128
|
};
|
|
130
129
|
try {
|
|
131
130
|
const result = await (0, call_step_file_1.callStepFile)({ data, step, logger, tracer, traceId }, motia);
|
|
131
|
+
(0, utils_1.trackEvent)('api_call_success', { stepName });
|
|
132
132
|
if (!result) {
|
|
133
133
|
console.log('no result');
|
|
134
134
|
res.status(500).json({ error: 'Internal server error' });
|
|
@@ -194,7 +194,6 @@ const createServer = (lockedData, eventManager, state, config) => {
|
|
|
194
194
|
(0, flows_endpoint_1.flowsEndpoint)(lockedData);
|
|
195
195
|
(0, flows_config_endpoint_1.flowsConfigEndpoint)(app, process.cwd(), lockedData);
|
|
196
196
|
(0, analytics_endpoint_1.analyticsEndpoint)(app, process.cwd());
|
|
197
|
-
(0, step_endpoint_1.stepEndpoint)(app, lockedData);
|
|
198
197
|
server.on('error', (error) => {
|
|
199
198
|
console.error('Server error:', error);
|
|
200
199
|
});
|
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.2-beta.
|
|
5
|
+
"version": "0.5.2-beta.103",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"body-parser": "^1.20.3",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"node-cron": "^3.0.3",
|
|
15
15
|
"ts-node": "^10.9.2",
|
|
16
16
|
"tsconfig-paths": "^4.2.0",
|
|
17
|
-
"uuid": "^11.1.0",
|
|
18
17
|
"ws": "^8.18.2",
|
|
19
18
|
"zod": "^3.24.1",
|
|
20
19
|
"zod-to-json-schema": "^3.24.1"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.stepEndpoint = void 0;
|
|
7
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
-
const flows_helper_1 = require("./helper/flows-helper");
|
|
9
|
-
const stepEndpoint = (app, lockedData) => {
|
|
10
|
-
app.get('/step/:stepId', async (req, res) => {
|
|
11
|
-
const stepId = req.params.stepId;
|
|
12
|
-
const allSteps = [...lockedData.activeSteps, ...lockedData.devSteps];
|
|
13
|
-
const step = allSteps.find((step) => (0, flows_helper_1.generateStepId)(step.filePath) === stepId);
|
|
14
|
-
if (!step) {
|
|
15
|
-
res.status(404).send({
|
|
16
|
-
error: 'Step not found',
|
|
17
|
-
});
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const content = await promises_1.default.readFile(step.filePath, 'utf8');
|
|
22
|
-
res.status(200).send({
|
|
23
|
-
id: stepId,
|
|
24
|
-
content,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.error('Error reading step file:', error);
|
|
29
|
-
res.status(500).send({
|
|
30
|
-
error: 'Failed to read step file',
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
exports.stepEndpoint = stepEndpoint;
|