@motiadev/core 0.13.1-beta.163-010752 → 0.13.2-beta.163
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/pretty-print.js +15 -15
- package/dist/src/printer.js +45 -45
- package/package.json +2 -2
package/dist/src/pretty-print.js
CHANGED
|
@@ -4,26 +4,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.prettyPrint = void 0;
|
|
7
|
-
const
|
|
8
|
-
const stepTag = (step) =>
|
|
9
|
-
const timestampTag = (timestamp) =>
|
|
10
|
-
const traceIdTag = (traceId) =>
|
|
7
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
+
const stepTag = (step) => picocolors_1.default.bold(picocolors_1.default.cyan(step));
|
|
9
|
+
const timestampTag = (timestamp) => picocolors_1.default.gray(timestamp);
|
|
10
|
+
const traceIdTag = (traceId) => picocolors_1.default.gray(traceId);
|
|
11
11
|
const levelTags = {
|
|
12
|
-
error:
|
|
13
|
-
info:
|
|
14
|
-
warn:
|
|
15
|
-
debug:
|
|
16
|
-
trace:
|
|
12
|
+
error: picocolors_1.default.red('[ERROR]'),
|
|
13
|
+
info: picocolors_1.default.blue('[INFO]'),
|
|
14
|
+
warn: picocolors_1.default.yellow('[WARN]'),
|
|
15
|
+
debug: picocolors_1.default.gray('[DEBUG]'),
|
|
16
|
+
trace: picocolors_1.default.gray('[TRACE]'),
|
|
17
17
|
};
|
|
18
|
-
const numericTag = (value) =>
|
|
19
|
-
const stringTag = (value) =>
|
|
20
|
-
const booleanTag = (value) =>
|
|
21
|
-
const arrayBrackets = ['[', ']'].map((s) =>
|
|
22
|
-
const objectBrackets = ['{', '}'].map((s) =>
|
|
18
|
+
const numericTag = (value) => picocolors_1.default.green(value);
|
|
19
|
+
const stringTag = (value) => picocolors_1.default.cyan(value);
|
|
20
|
+
const booleanTag = (value) => picocolors_1.default.blue(value);
|
|
21
|
+
const arrayBrackets = ['[', ']'].map((s) => picocolors_1.default.gray(s));
|
|
22
|
+
const objectBrackets = ['{', '}'].map((s) => picocolors_1.default.gray(s));
|
|
23
23
|
const prettyPrintObject = (obj, depth = 0, parentIsLast = false, prefix = '') => {
|
|
24
24
|
const tab = prefix + (depth === 0 ? '' : parentIsLast ? '│ ' : '│ ');
|
|
25
25
|
if (depth > 2) {
|
|
26
|
-
return `${tab} └ ${
|
|
26
|
+
return `${tab} └ ${picocolors_1.default.gray('[...]')}`;
|
|
27
27
|
}
|
|
28
28
|
const entries = Object.entries(obj);
|
|
29
29
|
return entries
|
package/dist/src/printer.js
CHANGED
|
@@ -4,23 +4,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NoPrinter = exports.Printer = void 0;
|
|
7
|
-
const colors_1 = __importDefault(require("colors"));
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
9
9
|
const guards_1 = require("./guards");
|
|
10
|
-
const stepTag =
|
|
11
|
-
const flowTag =
|
|
12
|
-
const streamTag =
|
|
13
|
-
const registered =
|
|
14
|
-
const building =
|
|
15
|
-
const built =
|
|
16
|
-
const updated =
|
|
17
|
-
const removed =
|
|
18
|
-
const invalidEmit =
|
|
19
|
-
const error =
|
|
20
|
-
const warning =
|
|
21
|
-
const warnIcon =
|
|
22
|
-
const infoIcon =
|
|
23
|
-
const errorIcon =
|
|
10
|
+
const stepTag = picocolors_1.default.bold(picocolors_1.default.magenta('Step'));
|
|
11
|
+
const flowTag = picocolors_1.default.bold(picocolors_1.default.blue('Flow'));
|
|
12
|
+
const streamTag = picocolors_1.default.bold(picocolors_1.default.green('Stream'));
|
|
13
|
+
const registered = picocolors_1.default.green('➜ [REGISTERED]');
|
|
14
|
+
const building = picocolors_1.default.yellow('⚡ [BUILDING]');
|
|
15
|
+
const built = picocolors_1.default.green('✓ [BUILT]');
|
|
16
|
+
const updated = picocolors_1.default.yellow('➜ [UPDATED]');
|
|
17
|
+
const removed = picocolors_1.default.red('➜ [REMOVED]');
|
|
18
|
+
const invalidEmit = picocolors_1.default.red('➜ [INVALID EMIT]');
|
|
19
|
+
const error = picocolors_1.default.red('[ERROR]');
|
|
20
|
+
const warning = picocolors_1.default.yellow('[WARNING]');
|
|
21
|
+
const warnIcon = picocolors_1.default.yellow('⚠');
|
|
22
|
+
const infoIcon = picocolors_1.default.blue('ℹ');
|
|
23
|
+
const errorIcon = picocolors_1.default.red('✖');
|
|
24
24
|
class Printer {
|
|
25
25
|
constructor(baseDir) {
|
|
26
26
|
this.baseDir = baseDir;
|
|
@@ -33,27 +33,27 @@ class Printer {
|
|
|
33
33
|
this.removed = removed;
|
|
34
34
|
}
|
|
35
35
|
printEventInputValidationError(emit, details) {
|
|
36
|
-
const emitPath =
|
|
36
|
+
const emitPath = picocolors_1.default.bold(picocolors_1.default.cyan(`Emit ${emit.topic}`));
|
|
37
37
|
console.log(`${warnIcon} ${warning} ${emitPath} validation issues:`);
|
|
38
38
|
const hasAny = details.missingFields?.length || details.extraFields?.length || details.typeMismatches?.length;
|
|
39
39
|
if (!hasAny) {
|
|
40
|
-
console.log(`${
|
|
41
|
-
console.log(`${
|
|
40
|
+
console.log(`${picocolors_1.default.yellow('│')} No issues found.`);
|
|
41
|
+
console.log(`${picocolors_1.default.yellow('└─')} Validation passed.`);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
if (details.missingFields?.length) {
|
|
45
|
-
console.log(`${
|
|
45
|
+
console.log(`${picocolors_1.default.yellow('│')} ${picocolors_1.default.yellow(`⚠ Missing fields: ${details.missingFields.join(', ')}`)}`);
|
|
46
46
|
}
|
|
47
47
|
if (details.extraFields?.length) {
|
|
48
|
-
console.log(`${
|
|
48
|
+
console.log(`${picocolors_1.default.yellow('│')} ${picocolors_1.default.yellow(`⚠ Extra fields: ${details.extraFields.join(', ')}`)}`);
|
|
49
49
|
}
|
|
50
50
|
if (details.typeMismatches?.length) {
|
|
51
|
-
console.log(`${
|
|
51
|
+
console.log(`${picocolors_1.default.yellow('│')} ${picocolors_1.default.yellow(`⚠ Type mismatches: ${details.typeMismatches.join(', ')}`)}`);
|
|
52
52
|
}
|
|
53
|
-
console.log(`${
|
|
53
|
+
console.log(`${picocolors_1.default.yellow('└─')} ${picocolors_1.default.yellow('Payload does not match schema.')}`);
|
|
54
54
|
}
|
|
55
55
|
printInvalidEmit(step, emit) {
|
|
56
|
-
console.log(`${invalidEmit} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} tried to emit an event not defined in the step config: ${
|
|
56
|
+
console.log(`${invalidEmit} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} tried to emit an event not defined in the step config: ${picocolors_1.default.yellow(emit)}`);
|
|
57
57
|
}
|
|
58
58
|
printStepCreated(step) {
|
|
59
59
|
console.log(`${registered} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} registered`);
|
|
@@ -65,13 +65,13 @@ class Printer {
|
|
|
65
65
|
console.log(`${removed} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} removed`);
|
|
66
66
|
}
|
|
67
67
|
printFlowCreated(flowName) {
|
|
68
|
-
console.log(`${registered} ${flowTag} ${
|
|
68
|
+
console.log(`${registered} ${flowTag} ${picocolors_1.default.bold(picocolors_1.default.cyan(flowName))} registered`);
|
|
69
69
|
}
|
|
70
70
|
printFlowUpdated(flowName) {
|
|
71
|
-
console.log(`${updated} ${flowTag} ${
|
|
71
|
+
console.log(`${updated} ${flowTag} ${picocolors_1.default.bold(picocolors_1.default.cyan(flowName))} updated`);
|
|
72
72
|
}
|
|
73
73
|
printFlowRemoved(flowName) {
|
|
74
|
-
console.log(`${removed} ${flowTag} ${
|
|
74
|
+
console.log(`${removed} ${flowTag} ${picocolors_1.default.bold(picocolors_1.default.cyan(flowName))} removed`);
|
|
75
75
|
}
|
|
76
76
|
printStreamCreated(stream) {
|
|
77
77
|
console.log(`${registered} ${streamTag} ${this.getStreamPath(stream)} registered`);
|
|
@@ -83,60 +83,60 @@ class Printer {
|
|
|
83
83
|
console.log(`${removed} ${streamTag} ${this.getStreamPath(stream)} removed`);
|
|
84
84
|
}
|
|
85
85
|
printInvalidEmitConfiguration(step, emit) {
|
|
86
|
-
console.log(`${warnIcon} ${warning} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} emits to ${
|
|
86
|
+
console.log(`${warnIcon} ${warning} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} emits to ${picocolors_1.default.yellow(emit)}, but there is no subscriber defined`);
|
|
87
87
|
}
|
|
88
88
|
printInvalidSchema(topic, step) {
|
|
89
|
-
console.log(`${error} Topic ${
|
|
89
|
+
console.log(`${error} Topic ${picocolors_1.default.bold(picocolors_1.default.blue(topic))} has incompatible schemas in the following steps:`);
|
|
90
90
|
step.forEach((step) => {
|
|
91
|
-
console.log(`${
|
|
91
|
+
console.log(`${picocolors_1.default.red(' ✖')} ${this.getStepPath(step)}`);
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
printValidationError(stepPath, validationError) {
|
|
95
95
|
const relativePath = this.getRelativePath(stepPath);
|
|
96
|
-
console.log(`${error} ${
|
|
96
|
+
console.log(`${error} ${picocolors_1.default.bold(picocolors_1.default.cyan(relativePath))}`);
|
|
97
97
|
validationError.errors?.forEach((error) => {
|
|
98
98
|
if (error.path) {
|
|
99
|
-
console.log(`${
|
|
99
|
+
console.log(`${picocolors_1.default.red('│')} ${picocolors_1.default.yellow(`✖ ${error.path}`)}: ${error.message}`);
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
console.log(`${
|
|
102
|
+
console.log(`${picocolors_1.default.red('│')} ${picocolors_1.default.yellow('✖')} ${error.message}`);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
-
console.log(`${
|
|
105
|
+
console.log(`${picocolors_1.default.red('└─')} ${picocolors_1.default.red(validationError.error)} `);
|
|
106
106
|
}
|
|
107
107
|
getRelativePath(filePath) {
|
|
108
108
|
return path_1.default.relative(this.baseDir, filePath);
|
|
109
109
|
}
|
|
110
110
|
getStepType(step) {
|
|
111
111
|
if ((0, guards_1.isApiStep)(step))
|
|
112
|
-
return
|
|
112
|
+
return picocolors_1.default.gray('(API)');
|
|
113
113
|
if ((0, guards_1.isEventStep)(step))
|
|
114
|
-
return
|
|
114
|
+
return picocolors_1.default.gray('(Event)');
|
|
115
115
|
if ((0, guards_1.isCronStep)(step))
|
|
116
|
-
return
|
|
116
|
+
return picocolors_1.default.gray('(Cron)');
|
|
117
117
|
if ((0, guards_1.isNoopStep)(step))
|
|
118
|
-
return
|
|
119
|
-
return
|
|
118
|
+
return picocolors_1.default.gray('(Noop)');
|
|
119
|
+
return picocolors_1.default.gray('(Unknown)');
|
|
120
120
|
}
|
|
121
121
|
getStepPath(step) {
|
|
122
122
|
const stepPath = this.getRelativePath(step.filePath);
|
|
123
|
-
return
|
|
123
|
+
return picocolors_1.default.bold(picocolors_1.default.cyan(stepPath));
|
|
124
124
|
}
|
|
125
125
|
getStreamPath(stream) {
|
|
126
126
|
const streamPath = this.getRelativePath(stream.filePath);
|
|
127
|
-
return
|
|
127
|
+
return picocolors_1.default.bold(picocolors_1.default.magenta(streamPath));
|
|
128
128
|
}
|
|
129
129
|
printPluginLog(message) {
|
|
130
|
-
const pluginTag =
|
|
130
|
+
const pluginTag = picocolors_1.default.bold(picocolors_1.default.cyan('[motia-plugins]'));
|
|
131
131
|
console.log(`${infoIcon} ${pluginTag} ${message}`);
|
|
132
132
|
}
|
|
133
133
|
printPluginWarn(message) {
|
|
134
|
-
const pluginTag =
|
|
135
|
-
console.warn(`${warnIcon} ${pluginTag} ${
|
|
134
|
+
const pluginTag = picocolors_1.default.bold(picocolors_1.default.cyan('[motia-plugins]'));
|
|
135
|
+
console.warn(`${warnIcon} ${pluginTag} ${picocolors_1.default.yellow(message)}`);
|
|
136
136
|
}
|
|
137
137
|
printPluginError(message, ...args) {
|
|
138
|
-
const pluginTag =
|
|
139
|
-
console.error(`${errorIcon} ${pluginTag} ${
|
|
138
|
+
const pluginTag = picocolors_1.default.bold(picocolors_1.default.cyan('[motia-plugins]'));
|
|
139
|
+
console.error(`${errorIcon} ${pluginTag} ${picocolors_1.default.red(message)}`, ...args);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
exports.Printer = Printer;
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
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.13.
|
|
5
|
+
"version": "0.13.2-beta.163",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"ajv": "^8.17.1",
|
|
9
9
|
"body-parser": "^1.20.3",
|
|
10
|
-
"
|
|
10
|
+
"picocolors": "^1.1.1",
|
|
11
11
|
"dotenv": "^16.4.7",
|
|
12
12
|
"express": "^4.21.2",
|
|
13
13
|
"node-cron": "^3.0.3",
|