@motiadev/core 0.5.2-beta.103 → 0.5.2-beta.104-780167

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,3 +1,5 @@
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;
3
5
  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 = void 0;
6
+ exports.generateFlow = exports.generateStepId = exports.STEP_NAMESPACE = void 0;
7
7
  const guards_1 = require("../guards");
8
- const crypto_1 = require("crypto");
9
8
  const get_step_language_1 = require("../get-step-language");
10
9
  const path_1 = __importDefault(require("path"));
11
10
  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,8 +107,13 @@ 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;
110
115
  const createStepResponse = (step) => {
111
- const id = (0, crypto_1.randomUUID)();
116
+ const id = (0, exports.generateStepId)(step.filePath);
112
117
  if ((0, guards_1.isApiStep)(step))
113
118
  return createApiStepResponse(step, id);
114
119
  if ((0, guards_1.isEventStep)(step))
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTrace = void 0;
4
+ const crypto_1 = require("crypto");
4
5
  const createTrace = (traceGroup, step) => {
5
- const id = crypto.randomUUID();
6
+ const id = (0, crypto_1.randomUUID)();
6
7
  const trace = {
7
8
  id,
8
9
  name: step.config.name,
@@ -25,6 +25,7 @@ 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");
28
29
  const createServer = (lockedData, eventManager, state, config) => {
29
30
  const printer = config.printer ?? new printer_1.Printer(process.cwd());
30
31
  const app = (0, express_1.default)();
@@ -194,6 +195,7 @@ const createServer = (lockedData, eventManager, state, config) => {
194
195
  (0, flows_endpoint_1.flowsEndpoint)(lockedData);
195
196
  (0, flows_config_endpoint_1.flowsConfigEndpoint)(app, process.cwd(), lockedData);
196
197
  (0, analytics_endpoint_1.analyticsEndpoint)(app, process.cwd());
198
+ (0, step_endpoint_1.stepEndpoint)(app, lockedData);
197
199
  server.on('error', (error) => {
198
200
  console.error('Server error:', error);
199
201
  });
@@ -0,0 +1,3 @@
1
+ import { LockedData } from './locked-data';
2
+ import { Express } from 'express';
3
+ export declare const stepEndpoint: (app: Express, lockedData: LockedData) => void;
@@ -0,0 +1,35 @@
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;
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.103",
5
+ "version": "0.5.2-beta.104-780167",
6
6
  "dependencies": {
7
7
  "@amplitude/analytics-node": "^1.3.8",
8
8
  "body-parser": "^1.20.3",
@@ -14,6 +14,7 @@
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",
17
18
  "ws": "^8.18.2",
18
19
  "zod": "^3.24.1",
19
20
  "zod-to-json-schema": "^3.24.1"