motia 0.0.26 → 0.0.28
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/dev/state-endpoints.js +39 -0
- package/dist/src/dev.js +5 -2
- package/package.json +3 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stateEndpoints = void 0;
|
|
4
|
+
const stateEndpoints = (server, stateAdapter) => {
|
|
5
|
+
const { app } = server;
|
|
6
|
+
app.get('/motia/state', async (_, res) => {
|
|
7
|
+
try {
|
|
8
|
+
const traceIds = await stateAdapter.traceIds();
|
|
9
|
+
res.json(traceIds);
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
res.status(500).json({ error: error.message });
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
app.get('/motia/state/:traceId', async (req, res) => {
|
|
17
|
+
const { traceId } = req.params;
|
|
18
|
+
try {
|
|
19
|
+
const keys = await stateAdapter.keys(traceId);
|
|
20
|
+
res.json(keys);
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
res.status(500).json({ error: error.message });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
app.get('/motia/state/:traceId/:key', async (req, res) => {
|
|
28
|
+
const { traceId, key } = req.params;
|
|
29
|
+
try {
|
|
30
|
+
const value = await stateAdapter.get(traceId, key);
|
|
31
|
+
res.json(value);
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
res.status(500).json({ error: error.message });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.stateEndpoints = stateEndpoints;
|
package/dist/src/dev.js
CHANGED
|
@@ -8,23 +8,26 @@ const core_1 = require("@motiadev/core");
|
|
|
8
8
|
const generate_locked_data_1 = require("./generate-locked-data");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const dev_watchers_1 = require("./dev-watchers");
|
|
11
|
+
const state_endpoints_1 = require("./dev/state-endpoints");
|
|
11
12
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
13
|
require('ts-node').register({
|
|
13
14
|
transpileOnly: true,
|
|
14
15
|
compilerOptions: { module: 'commonjs' },
|
|
15
16
|
});
|
|
16
17
|
const dev = async (port) => {
|
|
17
|
-
const
|
|
18
|
+
const baseDir = process.cwd();
|
|
19
|
+
const lockedData = await (0, generate_locked_data_1.generateLockedData)(baseDir);
|
|
18
20
|
const eventManager = (0, core_1.createEventManager)();
|
|
19
21
|
const state = (0, core_1.createStateAdapter)({
|
|
20
22
|
adapter: 'default',
|
|
21
|
-
filePath: path_1.default.join(
|
|
23
|
+
filePath: path_1.default.join(baseDir, '.motia'),
|
|
22
24
|
});
|
|
23
25
|
await state.init();
|
|
24
26
|
const motiaServer = await (0, core_1.createServer)(lockedData, eventManager, state);
|
|
25
27
|
const motiaEventManager = (0, core_1.createStepHandlers)(lockedData, eventManager, state);
|
|
26
28
|
const watcher = (0, dev_watchers_1.createDevWatchers)(lockedData, motiaServer, motiaEventManager, motiaServer.cronManager);
|
|
27
29
|
watcher.init();
|
|
30
|
+
(0, state_endpoints_1.stateEndpoints)(motiaServer, state);
|
|
28
31
|
motiaServer.server.listen(port);
|
|
29
32
|
console.log('🚀 Server ready and listening on port', port);
|
|
30
33
|
console.log(`🔗 Open http://localhost:${port}/ to open workbench 🛠️`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motia",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"motia": "dist/src/cli.js"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"inquirer": "^12.4.1",
|
|
15
15
|
"ts-node": "^10.9.2",
|
|
16
16
|
"yaml": "^2.7.0",
|
|
17
|
-
"@motiadev/core": "0.0.
|
|
18
|
-
"@motiadev/workbench": "0.0.
|
|
17
|
+
"@motiadev/core": "0.0.28",
|
|
18
|
+
"@motiadev/workbench": "0.0.28"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/figlet": "^1.7.0",
|