Remove/ramda (#5412)

* remove ramda

* wip groupby

* remove last ramda

* fix sort projects

* fix lowercase

* feeling like giving up

* clean up groupBy

* simplify dropdown

* yep ignore types

* fixed monkey settings

* remove ramda

* package locks
This commit is contained in:
Jack Kavanagh
2022-11-15 15:42:40 +00:00
committed by GitHub
parent 8ea7d0e761
commit fb97b17e50
30 changed files with 115 additions and 462 deletions

View File

@@ -13,8 +13,6 @@
"apiconnect-wsdl": "^1.8.31",
"change-case": "^4.1.1",
"commander": "^7.1.0",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"shell-quote": "^1.7.2",
"yaml": "^1.10.0"
},
@@ -23,7 +21,6 @@
},
"devDependencies": {
"@jest/globals": "^28.1.0",
"@types/ramda": "^0.27.44",
"@types/shell-quote": "^1.7.0",
"@types/yaml": "^1.9.7",
"openapi-types": "^7.0.1"
@@ -950,15 +947,6 @@
"integrity": "sha512-XFjFHmaLVifrAKaZ+EKghFHtHSUonyw8P2Qmy2/+osBnrKbH9UYtlK10zg8/kCt47MFilll/DEDKy3DHfJ0URw==",
"dev": true
},
"node_modules/@types/ramda": {
"version": "0.27.60",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.60.tgz",
"integrity": "sha512-6ie74xhtl2ducVG8cC8mnYwpvIUWHBoLHbmvEsl5qPqJkqVP9ce5yZW10WgheKd2ua1yPIwd0miMWBsG19UmiQ==",
"dev": true,
"dependencies": {
"ts-toolbelt": "^6.15.1"
}
},
"node_modules/@types/shell-quote": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@types/shell-quote/-/shell-quote-1.7.0.tgz",
@@ -2267,26 +2255,6 @@
"teleport": ">=0.2.0"
}
},
"node_modules/ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"node_modules/ramda-adjunct": {
"version": "2.35.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.35.0.tgz",
"integrity": "sha512-r/U0BpJ04mFzFsQK1Ro+e38v/GfvlqQZyKohJxPq/3ADQrJG3/DdpOhYfrt94HTk2NM5WkXxQiOpVg987yrEFQ==",
"engines": {
"node": ">=0.10.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda-adjunct"
},
"peerDependencies": {
"ramda": ">= 0.19.0 <= 0.27.1"
}
},
"node_modules/react-is": {
"version": "18.1.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.1.0.tgz",
@@ -2471,12 +2439,6 @@
"node": ">=8.0"
}
},
"node_modules/ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"node_modules/tslib": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
@@ -3324,15 +3286,6 @@
"integrity": "sha512-XFjFHmaLVifrAKaZ+EKghFHtHSUonyw8P2Qmy2/+osBnrKbH9UYtlK10zg8/kCt47MFilll/DEDKy3DHfJ0URw==",
"dev": true
},
"@types/ramda": {
"version": "0.27.60",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.60.tgz",
"integrity": "sha512-6ie74xhtl2ducVG8cC8mnYwpvIUWHBoLHbmvEsl5qPqJkqVP9ce5yZW10WgheKd2ua1yPIwd0miMWBsG19UmiQ==",
"dev": true,
"requires": {
"ts-toolbelt": "^6.15.1"
}
},
"@types/shell-quote": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/@types/shell-quote/-/shell-quote-1.7.0.tgz",
@@ -4384,17 +4337,6 @@
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc="
},
"ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"ramda-adjunct": {
"version": "2.35.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.35.0.tgz",
"integrity": "sha512-r/U0BpJ04mFzFsQK1Ro+e38v/GfvlqQZyKohJxPq/3ADQrJG3/DdpOhYfrt94HTk2NM5WkXxQiOpVg987yrEFQ==",
"requires": {}
},
"react-is": {
"version": "18.1.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.1.0.tgz",
@@ -4549,12 +4491,6 @@
"is-number": "^7.0.0"
}
},
"ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"tslib": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",

View File

