motia 0.8.7-beta.144 → 0.9.0-beta.145
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/cjs/dev.js +16 -8
- package/dist/cjs/generate-locked-data.d.ts +2 -3
- package/dist/cjs/generate-locked-data.js +2 -2
- package/dist/cjs/load-motia-config.d.ts +2 -0
- package/dist/cjs/load-motia-config.js +52 -0
- package/dist/cjs/start.js +13 -5
- package/dist/esm/dev.js +17 -9
- package/dist/esm/generate-locked-data.d.ts +2 -3
- package/dist/esm/generate-locked-data.js +2 -2
- package/dist/esm/load-motia-config.d.ts +2 -0
- package/dist/esm/load-motia-config.js +15 -0
- package/dist/esm/start.js +14 -6
- package/dist/types/generate-locked-data.d.ts +2 -3
- package/dist/types/load-motia-config.d.ts +2 -0
- package/package.json +4 -4
package/dist/cjs/dev.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.dev = void 0;
|
|
7
|
-
// packages/snap/src/dev.ts
|
|
8
7
|
const analytics_node_1 = require("@amplitude/analytics-node");
|
|
9
8
|
const core_1 = require("@motiadev/core");
|
|
10
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -12,6 +11,7 @@ const endpoints_1 = require("./cloud/endpoints");
|
|
|
12
11
|
const constants_1 = require("./constants");
|
|
13
12
|
const dev_watchers_1 = require("./dev-watchers");
|
|
14
13
|
const generate_locked_data_1 = require("./generate-locked-data");
|
|
14
|
+
const load_motia_config_1 = require("./load-motia-config");
|
|
15
15
|
const plugins_1 = require("./plugins");
|
|
16
16
|
const activate_python_env_1 = require("./utils/activate-python-env");
|
|
17
17
|
const analytics_1 = require("./utils/analytics");
|
|
@@ -40,15 +40,23 @@ const dev = async (port, hostname, disableVerbose, enableMermaid, motiaFileStora
|
|
|
40
40
|
(0, core_1.trackEvent)('python_environment_activated');
|
|
41
41
|
}
|
|
42
42
|
const motiaFileStoragePath = motiaFileStorageDir || '.motia';
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const appConfig = await (0, load_motia_config_1.loadMotiaConfig)(baseDir);
|
|
44
|
+
const adapters = {
|
|
45
|
+
eventAdapter: appConfig.adapters?.events || new core_1.DefaultQueueEventAdapter(),
|
|
46
|
+
cronAdapter: appConfig.adapters?.cron || new core_1.DefaultCronAdapter(),
|
|
47
|
+
streamAdapter: appConfig.adapters?.streams || new core_1.FileStreamAdapterManager(baseDir, motiaFileStoragePath),
|
|
48
|
+
};
|
|
49
|
+
const lockedData = await (0, generate_locked_data_1.generateLockedData)({
|
|
50
|
+
projectDir: baseDir,
|
|
51
|
+
streamAdapter: adapters.streamAdapter,
|
|
49
52
|
});
|
|
53
|
+
const state = appConfig.adapters?.state ||
|
|
54
|
+
(0, core_1.createStateAdapter)({
|
|
55
|
+
adapter: 'default',
|
|
56
|
+
filePath: path_1.default.join(baseDir, motiaFileStoragePath),
|
|
57
|
+
});
|
|
50
58
|
const config = { isVerbose };
|
|
51
|
-
const motiaServer = (0, core_1.createServer)(lockedData,
|
|
59
|
+
const motiaServer = (0, core_1.createServer)(lockedData, state, config, adapters);
|
|
52
60
|
const watcher = (0, dev_watchers_1.createDevWatchers)(lockedData, motiaServer, motiaServer.motiaEventManager, motiaServer.cronManager);
|
|
53
61
|
const plugins = await (0, plugins_1.processPlugins)(motiaServer);
|
|
54
62
|
// Initialize mermaid generator
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LockedData, type Step } from '@motiadev/core';
|
|
1
|
+
import { LockedData, type Step, type StreamAdapterManager } from '@motiadev/core';
|
|
2
2
|
export declare const getStepFiles: (projectDir: string) => string[];
|
|
3
3
|
export declare const getStreamFiles: (projectDir: string) => string[];
|
|
4
4
|
export declare const collectFlows: (projectDir: string, lockedData: LockedData) => Promise<Step[]>;
|
|
5
5
|
export declare const generateLockedData: (config: {
|
|
6
6
|
projectDir: string;
|
|
7
|
-
streamAdapter
|
|
7
|
+
streamAdapter: StreamAdapterManager;
|
|
8
8
|
printerType?: "disabled" | "default";
|
|
9
|
-
motiaFileStoragePath?: string;
|
|
10
9
|
}) => Promise<LockedData>;
|
|
@@ -107,13 +107,13 @@ const collectFlows = async (projectDir, lockedData) => {
|
|
|
107
107
|
exports.collectFlows = collectFlows;
|
|
108
108
|
const generateLockedData = async (config) => {
|
|
109
109
|
try {
|
|
110
|
-
const { projectDir, streamAdapter
|
|
110
|
+
const { projectDir, streamAdapter, printerType = 'default' } = config;
|
|
111
111
|
const printer = printerType === 'disabled' ? new printer_1.NoPrinter() : new printer_1.Printer(projectDir);
|
|
112
112
|
/*
|
|
113
113
|
* NOTE: right now for performance and simplicity let's enforce a folder,
|
|
114
114
|
* but we might want to remove this and scan the entire current directory
|
|
115
115
|
*/
|
|
116
|
-
const lockedData = new core_1.LockedData(projectDir, streamAdapter, printer
|
|
116
|
+
const lockedData = new core_1.LockedData(projectDir, streamAdapter, printer);
|
|
117
117
|
await (0, exports.collectFlows)(projectDir, lockedData);
|
|
118
118
|
lockedData.saveTypes();
|
|
119
119
|
return lockedData;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadMotiaConfig = void 0;
|
|
37
|
+
const glob_1 = require("glob");
|
|
38
|
+
const loadMotiaConfig = async (baseDir) => {
|
|
39
|
+
const configFiles = (0, glob_1.globSync)('motia.config.{ts,js}', { absolute: true, cwd: baseDir });
|
|
40
|
+
if (configFiles.length === 0) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const appConfig = (await Promise.resolve(`${configFiles[0]}`).then(s => __importStar(require(s)))).default;
|
|
45
|
+
return appConfig || {};
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.warn('Failed to load motia.config.ts:', error);
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.loadMotiaConfig = loadMotiaConfig;
|
package/dist/cjs/start.js
CHANGED
|
@@ -8,6 +8,7 @@ const core_1 = require("@motiadev/core");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
10
|
const generate_locked_data_1 = require("./generate-locked-data");
|
|
11
|
+
const load_motia_config_1 = require("./load-motia-config");
|
|
11
12
|
const plugins_1 = require("./plugins");
|
|
12
13
|
const activate_python_env_1 = require("./utils/activate-python-env");
|
|
13
14
|
const version_1 = require("./version");
|
|
@@ -26,12 +27,19 @@ const start = async (port, hostname, disableVerbose, motiaFileStorageDir) => {
|
|
|
26
27
|
}
|
|
27
28
|
const motiaFileStoragePath = motiaFileStorageDir || '.motia';
|
|
28
29
|
const dotMotia = path_1.default.join(baseDir, motiaFileStoragePath);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const appConfig = await (0, load_motia_config_1.loadMotiaConfig)(baseDir);
|
|
31
|
+
const adapters = {
|
|
32
|
+
eventAdapter: appConfig.adapters?.events || new core_1.DefaultQueueEventAdapter(),
|
|
33
|
+
cronAdapter: appConfig.adapters?.cron || new core_1.DefaultCronAdapter(),
|
|
34
|
+
streamAdapter: appConfig.adapters?.streams || new core_1.FileStreamAdapterManager(baseDir),
|
|
35
|
+
};
|
|
36
|
+
const lockedData = await (0, generate_locked_data_1.generateLockedData)({
|
|
37
|
+
projectDir: baseDir,
|
|
38
|
+
streamAdapter: adapters.streamAdapter,
|
|
39
|
+
});
|
|
40
|
+
const state = appConfig.adapters?.state || (0, core_1.createStateAdapter)({ adapter: 'default', filePath: dotMotia });
|
|
33
41
|
const config = { isVerbose, isDev: false, version: version_1.version };
|
|
34
|
-
const motiaServer = (0, core_1.createServer)(lockedData,
|
|
42
|
+
const motiaServer = (0, core_1.createServer)(lockedData, state, config, adapters);
|
|
35
43
|
const plugins = await (0, plugins_1.processPlugins)(motiaServer);
|
|
36
44
|
if (!process.env.MOTIA_DOCKER_DISABLE_WORKBENCH) {
|
|
37
45
|
const { applyMiddleware } = require('@motiadev/workbench/dist/middleware');
|
package/dist/esm/dev.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// packages/snap/src/dev.ts
|
|
2
1
|
import { flush } from '@amplitude/analytics-node';
|
|
3
|
-
import {
|
|
2
|
+
import { createMermaidGenerator, createServer, createStateAdapter, DefaultCronAdapter, DefaultQueueEventAdapter, FileStreamAdapterManager, getProjectIdentifier, trackEvent, } from '@motiadev/core';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
import { deployEndpoints } from './cloud/endpoints';
|
|
6
5
|
import { isTutorialDisabled, workbenchBase } from './constants';
|
|
7
6
|
import { createDevWatchers } from './dev-watchers';
|
|
8
7
|
import { generateLockedData, getStepFiles } from './generate-locked-data';
|
|
8
|
+
import { loadMotiaConfig } from './load-motia-config';
|
|
9
9
|
import { processPlugins } from './plugins';
|
|
10
10
|
import { activatePythonVenv } from './utils/activate-python-env';
|
|
11
11
|
import { identifyUser } from './utils/analytics';
|
|
@@ -34,15 +34,23 @@ export const dev = async (port, hostname, disableVerbose, enableMermaid, motiaFi
|
|
|
34
34
|
trackEvent('python_environment_activated');
|
|
35
35
|
}
|
|
36
36
|
const motiaFileStoragePath = motiaFileStorageDir || '.motia';
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const appConfig = await loadMotiaConfig(baseDir);
|
|
38
|
+
const adapters = {
|
|
39
|
+
eventAdapter: appConfig.adapters?.events || new DefaultQueueEventAdapter(),
|
|
40
|
+
cronAdapter: appConfig.adapters?.cron || new DefaultCronAdapter(),
|
|
41
|
+
streamAdapter: appConfig.adapters?.streams || new FileStreamAdapterManager(baseDir, motiaFileStoragePath),
|
|
42
|
+
};
|
|
43
|
+
const lockedData = await generateLockedData({
|
|
44
|
+
projectDir: baseDir,
|
|
45
|
+
streamAdapter: adapters.streamAdapter,
|
|
43
46
|
});
|
|
47
|
+
const state = appConfig.adapters?.state ||
|
|
48
|
+
createStateAdapter({
|
|
49
|
+
adapter: 'default',
|
|
50
|
+
filePath: path.join(baseDir, motiaFileStoragePath),
|
|
51
|
+
});
|
|
44
52
|
const config = { isVerbose };
|
|
45
|
-
const motiaServer = createServer(lockedData,
|
|
53
|
+
const motiaServer = createServer(lockedData, state, config, adapters);
|
|
46
54
|
const watcher = createDevWatchers(lockedData, motiaServer, motiaServer.motiaEventManager, motiaServer.cronManager);
|
|
47
55
|
const plugins = await processPlugins(motiaServer);
|
|
48
56
|
// Initialize mermaid generator
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LockedData, type Step } from '@motiadev/core';
|
|
1
|
+
import { LockedData, type Step, type StreamAdapterManager } from '@motiadev/core';
|
|
2
2
|
export declare const getStepFiles: (projectDir: string) => string[];
|
|
3
3
|
export declare const getStreamFiles: (projectDir: string) => string[];
|
|
4
4
|
export declare const collectFlows: (projectDir: string, lockedData: LockedData) => Promise<Step[]>;
|
|
5
5
|
export declare const generateLockedData: (config: {
|
|
6
6
|
projectDir: string;
|
|
7
|
-
streamAdapter
|
|
7
|
+
streamAdapter: StreamAdapterManager;
|
|
8
8
|
printerType?: "disabled" | "default";
|
|
9
|
-
motiaFileStoragePath?: string;
|
|
10
9
|
}) => Promise<LockedData>;
|
|
@@ -98,13 +98,13 @@ export const collectFlows = async (projectDir, lockedData) => {
|
|
|
98
98
|
};
|
|
99
99
|
export const generateLockedData = async (config) => {
|
|
100
100
|
try {
|
|
101
|
-
const { projectDir, streamAdapter
|
|
101
|
+
const { projectDir, streamAdapter, printerType = 'default' } = config;
|
|
102
102
|
const printer = printerType === 'disabled' ? new NoPrinter() : new Printer(projectDir);
|
|
103
103
|
/*
|
|
104
104
|
* NOTE: right now for performance and simplicity let's enforce a folder,
|
|
105
105
|
* but we might want to remove this and scan the entire current directory
|
|
106
106
|
*/
|
|
107
|
-
const lockedData = new LockedData(projectDir, streamAdapter, printer
|
|
107
|
+
const lockedData = new LockedData(projectDir, streamAdapter, printer);
|
|
108
108
|
await collectFlows(projectDir, lockedData);
|
|
109
109
|
lockedData.saveTypes();
|
|
110
110
|
return lockedData;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { globSync } from 'glob';
|
|
2
|
+
export const loadMotiaConfig = async (baseDir) => {
|
|
3
|
+
const configFiles = globSync('motia.config.{ts,js}', { absolute: true, cwd: baseDir });
|
|
4
|
+
if (configFiles.length === 0) {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
const appConfig = (await import(configFiles[0])).default;
|
|
9
|
+
return appConfig || {};
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
console.warn('Failed to load motia.config.ts:', error);
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
};
|
package/dist/esm/start.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createServer, createStateAdapter, DefaultCronAdapter, DefaultQueueEventAdapter, FileStreamAdapterManager, } from '@motiadev/core';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { workbenchBase } from './constants';
|
|
4
4
|
import { generateLockedData, getStepFiles } from './generate-locked-data';
|
|
5
|
+
import { loadMotiaConfig } from './load-motia-config';
|
|
5
6
|
import { processPlugins } from './plugins';
|
|
6
7
|
import { activatePythonVenv } from './utils/activate-python-env';
|
|
7
8
|
import { version } from './version';
|
|
@@ -20,12 +21,19 @@ export const start = async (port, hostname, disableVerbose, motiaFileStorageDir)
|
|
|
20
21
|
}
|
|
21
22
|
const motiaFileStoragePath = motiaFileStorageDir || '.motia';
|
|
22
23
|
const dotMotia = path.join(baseDir, motiaFileStoragePath);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const appConfig = await loadMotiaConfig(baseDir);
|
|
25
|
+
const adapters = {
|
|
26
|
+
eventAdapter: appConfig.adapters?.events || new DefaultQueueEventAdapter(),
|
|
27
|
+
cronAdapter: appConfig.adapters?.cron || new DefaultCronAdapter(),
|
|
28
|
+
streamAdapter: appConfig.adapters?.streams || new FileStreamAdapterManager(baseDir),
|
|
29
|
+
};
|
|
30
|
+
const lockedData = await generateLockedData({
|
|
31
|
+
projectDir: baseDir,
|
|
32
|
+
streamAdapter: adapters.streamAdapter,
|
|
33
|
+
});
|
|
34
|
+
const state = appConfig.adapters?.state || createStateAdapter({ adapter: 'default', filePath: dotMotia });
|
|
27
35
|
const config = { isVerbose, isDev: false, version };
|
|
28
|
-
const motiaServer = createServer(lockedData,
|
|
36
|
+
const motiaServer = createServer(lockedData, state, config, adapters);
|
|
29
37
|
const plugins = await processPlugins(motiaServer);
|
|
30
38
|
if (!process.env.MOTIA_DOCKER_DISABLE_WORKBENCH) {
|
|
31
39
|
const { applyMiddleware } = require('@motiadev/workbench/dist/middleware');
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { LockedData, type Step } from '@motiadev/core';
|
|
1
|
+
import { LockedData, type Step, type StreamAdapterManager } from '@motiadev/core';
|
|
2
2
|
export declare const getStepFiles: (projectDir: string) => string[];
|
|
3
3
|
export declare const getStreamFiles: (projectDir: string) => string[];
|
|
4
4
|
export declare const collectFlows: (projectDir: string, lockedData: LockedData) => Promise<Step[]>;
|
|
5
5
|
export declare const generateLockedData: (config: {
|
|
6
6
|
projectDir: string;
|
|
7
|
-
streamAdapter
|
|
7
|
+
streamAdapter: StreamAdapterManager;
|
|
8
8
|
printerType?: "disabled" | "default";
|
|
9
|
-
motiaFileStoragePath?: string;
|
|
10
9
|
}) => Promise<LockedData>;
|
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
|
+
"version": "0.9.0-beta.145",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"python-ast": "^0.1.0",
|
|
47
47
|
"table": "^6.9.0",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
|
-
"@motiadev/
|
|
50
|
-
"@motiadev/workbench": "0.
|
|
51
|
-
"@motiadev/
|
|
49
|
+
"@motiadev/stream-client-node": "0.9.0-beta.145",
|
|
50
|
+
"@motiadev/workbench": "0.9.0-beta.145",
|
|
51
|
+
"@motiadev/core": "0.9.0-beta.145"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@amplitude/analytics-types": "^2.9.2",
|