@motiadev/core 0.0.17 → 0.0.19
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.
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApiRouteConfig, StepHandler } from '../types'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
export const config: ApiRouteConfig = {
|
|
5
|
+
type: 'api',
|
|
6
|
+
name: 'Event Emitter',
|
|
7
|
+
description: 'System endpoint for emitting events',
|
|
8
|
+
path: '/emit',
|
|
9
|
+
method: 'POST',
|
|
10
|
+
emits: [], // Dynamic emissions
|
|
11
|
+
flows: ['_system'],
|
|
12
|
+
bodySchema: z.object({
|
|
13
|
+
type: z.string(),
|
|
14
|
+
data: z.record(z.unknown()),
|
|
15
|
+
}),
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const handler: StepHandler<typeof config> = async (req, { emit, logger }) => {
|
|
19
|
+
const { type, data } = req.body
|
|
20
|
+
|
|
21
|
+
logger.info('[Event Emitter] Emitting event', { type, data })
|
|
22
|
+
await emit({ type, data })
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
status: 200,
|
|
26
|
+
body: { success: true, emitted: { type, data } },
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/src/steps/index.js
CHANGED
|
@@ -8,7 +8,8 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const emit_step_1 = require("./emit.step");
|
|
9
9
|
exports.systemSteps = [
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
// NOTE: this is the path of the file inside the dist folder
|
|
12
|
+
filePath: path_1.default.join(__dirname, 'emit.step.js'),
|
|
12
13
|
version: '1',
|
|
13
14
|
config: emit_step_1.config,
|
|
14
15
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.19",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"body-parser": "^1.20.3",
|
|
7
7
|
"express": "^4.21.2",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"move:python": "cp src/python/*.py dist/src/python",
|
|
28
28
|
"move:rb": "cp src/ruby/*.rb dist/src/ruby",
|
|
29
|
-
"
|
|
29
|
+
"move:steps": "cp src/steps/*.ts dist/src/steps",
|
|
30
|
+
"build": "rm -rf dist && tsc && npm run move:python && npm run move:rb && npm run move:steps",
|
|
30
31
|
"lint": "eslint --config ../../eslint.config.js",
|
|
31
32
|
"watch": "tsc --watch",
|
|
32
33
|
"test": "jest"
|