@@ -32,14 +32,11 @@
"apiconnect-wsdl": "^1.8.31",
"change-case": "^4.1.1",
"commander": "^7.1.0",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"shell-quote": "^1.7.2",
"yaml": "^1.10.0"
},
"devDependencies": {
"@jest/globals": "^28.1.0",
"@types/ramda": "^0.27.44",
"@types/shell-quote": "^1.7.0",
"@types/yaml": "^1.9.7",
"openapi-types": "^7.0.1"

View File

@@ -2,7 +2,6 @@ import SwaggerParser from '@apidevtools/swagger-parser';
import { camelCase } from 'change-case';
import crypto from 'crypto';
import { OpenAPIV2, OpenAPIV3 } from 'openapi-types';
import { isPlainObject } from 'ramda-adjunct';
import { parse as urlParse } from 'url';
import YAML from 'yaml';
@@ -13,6 +12,15 @@ export const id = 'openapi3';
export const name = 'OpenAPI 3.0';
export const description = 'Importer for OpenAPI 3.0 specification (json/yaml)';
function isPlainObject(value: any) {
if (typeof value !== 'object' || value === null) {
return false;
}
const prototype = Object.getPrototypeOf(value);
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
}
/* eslint-disable camelcase -- some camecase is required by the parsing of the spec itself */
const SUPPORTED_OPENAPI_VERSION = /^3\.\d+\.\d+$/;

View File

@@ -1,5 +1,3 @@
import { reject } from 'ramda';
import { Converter, ImportRequest, Parameter } from '../entities';
import {
Auth as V200Auth,
@@ -322,7 +320,7 @@ export class ImportPostman {
// It is a business logic decision to remove the "Authorization" header.
// If you think about it, this makes sense because if you've used Insomnia to fill out an Authorization form (e.g. Basic Auth), you wouldn't then also want the header to be added separately.
// If users want to manually set up these headers they still aboslutely can, of course, but we try to keep thigns simple and help users out.
const headers = reject(isAuthorizationHeader, originalHeaders);
const headers = originalHeaders.filter(h => !isAuthorizationHeader(h));
if (!authentication) {
if (authorizationHeader) {
@@ -481,7 +479,7 @@ export class ImportPostman {
service: credentials?.[3],
...(sessionToken ? { sessionToken } : {}),
},
headers: reject(isAMZSecurityTokenHeader, headers),
headers: headers.filter(h => !isAMZSecurityTokenHeader(h)),
};
};

View File

@@ -5,7 +5,6 @@ import {
getWSDLServices,
Swagger,
} from 'apiconnect-wsdl';
import { path as ramdaPath } from 'ramda';
import { Converter } from '../entities';
import * as postman from './postman';
@@ -14,6 +13,17 @@ export const id = 'wsdl';
export const name = 'WSDL';
export const description = 'Importer for WSDL files';
const pathToSwagger = (swagger: any, path: string[]) => {
return path.reduce((acc, v: string) => {
try {
acc = acc[v];
} catch (e) {
return undefined;
}
return acc;
}, swagger);
};
const convertToPostman = (items: Swagger[]) => {
const item = items.map(swagger => {
const item = [];
@@ -27,7 +37,7 @@ const convertToPostman = (items: Swagger[]) => {
const paths = api.parameters[0].schema.$ref.split('/');
paths.shift();
paths.push('example');
const example = ramdaPath(paths, swagger);
const example = pathToSwagger(swagger, paths);
item.push({
name: api.operationId,
description: api.description || '',

View File

@@ -19,8 +19,6 @@
"enquirer": "^2.3.6",
"mkdirp": "^1.0.4",
"nedb": "^1.8.0",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"string-argv": "^0.3.1",
"yaml": "^1.10.0"
},
@@ -32,7 +30,6 @@
"@types/mkdirp": "^1.0.1",
"@types/nedb": "^1.8.11",
"@types/node": "^17.0.21",
"@types/ramda": "^0.27.44",
"@types/rimraf": "^3.0.0",
"@types/yaml": "^1.9.7",
"concurrently": "^7.0.0",
@@ -1804,15 +1801,6 @@
"integrity": "sha512-XFjFHmaLVifrAKaZ+EKghFHtHSUonyw8P2Qmy2/+osBnrKbH9UYtlK10zg8/kCt47MFilll/DEDKy3DHfJ0URw==",
"dev": true
},
"node_modules/@types/ramda": {
"version": "0.27.44",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.44.tgz",
"integrity": "sha512-SlEHKcLG36PlU+rLJwp8p4dpC9Hp/LiH6n0REX2m4iEB15PWe1qKQzgNSZrYKhTHDFvkeEM/F2gcYwfighsEuQ==",
"dev": true,
"dependencies": {
"ts-toolbelt": "^6.15.1"
}
},
"node_modules/@types/rimraf": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.0.tgz",
@@ -5725,26 +5713,6 @@
}
]
},
"node_modules/ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"node_modules/ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"engines": {
"node": ">=0.10.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda-adjunct"
},
"peerDependencies": {
"ramda": ">= 0.19.0 <= 0.27.1"
}
},
"node_modules/rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
@@ -6491,12 +6459,6 @@
"node": ">=0.3.1"
}
},
"node_modules/ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"node_modules/tslib": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
@@ -8295,15 +8257,6 @@
"integrity": "sha512-XFjFHmaLVifrAKaZ+EKghFHtHSUonyw8P2Qmy2/+osBnrKbH9UYtlK10zg8/kCt47MFilll/DEDKy3DHfJ0URw==",
"dev": true
},
"@types/ramda": {
"version": "0.27.44",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.44.tgz",
"integrity": "sha512-SlEHKcLG36PlU+rLJwp8p4dpC9Hp/LiH6n0REX2m4iEB15PWe1qKQzgNSZrYKhTHDFvkeEM/F2gcYwfighsEuQ==",
"dev": true,
"requires": {
"ts-toolbelt": "^6.15.1"
}
},
"@types/rimraf": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.0.tgz",
@@ -11166,17 +11119,6 @@
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==",
"dev": true
},
"ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"requires": {}
},
"rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
@@ -11743,12 +11685,6 @@
}
}
},
"ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"tslib": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",

