From 2496269176af7a36edada39d95a55fe6cfb1dfb9 Mon Sep 17 00:00:00 2001 From: Siddharth Gelera Date: Tue, 30 Sep 2025 18:50:14 +0530 Subject: [PATCH] chore: reformat --- .../bruno-filestore/src/formats/bru/index.ts | 8 +-- packages/bruno-lang/v2/src/bruToJson.js | 4 +- packages/bruno-lang/v2/src/jsonToBru.js | 2 +- packages/bruno-requests/rollup.config.js | 2 +- packages/bruno-requests/src/ws/ws-client.js | 52 +++++++++---------- tests/websockets/connection.spec.ts | 2 +- tests/websockets/lib/locators.ts | 6 +-- tests/websockets/persistence.spec.ts | 6 +-- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/bruno-filestore/src/formats/bru/index.ts b/packages/bruno-filestore/src/formats/bru/index.ts index 5b394a381..61002db64 100644 --- a/packages/bruno-filestore/src/formats/bru/index.ts +++ b/packages/bruno-filestore/src/formats/bru/index.ts @@ -35,7 +35,7 @@ export const bruRequestToJson = (data: string | any, parsed: boolean = false): a const urlPath: Record = { 'grpc-request': 'grpc.url', 'ws-request': 'ws.url', - 'default': 'http.url', + 'default': 'http.url' }; const transformedJson = { type: requestType, @@ -192,9 +192,9 @@ export const jsonRequestToBru = (json: any): string => { ws: _.get(json, 'request.body.ws', [ { name: 'message 1', - content: '{}', - }, - ]), + content: '{}' + } + ]) }); } diff --git a/packages/bruno-lang/v2/src/bruToJson.js b/packages/bruno-lang/v2/src/bruToJson.js index 0dcc27e48..2c91f2a05 100644 --- a/packages/bruno-lang/v2/src/bruToJson.js +++ b/packages/bruno-lang/v2/src/bruToJson.js @@ -424,7 +424,7 @@ const sem = grammar.createSemantics().addAttribute('ast', { }, ws(_1, dictionary) { return { - ws: mapPairListToKeyValPair(dictionary.ast), + ws: mapPairListToKeyValPair(dictionary.ast) }; }, get(_1, dictionary) { @@ -827,7 +827,7 @@ const sem = grammar.createSemantics().addAttribute('ast', { body: 'json' }, body: { - json: outdentString(textblock.sourceString), + json: outdentString(textblock.sourceString) } }; }, diff --git a/packages/bruno-lang/v2/src/jsonToBru.js b/packages/bruno-lang/v2/src/jsonToBru.js index 9ae563820..9606324ff 100644 --- a/packages/bruno-lang/v2/src/jsonToBru.js +++ b/packages/bruno-lang/v2/src/jsonToBru.js @@ -613,7 +613,7 @@ ${indentString(body.sparql)} if (body && body.ws) { // Convert each ws message to a separate body:ws block if (Array.isArray(body.ws)) { - body.ws.forEach(message => { + body.ws.forEach((message) => { const { name, content, type = '' } = message; bru += `body:ws {\n`; diff --git a/packages/bruno-requests/rollup.config.js b/packages/bruno-requests/rollup.config.js index cc5bf34e5..f2b031284 100644 --- a/packages/bruno-requests/rollup.config.js +++ b/packages/bruno-requests/rollup.config.js @@ -38,6 +38,6 @@ module.exports = [ typescript({ tsconfig: './tsconfig.json' }), terser(), ], - external: ['axios', 'qs', 'ws'], + external: ['axios', 'qs', 'ws'] } ]; diff --git a/packages/bruno-requests/src/ws/ws-client.js b/packages/bruno-requests/src/ws/ws-client.js index 005da3b56..093c822cb 100644 --- a/packages/bruno-requests/src/ws/ws-client.js +++ b/packages/bruno-requests/src/ws/ws-client.js @@ -15,7 +15,7 @@ const safeJsonParse = (jsonString, context = 'JSON string') => { const errorMessage = `Failed to parse ${context}: ${error.message}`; console.error(errorMessage, { originalString: jsonString, - parseError: error, + parseError: error }); throw new Error(errorMessage); } @@ -26,8 +26,8 @@ const safeJsonParse = (jsonString, context = 'JSON string') => { * @param {string} url - The WebSocket URL * @returns {Object} Parsed URL object with protocol, host, path */ -const getParsedWsUrlObject = url => { - const addProtocolIfMissing = str => { +const getParsedWsUrlObject = (url) => { + const addProtocolIfMissing = (str) => { if (str.includes('://')) return str; // For localhost, default to insecure (grpc://) for local development @@ -39,7 +39,7 @@ const getParsedWsUrlObject = url => { return `wss://${str}`; }; - const removeTrailingSlash = str => (str.endsWith('/') ? str.slice(0, -1) : str); + const removeTrailingSlash = (str) => (str.endsWith('/') ? str.slice(0, -1) : str); if (!url) return { host: '', path: '' }; @@ -50,13 +50,13 @@ const getParsedWsUrlObject = url => { host: urlObj.host, path: removeTrailingSlash(urlObj.pathname), search: urlObj.search, - fullUrl: urlObj.href, + fullUrl: urlObj.href }; } catch (err) { console.error({ err }); return { host: '', - path: '', + path: '' }; } }; @@ -94,7 +94,7 @@ class WsClient { const wsOptions = { headers, handshakeTimeout: timeout, - followRedirects: true, + followRedirects: true }; if (protocolVersion) { @@ -116,7 +116,7 @@ class WsClient { } catch (error) { console.error('Error creating WebSocket connection:', error); this.eventCallback('ws:error', requestId, collectionUid, { - error: error.message, + error: error.message }); throw error; } @@ -172,7 +172,7 @@ class WsClient { } // Send the message - connection.send(JSON.stringify(messageToSend), error => { + connection.send(JSON.stringify(messageToSend), (error) => { if (error) { this.eventCallback('ws:error', requestId, collectionUid, { error }); } else { @@ -181,14 +181,14 @@ class WsClient { message: messageToSend, messageHexdump: hexdump(JSON.stringify(messageToSend)), type: 'outgoing', - timestamp: Date.now(), + timestamp: Date.now() }); } }); } else { const error = new Error('WebSocket connection not available or not open'); this.eventCallback('ws:error', requestId, collectionUid, { - error: error.message, + error: error.message }); } } @@ -231,7 +231,7 @@ class WsClient { clearAllConnections() { const connectionIds = this.getActiveConnectionIds(); - this.activeConnections.forEach(connection => { + this.activeConnections.forEach((connection) => { if (connection.readyState === WebSocket.OPEN) { connection.close(1000, 'Client clearing all connections'); } @@ -243,7 +243,7 @@ class WsClient { if (connectionIds.length > 0) { this.eventCallback('ws:connections-changed', { type: 'cleared', - activeConnectionIds: [], + activeConnectionIds: [] }); } } @@ -274,37 +274,37 @@ class WsClient { this.eventCallback('ws:open', requestId, collectionUid, { timestamp: Date.now(), - url: ws.url, + url: ws.url }); }); ws.on('redirect', (url, req) => { const headerNames = req.getHeaderNames(); - const headers = Object.fromEntries(headerNames.map(d => [d, req.getHeader(d)])); + const headers = Object.fromEntries(headerNames.map((d) => [d, req.getHeader(d)])); this.eventCallback('ws:redirect', requestId, collectionUid, { message: `Redirected to ${url}`, type: 'info', timestamp: Date.now(), - headers: headers, + headers: headers }); }); - ws.on('upgrade', response => { + ws.on('upgrade', (response) => { this.eventCallback('ws:upgrade', requestId, collectionUid, { type: 'info', timestamp: Date.now(), - headers: { ...response.headers }, + headers: { ...response.headers } }); }); - ws.on('message', data => { + ws.on('message', (data) => { try { const message = JSON.parse(data.toString()); this.eventCallback('ws:message', requestId, collectionUid, { message, messageHexdump: hexdump(Buffer.from(data)), type: 'incoming', - timestamp: Date.now(), + timestamp: Date.now() }); } catch (error) { // If parsing fails, send as raw data @@ -312,7 +312,7 @@ class WsClient { message: data.toString(), messageHexdump: hexdump(data), type: 'incoming', - timestamp: Date.now(), + timestamp: Date.now() }); } }); @@ -321,15 +321,15 @@ class WsClient { this.eventCallback('ws:close', requestId, collectionUid, { code, reason: Buffer.from(reason).toString(), - timestamp: Date.now(), + timestamp: Date.now() }); this.#removeConnection(requestId); }); - ws.on('error', error => { + ws.on('error', (error) => { this.eventCallback('ws:error', requestId, collectionUid, { error: error.message, - timestamp: Date.now(), + timestamp: Date.now() }); }); } @@ -347,7 +347,7 @@ class WsClient { this.eventCallback('ws:connections-changed', { type: 'added', requestId, - activeConnectionIds: this.getActiveConnectionIds(), + activeConnectionIds: this.getActiveConnectionIds() }); } @@ -374,7 +374,7 @@ class WsClient { this.eventCallback('ws:connections-changed', { type: 'removed', requestId, - activeConnectionIds: this.getActiveConnectionIds(), + activeConnectionIds: this.getActiveConnectionIds() }); } } diff --git a/tests/websockets/connection.spec.ts b/tests/websockets/connection.spec.ts index 4f9edfd28..b78cd2363 100644 --- a/tests/websockets/connection.spec.ts +++ b/tests/websockets/connection.spec.ts @@ -18,7 +18,7 @@ test.describe.serial('websockets', () => { await locators.connectionControls.connect().click(); await expect(locators.connectionControls.disconnect()).toBeAttached({ - timeout: MAX_CONNECTION_TIME, + timeout: MAX_CONNECTION_TIME }); }); diff --git a/tests/websockets/lib/locators.ts b/tests/websockets/lib/locators.ts index edbff8477..2653897dd 100644 --- a/tests/websockets/lib/locators.ts +++ b/tests/websockets/lib/locators.ts @@ -15,12 +15,12 @@ export const buildCommonLocators = (page: Page) => ({ page .locator('div.connection-controls') .locator('.infotip') - .filter({ hasText: /^Close Connection$/ }), + .filter({ hasText: /^Close Connection$/ }) }, messages: () => page.locator('.ws-message').all(), toolbar: { latestFirst: () => page.getByRole('button', { name: 'Latest First' }), latestLast: () => page.getByRole('button', { name: 'Latest Last' }), - clearResponse: () => page.getByRole('button', { name: 'Clear Response' }), - }, + clearResponse: () => page.getByRole('button', { name: 'Clear Response' }) + } }); diff --git a/tests/websockets/persistence.spec.ts b/tests/websockets/persistence.spec.ts index 61faebb0c..85de63c9c 100644 --- a/tests/websockets/persistence.spec.ts +++ b/tests/websockets/persistence.spec.ts @@ -8,14 +8,14 @@ const BRU_FILE_NAME = /^base$/; // TODO: reaper move to someplace common const isRequestSaved = async (saveButton: Locator) => { const savedColor = '#9f9f9f'; - return (await saveButton.evaluate(d => d.querySelector('svg')?.getAttribute('stroke') ?? '#invalid')) === savedColor; + return (await saveButton.evaluate((d) => d.querySelector('svg')?.getAttribute('stroke') ?? '#invalid')) === savedColor; }; test.describe.serial('persistence', () => { let originalUrl = ''; let originalContext = { path: join(__dirname, 'fixtures/collection/base.bru'), - data: '', + data: '' }; test.beforeAll(async () => { @@ -35,7 +35,7 @@ test.describe.serial('persistence', () => { const replacementUrl = 'ws://localhost:8082'; const locators = buildCommonLocators(page); const unsavedColor = '#d97706'; - const getSaveSvg = () => locators.saveButton().evaluate(d => d.querySelector('svg')); + const getSaveSvg = () => locators.saveButton().evaluate((d) => d.querySelector('svg')); const clearText = async (text: string) => { for (let i = text.length; i > 0; i--) {