motia 0.5.11-beta.120-382150 → 0.5.11-beta.120-391598

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.
@@ -68,7 +68,10 @@ class NodeBuilder {
68
68
  async buildApiSteps(steps) {
69
69
  const relativePath = path_1.default.relative(constants_1.distDir, this.builder.projectDir);
70
70
  const getStepPath = (step) => {
71
- return step.filePath.replace(this.builder.projectDir, relativePath).replace(/(.*)\.(ts|js)$/, '$1.js');
71
+ return step.filePath
72
+ .replace(this.builder.projectDir, relativePath)
73
+ .replace(/(.*)\.(ts|js)$/, '$1.js')
74
+ .replace(/\\/g, '/');
72
75
  };
73
76
  const file = fs_1.default
74
77
  .readFileSync(path_1.default.join(__dirname, 'router-template.ts'), 'utf-8')
@@ -74,6 +74,7 @@ class PythonBuilder {
74
74
  return normalizedEntrypointPath
75
75
  .replace(`${this.builder.projectDir}/`, '')
76
76
  .replace(/(.*)\.py$/, '$1')
77
+ .replace(/\\/g, '.')
77
78
  .replace(/\//g, '.');
78
79
  };
79
80
  const zipName = 'router-python.zip';
@@ -8,6 +8,7 @@ const build_1 = require("./new-deployment/build");
8
8
  const upload_artifacts_1 = require("./new-deployment/upload-artifacts");
9
9
  const deployment_stream_1 = require("./new-deployment/streams/deployment-stream");
10
10
  const cloud_api_1 = require("./new-deployment/cloud-api");
11
+ const version_1 = require("../version");
11
12
  const deployEndpoints = (server, lockedData) => {
12
13
  const { app } = server;
13
14
  // Criar stream de deployment se não existir
@@ -21,16 +22,20 @@ const deployEndpoints = (server, lockedData) => {
21
22
  },
22
23
  })();
23
24
  const deploymentManager = new deployment_stream_1.DeploymentStreamManager(deploymentStream);
24
- app.post('/cloud/deploy/start', async (req, res) => {
25
+ app.get('/__motia', (_, res) => {
26
+ res.status(200).json({ version: version_1.version });
27
+ });
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ app.post('/__motia/cloud/deploy/start', async (req, res) => {
25
30
  try {
26
31
  const { deploymentToken, deploymentId, envs } = req.body;
32
+ const sessionId = deploymentId || (0, crypto_1.randomUUID)();
27
33
  if (!deploymentToken || !deploymentId) {
28
34
  return res.status(400).json({
29
35
  success: false,
30
36
  error: 'deploymentToken and deploymentId are required',
31
37
  });
32
38
  }
33
- const sessionId = deploymentId || (0, crypto_1.randomUUID)();
34
39
  await deploymentManager.startDeployment(sessionId);
35
40
  const listener = new streaming_deployment_listener_1.StreamingDeploymentListener(sessionId, deploymentStream);
36
41
  res.json({
@@ -44,16 +49,16 @@ const deployEndpoints = (server, lockedData) => {
44
49
  setImmediate(async () => {
45
50
  try {
46
51
  await listener.startBuildPhase();
47
- const builder = await (0, build_1.build)(listener);
52
+ const builder = await (0, build_1.build)(listener).catch(() => {
53
+ throw new Error('Build failed, check the logs for more information');
54
+ });
48
55
  const isValid = (0, build_validation_1.buildValidation)(builder, listener);
49
56
  if (!isValid) {
50
57
  await listener.onBuildErrors(listener.getErrors());
51
58
  return;
52
59
  }
53
- await listener.completeBuildPhase();
54
60
  await listener.startUploadPhase();
55
61
  await (0, upload_artifacts_1.uploadArtifacts)(builder, deploymentToken, listener);
56
- await listener.completeUploadPhase();
57
62
  await listener.startDeployPhase();
58
63
  await cloud_api_1.cloudApi.startDeployment({
59
64
  deploymentToken,
@@ -62,6 +67,7 @@ const deployEndpoints = (server, lockedData) => {
62
67
  streams: builder.streamsConfig,
63
68
  routers: builder.routersConfig,
64
69
  });
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
71
  }
66
72
  catch (error) {
67
73
  console.error('Deployment failed:', error);
@@ -71,36 +77,25 @@ const deployEndpoints = (server, lockedData) => {
71
77
  }
72
78
  }
73
79
  });
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
81
  }
75
82
  catch (error) {
76
83
  console.error('Failed to start deployment:', error);
77
- res.status(500).json({
78
- success: false,
79
- error: error.message,
80
- });
84
+ res.status(500).json({ success: false, error: error.message });
81
85
  }
82
86
  });
83
- // Get deployment status by ID
84
- app.get('/cloud/deploy/status/:deploymentId', async (req, res) => {
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
+ app.get('/__motia/cloud/deploy/status/:deploymentId', async (req, res) => {
85
89
  try {
86
90
  const { deploymentId } = req.params;
87
91
  const deployment = await deploymentManager.getDeployment(deploymentId);
88
- if (!deployment) {
89
- return res.status(404).json({
90
- success: false,
91
- error: 'Deployment not found',
92
- });
93
- }
94
- res.json({
95
- success: true,
96
- deployment,
97
- });
92
+ return deployment
93
+ ? res.status(200).json({ success: true, deployment })
94
+ : res.status(404).json({ success: false, error: 'Deployment not found' });
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
96
  }
99
97
  catch (error) {
100
- res.status(500).json({
101
- success: false,
102
- error: error.message,
103
- });
98
+ res.status(500).json({ success: false, error: error.message });
104
99
  }
105
100
  });
106
101
  };
@@ -10,36 +10,35 @@ export declare class StreamingDeploymentListener implements DeploymentListener {
10
10
  private warnings;
11
11
  private streamManager;
12
12
  constructor(deploymentId: string, deploymentStream: MotiaStream<DeploymentData>);
13
+ private relativePath;
13
14
  private getStepType;
14
15
  private getLanguage;
15
16
  private updateStream;
16
17
  getErrors(): ValidationError[];
17
- onBuildStart(step: Step): void;
18
- onBuildProgress(step: Step, message: string): void;
19
- onBuildEnd(step: Step, size: number): void;
20
- onBuildError(step: Step, error: Error): void;
21
- onBuildSkip(step: Step, reason: string): void;
22
- onStreamCreated(stream: Stream): void;
23
- onApiRouterBuilding(language: string): void;
24
- onApiRouterBuilt(language: string, size: number): void;
25
- onWarning(id: string, warning: string): void;
18
+ onBuildStart(step: Step): Promise<void>;
19
+ onBuildProgress(step: Step, message: string): Promise<void>;
20
+ onBuildEnd(step: Step, size: number): Promise<void>;
21
+ onBuildError(step: Step, error: Error): Promise<void>;
22
+ onBuildSkip(step: Step, reason: string): Promise<void>;
23
+ onStreamCreated(stream: Stream): Promise<void>;
24
+ onApiRouterBuilding(language: string): Promise<void>;
25
+ onApiRouterBuilt(language: string, size: number): Promise<void>;
26
+ onWarning(id: string, warning: string): Promise<void>;
26
27
  onBuildWarning(warning: ValidationError): Promise<void>;
27
28
  onBuildErrors(errors: ValidationError[]): Promise<void>;
28
- stepUploadStart(stepPath: string, step: BuildStepConfig): void;
29
- stepUploadProgress(stepPath: string, step: BuildStepConfig, progress: number): void;
30
- stepUploadEnd(stepPath: string, step: BuildStepConfig): void;
31
- stepUploadError(stepPath: string, step: BuildStepConfig): void;
32
- routeUploadStart(path: string, language: string): void;
33
- routeUploadProgress(path: string, language: string, progress: number): void;
34
- routeUploadEnd(path: string, language: string): void;
35
- routeUploadError(path: string, language: string): void;
36
- onDeployStart(): void;
37
- onDeployProgress(data: DeployData): void;
29
+ stepUploadStart(stepPath: string, step: BuildStepConfig): Promise<void>;
30
+ stepUploadProgress(stepPath: string, step: BuildStepConfig, progress: number): Promise<void>;
31
+ stepUploadEnd(stepPath: string, step: BuildStepConfig): Promise<void>;
32
+ stepUploadError(stepPath: string, step: BuildStepConfig): Promise<void>;
33
+ routeUploadStart(path: string, language: string): Promise<void>;
34
+ routeUploadProgress(path: string, language: string, progress: number): Promise<void>;
35
+ routeUploadEnd(path: string, language: string): Promise<void>;
36
+ routeUploadError(path: string, language: string): Promise<void>;
37
+ onDeployStart(): Promise<void>;
38
+ onDeployProgress(data: DeployData): Promise<void>;
38
39
  onDeployEnd(): Promise<void>;
39
40
  onDeployError(errorMessage: string): Promise<void>;
40
41
  startBuildPhase(): Promise<void>;
41
- completeBuildPhase(): Promise<void>;
42
42
  startUploadPhase(): Promise<void>;
43
- completeUploadPhase(): Promise<void>;
44
43
  startDeployPhase(): Promise<void>;
45
44
  }
@@ -9,6 +9,9 @@ class StreamingDeploymentListener {
9
9
  this.warnings = [];
10
10
  this.streamManager = new deployment_stream_1.DeploymentStreamManager(deploymentStream);
11
11
  }
12
+ relativePath(path) {
13
+ return path.replace(`${process.cwd()}/`, '');
14
+ }
12
15
  getStepType(step) {
13
16
  if (step.config.type === 'api')
14
17
  return 'api';
@@ -39,104 +42,83 @@ class StreamingDeploymentListener {
39
42
  return this.errors;
40
43
  }
41
44
  // Build phase events
42
- onBuildStart(step) {
45
+ async onBuildStart(step) {
43
46
  const message = `Building step: ${step.config.name}`;
44
47
  const buildOutput = {
45
- packagePath: step.filePath,
48
+ packagePath: this.relativePath(step.filePath),
46
49
  language: this.getLanguage(step.filePath),
47
50
  status: 'building',
48
51
  type: this.getStepType(step),
49
52
  };
50
- this.updateStream({
53
+ await this.updateStream({
51
54
  phase: 'build',
52
55
  status: 'building',
53
56
  message,
54
- progress: 0,
55
57
  });
56
- this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
58
+ await this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
57
59
  }
58
- onBuildProgress(step, message) {
60
+ async onBuildProgress(step, message) {
59
61
  const logMessage = `${step.config.name}: ${message}`;
60
- this.updateStream({
61
- message: logMessage,
62
- progress: 25,
63
- });
62
+ await this.updateStream({ message: logMessage });
64
63
  }
65
- onBuildEnd(step, size) {
64
+ async onBuildEnd(step, size) {
66
65
  const message = `Built ${step.config.name} (${size} bytes)`;
67
66
  const buildOutput = {
68
- packagePath: step.filePath,
67
+ packagePath: this.relativePath(step.filePath),
69
68
  language: this.getLanguage(step.filePath),
70
69
  status: 'built',
71
70
  type: this.getStepType(step),
72
71
  size,
73
72
  };
74
- this.updateStream({
75
- message,
76
- progress: 50,
77
- });
78
- this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
73
+ await this.updateStream({ message });
74
+ await this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
79
75
  }
80
- onBuildError(step, error) {
76
+ async onBuildError(step, error) {
81
77
  const message = `Error building ${step.config.name}: ${error.message}`;
82
78
  const buildOutput = {
83
- packagePath: step.filePath,
79
+ packagePath: this.relativePath(step.filePath),
84
80
  language: this.getLanguage(step.filePath),
85
81
  status: 'error',
86
82
  type: this.getStepType(step),
87
83
  errorMessage: error.message,
88
84
  };
89
- this.updateStream({
85
+ await this.updateStream({
90
86
  status: 'failed',
91
87
  message,
92
88
  error: error.message,
93
89
  });
94
- this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
90
+ await this.streamManager.updateBuildOutput(this.deploymentId, buildOutput);
95
91
  }
96
- onBuildSkip(step, reason) {
92
+ async onBuildSkip(step, reason) {
97
93
  const message = `Skipped ${step.config.name}: ${reason}`;
98
- this.updateStream({
99
- message,
100
- progress: 10,
101
- });
94
+ await this.updateStream({ message });
102
95
  }
103
- onStreamCreated(stream) {
96
+ async onStreamCreated(stream) {
104
97
  const message = `Created stream: ${stream.config.name}`;
105
- this.updateStream({
106
- message,
107
- progress: 20,
108
- });
98
+ await this.updateStream({ message });
109
99
  }
110
- onApiRouterBuilding(language) {
100
+ async onApiRouterBuilding(language) {
111
101
  const message = `Building API router for ${language}`;
112
- this.updateStream({
113
- message,
114
- progress: 60,
115
- });
102
+ await this.updateStream({ message });
116
103
  }
117
- onApiRouterBuilt(language, size) {
104
+ async onApiRouterBuilt(language, size) {
118
105
  const message = `Built API router for ${language} (${size} bytes)`;
119
- this.updateStream({
120
- message,
121
- progress: 80,
122
- });
106
+ await this.updateStream({ message });
123
107
  }
124
- onWarning(id, warning) {
108
+ async onWarning(id, warning) {
125
109
  this.warnings.push({
126
110
  relativePath: id,
127
111
  message: warning,
128
112
  step: {},
129
113
  });
130
- this.updateStream({
114
+ await this.updateStream({
131
115
  message: `Warning: ${warning}`,
132
- progress: 10,
133
116
  });
134
117
  }
135
118
  async onBuildWarning(warning) {
136
119
  this.warnings.push(warning);
137
120
  await this.updateStream({
138
121
  message: `Build warning: ${warning.message}`,
139
- progress: 10,
140
122
  });
141
123
  }
142
124
  async onBuildErrors(errors) {
@@ -145,28 +127,27 @@ class StreamingDeploymentListener {
145
127
  await this.updateStream({
146
128
  status: 'failed',
147
129
  message: errorMessage,
148
- error: errorMessage,
130
+ error: errors.map((error) => error.message).join('\n'),
149
131
  });
150
132
  }
151
133
  // Upload phase events
152
- stepUploadStart(stepPath, step) {
134
+ async stepUploadStart(stepPath, step) {
153
135
  const message = `Starting upload: ${step.config.name}`;
154
136
  const uploadOutput = {
155
- packagePath: stepPath,
137
+ packagePath: this.relativePath(stepPath),
156
138
  language: this.getLanguage(step.filePath),
157
139
  status: 'uploading',
158
140
  type: step.config.type,
159
141
  progress: 0,
160
142
  };
161
- this.updateStream({
143
+ await this.updateStream({
162
144
  phase: 'upload',
163
145
  status: 'uploading',
164
146
  message,
165
147
  });
166
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
148
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
167
149
  }
168
- stepUploadProgress(stepPath, step, progress) {
169
- const message = `Uploading ${step.config.name}: ${progress}%`;
150
+ async stepUploadProgress(stepPath, step, progress) {
170
151
  const uploadOutput = {
171
152
  packagePath: stepPath,
172
153
  language: this.getLanguage(step.filePath),
@@ -174,125 +155,102 @@ class StreamingDeploymentListener {
174
155
  type: step.config.type,
175
156
  progress,
176
157
  };
177
- this.updateStream({
178
- message,
179
- progress,
180
- });
181
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
158
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
182
159
  }
183
- stepUploadEnd(stepPath, step) {
184
- const message = `Uploaded: ${step.config.name}`;
160
+ async stepUploadEnd(stepPath, step) {
185
161
  const uploadOutput = {
186
- packagePath: stepPath,
162
+ packagePath: this.relativePath(stepPath),
187
163
  language: this.getLanguage(step.filePath),
188
164
  status: 'uploaded',
189
165
  type: step.config.type,
190
166
  progress: 100,
191
167
  };
192
- this.updateStream({
193
- message,
194
- progress: 100,
195
- });
196
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
168
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
197
169
  }
198
- stepUploadError(stepPath, step) {
170
+ async stepUploadError(stepPath, step) {
199
171
  const message = `Upload failed: ${step.config.name}`;
200
172
  const uploadOutput = {
201
- packagePath: stepPath,
173
+ packagePath: this.relativePath(stepPath),
202
174
  language: this.getLanguage(step.filePath),
203
175
  status: 'error',
204
176
  type: step.config.type,
205
177
  errorMessage: message,
206
178
  };
207
- this.updateStream({
179
+ await this.updateStream({
208
180
  status: 'failed',
209
181
  message,
210
182
  error: message,
211
183
  });
212
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
184
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
213
185
  }
214
- routeUploadStart(path, language) {
215
- const message = `Starting upload: ${language} router`;
186
+ async routeUploadStart(path, language) {
216
187
  const uploadOutput = {
217
- packagePath: path,
188
+ packagePath: this.relativePath(path),
218
189
  language,
219
190
  status: 'uploading',
220
191
  type: 'api',
221
192
  progress: 0,
222
193
  };
223
- this.updateStream({
224
- message,
225
- progress: 50,
226
- });
227
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
194
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
228
195
  }
229
- routeUploadProgress(path, language, progress) {
230
- const message = `Uploading ${language} router: ${progress}%`;
196
+ async routeUploadProgress(path, language, progress) {
231
197
  const uploadOutput = {
232
- packagePath: path,
198
+ packagePath: this.relativePath(path),
233
199
  language,
234
200
  status: 'uploading',
235
201
  type: 'api',
236
202
  progress,
237
203
  };
238
- this.updateStream({
239
- message,
240
- progress,
241
- });
242
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
204
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
243
205
  }
244
- routeUploadEnd(path, language) {
206
+ async routeUploadEnd(path, language) {
245
207
  const message = `Uploaded: ${language} router`;
246
208
  const uploadOutput = {
247
- packagePath: path,
209
+ packagePath: this.relativePath(path),
248
210
  language,
249
211
  status: 'uploaded',
250
212
  type: 'api',
251
213
  progress: 100,
252
214
  };
253
- this.updateStream({
254
- message,
255
- progress: 100,
256
- });
257
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
215
+ await this.updateStream({ message });
216
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
258
217
  }
259
- routeUploadError(path, language) {
218
+ async routeUploadError(path, language) {
260
219
  const message = `Upload failed: ${language} router`;
261
220
  const uploadOutput = {
262
- packagePath: path,
221
+ packagePath: this.relativePath(path),
263
222
  language,
264
223
  status: 'error',
265
224
  type: 'api',
266
225
  errorMessage: message,
267
226
  };
268
- this.updateStream({
227
+ await this.updateStream({
269
228
  status: 'failed',
270
229
  message,
271
230
  error: message,
272
231
  });
273
- this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
232
+ await this.streamManager.updateUploadOutput(this.deploymentId, uploadOutput);
274
233
  }
275
234
  // Deploy phase events
276
- onDeployStart() {
235
+ async onDeployStart() {
277
236
  const message = 'Deployment started';
278
- this.updateStream({
237
+ await this.updateStream({
279
238
  phase: 'deploy',
280
239
  status: 'deploying',
281
240
  message,
282
241
  });
283
242
  }
284
- onDeployProgress(data) {
243
+ async onDeployProgress(data) {
285
244
  const message = `Deployment status: ${data.status}`;
286
- this.updateStream({
245
+ await this.updateStream({
287
246
  message,
288
- progress: 50,
289
247
  });
290
248
  }
291
249
  async onDeployEnd() {
292
- await this.streamManager.completeDeployment(this.deploymentId, true);
250
+ await this.streamManager.completeDeployment(this.deploymentId);
293
251
  }
294
252
  async onDeployError(errorMessage) {
295
- await this.streamManager.completeDeployment(this.deploymentId, false, errorMessage);
253
+ await this.streamManager.completeDeployment(this.deploymentId, errorMessage);
296
254
  }
297
255
  // Utility methods for phase management
298
256
  async startBuildPhase() {
@@ -302,24 +260,11 @@ class StreamingDeploymentListener {
302
260
  message: 'Build phase started',
303
261
  });
304
262
  }
305
- async completeBuildPhase() {
306
- await this.updateStream({
307
- message: 'Build phase completed',
308
- progress: 100,
309
- });
310
- }
311
263
  async startUploadPhase() {
312
264
  await this.updateStream({
313
265
  phase: 'upload',
314
266
  status: 'uploading',
315
267
  message: 'Upload phase started',
316
- progress: 0,
317
- });
318
- }
319
- async completeUploadPhase() {
320
- await this.updateStream({
321
- message: 'Upload phase completed',
322
- progress: 100,
323
268
  });
324
269
  }
325
270
  async startDeployPhase() {
@@ -327,7 +272,6 @@ class StreamingDeploymentListener {
327
272
  phase: 'deploy',
328
273
  status: 'deploying',
329
274
  message: 'Deploy phase started',
330
- progress: 0,
331
275
  });
332
276
  }
333
277
  }
@@ -16,22 +16,22 @@ export type UploadOutput = {
16
16
  type: 'event' | 'api' | 'cron';
17
17
  errorMessage?: string;
18
18
  };
19
+ export type Metadata = {
20
+ totalSteps?: number;
21
+ builtSteps?: number;
22
+ uploadedSteps?: number;
23
+ };
19
24
  export interface DeploymentData {
20
25
  id: string;
21
26
  status: 'idle' | 'building' | 'uploading' | 'deploying' | 'completed' | 'failed';
22
27
  phase: 'build' | 'upload' | 'deploy' | null;
23
- progress: number;
24
28
  message: string;
25
29
  build: BuildOutput[];
26
30
  upload: UploadOutput[];
27
31
  error?: string;
28
32
  startedAt?: number;
29
33
  completedAt?: number;
30
- metadata?: {
31
- totalSteps: number;
32
- uploadedSteps?: number;
33
- buildedSteps?: number;
34
- };
34
+ metadata?: Metadata;
35
35
  }
36
36
  export declare const createDefaultDeploymentData: (deploymentId: string) => DeploymentData;
37
37
  export declare class DeploymentStreamManager {
@@ -40,7 +40,7 @@ export declare class DeploymentStreamManager {
40
40
  getDeployment(deploymentId: string): Promise<DeploymentData | null>;
41
41
  updateDeployment(deploymentId: string, data: Partial<DeploymentData>): Promise<void>;
42
42
  startDeployment(deploymentId: string): Promise<void>;
43
- completeDeployment(deploymentId: string, success: boolean, error?: string): Promise<void>;
43
+ completeDeployment(deploymentId: string, error?: string): Promise<void>;
44
44
  updateBuildOutput(deploymentId: string, buildOutput: BuildOutput): Promise<void>;
45
45
  updateUploadOutput(deploymentId: string, uploadOutput: UploadOutput): Promise<void>;
46
46
  }
@@ -5,12 +5,13 @@ const createDefaultDeploymentData = (deploymentId) => ({
5
5
  id: deploymentId,
6
6
  status: 'idle',
7
7
  phase: null,
8
- progress: 0,
9
8
  message: 'No deployment in progress',
10
9
  build: [],
11
10
  upload: [],
12
11
  metadata: {
13
12
  totalSteps: 0,
13
+ builtSteps: 0,
14
+ uploadedSteps: 0,
14
15
  },
15
16
  });
16
17
  exports.createDefaultDeploymentData = createDefaultDeploymentData;
@@ -51,16 +52,15 @@ class DeploymentStreamManager {
51
52
  message: 'Starting deployment...',
52
53
  });
53
54
  }
54
- async completeDeployment(deploymentId, success, error) {
55
+ async completeDeployment(deploymentId, error) {
55
56
  const current = await this.getDeployment(deploymentId);
56
57
  if (!current)
57
58
  return;
58
59
  await this.stream.set(deploymentId, 'data', {
59
60
  ...current,
60
- status: success ? 'completed' : 'failed',
61
- phase: null,
62
- progress: 100,
63
- message: success ? 'Deployment completed successfully' : `Deployment failed: ${error}`,
61
+ status: error ? 'failed' : 'completed',
62
+ phase: error ? current.phase : null,
63
+ message: error || 'Deployment completed successfully',
64
64
  completedAt: Date.now(),
65
65
  error,
66
66
  });
@@ -77,12 +77,10 @@ class DeploymentStreamManager {
77
77
  else {
78
78
  updatedBuild.push(buildOutput);
79
79
  }
80
- // Update buildedSteps count
81
- const buildedSteps = updatedBuild.filter(b => b.status === 'built').length;
80
+ const builtSteps = updatedBuild.filter((b) => b.status === 'built').length;
82
81
  const metadata = {
83
82
  ...current.metadata,
84
- buildedSteps,
85
- totalSteps: current.metadata?.totalSteps || updatedBuild.length,
83
+ builtSteps,
86
84
  };
87
85
  await this.updateDeployment(deploymentId, { build: updatedBuild, metadata });
88
86
  }
@@ -99,11 +97,10 @@ class DeploymentStreamManager {
99
97
  updatedUpload.push(uploadOutput);
100
98
  }
101
99
  // Update uploadedSteps count
102
- const uploadedSteps = updatedUpload.filter(u => u.status === 'uploaded').length;
100
+ const uploadedSteps = updatedUpload.filter((u) => u.status === 'uploaded').length;
103
101
  const metadata = {
104
102
  ...current.metadata,
105
103
  uploadedSteps,
106
- totalSteps: current.metadata?.totalSteps || updatedUpload.length,
107
104
  };
108
105
  await this.updateDeployment(deploymentId, { upload: updatedUpload, metadata });
109
106
  }
package/dist/cjs/dev.js CHANGED
@@ -75,7 +75,7 @@ const dev = async (port, hostname, disableVerbose, enableMermaid) => {
75
75
  require('@motiadev/workbench/middleware')
76
76
  : // eslint-disable-next-line @typescript-eslint/no-require-imports
77
77
  require('@motiadev/workbench/dist/middleware');
78
- await applyMiddleware(motiaServer.app);
78
+ await applyMiddleware(motiaServer.app, port);
79
79
  // 6) Gracefully shut down on SIGTERM
80
80
  process.on('SIGTERM', async () => {
81
81
  (0, core_1.trackEvent)('dev_server_shutdown', { reason: 'SIGTERM' });
@@ -29,7 +29,10 @@ export class NodeBuilder {
29
29
  async buildApiSteps(steps) {
30
30
  const relativePath = path.relative(distDir, this.builder.projectDir);
31
31
  const getStepPath = (step) => {
32
- return step.filePath.replace(this.builder.projectDir, relativePath).replace(/(.*)\.(ts|js)$/, '$1.js');
32
+ return step.filePath
33
+ .replace(this.builder.projectDir, relativePath)
34
+ .replace(/(.*)\.(ts|js)$/, '$1.js')
35
+ .replace(/\\/g, '/');
33
36
  };
34
37
  const file = fs
35
38
  .readFileSync(path.join(__dirname, 'router-template.ts'), 'utf-8')