motia 0.4.2-beta.95 → 0.4.4-beta.97

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.
Files changed (28) hide show
  1. package/dist/cjs/cloud/api/clients/versions-client.d.ts +2 -2
  2. package/dist/cjs/cloud/api/clients/versions-client.js +3 -4
  3. package/dist/cjs/cloud/deploy/deploy.js +3 -4
  4. package/dist/cjs/cloud/deploy/printer.d.ts +12 -0
  5. package/dist/cjs/cloud/deploy/printer.js +72 -0
  6. package/dist/cjs/cloud/deploy/services/version-service.d.ts +3 -3
  7. package/dist/cjs/cloud/deploy/services/version-service.js +18 -23
  8. package/dist/cjs/cloud/deploy/types.d.ts +0 -5
  9. package/dist/cjs/dev/state-endpoints.js +11 -0
  10. package/dist/esm/cloud/api/clients/versions-client.d.ts +2 -2
  11. package/dist/esm/cloud/api/clients/versions-client.js +3 -4
  12. package/dist/esm/cloud/deploy/deploy.js +3 -4
  13. package/dist/esm/cloud/deploy/printer.d.ts +12 -0
  14. package/dist/esm/cloud/deploy/printer.js +65 -0
  15. package/dist/esm/cloud/deploy/services/version-service.d.ts +3 -3
  16. package/dist/esm/cloud/deploy/services/version-service.js +18 -23
  17. package/dist/esm/cloud/deploy/types.d.ts +0 -5
  18. package/dist/esm/dev/state-endpoints.js +11 -0
  19. package/dist/types/cloud/api/clients/versions-client.d.ts +2 -2
  20. package/dist/types/cloud/deploy/printer.d.ts +12 -0
  21. package/dist/types/cloud/deploy/services/version-service.d.ts +3 -3
  22. package/dist/types/cloud/deploy/types.d.ts +0 -5
  23. package/package.json +3 -3
  24. package/dist/cjs/cloud/deploy/file-manager.d.ts +0 -9
  25. package/dist/cjs/cloud/deploy/file-manager.js +0 -23
  26. package/dist/esm/cloud/deploy/file-manager.d.ts +0 -9
  27. package/dist/esm/cloud/deploy/file-manager.js +0 -19
  28. package/dist/types/cloud/deploy/file-manager.d.ts +0 -9
@@ -3,8 +3,8 @@ import { Version } from '../models/entities/version';
3
3
  import { VersionStartResponse } from '../models/responses/version-responses';
4
4
  import { BuildStreamsConfig, BuildStepsConfig } from '../../build/builder';
