@synergenius/flow-weaver 0.29.1 → 0.30.0
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/cli/commands/compile.js +40 -38
- package/dist/cli/commands/dev.d.ts +4 -0
- package/dist/cli/commands/dev.js +35 -3
- package/dist/cli/flow-weaver.mjs +70 -43
- package/dist/cli/index.js +2 -0
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +1 -1
- package/package.json +1 -1
|
@@ -137,48 +137,50 @@ export async function compileCommand(input, options = {}) {
|
|
|
137
137
|
errorCount++;
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
|
-
// Validate the AST
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
140
|
+
// Validate the AST
|
|
141
|
+
const validation = validator.validate(parseResult.ast, { strictMode: strict });
|
|
142
|
+
// In strict mode, validation errors block compilation
|
|
143
|
+
if (strict && validation.errors.length > 0) {
|
|
144
|
+
logger.error(` ${fileName}`);
|
|
145
|
+
validation.errors.forEach((err) => {
|
|
146
|
+
const friendly = getFriendlyError(err);
|
|
147
|
+
if (friendly) {
|
|
148
|
+
const loc = err.location ? `[line ${err.location.line}] ` : '';
|
|
149
|
+
logger.error(` ${loc}${friendly.title}: ${friendly.explanation}`);
|
|
150
|
+
logger.warn(` How to fix: ${friendly.fix}`);
|
|
151
|
+
if (err.docUrl) {
|
|
152
|
+
logger.warn(` See: ${err.docUrl}`);
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
logger.error(msg);
|
|
161
|
-
if (err.docUrl) {
|
|
162
|
-
logger.warn(` See: ${err.docUrl}`);
|
|
163
|
-
}
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
let msg = ` ${err.message}`;
|
|
157
|
+
if (err.node) {
|
|
158
|
+
msg += ` (node: ${err.node})`;
|
|
164
159
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
if (validation.warnings.length > 0 && verbose) {
|
|
170
|
-
validation.warnings.forEach((warn) => {
|
|
171
|
-
const friendly = getFriendlyError(warn);
|
|
172
|
-
if (friendly) {
|
|
173
|
-
const loc = warn.location ? `[line ${warn.location.line}] ` : '';
|
|
174
|
-
logger.warn(` ${loc}${friendly.title}: ${friendly.explanation}`);
|
|
175
|
-
logger.warn(` How to fix: ${friendly.fix}`);
|
|
160
|
+
logger.error(msg);
|
|
161
|
+
if (err.docUrl) {
|
|
162
|
+
logger.warn(` See: ${err.docUrl}`);
|
|
176
163
|
}
|
|
177
|
-
|
|
178
|
-
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
errorCount++;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
// Always show validation warnings (not just in verbose mode)
|
|
170
|
+
if (validation.warnings.length > 0) {
|
|
171
|
+
validation.warnings.forEach((warn) => {
|
|
172
|
+
const friendly = getFriendlyError(warn);
|
|
173
|
+
if (friendly) {
|
|
174
|
+
const loc = warn.location ? `[line ${warn.location.line}] ` : '';
|
|
175
|
+
logger.warn(` ${loc}${friendly.title}: ${friendly.explanation}`);
|
|
176
|
+
if (verbose) {
|
|
177
|
+
logger.warn(` How to fix: ${friendly.fix}`);
|
|
179
178
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
logger.warn(` ${warn.message}`);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
182
184
|
}
|
|
183
185
|
// Read original source
|
|
184
186
|
const sourceCode = fs.readFileSync(file, 'utf8');
|
|
@@ -13,6 +13,10 @@ export interface DevOptions extends DevModeOptions {
|
|
|
13
13
|
clean?: boolean;
|
|
14
14
|
/** Compilation target (default: typescript in-place) */
|
|
15
15
|
target?: string;
|
|
16
|
+
/** Mock config for built-in nodes as JSON string */
|
|
17
|
+
mocks?: string;
|
|
18
|
+
/** Path to JSON file with mock config */
|
|
19
|
+
mocksFile?: string;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* Dev command: watch + compile + run in a single loop.
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -52,11 +52,38 @@ function parseParams(options) {
|
|
|
52
52
|
}
|
|
53
53
|
return {};
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse mock config from --mocks or --mocks-file.
|
|
57
|
+
*/
|
|
58
|
+
function parseMocks(options) {
|
|
59
|
+
if (options.mocks) {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(options.mocks);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new Error(`Invalid JSON in --mocks: ${options.mocks}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (options.mocksFile) {
|
|
68
|
+
const mocksFilePath = path.resolve(options.mocksFile);
|
|
69
|
+
if (!fs.existsSync(mocksFilePath)) {
|
|
70
|
+
throw new Error(`Mocks file not found: ${mocksFilePath}`);
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const content = fs.readFileSync(mocksFilePath, 'utf8');
|
|
74
|
+
return JSON.parse(content);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error(`Failed to parse mocks file: ${options.mocksFile}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
55
82
|
/**
|
|
56
83
|
* Run a single compile + execute cycle.
|
|
57
84
|
* Returns true if both compile and run succeeded.
|
|
58
85
|
*/
|
|
59
|
-
async function compileAndRun(filePath, params, options) {
|
|
86
|
+
async function compileAndRun(filePath, params, mocks, options) {
|
|
60
87
|
// Step 1: Compile
|
|
61
88
|
const compileOpts = {
|
|
62
89
|
format: options.format,
|
|
@@ -96,6 +123,7 @@ async function compileAndRun(filePath, params, options) {
|
|
|
96
123
|
workflowName: options.workflow,
|
|
97
124
|
production: options.production ?? false,
|
|
98
125
|
includeTrace: !options.production,
|
|
126
|
+
mocks,
|
|
99
127
|
});
|
|
100
128
|
if (options.json) {
|
|
101
129
|
process.stdout.write(JSON.stringify({
|
|
@@ -143,16 +171,20 @@ export async function devCommand(input, options = {}) {
|
|
|
143
171
|
throw new Error(`Unknown dev target "${options.target}". ${available.length ? `Available: ${available.join(', ')}` : 'No dev mode providers registered. Install a pack that provides one.'}`);
|
|
144
172
|
}
|
|
145
173
|
const params = parseParams(options);
|
|
174
|
+
const mocks = parseMocks(options);
|
|
146
175
|
if (!options.json) {
|
|
147
176
|
logger.section('Dev Mode');
|
|
148
177
|
logger.info(`File: ${path.basename(filePath)}`);
|
|
149
178
|
if (Object.keys(params).length > 0) {
|
|
150
179
|
logger.info(`Params: ${JSON.stringify(params)}`);
|
|
151
180
|
}
|
|
181
|
+
if (mocks) {
|
|
182
|
+
logger.info(`Mocks: ${JSON.stringify(mocks)}`);
|
|
183
|
+
}
|
|
152
184
|
logger.newline();
|
|
153
185
|
}
|
|
154
186
|
// Initial compile + run
|
|
155
|
-
await compileAndRun(filePath, params, options);
|
|
187
|
+
await compileAndRun(filePath, params, mocks, options);
|
|
156
188
|
// If --once, exit after first cycle
|
|
157
189
|
if (options.once) {
|
|
158
190
|
return;
|
|
@@ -173,7 +205,7 @@ export async function devCommand(input, options = {}) {
|
|
|
173
205
|
if (!options.json) {
|
|
174
206
|
cycleSeparator(file);
|
|
175
207
|
}
|
|
176
|
-
await compileAndRun(filePath, params, options);
|
|
208
|
+
await compileAndRun(filePath, params, mocks, options);
|
|
177
209
|
});
|
|
178
210
|
// Handle process termination
|
|
179
211
|
const cleanup = () => {
|
package/dist/cli/flow-weaver.mjs
CHANGED
|
@@ -5987,7 +5987,7 @@ var VERSION;
|
|
|
5987
5987
|
var init_generated_version = __esm({
|
|
5988
5988
|
"src/generated-version.ts"() {
|
|
5989
5989
|
"use strict";
|
|
5990
|
-
VERSION = "0.
|
|
5990
|
+
VERSION = "0.30.0";
|
|
5991
5991
|
}
|
|
5992
5992
|
});
|
|
5993
5993
|
|
|
@@ -47602,45 +47602,45 @@ async function compileCommand(input, options = {}) {
|
|
|
47602
47602
|
errorCount++;
|
|
47603
47603
|
continue;
|
|
47604
47604
|
}
|
|
47605
|
-
|
|
47606
|
-
|
|
47607
|
-
|
|
47608
|
-
|
|
47609
|
-
|
|
47610
|
-
|
|
47611
|
-
|
|
47612
|
-
|
|
47613
|
-
|
|
47614
|
-
|
|
47615
|
-
|
|
47616
|
-
logger.warn(` See: ${err.docUrl}`);
|
|
47617
|
-
}
|
|
47618
|
-
} else {
|
|
47619
|
-
let msg = ` ${err.message}`;
|
|
47620
|
-
if (err.node) {
|
|
47621
|
-
msg += ` (node: ${err.node})`;
|
|
47622
|
-
}
|
|
47623
|
-
logger.error(msg);
|
|
47624
|
-
if (err.docUrl) {
|
|
47625
|
-
logger.warn(` See: ${err.docUrl}`);
|
|
47626
|
-
}
|
|
47605
|
+
const validation = validator.validate(parseResult.ast, { strictMode: strict });
|
|
47606
|
+
if (strict && validation.errors.length > 0) {
|
|
47607
|
+
logger.error(` ${fileName}`);
|
|
47608
|
+
validation.errors.forEach((err) => {
|
|
47609
|
+
const friendly = getFriendlyError(err);
|
|
47610
|
+
if (friendly) {
|
|
47611
|
+
const loc = err.location ? `[line ${err.location.line}] ` : "";
|
|
47612
|
+
logger.error(` ${loc}${friendly.title}: ${friendly.explanation}`);
|
|
47613
|
+
logger.warn(` How to fix: ${friendly.fix}`);
|
|
47614
|
+
if (err.docUrl) {
|
|
47615
|
+
logger.warn(` See: ${err.docUrl}`);
|
|
47627
47616
|
}
|
|
47628
|
-
}
|
|
47629
|
-
|
|
47630
|
-
|
|
47631
|
-
|
|
47632
|
-
|
|
47633
|
-
|
|
47634
|
-
|
|
47635
|
-
|
|
47636
|
-
|
|
47637
|
-
|
|
47617
|
+
} else {
|
|
47618
|
+
let msg = ` ${err.message}`;
|
|
47619
|
+
if (err.node) {
|
|
47620
|
+
msg += ` (node: ${err.node})`;
|
|
47621
|
+
}
|
|
47622
|
+
logger.error(msg);
|
|
47623
|
+
if (err.docUrl) {
|
|
47624
|
+
logger.warn(` See: ${err.docUrl}`);
|
|
47625
|
+
}
|
|
47626
|
+
}
|
|
47627
|
+
});
|
|
47628
|
+
errorCount++;
|
|
47629
|
+
continue;
|
|
47630
|
+
}
|
|
47631
|
+
if (validation.warnings.length > 0) {
|
|
47632
|
+
validation.warnings.forEach((warn) => {
|
|
47633
|
+
const friendly = getFriendlyError(warn);
|
|
47634
|
+
if (friendly) {
|
|
47635
|
+
const loc = warn.location ? `[line ${warn.location.line}] ` : "";
|
|
47636
|
+
logger.warn(` ${loc}${friendly.title}: ${friendly.explanation}`);
|
|
47637
|
+
if (verbose) {
|
|
47638
47638
|
logger.warn(` How to fix: ${friendly.fix}`);
|
|
47639
|
-
} else {
|
|
47640
|
-
logger.warn(` ${warn.message}`);
|
|
47641
47639
|
}
|
|
47642
|
-
}
|
|
47643
|
-
|
|
47640
|
+
} else {
|
|
47641
|
+
logger.warn(` ${warn.message}`);
|
|
47642
|
+
}
|
|
47643
|
+
});
|
|
47644
47644
|
}
|
|
47645
47645
|
const sourceCode = fs11.readFileSync(file, "utf8");
|
|
47646
47646
|
const result = generateInPlace(sourceCode, parseResult.ast, { production, moduleFormat, sourceFile: file, skipParamReturns: clean });
|
|
@@ -60762,7 +60762,29 @@ function parseParams(options) {
|
|
|
60762
60762
|
}
|
|
60763
60763
|
return {};
|
|
60764
60764
|
}
|
|
60765
|
-
|
|
60765
|
+
function parseMocks(options) {
|
|
60766
|
+
if (options.mocks) {
|
|
60767
|
+
try {
|
|
60768
|
+
return JSON.parse(options.mocks);
|
|
60769
|
+
} catch {
|
|
60770
|
+
throw new Error(`Invalid JSON in --mocks: ${options.mocks}`);
|
|
60771
|
+
}
|
|
60772
|
+
}
|
|
60773
|
+
if (options.mocksFile) {
|
|
60774
|
+
const mocksFilePath = path21.resolve(options.mocksFile);
|
|
60775
|
+
if (!fs21.existsSync(mocksFilePath)) {
|
|
60776
|
+
throw new Error(`Mocks file not found: ${mocksFilePath}`);
|
|
60777
|
+
}
|
|
60778
|
+
try {
|
|
60779
|
+
const content = fs21.readFileSync(mocksFilePath, "utf8");
|
|
60780
|
+
return JSON.parse(content);
|
|
60781
|
+
} catch {
|
|
60782
|
+
throw new Error(`Failed to parse mocks file: ${options.mocksFile}`);
|
|
60783
|
+
}
|
|
60784
|
+
}
|
|
60785
|
+
return void 0;
|
|
60786
|
+
}
|
|
60787
|
+
async function compileAndRun(filePath, params, mocks, options) {
|
|
60766
60788
|
const compileOpts = {
|
|
60767
60789
|
format: options.format,
|
|
60768
60790
|
clean: options.clean
|
|
@@ -60796,7 +60818,8 @@ async function compileAndRun(filePath, params, options) {
|
|
|
60796
60818
|
const result = await executeWorkflowFromFile(filePath, params, {
|
|
60797
60819
|
workflowName: options.workflow,
|
|
60798
60820
|
production: options.production ?? false,
|
|
60799
|
-
includeTrace: !options.production
|
|
60821
|
+
includeTrace: !options.production,
|
|
60822
|
+
mocks
|
|
60800
60823
|
});
|
|
60801
60824
|
if (options.json) {
|
|
60802
60825
|
process.stdout.write(
|
|
@@ -60844,15 +60867,19 @@ async function devCommand(input, options = {}) {
|
|
|
60844
60867
|
);
|
|
60845
60868
|
}
|
|
60846
60869
|
const params = parseParams(options);
|
|
60870
|
+
const mocks = parseMocks(options);
|
|
60847
60871
|
if (!options.json) {
|
|
60848
60872
|
logger.section("Dev Mode");
|
|
60849
60873
|
logger.info(`File: ${path21.basename(filePath)}`);
|
|
60850
60874
|
if (Object.keys(params).length > 0) {
|
|
60851
60875
|
logger.info(`Params: ${JSON.stringify(params)}`);
|
|
60852
60876
|
}
|
|
60877
|
+
if (mocks) {
|
|
60878
|
+
logger.info(`Mocks: ${JSON.stringify(mocks)}`);
|
|
60879
|
+
}
|
|
60853
60880
|
logger.newline();
|
|
60854
60881
|
}
|
|
60855
|
-
await compileAndRun(filePath, params, options);
|
|
60882
|
+
await compileAndRun(filePath, params, mocks, options);
|
|
60856
60883
|
if (options.once) {
|
|
60857
60884
|
return;
|
|
60858
60885
|
}
|
|
@@ -60870,7 +60897,7 @@ async function devCommand(input, options = {}) {
|
|
|
60870
60897
|
if (!options.json) {
|
|
60871
60898
|
cycleSeparator(file);
|
|
60872
60899
|
}
|
|
60873
|
-
await compileAndRun(filePath, params, options);
|
|
60900
|
+
await compileAndRun(filePath, params, mocks, options);
|
|
60874
60901
|
});
|
|
60875
60902
|
const cleanup = () => {
|
|
60876
60903
|
if (!options.json) {
|
|
@@ -88933,7 +88960,7 @@ function parseIntStrict(value) {
|
|
|
88933
88960
|
// src/cli/index.ts
|
|
88934
88961
|
init_logger();
|
|
88935
88962
|
init_error_utils();
|
|
88936
|
-
var version2 = true ? "0.
|
|
88963
|
+
var version2 = true ? "0.30.0" : "0.0.0-dev";
|
|
88937
88964
|
var program2 = new Command();
|
|
88938
88965
|
program2.name("fw").description("Flow Weaver Annotations - Compile and validate workflow files").option("-v, --version", "Output the current version").option("--no-color", "Disable colors").option("--color", "Force colors").on("option:version", () => {
|
|
88939
88966
|
logger.banner(version2);
|
|
@@ -89009,7 +89036,7 @@ program2.command("watch <input>").description("Watch workflow files and recompil
|
|
|
89009
89036
|
if (options.workflow) options.workflowName = options.workflow;
|
|
89010
89037
|
await watchCommand2(input, options);
|
|
89011
89038
|
}));
|
|
89012
|
-
program2.command("dev <input>").description("Watch, compile, and run workflow on changes").option("--params <json>", "Input parameters as JSON string").option("--params-file <path>", "Path to JSON file with input parameters").option("-w, --workflow <name>", "Specific workflow name to run").option("-p, --production", "Run in production mode (no trace events)", false).option("-f, --format <format>", "Module format: esm, cjs, or auto", "auto").option("--clean", "Omit redundant @param/@returns annotations", false).option("--once", "Run once then exit", false).option("--json", "Output result as JSON", false).option("--target <target>", "Compilation target (default: typescript)").action(wrapAction(async (input, options) => {
|
|
89039
|
+
program2.command("dev <input>").description("Watch, compile, and run workflow on changes").option("--params <json>", "Input parameters as JSON string").option("--params-file <path>", "Path to JSON file with input parameters").option("-w, --workflow <name>", "Specific workflow name to run").option("-p, --production", "Run in production mode (no trace events)", false).option("-f, --format <format>", "Module format: esm, cjs, or auto", "auto").option("--clean", "Omit redundant @param/@returns annotations", false).option("--once", "Run once then exit", false).option("--json", "Output result as JSON", false).option("--target <target>", "Compilation target (default: typescript)").option("--mocks <json>", "Mock config for built-in nodes (events, invocations, agents, fast) as JSON").option("--mocks-file <path>", "Path to JSON file with mock config for built-in nodes").action(wrapAction(async (input, options) => {
|
|
89013
89040
|
const { devCommand: devCommand2 } = await Promise.resolve().then(() => (init_dev(), dev_exports));
|
|
89014
89041
|
await devCommand2(input, options);
|
|
89015
89042
|
}));
|
package/dist/cli/index.js
CHANGED
|
@@ -223,6 +223,8 @@ program
|
|
|
223
223
|
.option('--once', 'Run once then exit', false)
|
|
224
224
|
.option('--json', 'Output result as JSON', false)
|
|
225
225
|
.option('--target <target>', 'Compilation target (default: typescript)')
|
|
226
|
+
.option('--mocks <json>', 'Mock config for built-in nodes (events, invocations, agents, fast) as JSON')
|
|
227
|
+
.option('--mocks-file <path>', 'Path to JSON file with mock config for built-in nodes')
|
|
226
228
|
.action(wrapAction(async (input, options) => {
|
|
227
229
|
const { devCommand } = await import('./commands/dev.js');
|
|
228
230
|
await devCommand(input, options);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.30.0";
|
|
2
2
|
//# sourceMappingURL=generated-version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synergenius/flow-weaver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"description": "Flow Weaver: deterministic TypeScript workflow compiler. Define workflows with JSDoc annotations, compile to standalone functions with zero runtime dependencies.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|