Skip to content

Commit 9261e3b

Browse files
committed
merged subscription with dev
2 parents 924e5bf + 6b87b64 commit 9261e3b

File tree

10 files changed

+66
-107
lines changed

10 files changed

+66
-107
lines changed

index-csp.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Swell</title>
7+
</head>
38

4-
<head>
5-
<meta charset="UTF-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<!-- <link rel="stylesheet" href="./node_modules/chart.js/dist/Chart.min.css" /> -->
8-
<title>Swell</title>
9-
</head>
10-
11-
<body></body>
12-
13-
</html>
9+
<body></body>
10+
</html>

main_process/openapiParser.js

Lines changed: 18 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,47 @@
11
const YAML = require('yamljs');
22

3-
/////////////
4-
const Ajv = require('ajv');
5-
const openapiSchema = require('openapi-schema-validation');
6-
7-
const ajv = new Ajv();
8-
const validateOpenAPI = ajv.compile(openapiSchema);
9-
10-
11-
const errors = validateOpenAPI.errors;
12-
if (errors) {
13-
const errorMessages = errors.map((error) => `Validation Error: ${error.dataPath} ${error.message}`);
14-
throw new Error(`Invalid OpenAPI document.\n${errorMessages.join('\n')}`);
15-
}
16-
/////////////
17-
183
// TODO The security keys need to be implmented into the OpenApi request
194