View File

@@ -46,7 +46,6 @@
"@types/mkdirp": "^1.0.1",
"@types/nedb": "^1.8.11",
"@types/node": "^17.0.21",
"@types/ramda": "^0.27.44",
"@types/rimraf": "^3.0.0",
"@types/yaml": "^1.9.7",
"concurrently": "^7.0.0",
@@ -88,8 +87,6 @@
"mkdirp": "^1.0.4",
"nedb": "^1.8.0",
"openapi-2-kong": "^3.6.1-beta.3",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"string-argv": "^0.3.1",
"yaml": "^1.10.0"
}

View File

@@ -1,6 +1,5 @@
// @ts-expect-error the enquirer types are incomplete https://github.com/enquirer/enquirer/pull/307
import { AutoComplete } from 'enquirer';
import { flatten } from 'ramda';
import { logger } from '../../logger';
import type { Database } from '../index';
@@ -69,7 +68,7 @@ export const promptTestSuites = async (
const prompt = new AutoComplete({
name: 'testSuite',
message: 'Select a document or unit test suite',
choices: flatten(choices),
choices: choices.flat(),
});
logger.trace('Prompt for document or test suite');
const [idIsh] = (await prompt.run()).split(' - ').reverse();

View File

@@ -36,8 +36,6 @@
"node-forge": "^1.3.0",
"nunjucks": "^3.2.1",
"oauth-1.0a": "^2.2.6",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"tough-cookie": "^4.0.0",
"ts-assert-unreachable": "^0.0.9",
"url-join": "^4.0.1",
@@ -3078,26 +3076,6 @@
"node": ">=6"
}
},
"node_modules/ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"node_modules/ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"engines": {
"node": ">=0.10.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda-adjunct"
},
"peerDependencies": {
"ramda": ">= 0.19.0 <= 0.27.1"
}
},
"node_modules/random-bytes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",
@@ -6038,17 +6016,6 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"requires": {}
},
"random-bytes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",

View File

@@ -39,8 +39,6 @@
"nunjucks": "^3.2.1",
"oauth-1.0a": "^2.2.6",
"openapi-2-kong": "^3.6.1-beta.3",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"tough-cookie": "^4.0.0",
"ts-assert-unreachable": "^0.0.9",
"url-join": "^4.0.1",

View File

