Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

outport

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

outport - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

47

lib/index.d.ts
import express, { NextFunction, Request } from 'express';
import { APIDocumentation, Endpoint } from './schema.js';
export interface SchemaApi {
name: string;
endpoints: Endpoint[];
export interface Parameter {
key: string;
value: string;
description?: string;
}
export interface Header {
key: string;
value: string;
description?: string;
}
export interface BodyData {
key: string;
value?: Object;
description?: string;
type?: "text" | 'file';
}
export interface ExampleResponse {
status: number;
description: string;
value?: string | Object;
headers?: Header[];
}
export interface Endpoint {
path: string;
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
summary: string;
description?: string;
body?: {
type: 'json' | 'form';
data: BodyData[];
};
headers?: Header[];
parameters?: Parameter[];
responses?: ExampleResponse[];
}
export interface APIDocumentation {
title: string;
version: string;
servers?: string[];
headers?: Header[];
playground?: boolean;
description: string;
timeout?: number;
}
declare class Outport {

@@ -8,0 +47,0 @@ #private;

6

lib/public/index.js

@@ -134,6 +134,8 @@ "use strict";

const bodyTypeSelector = document.getElementById(`${endpointId}_body_type_selector`);
const bodyType = bodyTypeSelector.value;
const bodyType = bodyTypeSelector?.value;
if (!bodyType)
return;
if (bodyType === "json") {
const jsonInputBody = document.getElementById(`${endpointId}_json_input_body`);
const body = jsonInputBody.value;
const body = jsonInputBody?.value;
if (body && !isValidJson(body)) {

@@ -140,0 +142,0 @@ showErrorOnBody(endpointId);

@@ -18,12 +18,20 @@ declare const bodyTypeSelectElement: HTMLSelectElement;

declare function toggleRequestBodyType(): void;
declare function changeBodyFormInputType(selectElement: HTMLSelectElement): void;
declare function addRowWithQueryParamListeners(): void;
declare function addRow(tableId: string, key?: string, value?: string): void;
declare function addParamRow(tableId: string, key?: string, value?: string, description?: string): void;
declare function addReqBodyRow(key?: string, valueType?: string, value?: string): void;
declare function deleteRow(element: HTMLElement): void;
declare function deleteParamRow(element: HTMLElement): void;
declare function sendRequest(event: Event): Promise<void>;
declare function getBody(): string | FormData | undefined;
declare function getHeaders(): {
[key: string]: string;
[key: string]: {
value: string;
description: string;
};
};
declare function getParams(): {
[key: string]: {
value: string;
description: string;
};
};
declare function initializeRealTimeURLUpdate(): void;

@@ -30,0 +38,0 @@ declare function initializeInputListeners(parametersTable: HTMLTableElement): void;

@@ -85,14 +85,9 @@ "use strict";

}
function changeBodyFormInputType(selectElement) {
const inputField = selectElement.closest('td')?.nextElementSibling?.querySelector('input');
if (inputField) {
inputField.type = selectElement.value;
}
}
function addRowWithQueryParamListeners() {
addRow("parametersTable");
addParamRow("parametersTable");
initializeRealTimeURLUpdate();
}
function addRow(tableId, key, value) {
const tableBody = document.querySelector(`#${tableId} tbody`);
function addParamRow(tableId, key, value, description) {
const table = document.getElementById(tableId);
const tableBody = table.querySelector('tbody');
if (tableBody) {

@@ -104,7 +99,11 @@ const newRow = document.createElement('tr');

<td class="data-cell">
<input class="param-cell-input border-background-non" placeholder="value" name="value" value="${value || ""}">
</td>
<td class="data-cell">
<div class="flex-box">
<input class="param-cell-input border-background-non" placeholder="value" name="value" value="${value || ""}">
<h6 class="delete-text-btn" onclick="deleteRow(this)">delete</h6>
<input class="param-cell-input border-background-non" placeholder="description" name="description" value="${description || ""}">
<h6 class="delete-text-btn" onclick="deleteParamRow(this)">delete</h6>
</div>
</td>`;
</td>
`;
tableBody.appendChild(newRow);

@@ -136,3 +135,3 @@ }

}
function deleteRow(element) {
function deleteParamRow(element) {
element.closest('tr')?.remove();

@@ -148,3 +147,7 @@ updateURL();

const method = methodSelect.value;
const headers = getHeaders();
const headersList = getHeaders();
const headers = {};
Object.keys(headersList).forEach(key => {
headers[key] = headersList[key].value;
});
const body = method !== "get" ? getBody() : undefined;

@@ -207,4 +210,5 @@ if (!url || !method) {

const value = row.querySelector('input[name="value"]').value;
const description = row.querySelector('input[name="description"]').value;
if (key && value) {
headers[key] = value;
headers[key] = { value, description };
}

@@ -214,2 +218,15 @@ });

}
function getParams() {
const params = {};
const rows = parametersTable.querySelectorAll("tr.data-row");
rows.forEach(row => {
const key = row.querySelector('input[name="key"]').value;
const value = row.querySelector('input[name="value"]').value;
const description = row.querySelector('input[name="description"]').value;
if (key && value) {
params[key] = { value, description };
}
});
return params;
}
function initializeRealTimeURLUpdate() {

@@ -254,5 +271,8 @@ initializeInputListeners(parametersTable);

<td class="data-cell">
<input class="param-cell-input border-background-non" placeholder="value" value="${decodeURIComponent(value)}" name="value">
</td>
<td class="data-cell">
<div class="flex-box">
<input class="param-cell-input border-background-non" placeholder="value" value="${decodeURIComponent(value)}" name="value">
<h6 class="delete-text-btn" onclick="deleteRow(this)">delete</h6>
<input class="param-cell-input border-background-non" placeholder="description" value="" name="description">
<h6 class="delete-text-btn" onclick="deleteParamRow(this)">delete</h6>
</div>

@@ -270,10 +290,16 @@ </td>`;

if (!urlInput.value || !methodSelect.value) {
return showToast("Request is empty.");
return showToast("Request is empty!");
}
const url = new URL(decodeURIComponent(urlInput.value));
let url;
try {
url = new URL(decodeURIComponent(urlInput.value));
}
catch (error) {
return showToast("Invalid url!");
}
const method = methodSelect.value;
const headers = getHeaders();
const headersList = Object.keys(headers).map(key => ({ key, value: headers[key], description: "" }));
const params = Object.fromEntries(new URLSearchParams(url.search).entries());
const paramsList = Object.keys(params).map(key => ({ key, value: params[key], description: "" }));
const headersList = Object.keys(headers).map(key => ({ key, value: headers[key].value, description: headers[key].description }));
const params = getParams();
const paramsList = Object.keys(params).map(key => ({ key, value: params[key].value, description: params[key].description }));
let bodyType = bodyTypeSelectElement.value;

@@ -283,14 +309,15 @@ let bodyData;

const body = getBody();
let data = null;
if (body instanceof FormData) {
data = JSON.parse(convertFormBodyToJson(body, formBodyData));
let data = JSON.parse(convertFormBodyToJson(body, formBodyData));
bodyData = Object.entries(data).map(([key, value]) => ({
key,
value: value?.value,
type: value?.type
}));
}
else if (typeof body === "string") {
data = JSON.parse(body);
}
if (data) {
let data = JSON.parse(body);
bodyData = Object.entries(data).map(([key, value]) => ({
key,
value: value?.value ?? value,
type: value?.type
value
}));

@@ -297,0 +324,0 @@ }

@@ -307,3 +307,3 @@ // @ts-ignore

<div id="${endpointId}_request_parameters_content" class="tab-content active">
<table class="table">
<table id="${endpointId}_parameters_table" class="table">
<thead>

@@ -320,2 +320,3 @@ <tr>

</table>
<h6 class="add-more-text-btn" onclick="addRow('${endpointId}_parameters_table')">Add more...</h6>
</div>

@@ -329,3 +330,3 @@ `;

<td class="data-cell"><input class="param-cell-input border-background-non" placeholder="value" name="value" value="${param.value}"></input></td>
<td class="data-cell"><input class="param-cell-input" disabled placeholder="description" value="${param.description}"></input></td>
<td class="data-cell"><input class="param-cell-input border-background-non" disabled placeholder="description" name="description" value="${param.description || ""}"></td>
</tr>

@@ -332,0 +333,0 @@ `;

@@ -25,1 +25,3 @@ declare const isValidJson: (str: string) => boolean;

declare function showElement(id: string): void;
declare function addRow(tableId: string, key?: string, value?: string, description?: string): void;
declare function deleteRow(element: HTMLElement): void;

@@ -117,1 +117,23 @@ "use strict";

}
function addRow(tableId, key, value, description) {
const table = document.getElementById(tableId);
const tableBody = table.querySelector('tbody');
const newRow = document.createElement('tr');
newRow.classList.add('data-row');
newRow.innerHTML = `
<td class="data-cell"><input class="param-cell-input border-background-non" value="${key || ""}" placeholder="key" name="key"></td>
<td class="data-cell">
<input class="param-cell-input border-background-non" placeholder="value" name="value" value="${value || ""}">
</td>
<td class="data-cell">
<div class="flex-box">
<input class="param-cell-input border-background-non" placeholder="description" name="description" value="${description || ""}">
<h6 class="delete-text-btn" onclick="deleteRow(this)">delete</h6>
</div>
</td>
`;
tableBody.appendChild(newRow);
}
function deleteRow(element) {
element.closest('tr')?.remove();
}
{
"name": "outport",
"version": "1.1.12",
"version": "1.1.13",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc