@motiadev/core 0.5.5-beta.114-291584 → 0.5.5-beta.114-384584
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/printer.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class Printer {
|
|
|
21
21
|
printStreamCreated(stream: Stream): void;
|
|
22
22
|
printStreamUpdated(stream: Stream): void;
|
|
23
23
|
printStreamRemoved(stream: Stream): void;
|
|
24
|
+
printInvalidEmitConfiguration(step: Step, emit: string): void;
|
|
24
25
|
printInvalidSchema(topic: string, step: Step[]): void;
|
|
25
26
|
printValidationError(stepPath: string, validationError: ValidationError): void;
|
|
26
27
|
getRelativePath(filePath: string): string;
|
package/dist/src/printer.js
CHANGED
|
@@ -17,6 +17,7 @@ const updated = colors_1.default.yellow('➜ [UPDATED]');
|
|
|
17
17
|
const removed = colors_1.default.red('➜ [REMOVED]');
|
|
18
18
|
const invalidEmit = colors_1.default.red('➜ [INVALID EMIT]');
|
|
19
19
|
const error = colors_1.default.red('[ERROR]');
|
|
20
|
+
const warning = colors_1.default.yellow('[WARNING]');
|
|
20
21
|
class Printer {
|
|
21
22
|
constructor(baseDir) {
|
|
22
23
|
this.baseDir = baseDir;
|
|
@@ -58,6 +59,9 @@ class Printer {
|
|
|
58
59
|
printStreamRemoved(stream) {
|
|
59
60
|
console.log(`${removed} ${streamTag} ${this.getStreamPath(stream)} removed`);
|
|
60
61
|
}
|
|
62
|
+
printInvalidEmitConfiguration(step, emit) {
|
|
63
|
+
console.log(`${warning} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} emits to ${colors_1.default.yellow(emit)}, but there is no subscriber defined`);
|
|
64
|
+
}
|
|
61
65
|
printInvalidSchema(topic, step) {
|
|
62
66
|
console.log(`${error} Topic ${colors_1.default.bold(colors_1.default.blue(topic))} has incompatible schemas in the following steps:`);
|
|
63
67
|
step.forEach((step) => {
|
|
@@ -12,7 +12,7 @@ const generateTypesString = (handlers, streams) => {
|
|
|
12
12
|
*
|
|
13
13
|
* Consider adding this file to .prettierignore and eslint ignore.
|
|
14
14
|
*/
|
|
15
|
-
import { EventHandler, ApiRouteHandler, ApiResponse,
|
|
15
|
+
import { EventHandler, ApiRouteHandler, ApiResponse, CronHandler, MotiaStream } from 'motia'
|
|
16
16
|
|
|
17
17
|
declare module 'motia' {
|
|
18
18
|
interface FlowContextStateStreams {
|
|
@@ -22,7 +22,7 @@ declare module 'motia' {
|
|
|
22
22
|
.trim()}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
interface Handlers {
|
|
26
26
|
${Object.entries(handlers)
|
|
27
27
|
.map(([key, { type, generics }]) => `'${key}': ${type}<${generics.join(', ')}>`)
|
|
28
28
|
.join('\n ')
|
|
@@ -37,7 +37,15 @@ const generateTypesFromSteps = (steps, printer) => {
|
|
|
37
37
|
const topicsSchemas = {};
|
|
38
38
|
const topicsSteps = {};
|
|
39
39
|
for (const step of steps) {
|
|
40
|
-
if ((0, guards_1.isEventStep)(step)
|
|
40
|
+
if ((0, guards_1.isEventStep)(step)) {
|
|
41
|
+
if (!step.config.input) {
|
|
42
|
+
for (const topic of step.config.subscribes) {
|
|
43
|
+
if (!topics[topic]) {
|
|
44
|
+
topics[topic] = 'never';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
41
49
|
for (const topic of step.config.subscribes) {
|
|
42
50
|
const existingSchema = topicsSchemas[topic];
|
|
43
51
|
topicsSteps[topic] = topicsSteps[topic] ?? [];
|
|
@@ -56,7 +64,7 @@ const generateTypesFromSteps = (steps, printer) => {
|
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
|
-
const generateEmitData = (emit) => {
|
|
67
|
+
const generateEmitData = (emit, step) => {
|
|
60
68
|
const emits = emit
|
|
61
69
|
.reduce((acc, emit) => {
|
|
62
70
|
const topic = typeof emit === 'string' ? emit : emit.topic;
|
|
@@ -64,13 +72,16 @@ const generateTypesFromSteps = (steps, printer) => {
|
|
|
64
72
|
if (topicType) {
|
|
65
73
|
acc.push(`{ topic: '${topic.replace(/'/g, "\\'")}'; data: ${topicType} }`);
|
|
66
74
|
}
|
|
75
|
+
else {
|
|
76
|
+
printer.printInvalidEmitConfiguration(step, topic);
|
|
77
|
+
}
|
|
67
78
|
return acc;
|
|
68
79
|
}, [])
|
|
69
80
|
.join(' | ');
|
|
70
81
|
return emits.length === 0 ? 'never' : emits;
|
|
71
82
|
};
|
|
72
83
|
for (const step of steps) {
|
|
73
|
-
const emits = 'emits' in step.config ? generateEmitData(step.config.emits) : 'never';
|
|
84
|
+
const emits = 'emits' in step.config ? generateEmitData(step.config.emits, step) : 'never';
|
|
74
85
|
if ((0, guards_1.isEventStep)(step)) {
|
|
75
86
|
const input = step.config.input ? (0, generate_type_from_schema_1.generateTypeFromSchema)(step.config.input) : 'never';
|
|
76
87
|
handlers[step.config.name] = { type: 'EventHandler', generics: [input, emits] };
|
package/dist/src/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.5.5-beta.114-
|
|
5
|
+
"version": "0.5.5-beta.114-384584",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"body-parser": "^1.20.3",
|