Skip to content

Commit cbdba93

Browse files
committed
flatten spec before storing to avoid circular reference error
1 parent 2d15944 commit cbdba93

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/flowtest-electron/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"chokidar": "^3.6.0",
2929
"dotenv": "^16.4.5",
3030
"electron-store": "^8.1.0",
31+
"flatted": "^3.3.1",
3132
"fs": "^0.0.1-security",
3233
"json-refs": "^3.0.15",
3334
"langchain": "^0.1.28",

packages/flowtest-electron/src/ipc/collection.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const deleteFile = require('../utils/filemanager/deletefile');
1616
const { flowDataToReadableData, readableDataToFlowData } = require('../utils/parser');
1717
const readFile = require('../utils/filemanager/readfile');
1818
const FlowtestAI = require('../utils/flowtestai');
19+
const { stringify, parse } = require('flatted');
1920

2021
const collectionStore = new Collections();
2122
const flowTestAI = new FlowtestAI();
@@ -87,7 +88,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
8788
id: id,
8889
name: collectionName,
8990
pathname: pathname,
90-
openapi_spec: resolvedSpec.resolved,
91+
openapi_spec: stringify(resolvedSpec.resolved),
9192
nodes: parsedNodes,
9293
};
9394

@@ -122,7 +123,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
122123
id: id,
123124
name: collectionName,
124125
pathname: collectionFolderPath,
125-
openapi_spec: resolvedSpec.resolved,
126+
openapi_spec: stringify(resolvedSpec.resolved),
126127
nodes: parsedNodes,
127128
};
128129

@@ -309,7 +310,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
309310
try {
310311
const collection = collectionStore.getAll().find((c) => c.id === collectionId);
311312
if (collection) {
312-
return await flowTestAI.generate(collection.openapi_spec, instruction, model);
313+
return await flowTestAI.generate(parse(collection.openapi_spec), instruction, model);
313314
} else {
314315
return Promise.reject(new Error('Collection not found'));
315316
}

0 commit comments

Comments
 (0)