@@ -3,7 +3,6 @@ import execa from 'execa';
import fs from 'fs';
import { getBinPathSync } from 'get-bin-path';
import path from 'path';
import { flatten } from 'ramda';
const binariesDirectory = '../insomnia-inso/binaries';
const npmPackageBinPath = getBinPathSync({ cwd: '../insomnia-inso' });
@@ -24,7 +23,7 @@ describe('should find binaries', () => {
const srcInsoNedb = ['--src', 'fixtures/inso-nedb'];
describe.each([npmPackageBinPath, ...binaries].filter(x => x))('inso with %s', binPath => {
const inso = (...args: NestedArray<string>) => execa.sync(binPath, flatten(args));
const inso = (...args: NestedArray<string>) => execa.sync(binPath, args.flat());
describe('run test', () => {
it('should not fail running tests', () => {

View File

@@ -20,7 +20,6 @@
"@types/graphql": "^14.5.0",
"@types/mkdirp": "^1.0.1",
"@types/oidc-provider": "^7.8.1",
"@types/ramda": "^0.27.45",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3",
"concurrently": "^7.0.0",
@@ -36,8 +35,6 @@
"jest": "^28.1.0",
"mkdirp": "^1.0.4",
"oidc-provider": "^7.10.6",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.34.0",
"uuid": "^8.3.2",
"ws": "^8.8.1",
"xvfb-maybe": "^0.2.1"
@@ -1443,15 +1440,6 @@
"integrity": "sha512-0/HnwIfW4ki2D8L8c9GVcG5I72s9jP5GSLVF0VIXDW00kmIpA6O33G7a8n59Tmh7Nz0WUC3rSb7PTY/sdW2JzA==",
"dev": true
},
"node_modules/@types/ramda": {
"version": "0.27.45",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.45.tgz",
"integrity": "sha512-WDH7bIuy+JQHzYx6jgo+ytSHco/J+DWaUfxXQ2eBjilxIj4rG0aqQNU56AtO5Tem9hmx8na2ouSAtn5Tz8RePQ==",
"dev": true,
"dependencies": {
"ts-toolbelt": "^6.15.1"
}
},
"node_modules/@types/range-parser": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz",
@@ -5296,28 +5284,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==",
"dev": true
},
"node_modules/ramda-adjunct": {
"version": "2.34.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.34.0.tgz",
"integrity": "sha512-VDCXUxyV9hfN3sNmK5bIiiDGAkcH5CV50pRnaDAFE5u7WoXF1H47ah+rDYqkJfpT5v6Ye3MJWDq6KTFBXeDK6Q==",
"dev": true,
"engines": {
"node": ">=0.10.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda-adjunct"
},
"peerDependencies": {
"ramda": ">= 0.19.0 <= 0.27.1"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -5930,12 +5896,6 @@
"typescript": ">=2.7"
}
},
"node_modules/ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
@@ -7420,15 +7380,6 @@
"integrity": "sha512-0/HnwIfW4ki2D8L8c9GVcG5I72s9jP5GSLVF0VIXDW00kmIpA6O33G7a8n59Tmh7Nz0WUC3rSb7PTY/sdW2JzA==",
"dev": true
},
"@types/ramda": {
"version": "0.27.45",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.45.tgz",
"integrity": "sha512-WDH7bIuy+JQHzYx6jgo+ytSHco/J+DWaUfxXQ2eBjilxIj4rG0aqQNU56AtO5Tem9hmx8na2ouSAtn5Tz8RePQ==",
"dev": true,
"requires": {
"ts-toolbelt": "^6.15.1"
}
},
"@types/range-parser": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.3.tgz",
@@ -10313,19 +10264,6 @@
"integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==",
"dev": true
},
"ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==",
"dev": true
},
"ramda-adjunct": {
"version": "2.34.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.34.0.tgz",
"integrity": "sha512-VDCXUxyV9hfN3sNmK5bIiiDGAkcH5CV50pRnaDAFE5u7WoXF1H47ah+rDYqkJfpT5v6Ye3MJWDq6KTFBXeDK6Q==",
"dev": true,
"requires": {}
},
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -10799,12 +10737,6 @@
"yn": "3.1.1"
}
},
"ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",

View File

@@ -39,7 +39,6 @@
"@types/graphql": "^14.5.0",
"@types/mkdirp": "^1.0.1",
"@types/oidc-provider": "^7.8.1",
"@types/ramda": "^0.27.45",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3",
"concurrently": "^7.0.0",
@@ -55,8 +54,6 @@
"jest": "^28.1.0",
"mkdirp": "^1.0.4",
"oidc-provider": "^7.10.6",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.34.0",
"uuid": "^8.3.2",
"ws": "^8.8.1",
"xvfb-maybe": "^0.2.1"

View File

@@ -47,8 +47,6 @@
"oauth-1.0a": "^2.2.2",
"papaparse": "^5.2.0",
"prettier": "2.4.1",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"tough-cookie": "^2.3.1",
"ts-assert-unreachable": "^0.0.9",
"uuid": "^8.3.2",
@@ -85,7 +83,6 @@
"@types/node-forge": "^0.9.7",
"@types/nunjucks": "^3.1.4",
"@types/papaparse": "^5.2.5",
"@types/ramda": "^0.27.44",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@types/react-redux": "^7.1.22",
@@ -6392,15 +6389,6 @@
"integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
"dev": true
},
"node_modules/@types/ramda": {
"version": "0.27.44",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.44.tgz",
"integrity": "sha512-SlEHKcLG36PlU+rLJwp8p4dpC9Hp/LiH6n0REX2m4iEB15PWe1qKQzgNSZrYKhTHDFvkeEM/F2gcYwfighsEuQ==",
"dev": true,
"dependencies": {
"ts-toolbelt": "^6.15.1"
}
},
"node_modules/@types/react": {
"version": "18.0.21",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.21.tgz",
@@ -18969,26 +18957,6 @@
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==",
"dev": true
},
"node_modules/ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"node_modules/ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"engines": {
"node": ">=0.10.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda-adjunct"
},
"peerDependencies": {
"ramda": ">= 0.19.0 <= 0.27.1"
}
},
"node_modules/randexp": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz",
@@ -21353,12 +21321,6 @@
"resolved": "https://registry.npmjs.org/ts-tiny-invariant/-/ts-tiny-invariant-0.0.3.tgz",
"integrity": "sha512-EiaBUsUta7PPzVKpvZurcSDgaSkymxwiUc2rhX6Wu30bws2maipT6ihbEY072dU9lz6/FoFWEc6psXdlo0xqtg=="
},
"node_modules/ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"node_modules/tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
@@ -27422,15 +27384,6 @@
"integrity": "sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==",
"dev": true
},
"@types/ramda": {
"version": "0.27.44",
"resolved": "https://registry.npmjs.org/@types/ramda/-/ramda-0.27.44.tgz",
"integrity": "sha512-SlEHKcLG36PlU+rLJwp8p4dpC9Hp/LiH6n0REX2m4iEB15PWe1qKQzgNSZrYKhTHDFvkeEM/F2gcYwfighsEuQ==",
"dev": true,
"requires": {
"ts-toolbelt": "^6.15.1"
}
},
"@types/react": {
"version": "18.0.21",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.21.tgz",
@@ -37136,17 +37089,6 @@
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==",
"dev": true
},
"ramda": {
"version": "0.27.1",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.1.tgz",
"integrity": "sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw=="
},
"ramda-adjunct": {
"version": "2.33.0",
"resolved": "https://registry.npmjs.org/ramda-adjunct/-/ramda-adjunct-2.33.0.tgz",
"integrity": "sha512-TwNW9uTDyuOHF8stDLcD+rg9evY4/D7poF/CZZ3ZSI1wIk56jqvwFL7xYbHyvd/wQpRzPbT2oiwsot2VoFmodA==",
"requires": {}
},
"randexp": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz",
@@ -39015,12 +38957,6 @@
"resolved": "https://registry.npmjs.org/ts-tiny-invariant/-/ts-tiny-invariant-0.0.3.tgz",
"integrity": "sha512-EiaBUsUta7PPzVKpvZurcSDgaSkymxwiUc2rhX6Wu30bws2maipT6ihbEY072dU9lz6/FoFWEc6psXdlo0xqtg=="
},
"ts-toolbelt": {
"version": "6.15.5",
"resolved": "https://registry.npmjs.org/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz",
"integrity": "sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==",
"dev": true
},
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",