205
const openapiParserFunc = (input) => {
216

22-
// Input validation
23-
if (typeof input !== 'string') {
24-
throw new TypeError('Input must be a string.');
25-
}
26-
277
if (input === undefined || input === null) {
288
throw new ReferenceError('OpenAPI Document not found.');
299
}
3010
// Parse the input into JSON or YAML
3111
let doc;
3212
try {
33-
//try json parse
3413
doc = JSON.parse(input);
35-
} catch (jsonError) {
36-
// try to parse as yaml
37-
try{
38-
doc = YAML.parse(input)
39-
} catch (yamlError) {
40-
throw new Error('Invalid JSON, or YAML format: ' + yamlError.message)
41-
}
42-
}
43-
44-
// Schema validation
45-
const isValidOpenAPI = validateOpenAPI(doc);
46-
if (!isValidOpenAPI) {
47-
throw new Error('Invalid OpenAPI document. Schema validation failed.');
14+
} catch (SyntaxError) {
15+
doc = YAML.parse(input);
4816
}
4917

50-
51-
const { info = {}, servers = [], tags = [], paths = {}, components = {} } = doc;
18+
const { info, servers, tags, paths, components } = doc;
5219

5320
info.openapi = doc.openapi;
5421

55-
const serverUrls = servers.map((server) => server.url);
56-
57-
const openapiReqArray = [];
22+
let serverUrls
23+
if (servers) {
24+
serverUrls = [...servers.map((server) => server.url)];
25+
} else {
26+
serverUrls = []
27+
}
5828
let id = 0;
5929

30+
const openapiReqArray = [];
6031
Object.entries(paths).forEach(([endpoint, pathObj]) => {
6132
Object.entries(pathObj).forEach(([method, operationObj]) => {
6233
id += 1;
63-
6434
const {
65-
summary = '',
66-
description = '',
67-
operationId = '',
68-
tags = [],
69-
parameters = [],
70-
security = [],
71-
responses = {},
72-
externalDocs = {},
73-
version = '',
35+
summary,
36+
description,
37+
operationId,
38+
tags,
39+
parameters, // security
7440
} = operationObj;
7541

76-
const securitySchemes = components.securitySchemes || {};
77-
const responseExamples = {}; // Extract response examples from responses object if available
78-
79-
// const request = {
80-
// id,
81-
// // enabled: true,
82-
// reqTags: tags,
83-
// summary,
84-
// description,
85-
// operationId,
86-
// method: method.toUpperCase(),
87-
// reqServers: [],
88-
// endpoint,
89-
// parameters,
90-
// body: new Map(),
91-
// headers: {},
92-
// cookies: {},
93-
// // params: {},
94-
// // queries: {},
95-
// urls: [],
96-
// };
9742
const request = {
9843
id,
44+
// enabled: true,
9945
reqTags: tags,
10046
summary,
10147
description,
@@ -107,10 +53,8 @@ const openapiParserFunc = (input) => {
10753
body: new Map(),
10854
headers: {},
10955
cookies: {},
110-
securitySchemes,
111-
responseExamples,
112-
externalDocs,
113-
version,
56+
// params: {},
57+
// queries: {},
11458
urls: [],
11559
};
11660
openapiReqArray.push(request);

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
"dependencies": {
9797
"@apollo/client": "^3.5.0",
9898
"@apollo/server": "^4.6.0",
99-
"@emotion/react": "^11.10.8",
100-
"@emotion/styled": "^11.10.8",
10199
"@graphql-tools/schema": "^8.3.10",
102100
"@grpc/grpc-js": "^1.6.7",
103101
"@grpc/proto-loader": "^0.6.9",
@@ -110,14 +108,11 @@
110108
"@uiw/codemirror-extensions-langs": "^4.19.9",
111109
"@uiw/codemirror-theme-vscode": "^4.19.9",
112110
"@uiw/react-codemirror": "^4.19.9",
113-
"axios": "^0.27.1",
114-
"ajv": "8.12.0",
115111
"body-parser": "^1.20.0",
116112
"bulma": "^0.9.3",
117113
"bulma-checkradio": "^2.1.3",
118114
"bulma-switch": "^2.0.4",
119115
"chai": "^4.3.7",
120-
"chart.js": "^3.7.1",
121116
"classnames": "^2.3.1",
122117
"cookie-parser": "^1.4.6",
123118
"cors": "^2.8.5",
@@ -138,12 +133,10 @@
138133
"graphql-tag": "^2.12.6",
139134
"graphql-ws": "^5.8.1",
140135
"highland": "^2.13.5",
141-
"js-beautify": "^1.14.3",
142136
"mali": "^0.46.1",
143137
"ngrok": "^4.3.1",
144138
"node-fetch": "^3.3.0",
145139
"npm": "^8.7.0",
146-
"openapi-schema-validation": "0.4.2",
147140
"patch-package": "^6.4.7",
148141
"path": "^0.12.7",
149142
"prop-types": "^15.8.1",
@@ -156,7 +149,6 @@
156149
"react-router-dom": "^6.3.0",
157150
"react-split": "^2.0.14",
158151
"redux": "^4.2.0",
159-
"resize-observer-polyfill": "^1.5.1",
160152
"sass": "^1.51.0",
161153
"set-cookie-parser": "^2.4.8",
162154
"socket.io": "^4.5.0",
14.6 KB
Binary file not shown.

src/client/components/main/TRPC-composer/TRPCComposer.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,34 @@ export default function TRPCComposer(props) {
124124
proceduresDipatch({ type: 'ADD' });
125125
};
126126

127+
const dispatchTRPCResponse = (tRPCResponse) => {
128+
const newCurrentResponse: any = {
129+
checkSelected: false,
130+
checked: false,
131+
connection: 'closed',
132+
connectionType: 'plain',
133+
createdAt: new Date(),
134+
gRPC: false,
135+
graphQL: false,
136+
host: requestFields.url,
137+
id: uuid(),
138+
minimized: false,
139+
path: '/',
140+
protoPath: undefined,
141+
protocol: 'http://',
142+
request: { ...newRequest },
143+
tab: undefined,
144+
timeReceived: null,
145+
timeSent: null,
146+
url: requestFields.url,
147+
webrtc: false,
148+
response: {
149+
events: [tRPCResponse],
150+
},
151+
};
152+
dispatch(responseDataSaved(newCurrentResponse));
153+
};
154+
127155
const sendRequest = async () => {
128156
const id = uuid();
129157
const headers = newRequest.newRequestHeaders.headersArr.filter(

src/client/components/main/WebRTC-composer/WebRTCServerEntryForm.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { EditorView } from '@codemirror/view';
55
import { javascript } from '@codemirror/lang-javascript';
66
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
77

8-
9-
const jBeautify = require('js-beautify').js;
8+
// const jBeautify = require('js-beautify').js;
109

1110
interface Props {
1211
warningMessage: {
@@ -15,7 +14,9 @@ interface Props {
1514
}
1615

1716
const WebRTCServerEntryForm: React.FC<Props> = ({ warningMessage }) => {
18-
const requestBody = useSelector((state: any) => state.newRequest.newRequestBody);
17+
const requestBody = useSelector(
18+
(state: any) => state.newRequest.newRequestBody
19+
);
1920
const { bodyIsNew } = requestBody;
2021
const [cmValue, setValue] = useState<string>('');
2122
const isDark = useSelector((state: any) => state.ui.isDark);
@@ -28,14 +29,14 @@ const WebRTCServerEntryForm: React.FC<Props> = ({ warningMessage }) => {
2829
/**
2930
* @todo This code randomly causes parts of the app to crash. As in, it
3031
* will randomly decide to start or stop working without you changing
31-
* anything. Need to investigate
32-
*
32+
* anything. Need to investigate
33+
*
3334
* (OR needs to be re-built....
3435
* - another iteration group)
3536
*/
36-
setValue(
37-
jBeautify(JSON.stringify(bodyContent?.iceConfiguration?.iceServers))
38-
);
37+
// setValue(
38+
// jBeautify(JSON.stringify(bodyContent?.iceConfiguration?.iceServers))
39+
// );
3940
}
4041
}, [bodyContent, bodyIsNew]);
4142

@@ -64,7 +65,6 @@ const WebRTCServerEntryForm: React.FC<Props> = ({ warningMessage }) => {
6465

6566
export default WebRTCServerEntryForm;
6667

67-
6868
// const WebRTCServerEntryForm = (props) => {
6969
// const { warningMessage } = props;
7070
// const requestBody = useSelector((state) => state.newRequest.newRequestBody);

src/client/components/main/response-composer/EmptyState.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
2-
import logofaded from '../../../../assets/img/swell-logo-faded.png';
3-
2+
import logofaded from '../../../../assets/img/swell-logo-faded.avif';
43

54
interface EmptyStateProps {
65
connection?: any;

src/client/components/navbar/ProtocolSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ const pages: page[] = [
7272
{ name: 'GraphQL', route: '/graphql', value: 'graphQL' },
7373
{ name: 'WebSocket', route: '/websocket', value: 'ws' },
7474
{ name: 'gRPC', route: '/grpc', value: 'grpc' },
75+
{ name: 'tRPC', route: '/trpc', value: 'tRPC' },
7576
];
7677

7778
const experimentalPages: page[] = [
7879
{ name: 'Mock', route: '/mockserver', value: 'mockserver' },
79-
{ name: 'tRPC', route: '/trpc', value: 'tRPC' },
8080
{ name: 'Webhook', route: '/webhook', value: 'webhook' },
8181
{ name: 'WebRTC', route: '/webrtc', value: 'webrtc' },
8282
{ name: 'OpenAPI', route: '/openapi', value: 'openapi' },

src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,11 @@ export type NewRequestFields = {
167167
openapiReqObj: Record<string, $TSFixMe>;
168168
};
169169

170+
export interface ReqResRequest {
170171
// Currently, the body for WebRTC connection is an object
171172
// and typescript does not support union between string and object very well
172173
// Ideally we should move the WebRTC body information to a new key value
173174
// to fully resolve the issue
174-
175-
export interface ReqResRequest {
176175
body: string;
177176
bodyType: string;
178177
bodyVariables: string;

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = {
7373
},
7474
},
7575
{
76-
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
76+
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif|avif)$/,
7777
use: 'url-loader',
7878
},
7979
],

0 commit comments

Comments
 (0)