5
5
  export declare class VersionsClient extends AxiosClient {
6
- uploadStepsConfig(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
- uploadZipFile(zipPath: string, versionId: string): Promise<string>;
6
+ uploadStepsConfig(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
+ uploadZipFile(zipPath: string, versionId: string, fileName: string): Promise<string>;
8
8
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
9
9
  promoteVersion(environmentId: string, version: string): Promise<void>;
10
10
  getVersion(versionId: string): Promise<Version>;
@@ -12,12 +12,12 @@ const api_constants_1 = require("../core/api-constants");
12
12
  const api_base_1 = require("../core/api-base");
13
13
  const version_errors_1 = require("../models/errors/version-errors");
14
14
  class VersionsClient extends axios_client_1.AxiosClient {
15
- async uploadStepsConfig(environmentId, version, stepsConfig, streamsConfig) {
15
+ async uploadStepsConfig(environmentId, motiaVersion, version, stepsConfig, streamsConfig) {
16
16
  if (!stepsConfig || Object.keys(stepsConfig).length === 0) {
17
17
  throw new version_errors_1.InvalidConfigError();
18
18
  }
19
19
  try {
20
- const response = await this.makeRequest(`${api_constants_1.ENDPOINTS.ENVIRONMENTS}/${environmentId}/versions`, 'POST', { config: stepsConfig, version, streamsConfig });
20
+ const response = await this.makeRequest(`${api_constants_1.ENDPOINTS.ENVIRONMENTS}/${environmentId}/versions`, 'POST', { config: stepsConfig, version, streamsConfig, motiaVersion });
21
21
  return response.versionId;
22
22
  }
23
23
  catch (error) {
@@ -27,11 +27,10 @@ class VersionsClient extends axios_client_1.AxiosClient {
27
27
  throw error;
28
28
  }
29
29
  }
30
- async uploadZipFile(zipPath, versionId) {
30
+ async uploadZipFile(zipPath, versionId, fileName) {
31
31
  if (!fs_1.default.existsSync(zipPath)) {
32
32
  throw new version_errors_1.FileUploadError(new Error('File not found'), zipPath);
33
33
  }
34
- const fileName = path_1.default.basename(zipPath);
35
34
  const fileStats = fs_1.default.statSync(zipPath);
36
35
  try {
37
36
  const { uploadId, presignedUrl } = await this.makeRequest(`${api_constants_1.ENDPOINTS.VERSIONS}/${versionId}/files`, 'POST', {
@@ -7,6 +7,7 @@ exports.VersionManager = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const env_parser_1 = require("./utils/env-parser");
10
+ const version_1 = require("../../version");
10
11
  class VersionManager {
11
12
  async deploy(context, projectDir = process.cwd(), versionName = 'latest', options = {}) {
12
13
  const { config } = context;
@@ -38,8 +39,8 @@ class VersionManager {
38
39
  .append(environment.name, 'dark')
39
40
  .append('version')
40
41
  .append(versionName, 'dark'));
41
- const versionId = await context.versionService.uploadConfiguration(environment.id, versionName, configFile.steps, configFile.streams);
42
- const uploadResult = await context.versionService.uploadZipFile(versionId, distDir);
42
+ const versionId = await context.versionService.uploadConfiguration(environment.id, version_1.version, versionName, configFile.steps, configFile.streams);
43
+ const uploadResult = await context.versionService.uploadProject(versionId, distDir, configFile.steps);
43
44
  if (!uploadResult.success) {
44
45
  context.log('deploy-failed', (message) => message
45
46
  .tag('failed')
@@ -62,8 +63,6 @@ class VersionManager {
62
63
  const versionResults = [uploadResult].map((result) => ({
63
64
  bundlePath: result.bundlePath,
64
65
  versionId: result.success ? versionId : undefined,
65
- stepType: result.stepType,
66
- stepName: result.stepName,
67
66
  stepPath: configFile.steps[result.bundlePath]?.entrypointPath,
68
67
  flowName: configFile.steps[result.bundlePath]?.config?.flows?.[0] || 'unknown',
69
68
  environment: environment.name,
@@ -0,0 +1,12 @@
1
+ import { BuildStepConfig } from '../build/builder';
2
+ export declare class DeployPrinter {
3
+ private readonly printer;
4
+ private readonly output;
5
+ getStepLanguage(stepConfig: BuildStepConfig): string;
6
+ getStepType(stepConfig: BuildStepConfig): string;
7
+ getStepPath(stepConfig: BuildStepConfig): string;
8
+ printStepUploading(stepConfig: BuildStepConfig): void;
9
+ printStepUploaded(stepConfig: BuildStepConfig): void;
10
+ printConfigurationUploading(): void;
11
+ printConfigurationUploaded(): void;
12
+ }
@@ -0,0 +1,72 @@
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.DeployPrinter = void 0;
7
+ const colors_1 = __importDefault(require("colors"));
8
+ const printer_1 = require("@motiadev/core/dist/src/printer");
9
+ const cli_output_manager_1 = require("../cli-output-manager");
10
+ const uploading = colors_1.default.yellow('➜ [UPLOADING]');
11
+ const uploaded = colors_1.default.green('✓ [UPLOADED]');
12
+ class DeployPrinter {
13
+ constructor() {
14
+ this.printer = new printer_1.Printer(process.cwd());
15
+ this.output = new cli_output_manager_1.CLIOutputManager();
16
+ }
17
+ getStepLanguage(stepConfig) {
18
+ if (stepConfig.filePath.endsWith('.py')) {
19
+ return colors_1.default.bold(colors_1.default.blue('Python'));
20
+ }
21
+ else if (stepConfig.filePath.endsWith('.js') || stepConfig.filePath.endsWith('.ts')) {
22
+ return colors_1.default.bold(colors_1.default.green('Node'));
23
+ }
24
+ else if (stepConfig.filePath.endsWith('.rb')) {
25
+ return colors_1.default.bold(colors_1.default.red('Ruby'));
26
+ }
27
+ return colors_1.default.bold(colors_1.default.gray('Unknown'));
28
+ }
29
+ getStepType(stepConfig) {
30
+ if (stepConfig.config.type === 'api') {
31
+ return colors_1.default.gray('(API)');
32
+ }
33
+ else if (stepConfig.config.type === 'event') {
34
+ return colors_1.default.gray('(Event)');
35
+ }
36
+ else if (stepConfig.config.type === 'cron') {
37
+ return colors_1.default.gray('(Cron)');
38
+ }
39
+ else if (stepConfig.config.type === 'noop') {
40
+ return colors_1.default.gray('(Noop)');
41
+ }
42
+ return colors_1.default.gray('(Unknown)');
43
+ }
44
+ getStepPath(stepConfig) {
45
+ return colors_1.default.bold(colors_1.default.cyan(this.printer.getRelativePath(stepConfig.filePath)));
46
+ }
47
+ printStepUploading(stepConfig) {
48
+ const stepLanguage = this.getStepLanguage(stepConfig);
49
+ const stepType = this.getStepType(stepConfig);
50
+ const stepPath = this.getStepPath(stepConfig);
51
+ const stepTag = this.printer.stepTag;
52
+ this.output.log(stepConfig.filePath, (message) => {
53
+ message.append(`${uploading} ${stepLanguage} ${stepTag} ${stepType} ${stepPath}`);
54
+ });
55
+ }
56
+ printStepUploaded(stepConfig) {
57
+ const stepLanguage = this.getStepLanguage(stepConfig);
58
+ const stepType = this.getStepType(stepConfig);
59
+ const stepPath = this.getStepPath(stepConfig);
60
+ const stepTag = this.printer.stepTag;
61
+ this.output.log(stepConfig.filePath, (message) => {
62
+ message.append(`${uploaded} ${stepLanguage} ${stepTag} ${stepType} ${stepPath}`);
63
+ });
64
+ }
65
+ printConfigurationUploading() {
66
+ this.output.log('upload-config', (message) => message.tag('progress').append(`${uploading} Configuration`));
67
+ }
68
+ printConfigurationUploaded() {
69
+ this.output.log('upload-config', (message) => message.tag('success').append(`${uploaded} Configuration`));
70
+ }
71
+ }
72
+ exports.DeployPrinter = DeployPrinter;
@@ -5,10 +5,10 @@ import { BuildStepsConfig, BuildStreamsConfig } from '../../build/builder';
5
5
  export declare class VersionService {
6
6
  private readonly context;
7
7
  private readonly versionClient;
8
- private readonly fileManager;
8
+ private readonly printer;
9
9
  constructor(context: CliContext);
10
- uploadConfiguration(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
- uploadZipFile(versionId: string, distDir: string): Promise<UploadResult>;
10
+ uploadConfiguration(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
+ uploadProject(versionId: string, distDir: string, steps: BuildStepsConfig): Promise<UploadResult>;
12
12
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
13
13
  getVersionStatus(versionId: string): Promise<{
14
14
  status: string;
@@ -5,43 +5,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.VersionService = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const file_manager_1 = require("../file-manager");
8
+ const printer_1 = require("../printer");
9
9
  class VersionService {
10
10
  constructor(context) {
11
11
  this.context = context;
12
+ this.printer = new printer_1.DeployPrinter();
12
13
  this.versionClient = context.apiFactory.getVersionsClient();
13
- this.fileManager = new file_manager_1.FileManager(context);
14
14
  }
15
- async uploadConfiguration(environmentId, version, stepsConfig, streamsConfig) {
16
- this.context.log('upload-config', (message) => message.tag('progress').append('Uploading configuration...'));
17
- const versionId = await this.versionClient.uploadStepsConfig(environmentId, version, stepsConfig, streamsConfig);
18
- this.context.log('upload-config', (message) => message.tag('success').append('Configuration uploaded successfully'));
15
+ async uploadConfiguration(environmentId, motiaVersion, version, stepsConfig, streamsConfig) {
16
+ this.printer.printConfigurationUploading();
17
+ const versionId = await this.versionClient.uploadStepsConfig(environmentId, motiaVersion, version, stepsConfig, streamsConfig);
18
+ this.printer.printConfigurationUploaded();
19
19
  this.context.log('deploy', (message) => message.tag('success').append(`Version started with ID: ${versionId}`));
20
20
  return versionId;
21
21
  }
22
- async uploadZipFile(versionId, distDir) {
23
- const { filePath, cleanup } = await this.fileManager.createDeployableZip(versionId, distDir);
24
- const uploadResult = {
25
- bundlePath: filePath,
26
- uploadId: '',
27
- stepType: 'zip',
28
- stepName: path_1.default.basename(filePath),
29
- success: true,
30
- };
22
+ async uploadProject(versionId, distDir, steps) {
31
23
  try {
32
- this.context.log('upload-zip', (message) => message.tag('progress').append('Uploading bundle...'));
33
- const uploadId = await this.versionClient.uploadZipFile(filePath, versionId);
34
- uploadResult.uploadId = uploadId;
35
- this.context.log('upload-zip', (message) => message.tag('success').append('Uploaded bundle successfully'));
24
+ const stepEntries = Object.entries(steps);
25
+ await Promise.all(stepEntries.map(async ([stepPath, stepConfig]) => {
26
+ this.printer.printStepUploading(stepConfig);
27
+ const stepZipPath = path_1.default.join(distDir, stepPath);
28
+ await this.versionClient.uploadZipFile(stepZipPath, versionId, stepPath);
29
+ this.printer.printStepUploaded(stepConfig);
30
+ }));
31
+ return {
32
+ success: true,
33
+ bundlePath: distDir,
34
+ };
36
35
  }
37
36
  catch (error) {
38
37
  this.context.log('upload-zip', (message) => message.tag('failed').append('Failed to upload bundle'));
39
38
  throw error;
40
39
  }
41
- finally {
42
- cleanup();
43
- }
44
- return uploadResult;
45
40
  }
46
41
  async startVersion(versionId, envData) {
47
42
  this.context.log('deploy-progress', (message) => message.tag('progress').append('Finalizing version...'));
@@ -31,8 +31,6 @@ export interface VersionConfig {
31
31
  export interface VersionResult {
32
32
  bundlePath: string;
33
33
  versionId?: string;
34
- stepType: string;
35
- stepName: string;
36
34
  stepPath?: string;
37
35
  flowName: string;
38
36
  environment: string;
@@ -59,9 +57,6 @@ export interface VersionSummary {
59
57
  }
60
58
  export interface UploadResult {
61
59
  bundlePath: string;
62
- uploadId?: string;
63
- stepType: string;
64
- stepName: string;
65
60
  error?: string;
66
61
  success: boolean;
67
62
  }
@@ -15,5 +15,16 @@ const stateEndpoints = (server, stateAdapter) => {
15
15
  res.status(500).json({ error: error.message });
16
16
  }
17
17
  });
18
+ app.post('/motia/state', async (req, res) => {
19
+ try {
20
+ const { key, groupId, value } = req.body;
21
+ await stateAdapter.set(groupId, key, value);
22
+ res.json({ key, groupId, value });
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ }
25
+ catch (error) {
26
+ res.status(500).json({ error: error.message });
27
+ }
28
+ });
18
29
  };
19
30
  exports.stateEndpoints = stateEndpoints;
@@ -3,8 +3,8 @@ import { Version } from '../models/entities/version';
3
3
  import { VersionStartResponse } from '../models/responses/version-responses';
4
4
  import { BuildStreamsConfig, BuildStepsConfig } from '../../build/builder';
5
5
  export declare class VersionsClient extends AxiosClient {
6
- uploadStepsConfig(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
- uploadZipFile(zipPath: string, versionId: string): Promise<string>;
6
+ uploadStepsConfig(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
+ uploadZipFile(zipPath: string, versionId: string, fileName: string): Promise<string>;
8
8
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
9
9
  promoteVersion(environmentId: string, version: string): Promise<void>;
10
10
  getVersion(versionId: string): Promise<Version>;
@@ -6,12 +6,12 @@ import { ENDPOINTS, MAX_UPLOAD_SIZE } from '../core/api-constants';
6
6
  import { ApiError } from '../core/api-base';
7
7
  import { VersionError, VersionNotFoundError, VersionStartError, FileUploadError, InvalidConfigError, VersionPromotionError, } from '../models/errors/version-errors';
8
8
  export class VersionsClient extends AxiosClient {
9
- async uploadStepsConfig(environmentId, version, stepsConfig, streamsConfig) {
9
+ async uploadStepsConfig(environmentId, motiaVersion, version, stepsConfig, streamsConfig) {
10
10
  if (!stepsConfig || Object.keys(stepsConfig).length === 0) {
11
11
  throw new InvalidConfigError();
12
12
  }
13
13
  try {
14
- const response = await this.makeRequest(`${ENDPOINTS.ENVIRONMENTS}/${environmentId}/versions`, 'POST', { config: stepsConfig, version, streamsConfig });
14
+ const response = await this.makeRequest(`${ENDPOINTS.ENVIRONMENTS}/${environmentId}/versions`, 'POST', { config: stepsConfig, version, streamsConfig, motiaVersion });
15
15
  return response.versionId;
16
16
  }
17
17
  catch (error) {
@@ -21,11 +21,10 @@ export class VersionsClient extends AxiosClient {
21
21
  throw error;
22
22
  }
23
23
  }
24
- async uploadZipFile(zipPath, versionId) {
24
+ async uploadZipFile(zipPath, versionId, fileName) {
25
25
  if (!fs.existsSync(zipPath)) {
26
26
  throw new FileUploadError(new Error('File not found'), zipPath);
27
27
  }
28
- const fileName = path.basename(zipPath);
29
28
  const fileStats = fs.statSync(zipPath);
30
29
  try {
31
30
  const { uploadId, presignedUrl } = await this.makeRequest(`${ENDPOINTS.VERSIONS}/${versionId}/files`, 'POST', {
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { parseEnvFile } from './utils/env-parser';
4
+ import { version as motiaVersion } from '../../version';
4
5
  export class VersionManager {
5
6
  async deploy(context, projectDir = process.cwd(), versionName = 'latest', options = {}) {
6
7
  const { config } = context;
@@ -32,8 +33,8 @@ export class VersionManager {
32
33
  .append(environment.name, 'dark')
33
34
  .append('version')
34
35
  .append(versionName, 'dark'));
35
- const versionId = await context.versionService.uploadConfiguration(environment.id, versionName, configFile.steps, configFile.streams);
36
- const uploadResult = await context.versionService.uploadZipFile(versionId, distDir);
36
+ const versionId = await context.versionService.uploadConfiguration(environment.id, motiaVersion, versionName, configFile.steps, configFile.streams);
37
+ const uploadResult = await context.versionService.uploadProject(versionId, distDir, configFile.steps);
37
38
  if (!uploadResult.success) {
38
39
  context.log('deploy-failed', (message) => message
39
40
  .tag('failed')
@@ -56,8 +57,6 @@ export class VersionManager {
56
57
  const versionResults = [uploadResult].map((result) => ({
57
58
  bundlePath: result.bundlePath,
58
59
  versionId: result.success ? versionId : undefined,
59
- stepType: result.stepType,
60
- stepName: result.stepName,
61
60
  stepPath: configFile.steps[result.bundlePath]?.entrypointPath,
62
61
  flowName: configFile.steps[result.bundlePath]?.config?.flows?.[0] || 'unknown',
63
62
  environment: environment.name,
@@ -0,0 +1,12 @@
1
+ import { BuildStepConfig } from '../build/builder';
2
+ export declare class DeployPrinter {
3
+ private readonly printer;
4
+ private readonly output;
5
+ getStepLanguage(stepConfig: BuildStepConfig): string;
6
+ getStepType(stepConfig: BuildStepConfig): string;
7
+ getStepPath(stepConfig: BuildStepConfig): string;
8
+ printStepUploading(stepConfig: BuildStepConfig): void;
9
+ printStepUploaded(stepConfig: BuildStepConfig): void;
10
+ printConfigurationUploading(): void;
11
+ printConfigurationUploaded(): void;
12
+ }
@@ -0,0 +1,65 @@
1
+ import colors from 'colors';
2
+ import { Printer } from '@motiadev/core/dist/src/printer';
3
+ import { CLIOutputManager } from '../cli-output-manager';
4
+ const uploading = colors.yellow('➜ [UPLOADING]');
5
+ const uploaded = colors.green('✓ [UPLOADED]');
6
+ export class DeployPrinter {
7
+ constructor() {
8
+ this.printer = new Printer(process.cwd());
9
+ this.output = new CLIOutputManager();
10
+ }
11
+ getStepLanguage(stepConfig) {
12
+ if (stepConfig.filePath.endsWith('.py')) {
13
+ return colors.bold(colors.blue('Python'));
14
+ }
15
+ else if (stepConfig.filePath.endsWith('.js') || stepConfig.filePath.endsWith('.ts')) {
16
+ return colors.bold(colors.green('Node'));
17
+ }
18
+ else if (stepConfig.filePath.endsWith('.rb')) {
19
+ return colors.bold(colors.red('Ruby'));
20
+ }
21
+ return colors.bold(colors.gray('Unknown'));
22
+ }
23
+ getStepType(stepConfig) {
24
+ if (stepConfig.config.type === 'api') {
25
+ return colors.gray('(API)');
26
+ }
27
+ else if (stepConfig.config.type === 'event') {
28
+ return colors.gray('(Event)');
29
+ }
30
+ else if (stepConfig.config.type === 'cron') {
31
+ return colors.gray('(Cron)');
32
+ }
33
+ else if (stepConfig.config.type === 'noop') {
34
+ return colors.gray('(Noop)');
35
+ }
36
+ return colors.gray('(Unknown)');
37
+ }
38
+ getStepPath(stepConfig) {
39
+ return colors.bold(colors.cyan(this.printer.getRelativePath(stepConfig.filePath)));
40
+ }
41
+ printStepUploading(stepConfig) {
42
+ const stepLanguage = this.getStepLanguage(stepConfig);
43
+ const stepType = this.getStepType(stepConfig);
44
+ const stepPath = this.getStepPath(stepConfig);
45
+ const stepTag = this.printer.stepTag;
46
+ this.output.log(stepConfig.filePath, (message) => {
47
+ message.append(`${uploading} ${stepLanguage} ${stepTag} ${stepType} ${stepPath}`);
48
+ });
49
+ }
50
+ printStepUploaded(stepConfig) {
51
+ const stepLanguage = this.getStepLanguage(stepConfig);
52
+ const stepType = this.getStepType(stepConfig);
53
+ const stepPath = this.getStepPath(stepConfig);
54
+ const stepTag = this.printer.stepTag;
55
+ this.output.log(stepConfig.filePath, (message) => {
56
+ message.append(`${uploaded} ${stepLanguage} ${stepTag} ${stepType} ${stepPath}`);
57
+ });
58
+ }
59
+ printConfigurationUploading() {
60
+ this.output.log('upload-config', (message) => message.tag('progress').append(`${uploading} Configuration`));
61
+ }
62
+ printConfigurationUploaded() {
63
+ this.output.log('upload-config', (message) => message.tag('success').append(`${uploaded} Configuration`));
64
+ }
65
+ }
@@ -5,10 +5,10 @@ import { BuildStepsConfig, BuildStreamsConfig } from '../../build/builder';
5
5
  export declare class VersionService {
6
6
  private readonly context;
7
7
  private readonly versionClient;
8
- private readonly fileManager;
8
+ private readonly printer;
9
9
  constructor(context: CliContext);
10
- uploadConfiguration(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
- uploadZipFile(versionId: string, distDir: string): Promise<UploadResult>;
10
+ uploadConfiguration(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
+ uploadProject(versionId: string, distDir: string, steps: BuildStepsConfig): Promise<UploadResult>;
12
12
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
13
13
  getVersionStatus(versionId: string): Promise<{
14
14
  status: string;
@@ -1,41 +1,36 @@
1
1
  import path from 'path';
2
- import { FileManager } from '../file-manager';
2
+ import { DeployPrinter } from '../printer';
3
3
  export class VersionService {
4
4
  constructor(context) {
5
5
  this.context = context;
6
+ this.printer = new DeployPrinter();
6
7
  this.versionClient = context.apiFactory.getVersionsClient();
7
- this.fileManager = new FileManager(context);
8
8
  }
9
- async uploadConfiguration(environmentId, version, stepsConfig, streamsConfig) {
10
- this.context.log('upload-config', (message) => message.tag('progress').append('Uploading configuration...'));
11
- const versionId = await this.versionClient.uploadStepsConfig(environmentId, version, stepsConfig, streamsConfig);
12
- this.context.log('upload-config', (message) => message.tag('success').append('Configuration uploaded successfully'));
9
+ async uploadConfiguration(environmentId, motiaVersion, version, stepsConfig, streamsConfig) {
10
+ this.printer.printConfigurationUploading();
11
+ const versionId = await this.versionClient.uploadStepsConfig(environmentId, motiaVersion, version, stepsConfig, streamsConfig);
12
+ this.printer.printConfigurationUploaded();
13
13
  this.context.log('deploy', (message) => message.tag('success').append(`Version started with ID: ${versionId}`));
14
14
  return versionId;
15
15
  }
16
- async uploadZipFile(versionId, distDir) {
17
- const { filePath, cleanup } = await this.fileManager.createDeployableZip(versionId, distDir);
18
- const uploadResult = {
19
- bundlePath: filePath,
20
- uploadId: '',
21
- stepType: 'zip',
22
- stepName: path.basename(filePath),
23
- success: true,
24
- };
16
+ async uploadProject(versionId, distDir, steps) {
25
17
  try {
26
- this.context.log('upload-zip', (message) => message.tag('progress').append('Uploading bundle...'));
27
- const uploadId = await this.versionClient.uploadZipFile(filePath, versionId);
28
- uploadResult.uploadId = uploadId;
29
- this.context.log('upload-zip', (message) => message.tag('success').append('Uploaded bundle successfully'));
18
+ const stepEntries = Object.entries(steps);
19
+ await Promise.all(stepEntries.map(async ([stepPath, stepConfig]) => {
20
+ this.printer.printStepUploading(stepConfig);
21
+ const stepZipPath = path.join(distDir, stepPath);
22
+ await this.versionClient.uploadZipFile(stepZipPath, versionId, stepPath);
23
+ this.printer.printStepUploaded(stepConfig);
24
+ }));
25
+ return {
26
+ success: true,
27
+ bundlePath: distDir,
28
+ };
30
29
  }
31
30
  catch (error) {
32
31
  this.context.log('upload-zip', (message) => message.tag('failed').append('Failed to upload bundle'));
33
32
  throw error;
34
33
  }
35
- finally {
36
- cleanup();
37
- }
38
- return uploadResult;
39
34
  }
40
35
  async startVersion(versionId, envData) {
41
36
  this.context.log('deploy-progress', (message) => message.tag('progress').append('Finalizing version...'));
@@ -31,8 +31,6 @@ export interface VersionConfig {
31
31
  export interface VersionResult {
32
32
  bundlePath: string;
33
33
  versionId?: string;
34
- stepType: string;
35
- stepName: string;
36
34
  stepPath?: string;
37
35
  flowName: string;
38
36
  environment: string;
@@ -59,9 +57,6 @@ export interface VersionSummary {
59
57
  }
60
58
  export interface UploadResult {
61
59
  bundlePath: string;
62
- uploadId?: string;
63
- stepType: string;
64
- stepName: string;
65
60
  error?: string;
66
61
  success: boolean;
67
62
  }
@@ -12,4 +12,15 @@ export const stateEndpoints = (server, stateAdapter) => {
12
12
  res.status(500).json({ error: error.message });
13
13
  }
14
14
  });
15
+ app.post('/motia/state', async (req, res) => {
16
+ try {
17
+ const { key, groupId, value } = req.body;
18
+ await stateAdapter.set(groupId, key, value);
19
+ res.json({ key, groupId, value });
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ }
22
+ catch (error) {
23
+ res.status(500).json({ error: error.message });
24
+ }
25
+ });
15
26
  };
@@ -3,8 +3,8 @@ import { Version } from '../models/entities/version';
3
3
  import { VersionStartResponse } from '../models/responses/version-responses';
4
4
  import { BuildStreamsConfig, BuildStepsConfig } from '../../build/builder';
5
5
  export declare class VersionsClient extends AxiosClient {
6
- uploadStepsConfig(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
- uploadZipFile(zipPath: string, versionId: string): Promise<string>;
6
+ uploadStepsConfig(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
7
+ uploadZipFile(zipPath: string, versionId: string, fileName: string): Promise<string>;
8
8
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
9
9
  promoteVersion(environmentId: string, version: string): Promise<void>;
10
10
  getVersion(versionId: string): Promise<Version>;
@@ -0,0 +1,12 @@
1
+ import { BuildStepConfig } from '../build/builder';
2
+ export declare class DeployPrinter {
3
+ private readonly printer;
4
+ private readonly output;
5
+ getStepLanguage(stepConfig: BuildStepConfig): string;
6
+ getStepType(stepConfig: BuildStepConfig): string;
7
+ getStepPath(stepConfig: BuildStepConfig): string;
8
+ printStepUploading(stepConfig: BuildStepConfig): void;
9
+ printStepUploaded(stepConfig: BuildStepConfig): void;
10
+ printConfigurationUploading(): void;
11
+ printConfigurationUploaded(): void;
12
+ }
@@ -5,10 +5,10 @@ import { BuildStepsConfig, BuildStreamsConfig } from '../../build/builder';
5
5
  export declare class VersionService {
6
6
  private readonly context;
7
7
  private readonly versionClient;
8
- private readonly fileManager;
8
+ private readonly printer;
9
9
  constructor(context: CliContext);
10
- uploadConfiguration(environmentId: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
- uploadZipFile(versionId: string, distDir: string): Promise<UploadResult>;
10
+ uploadConfiguration(environmentId: string, motiaVersion: string, version: string, stepsConfig: BuildStepsConfig, streamsConfig: BuildStreamsConfig): Promise<string>;
11
+ uploadProject(versionId: string, distDir: string, steps: BuildStepsConfig): Promise<UploadResult>;
12
12
  startVersion(versionId: string, envData?: Record<string, string>): Promise<VersionStartResponse>;
13
13
  getVersionStatus(versionId: string): Promise<{
14
14
  status: string;
@@ -31,8 +31,6 @@ export interface VersionConfig {
31
31
  export interface VersionResult {
32
32
  bundlePath: string;
33
33
  versionId?: string;
34
- stepType: string;
35
- stepName: string;
36
34
  stepPath?: string;
37
35
  flowName: string;
38
36
  environment: string;
@@ -59,9 +57,6 @@ export interface VersionSummary {
59
57
  }
60
58
  export interface UploadResult {
61
59
  bundlePath: string;
62
- uploadId?: string;
63
- stepType: string;
64
- stepName: string;
65
60
  error?: string;
66
61
  success: boolean;
67
62
  }
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.4.2-beta.95",
4
+ "version": "0.4.4-beta.97",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -42,8 +42,8 @@
42
42
  "inquirer": "^8.2.5",
43
43
  "table": "^6.9.0",
44
44
  "ts-node": "^10.9.2",
45
- "@motiadev/workbench": "0.4.2-beta.95",
46
- "@motiadev/core": "0.4.2-beta.95"
45
+ "@motiadev/core": "0.4.4-beta.97",
46
+ "@motiadev/workbench": "0.4.4-beta.97"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@amplitude/analytics-types": "^2.9.2",
@@ -1,9 +0,0 @@
1
- import { CliContext } from '../config-utils';
2
- export declare class FileManager {
3
- private readonly context;
4
- constructor(context: CliContext);
5
- createDeployableZip(versionId: string, folderPath: string): Promise<{
6
- filePath: string;
7
- cleanup: () => void;
8
- }>;
9
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileManager = void 0;
4
- const archive_1 = require("./utils/archive");
5
- class FileManager {
6
- constructor(context) {
7
- this.context = context;
8
- }
9
- async createDeployableZip(versionId, folderPath) {
10
- try {
11
- this.context.log('preparing-zip', (message) => message.tag('progress').append('Preparing version package file...'));
12
- const zipFilePath = await (0, archive_1.createFolderZip)(versionId, folderPath);
13
- this.context.log('preparing-zip', (message) => message.tag('success').append('Version package file created successfully'));
14
- return zipFilePath;
15
- }
16
- catch (error) {
17
- const errorMessage = error instanceof Error ? error.message : String(error);
18
- this.context.log('preparing-zip', (message) => message.tag('failed').append(`Failed to create version package file: ${errorMessage}`, 'red'));
19
- process.exit(1);
20
- }
21
- }
22
- }
23
- exports.FileManager = FileManager;
@@ -1,9 +0,0 @@
1
- import { CliContext } from '../config-utils';
2
- export declare class FileManager {
3
- private readonly context;
4
- constructor(context: CliContext);
5
- createDeployableZip(versionId: string, folderPath: string): Promise<{
6
- filePath: string;
7
- cleanup: () => void;
8
- }>;
9
- }
@@ -1,19 +0,0 @@
1
- import { createFolderZip } from './utils/archive';
2
- export class FileManager {
3
- constructor(context) {
4
- this.context = context;
5
- }
6
- async createDeployableZip(versionId, folderPath) {
7
- try {
8
- this.context.log('preparing-zip', (message) => message.tag('progress').append('Preparing version package file...'));
9
- const zipFilePath = await createFolderZip(versionId, folderPath);
10
- this.context.log('preparing-zip', (message) => message.tag('success').append('Version package file created successfully'));
11
- return zipFilePath;
12
- }
13
- catch (error) {
14
- const errorMessage = error instanceof Error ? error.message : String(error);
15
- this.context.log('preparing-zip', (message) => message.tag('failed').append(`Failed to create version package file: ${errorMessage}`, 'red'));
16
- process.exit(1);
17
- }
18
- }
19
- }
@@ -1,9 +0,0 @@
1
- import { CliContext } from '../config-utils';
2
- export declare class FileManager {
3
- private readonly context;
4
- constructor(context: CliContext);
5
- createDeployableZip(versionId: string, folderPath: string): Promise<{
6
- filePath: string;
7
- cleanup: () => void;
8
- }>;
9
- }