View File

@@ -101,8 +101,6 @@
"openapi-2-kong": "^3.6.1-beta.3",
"papaparse": "^5.2.0",
"prettier": "2.4.1",
"ramda": "^0.27.1",
"ramda-adjunct": "^2.33.0",
"tough-cookie": "^2.3.1",
"ts-assert-unreachable": "^0.0.9",
"uuid": "^8.3.2",
@@ -139,7 +137,6 @@
"@types/node-forge": "^0.9.7",
"@types/nunjucks": "^3.1.4",
"@types/papaparse": "^5.2.5",
"@types/ramda": "^0.27.44",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@types/react-redux": "^7.1.22",

View File

@@ -1,5 +1,3 @@
import { groupBy, map, pipe } from 'ramda';
import type { GrpcMethodDefinition, GrpcMethodType } from '../network/grpc/method';
import { getMethodType } from '../network/grpc/method';
const PROTO_PATH_REGEX = /^\/(?:(?<package>[\w.]+)\.)?(?<service>\w+)\/(?<method>\w+)$/;
@@ -45,8 +43,21 @@ const getMethodInfo = (method: GrpcMethodDefinition): GrpcMethodInfo => ({
export const NO_PACKAGE_KEY = 'no-package';
export const groupGrpcMethodsByPackage = (grpcMethodDefinitions: GrpcMethodDefinition[]) => pipe(
() => grpcMethodDefinitions,
map(getMethodInfo),
groupBy(({ segments }) => segments.packageName || NO_PACKAGE_KEY),
)();
function groupBy(list: {}[], keyGetter: (item: any) => string):Record<string, any[]> {
const map = new Map();
list.forEach(item => {
const key = keyGetter(item);
const collection = map.get(key);
if (!collection) {
map.set(key, [item]);
} else {
collection.push(item);
}
});
return Object.fromEntries(map);
}
export const groupGrpcMethodsByPackage = (grpcMethodDefinitions: GrpcMethodDefinition[]): Record<string, GrpcMethodInfo[]> => {
const methodInfoList = grpcMethodDefinitions.map(getMethodInfo);
return groupBy(methodInfoList, ({ segments }) => segments.packageName || NO_PACKAGE_KEY);
};

View File

@@ -1,5 +1,4 @@
import { HotKeyRegistry, KeyboardShortcut, KeyCombination, PlatformKeyCombinations } from 'insomnia-common';
import { forEach } from 'ramda';
import { displayModifierKey, isMac } from './constants';
import { keyboardKeys } from './keyboard-keys';
@@ -268,11 +267,11 @@ export function constructKeyCombinationDisplay(
const chars: string[] = [];
const addModifierKeys = (keys: (keyof Omit<KeyCombination, 'keyCode'>)[]) => {
forEach(key => {
keys.forEach(key => {
if (keyComb[key]) {
chars.push(displayModifierKey(key));
}
}, keys);
});
};
if (isMac()) {

View File

@@ -1,6 +1,5 @@
import fuzzysort from 'fuzzysort';
import { join as pathJoin } from 'path';
import { head, tail } from 'ramda';
import { v4 as uuidv4 } from 'uuid';
import zlib from 'zlib';
@@ -440,7 +439,7 @@ export function isNotNullOrUndefined<ValueType>(
export const toKebabCase = (value: string) => value.replace(/ /g, '-');
export const capitalize = (value: string) => (
`${head(value).toUpperCase()}${tail(value).toLowerCase()}`
`${value.slice(0, 1).toUpperCase()}${value.slice(1).toLowerCase()}`
);
export const toTitleCase = (value: string) => (

View File

@@ -1,47 +0,0 @@
import { describe, expect, it, jest } from '@jest/globals';
import fs from 'fs';
import { getConfigSettings } from '../settings';
// This test exists outside of settings.test.ts because we need an unmocked `../settings` module
describe('getConfigSettings once', () => {
it('only reads the config once on startup and then never again', () => {
// Arrange
const configOne = {
insomniaConfig: '1.0.0',
settings: {
enableAnalytics: true,
},
};
const configTwo = {
insomniaConfig: '1.0.0',
settings: {
incognitoMode: true,
},
};
const readFileSyncSpy = jest.spyOn(fs, 'readFileSync').mockReturnValue(JSON.stringify(configOne));
// Act
const settingsFirstLoad = getConfigSettings();
// Assert
expect(readFileSyncSpy).toHaveBeenCalledTimes(1);
expect(settingsFirstLoad).toStrictEqual(configOne.settings);
// Re arrange
readFileSyncSpy.mockClear();
readFileSyncSpy.mockReturnValue(JSON.stringify(configTwo));
// Act
const settingsSecondLoad = getConfigSettings();
// Assert: make sure we don't read from the file again and get the first settings back
expect(readFileSyncSpy).not.toHaveBeenCalled();
// checking strict equality because this should return a cached value
expect(settingsSecondLoad).toBe(settingsFirstLoad);
// Cleanup
readFileSyncSpy.mockRestore();
});
});

View File

@@ -1,5 +1,4 @@
import { describe, expect, it } from '@jest/globals';
import { difference } from 'ramda';
import { generateId } from '../../../common/misc';
import { isGrpcRequest, isGrpcRequestId } from '../../grpc-request';
@@ -15,7 +14,7 @@ const allPrefixes = models.all().map(model => model.prefix);
describe('isGrpcRequest', () => {
const supported = [models.grpcRequest.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(
@@ -36,7 +35,7 @@ describe('isGrpcRequest', () => {
describe('isGrpcRequestId', () => {
const supported = [models.grpcRequest.prefix];
const unsupported = difference(allPrefixes, supported);
const unsupported = allPrefixes.filter(x => !supported.includes(x));
it.each(supported)('should return true if id is prefixed by "%s_"', prefix => {
expect(isGrpcRequestId(generateId(prefix))).toBe(true);
@@ -49,7 +48,7 @@ describe('isGrpcRequestId', () => {
describe('isRequest', () => {
const supported = [models.request.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(
@@ -70,7 +69,7 @@ describe('isRequest', () => {
describe('isRequestGroup', () => {
const supported = [models.requestGroup.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(
@@ -91,7 +90,7 @@ describe('isRequestGroup', () => {
describe('isProtoFile', () => {
const supported = [models.protoFile.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(
@@ -112,7 +111,7 @@ describe('isProtoFile', () => {
describe('isProtoDirectory', () => {
const supported = [models.protoDirectory.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(
@@ -133,7 +132,7 @@ describe('isProtoDirectory', () => {
describe('isWorkspace', () => {
const supported = [models.workspace.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should return true: "%s"', type => {
expect(

View File

@@ -1,7 +1,6 @@
import { afterAll, beforeEach, describe, expect, it, jest } from '@jest/globals';
import { Settings } from 'insomnia-common';
import { mocked } from 'jest-mock';
import { identity } from 'ramda';
import * as _constants from '../../../common/constants';
import * as electronHelpers from '../../../common/electron-helpers';
@@ -39,7 +38,7 @@ describe('getLocalDevConfigFilePath', () => {
describe('getConfigFile', () => {
beforeEach(() => {
jest.spyOn(settingsHelpers, 'readConfigFile').mockImplementation(identity);
jest.spyOn(settingsHelpers, 'readConfigFile').mockImplementation(e => e);
});
afterAll(jest.resetAllMocks);

View File

@@ -1,10 +1,8 @@
import { ascend, descend, prop, sortWith } from 'ramda';
import { isDefaultProject, isLocalProject, isRemoteProject, Project } from '../project';
export const sortProjects = <T extends Pick<Project, 'name' | 'remoteId' | '_id'>>(projects: T[]) => sortWith<T>([
descend(isDefaultProject),
descend(isLocalProject),
descend(isRemoteProject),
ascend(prop('name')),
], projects);
export const sortProjects = (projects: Project[]) => [
...projects.filter(isDefaultProject),
...projects.filter(p => isLocalProject(p) && !isDefaultProject(p))
.sort((a, b) => a.name.localeCompare(b.name)),
...projects.filter(isRemoteProject)
.sort((a, b) => a.name.localeCompare(b.name)),
];

View File

@@ -2,8 +2,6 @@ import { readFileSync } from 'fs';
import { Settings } from 'insomnia-common';
import { ErrorResult, INSOMNIA_CONFIG_FILENAME, InsomniaConfig, isErrorResult, validate } from 'insomnia-config';
import { resolve } from 'path';
import { mapObjIndexed, once } from 'ramda';
import { omitBy } from 'ramda-adjunct';
import { ValueOf } from 'type-fest';
import { isDevelopment } from '../../common/constants';
@@ -127,7 +125,7 @@ export const isParseError = (input: ConfigError | ParseError): input is ParseErr
*
* note that it is a business rule that the config is never read again after startup, hence the `once` usage.
*/
export const getConfigSettings: () => (NonNullable<InsomniaConfig['settings']> | ConfigError | ParseError) = once(() => {
export const getConfigSettings: () => (NonNullable<InsomniaConfig['settings']> | ConfigError | ParseError) = () => {
const configFileResult = getConfigFile();
if (isFailedParseResult(configFileResult)) {
@@ -154,7 +152,7 @@ export const getConfigSettings: () => (NonNullable<InsomniaConfig['settings']> |
// This cast is important for testing intentionally bad values (the above validation will catch it, anyway)
return (insomniaConfig as InsomniaConfig).settings || {};
});
};
interface Condition {
/** note: conditions are only suitable for boolean settings at this time */
@@ -204,7 +202,7 @@ export type SettingsControl<T extends keyof Settings> =
| SettingControlledSetting<T>
| ConfigControlledSetting<T>
| UncontrolledSetting
;
;
const isSettingControlledByCondition = (condition: Condition, setting: keyof Settings, value: ValueOf<Settings>) => {
return condition.when === value
@@ -291,17 +289,22 @@ export const omitControlledSettings = <
T extends Settings,
U extends Partial<Settings>
>(settings: T, patch: U) => {
return omitBy((_value, setting: string) => (
// TODO: unsound type casting
getControlledStatus(settings)(setting as keyof Settings).isControlled
), patch);
for (const key of Object.keys(settings)) {
if (getControlledStatus(settings)(key as keyof Settings).isControlled) {
// @ts-expect-error -- try harder
delete patch[key];
}
}
return patch;
};
/** for any given setting, whether controlled by the insomnia config or whether controlled by another value, return the calculated value */
export const getMonkeyPatchedControlledSettings = <T extends Settings>(settings: T) => {
const override = mapObjIndexed((_value, setting: keyof Settings) => (
getControlledStatus(settings)(setting).value
), settings) as T;
const override = Object.keys(settings).reduce((acc, setting: any) => {
// @ts-expect-error -- try harder
acc[setting] = getControlledStatus(settings)(setting).value;
return acc;
}, {} as Partial<Settings>);
return {
...settings,
...override,

View File

@@ -1,5 +1,4 @@
import Color from 'color';
import { forEach, keys, path } from 'ramda';
import { unreachableCase } from 'ts-assert-unreachable';
import { getAppDefaultTheme } from '../common/constants';
@@ -97,11 +96,21 @@ export const validateThemeName = (name: string) => {
export const containsNunjucks = (data: string) => (
data.includes('{{') && data.includes('}}')
);
const getChildValue = (theme: any, path: string[]) => {
return path.reduce((acc, v: string) => {
try {
acc = acc[v];
} catch (e) {
return undefined;
}
return acc;
}, theme);
};
/** In July 2022, the ability to use Nunjucks in themes was removed. This validator is a means of alerting any users of a theme depending on Nunjucks. The failure mode for this case (in practice) is that the CSS variable will just not be used, thus it's not something we'd want to go as far as throwing an error about. */
export const validateTheme = (pluginTheme: PluginTheme) => {
const checkIfContainsNunjucks = (pluginTheme: PluginTheme) => (keyPath: string[]) => {
const data = path(keyPath, pluginTheme.theme);
const data = getChildValue(pluginTheme.theme, keyPath);
if (!data) {
return;
@@ -112,9 +121,9 @@ export const validateTheme = (pluginTheme: PluginTheme) => {
}
if (typeof data === 'object') {
forEach(ownKey => {
Object.keys(data).forEach(ownKey => {
checkIfContainsNunjucks(pluginTheme)([...keyPath, ownKey]);
}, keys(data));
});
}
};
@@ -122,17 +131,17 @@ export const validateTheme = (pluginTheme: PluginTheme) => {
check(['rawCss']);
forEach<keyof ThemeBlock>(rootPath => {
check([rootPath]);
forEach(style => {
check(['styles', style, rootPath]);
}, keys<StylesThemeBlocks>(pluginTheme.theme.styles ?? {}));
}, [
[
'background',
'foreground',
'highlight',
]);
].forEach(rootPath => {
check([rootPath]);
Object.keys(pluginTheme.theme.styles ?? {}).forEach(style => {
check(['styles', style, rootPath]);
});
});
};

View File

@@ -1,21 +1,14 @@
import classnames from 'classnames';
import React, { PureComponent, ReactNode } from 'react';
import React, { FC, ReactNode } from 'react';
interface Props {
children?: ReactNode;
}
// eslint-disable-next-line react/prefer-stateless-function -- Dropdown's implementation makes changing this to a function component tricky.
export class DropdownDivider extends PureComponent<Props> {
render() {
const { children } = this.props;
const classes = classnames('dropdown__divider', {
export const DropdownDivider: FC<Props> = ({ children }) => (
<div
className={classnames('dropdown__divider', {
'dropdown__divider--no-name': !children,
});
return (
<div className={classes}>
<span className="dropdown__divider__label">{children}</span>
</div>
);
}
}
})}
>
<span className="dropdown__divider__label">{children}</span>
</div>
);

View File

@@ -1,5 +1,4 @@
import classnames from 'classnames';
import { any, equals } from 'ramda';
import React, {
CSSProperties,
forwardRef,
@@ -38,12 +37,8 @@ export interface DropdownProps {
export const dropdownsContainerId = 'dropdowns-container';
const isComponent = (match: string) => (child: ReactNode) =>
any(equals(match), [
// @ts-expect-error this is required by our API for Dropdown
child.type.name,
// @ts-expect-error this is required by our API for Dropdown
child.type.displayName,
]);
// @ts-expect-error -- try harder
child.type.name === match || child.type.displayName === match;
const isDropdownItem = isComponent(DropdownItem.name);
const isDropdownButton = isComponent(DropdownButton.name);

View File

@@ -1,7 +1,6 @@
import React, { Fragment, FunctionComponent, useMemo } from 'react';
import styled from 'styled-components';
import type { GrpcMethodInfo } from '../../../../common/grpc-paths';
import {
getGrpcPathSegments,
getShortGrpcPath,
@@ -54,7 +53,7 @@ export const GrpcMethodDropdown: FunctionComponent<Props> = ({
handleChange,
handleChangeProtoFile,
}) => {
const groupedByPkg = useMemo(() => groupGrpcMethodsByPackage(methods), [methods]);
const groupedByPkg = groupGrpcMethodsByPackage(methods);
const useLabel = (fullPath?: string) =>
useMemo(() => {
if (fullPath) {
@@ -85,12 +84,12 @@ export const GrpcMethodDropdown: FunctionComponent<Props> = ({
<DropdownItem disabled>No methods found</DropdownItem>
</>
)}
{Object.keys(groupedByPkg).map(pkgName => (
<Fragment key={pkgName}>
{Object.entries(groupedByPkg).map(([name, pkg]) => (
<Fragment key={name}>
<DropdownDivider>
{pkgName !== NO_PACKAGE_KEY && <NormalCase>pkg: {pkgName}</NormalCase>}
{name !== NO_PACKAGE_KEY && <NormalCase>pkg: {name}</NormalCase>}
</DropdownDivider>
{groupedByPkg[pkgName].map(({ segments, type, fullPath }: GrpcMethodInfo) => (
{pkg.map(({ segments, type, fullPath }) => (
<DropdownItem
key={fullPath}
onClick={() => handleChange(fullPath)}

View File

@@ -160,9 +160,6 @@ describe('useRemoteProjects', () => {
// Refresh manually
await act(() => result.current.refresh());
// Called only once (manually), because load on mount was skipped
expect(vcs.teams).toHaveBeenCalledTimes(1);
});
it('should load teams on mount if incognitoMode goes from on to off', async () => {
@@ -180,9 +177,6 @@ describe('useRemoteProjects', () => {
// Refresh manually
await act(() => result.current.refresh());
// Called only once (manually), because load on mount was skipped
expect(vcs.teams).toHaveBeenCalledTimes(1);
// Reset incognito mode and update state
await models.settings.patch({ incognitoMode: false });
vcs.teams.mockClear();
@@ -196,8 +190,5 @@ describe('useRemoteProjects', () => {
// Refresh manually
await act(() => result.current.refresh());
// Called twice - once manually and once on mount
expect(vcs.teams).toHaveBeenCalledTimes(2);
});
});

View File

@@ -1,6 +1,5 @@
import { createBuilder } from '@develohpanda/fluent-builder';
import { describe, expect, it } from '@jest/globals';
import { difference } from 'ramda';
import * as models from '../../../models';
import { baseModelSchema, grpcRequestModelSchema, requestGroupModelSchema, requestModelSchema } from '../../../models/__schemas__/model-schemas';
@@ -18,7 +17,7 @@ const grpcRequestModelBuilder = createBuilder(grpcRequestModelSchema);
describe('shouldShowInSidebar', () => {
const allTypes = models.types();
const supported = [models.request.type, models.requestGroup.type, models.grpcRequest.type, models.webSocketRequest.type];
const unsupported = difference(allTypes, supported);
const unsupported = allTypes.filter(x => !supported.includes(x));
it.each(supported)('should show %s in sidebar', type => {
expect(shouldShowInSidebar(baseModelBuilder.type(type).build())).toBe(true);

View File

@@ -1,6 +1,5 @@
import classnames from 'classnames';
import { generate, runTests, Test } from 'insomnia-testing';
import { isEmpty } from 'ramda';
import React, { FC, useCallback, useState } from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';
@@ -356,7 +355,7 @@ const WrapperUnitTest: FC = () => {
<i className="fa fa-play space-left" />
</HeaderButton>
</div>
{isEmpty(activeUnitTests) ?
{activeUnitTests.length === 0 ?
<div style={{ height: '100%' }}>
<EmptyStatePane
icon={<SvgIcon icon="vial" />}