mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
Import WSDL to collection (#5015)
* Import WSDL to bruno collection * feat(wsdl-import): remove unused code and minor refactor --------- Co-authored-by: Bijin Bruno <bijin@usebruno.com>
This commit is contained in:
@@ -52,10 +52,10 @@ const createQuery = (queryParams = [], request) => {
|
||||
value: param.value
|
||||
}));
|
||||
|
||||
if (request?.auth?.mode === 'apikey' &&
|
||||
request?.auth?.apikey?.placement === 'queryparams' &&
|
||||
request?.auth?.apikey?.key &&
|
||||
request?.auth?.apikey?.value) {
|
||||
if (request?.auth?.mode === 'apikey'
|
||||
&& request?.auth?.apikey?.placement === 'queryparams'
|
||||
&& request?.auth?.apikey?.key
|
||||
&& request?.auth?.apikey?.value) {
|
||||
params.push({
|
||||
name: request.auth.apikey.key,
|
||||
value: request.auth.apikey.value
|
||||
|
||||
@@ -29,7 +29,7 @@ const COPY_SUCCESS_COLOR = '#22c55e';
|
||||
|
||||
export const COPY_SUCCESS_TIMEOUT = 1000;
|
||||
|
||||
const getCopyButton = variableValue => {
|
||||
const getCopyButton = (variableValue) => {
|
||||
const copyButton = document.createElement('button');
|
||||
|
||||
copyButton.className = 'copy-button';
|
||||
@@ -64,7 +64,7 @@ const getCopyButton = variableValue => {
|
||||
copyButton.style.opacity = '0.7';
|
||||
});
|
||||
|
||||
copyButton.addEventListener('click', e => {
|
||||
copyButton.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
// Prevent clicking if showing success checkmark
|
||||
@@ -91,7 +91,7 @@ const getCopyButton = variableValue => {
|
||||
copyButton.classList.remove('copy-success');
|
||||
}, COPY_SUCCESS_TIMEOUT);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error('Failed to copy to clipboard:', err.message);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -237,7 +237,7 @@ describe('renderVarInfo', () => {
|
||||
clipboardText = '';
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: jest.fn(text => {
|
||||
writeText: jest.fn((text) => {
|
||||
if (text === 'cause-clipboard-error') {
|
||||
return Promise.reject(new Error('Clipboard error'));
|
||||
}
|
||||
@@ -245,9 +245,9 @@ describe('renderVarInfo', () => {
|
||||
clipboardText = text;
|
||||
|
||||
return Promise.resolve();
|
||||
}),
|
||||
})
|
||||
},
|
||||
configurable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
// mock console.error
|
||||
@@ -283,7 +283,7 @@ describe('renderVarInfo', () => {
|
||||
it('should correctly mask the variable value in the popup', () => {
|
||||
const { descriptionDiv } = setupRender({
|
||||
apiKey: 'test-value',
|
||||
maskedEnvVariables: ['apiKey'],
|
||||
maskedEnvVariables: ['apiKey']
|
||||
});
|
||||
|
||||
expect(descriptionDiv.textContent).toBe('*****');
|
||||
|
||||
@@ -54,7 +54,7 @@ export const safeStringifyJSON = (obj, indent = false) => {
|
||||
|
||||
export const prettifyJSON = (obj, spaces = 2) => {
|
||||
try {
|
||||
const text = obj.replace(/\\"/g, '"').replace(/\\'/g, "'");
|
||||
const text = obj.replace(/\\"/g, '"').replace(/\\'/g, '\'');
|
||||
|
||||
const placeholders = [];
|
||||
const modifiedJson = text.replace(/"[^"]*?"|{{[^{}]+}}/g, (match) => {
|
||||
|
||||
@@ -102,7 +102,6 @@ export class MaskedEditor {
|
||||
|
||||
// Restore cursor state
|
||||
this.restoreCursorState();
|
||||
|
||||
} finally {
|
||||
this.isProcessing = false;
|
||||
}
|
||||
@@ -135,7 +134,6 @@ export class MaskedEditor {
|
||||
|
||||
// Restore cursor state
|
||||
this.restoreCursorState();
|
||||
|
||||
} finally {
|
||||
this.isProcessing = false;
|
||||
}
|
||||
@@ -331,15 +329,13 @@ export class MaskedEditor {
|
||||
const maskedNode = document.createTextNode(this.maskChar.repeat(lineLength));
|
||||
|
||||
// Create mark with proper bounds checking
|
||||
const mark = this.editor.markText(
|
||||
{ line, ch: 0 },
|
||||
const mark = this.editor.markText({ line, ch: 0 },
|
||||
{ line, ch: lineLength },
|
||||
{
|
||||
replacedWith: maskedNode,
|
||||
handleMouseEvents: false,
|
||||
className: 'masked-line'
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// Store mark for cleanup
|
||||
this.marks.add(mark);
|
||||
@@ -355,7 +351,7 @@ export class MaskedEditor {
|
||||
* Clear all marks with proper cleanup
|
||||
*/
|
||||
clearAllMarks() {
|
||||
this.marks.forEach(mark => {
|
||||
this.marks.forEach((mark) => {
|
||||
try {
|
||||
mark.clear();
|
||||
} catch (e) {
|
||||
@@ -365,7 +361,7 @@ export class MaskedEditor {
|
||||
this.marks.clear();
|
||||
|
||||
// Also clear any marks that might have been created outside our control
|
||||
this.editor.getAllMarks().forEach(mark => {
|
||||
this.editor.getAllMarks().forEach((mark) => {
|
||||
try {
|
||||
mark.clear();
|
||||
} catch (e) {
|
||||
@@ -437,8 +433,8 @@ export function createMaskedEditor(editor, maskChar = '*') {
|
||||
* Utility function to check if an editor supports masking
|
||||
*/
|
||||
export function supportsMasking(editor) {
|
||||
return editor &&
|
||||
typeof editor.getValue === 'function' &&
|
||||
typeof editor.markText === 'function' &&
|
||||
typeof editor.operation === 'function';
|
||||
}
|
||||
return editor
|
||||
&& typeof editor.getValue === 'function'
|
||||
&& typeof editor.markText === 'function'
|
||||
&& typeof editor.operation === 'function';
|
||||
}
|
||||
|
||||
28
packages/bruno-app/src/utils/importers/wsdl-collection.js
Normal file
28
packages/bruno-app/src/utils/importers/wsdl-collection.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const isWSDLCollection = (data) => {
|
||||
// Check if data is a string (WSDL content)
|
||||
if (typeof data !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for WSDL-specific XML elements
|
||||
const wsdlIndicators = [
|
||||
'wsdl:definitions',
|
||||
'definitions',
|
||||
'wsdl:types',
|
||||
'wsdl:message',
|
||||
'wsdl:portType',
|
||||
'wsdl:binding',
|
||||
'wsdl:service'
|
||||
];
|
||||
|
||||
// Check if the content contains WSDL namespace or elements
|
||||
const hasWSDLNamespace = data.includes('xmlns:wsdl=')
|
||||
|| data.includes('xmlns="http://schemas.xmlsoap.org/wsdl/"')
|
||||
|| data.includes('xmlns="http://www.w3.org/2001/XMLSchema"');
|
||||
|
||||
const hasWSDLElements = wsdlIndicators.some((indicator) => data.includes(indicator));
|
||||
|
||||
return hasWSDLNamespace || hasWSDLElements;
|
||||
};
|
||||
|
||||
export { isWSDLCollection };
|
||||
@@ -34,7 +34,7 @@ export const parsePathParams = (url) => {
|
||||
|
||||
// Enhanced: also match :param inside parentheses and/or quotes
|
||||
const foundParams = new Set();
|
||||
paths.forEach(segment => {
|
||||
paths.forEach((segment) => {
|
||||
// traditional path parameters
|
||||
if (segment.startsWith(':')) {
|
||||
const name = segment.slice(1);
|
||||
@@ -65,7 +65,7 @@ export const parsePathParams = (url) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
return Array.from(foundParams).map(name => ({ name, value: '' }));
|
||||
return Array.from(foundParams).map((name) => ({ name, value: '' }));
|
||||
};
|
||||
|
||||
export const splitOnFirst = (str, char) => {
|
||||
|
||||
@@ -166,7 +166,6 @@ describe('Url Utils - parsePathParams', () => {
|
||||
const params = parsePathParams('https://example.com/start/1:2:AHLS-HASD/form');
|
||||
expect(params).toEqual([]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Url Utils - URN parsing', () => {
|
||||
|
||||
Reference in New Issue
Block a user