mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-08 22:05:16 +02:00
Biome tweaks
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
// biome-ignore-all lint/suspicious/noExplicitAny: too flexible for strict types
|
||||||
import type { PartialImportResources } from '@yaakapp/api';
|
import type { PartialImportResources } from '@yaakapp/api';
|
||||||
import { convertId, convertTemplateSyntax, isJSObject } from './common';
|
import { convertId, convertTemplateSyntax, isJSObject } from './common';
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
export function convertInsomniaV4(parsed: any) {
|
export function convertInsomniaV4(parsed: any) {
|
||||||
if (!Array.isArray(parsed.resources)) return null;
|
if (!Array.isArray(parsed.resources)) return null;
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ export function convertInsomniaV4(parsed: any) {
|
|||||||
|
|
||||||
// Import workspaces
|
// Import workspaces
|
||||||
const workspacesToImport = parsed.resources.filter(
|
const workspacesToImport = parsed.resources.filter(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
(r: any) => isJSObject(r) && r._type === 'workspace',
|
(r: any) => isJSObject(r) && r._type === 'workspace',
|
||||||
);
|
);
|
||||||
for (const w of workspacesToImport) {
|
for (const w of workspacesToImport) {
|
||||||
@@ -29,16 +28,13 @@ export function convertInsomniaV4(parsed: any) {
|
|||||||
description: w.description || undefined,
|
description: w.description || undefined,
|
||||||
});
|
});
|
||||||
const environmentsToImport = parsed.resources.filter(
|
const environmentsToImport = parsed.resources.filter(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
(r: any) => isJSObject(r) && r._type === 'environment',
|
(r: any) => isJSObject(r) && r._type === 'environment',
|
||||||
);
|
);
|
||||||
resources.environments.push(
|
resources.environments.push(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
...environmentsToImport.map((r: any) => importEnvironment(r, w._id)),
|
...environmentsToImport.map((r: any) => importEnvironment(r, w._id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextFolder = (parentId: string) => {
|
const nextFolder = (parentId: string) => {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
const children = parsed.resources.filter((r: any) => r.parentId === parentId);
|
const children = parsed.resources.filter((r: any) => r.parentId === parentId);
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (!isJSObject(child)) continue;
|
if (!isJSObject(child)) continue;
|
||||||
@@ -67,7 +63,6 @@ export function convertInsomniaV4(parsed: any) {
|
|||||||
return { resources: convertTemplateSyntax(resources) };
|
return { resources: convertTemplateSyntax(resources) };
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
function importHttpRequest(r: any, workspaceId: string): PartialImportResources['httpRequests'][0] {
|
function importHttpRequest(r: any, workspaceId: string): PartialImportResources['httpRequests'][0] {
|
||||||
let bodyType: string | null = null;
|
let bodyType: string | null = null;
|
||||||
let body = {};
|
let body = {};
|
||||||
@@ -77,7 +72,6 @@ function importHttpRequest(r: any, workspaceId: string): PartialImportResources[
|
|||||||
} else if (r.body?.mimeType === 'application/x-www-form-urlencoded') {
|
} else if (r.body?.mimeType === 'application/x-www-form-urlencoded') {
|
||||||
bodyType = 'application/x-www-form-urlencoded';
|
bodyType = 'application/x-www-form-urlencoded';
|
||||||
body = {
|
body = {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
form: (r.body.params ?? []).map((p: any) => ({
|
form: (r.body.params ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -87,7 +81,6 @@ function importHttpRequest(r: any, workspaceId: string): PartialImportResources[
|
|||||||
} else if (r.body?.mimeType === 'multipart/form-data') {
|
} else if (r.body?.mimeType === 'multipart/form-data') {
|
||||||
bodyType = 'multipart/form-data';
|
bodyType = 'multipart/form-data';
|
||||||
body = {
|
body = {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
form: (r.body.params ?? []).map((p: any) => ({
|
form: (r.body.params ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -129,7 +122,6 @@ function importHttpRequest(r: any, workspaceId: string): PartialImportResources[
|
|||||||
name: r.name,
|
name: r.name,
|
||||||
description: r.description || undefined,
|
description: r.description || undefined,
|
||||||
url: r.url,
|
url: r.url,
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
urlParameters: (r.parameters ?? []).map((p: any) => ({
|
urlParameters: (r.parameters ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -141,20 +133,16 @@ function importHttpRequest(r: any, workspaceId: string): PartialImportResources[
|
|||||||
authenticationType,
|
authenticationType,
|
||||||
method: r.method,
|
method: r.method,
|
||||||
headers: (r.headers ?? [])
|
headers: (r.headers ?? [])
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.map((h: any) => ({
|
.map((h: any) => ({
|
||||||
enabled: !h.disabled,
|
enabled: !h.disabled,
|
||||||
name: h.name ?? '',
|
name: h.name ?? '',
|
||||||
value: h.value ?? '',
|
value: h.value ?? '',
|
||||||
}))
|
}))
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
function importGrpcRequest(r: any, workspaceId: string): PartialImportResources['grpcRequests'][0] {
|
function importGrpcRequest(r: any, workspaceId: string): PartialImportResources['grpcRequests'][0] {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');
|
const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');
|
||||||
const service = parts[0] ?? null;
|
const service = parts[0] ?? null;
|
||||||
const method = parts[1] ?? null;
|
const method = parts[1] ?? null;
|
||||||
@@ -174,18 +162,15 @@ function importGrpcRequest(r: any, workspaceId: string): PartialImportResources[
|
|||||||
method,
|
method,
|
||||||
message: r.body?.text ?? '',
|
message: r.body?.text ?? '',
|
||||||
metadata: (r.metadata ?? [])
|
metadata: (r.metadata ?? [])
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.map((h: any) => ({
|
.map((h: any) => ({
|
||||||
enabled: !h.disabled,
|
enabled: !h.disabled,
|
||||||
name: h.name ?? '',
|
name: h.name ?? '',
|
||||||
value: h.value ?? '',
|
value: h.value ?? '',
|
||||||
}))
|
}))
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
function importFolder(f: any, workspaceId: string): PartialImportResources['folders'][0] {
|
function importFolder(f: any, workspaceId: string): PartialImportResources['folders'][0] {
|
||||||
return {
|
return {
|
||||||
id: convertId(f._id),
|
id: convertId(f._id),
|
||||||
@@ -200,7 +185,6 @@ function importFolder(f: any, workspaceId: string): PartialImportResources['fold
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importEnvironment(
|
function importEnvironment(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
e: any,
|
e: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
isParentOg?: boolean,
|
isParentOg?: boolean,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
// biome-ignore-all lint/suspicious/noExplicitAny: too flexible for strict types
|
||||||
import type { PartialImportResources } from '@yaakapp/api';
|
import type { PartialImportResources } from '@yaakapp/api';
|
||||||
import { convertId, convertTemplateSyntax, isJSObject } from './common';
|
import { convertId, convertTemplateSyntax, isJSObject } from './common';
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
export function convertInsomniaV5(parsed: any) {
|
export function convertInsomniaV5(parsed: any) {
|
||||||
// Assert parsed is object
|
// Assert parsed is object
|
||||||
if (parsed == null || typeof parsed !== 'object') {
|
if (parsed == null || typeof parsed !== 'object') {
|
||||||
@@ -22,7 +22,6 @@ export function convertInsomniaV5(parsed: any) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Import workspaces
|
// Import workspaces
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
const meta = ('meta' in parsed ? parsed.meta : {}) as Record<string, any>;
|
const meta = ('meta' in parsed ? parsed.meta : {}) as Record<string, any>;
|
||||||
resources.workspaces.push({
|
resources.workspaces.push({
|
||||||
id: convertId(meta.id ?? 'collection'),
|
id: convertId(meta.id ?? 'collection'),
|
||||||
@@ -38,12 +37,10 @@ export function convertInsomniaV5(parsed: any) {
|
|||||||
// Import environments
|
// Import environments
|
||||||
resources.environments.push(
|
resources.environments.push(
|
||||||
importEnvironment(parsed.environments, meta.id, true),
|
importEnvironment(parsed.environments, meta.id, true),
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
...(parsed.environments.subEnvironments ?? []).map((r: any) => importEnvironment(r, meta.id)),
|
...(parsed.environments.subEnvironments ?? []).map((r: any) => importEnvironment(r, meta.id)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Import folders
|
// Import folders
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
const nextFolder = (children: any[], parentId: string) => {
|
const nextFolder = (children: any[], parentId: string) => {
|
||||||
for (const child of children ?? []) {
|
for (const child of children ?? []) {
|
||||||
if (!isJSObject(child)) continue;
|
if (!isJSObject(child)) continue;
|
||||||
@@ -76,7 +73,6 @@ export function convertInsomniaV5(parsed: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importHttpRequest(
|
function importHttpRequest(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
r: any,
|
r: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
@@ -94,7 +90,6 @@ function importHttpRequest(
|
|||||||
} else if (r.body?.mimeType === 'application/x-www-form-urlencoded') {
|
} else if (r.body?.mimeType === 'application/x-www-form-urlencoded') {
|
||||||
bodyType = 'application/x-www-form-urlencoded';
|
bodyType = 'application/x-www-form-urlencoded';
|
||||||
body = {
|
body = {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
form: (r.body.params ?? []).map((p: any) => ({
|
form: (r.body.params ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -104,7 +99,6 @@ function importHttpRequest(
|
|||||||
} else if (r.body?.mimeType === 'multipart/form-data') {
|
} else if (r.body?.mimeType === 'multipart/form-data') {
|
||||||
bodyType = 'multipart/form-data';
|
bodyType = 'multipart/form-data';
|
||||||
body = {
|
body = {
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
form: (r.body.params ?? []).map((p: any) => ({
|
form: (r.body.params ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -131,7 +125,6 @@ function importHttpRequest(
|
|||||||
name: r.name,
|
name: r.name,
|
||||||
description: r.meta?.description || undefined,
|
description: r.meta?.description || undefined,
|
||||||
url: r.url,
|
url: r.url,
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
urlParameters: (r.parameters ?? []).map((p: any) => ({
|
urlParameters: (r.parameters ?? []).map((p: any) => ({
|
||||||
enabled: !p.disabled,
|
enabled: !p.disabled,
|
||||||
name: p.name ?? '',
|
name: p.name ?? '',
|
||||||
@@ -146,7 +139,6 @@ function importHttpRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importGrpcRequest(
|
function importGrpcRequest(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
r: any,
|
r: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
@@ -156,7 +148,6 @@ function importGrpcRequest(
|
|||||||
const updated = r.meta?.modified ?? r.updated;
|
const updated = r.meta?.modified ?? r.updated;
|
||||||
const sortKey = r.meta?.sortKey ?? r.sortKey;
|
const sortKey = r.meta?.sortKey ?? r.sortKey;
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');
|
const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');
|
||||||
const service = parts[0] ?? null;
|
const service = parts[0] ?? null;
|
||||||
const method = parts[1] ?? null;
|
const method = parts[1] ?? null;
|
||||||
@@ -176,19 +167,16 @@ function importGrpcRequest(
|
|||||||
method,
|
method,
|
||||||
message: r.body?.text ?? '',
|
message: r.body?.text ?? '',
|
||||||
metadata: (r.metadata ?? [])
|
metadata: (r.metadata ?? [])
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.map((h: any) => ({
|
.map((h: any) => ({
|
||||||
enabled: !h.disabled,
|
enabled: !h.disabled,
|
||||||
name: h.name ?? '',
|
name: h.name ?? '',
|
||||||
value: h.value ?? '',
|
value: h.value ?? '',
|
||||||
}))
|
}))
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
.filter(({ name, value }: any) => name !== '' || value !== ''),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function importWebsocketRequest(
|
function importWebsocketRequest(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
r: any,
|
r: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
@@ -215,21 +203,17 @@ function importWebsocketRequest(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
function importHeaders(obj: any) {
|
function importHeaders(obj: any) {
|
||||||
const headers = (obj.headers ?? [])
|
const headers = (obj.headers ?? [])
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.map((h: any) => ({
|
.map((h: any) => ({
|
||||||
enabled: !h.disabled,
|
enabled: !h.disabled,
|
||||||
name: h.name ?? '',
|
name: h.name ?? '',
|
||||||
value: h.value ?? '',
|
value: h.value ?? '',
|
||||||
}))
|
}))
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
.filter(({ name, value }: any) => name !== '' || value !== '');
|
.filter(({ name, value }: any) => name !== '' || value !== '');
|
||||||
return { headers } as const;
|
return { headers } as const;
|
||||||
}
|
}
|
||||||
|
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
function importAuthentication(obj: any) {
|
function importAuthentication(obj: any) {
|
||||||
let authenticationType: string | null = null;
|
let authenticationType: string | null = null;
|
||||||
let authentication = {};
|
let authentication = {};
|
||||||
@@ -250,7 +234,6 @@ function importAuthentication(obj: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importFolder(
|
function importFolder(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
f: any,
|
f: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
parentId: string,
|
parentId: string,
|
||||||
@@ -302,7 +285,6 @@ function importFolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function importEnvironment(
|
function importEnvironment(
|
||||||
// biome-ignore lint/suspicious/noExplicitAny: none
|
|
||||||
e: any,
|
e: any,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
isParent?: boolean,
|
isParent?: boolean,
|
||||||
|
|||||||
Reference in New Issue
Block a user