fix(core): Fix type errors (no-changelog) (#9571)

This commit is contained in:
Danny Martini 2024-05-31 14:06:13 +02:00 committed by GitHub
parent 400c005866
commit 8da0d6e9ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 30 additions and 42 deletions

View file

@ -66,7 +66,7 @@ export class Queue {
: getRedisStandardClient(Redis, clientConfig, (type + '(bull)') as RedisClientType), : getRedisStandardClient(Redis, clientConfig, (type + '(bull)') as RedisClientType),
}); });
this.jobQueue.on('global:progress', (jobId, progress: WebhookResponse) => { this.jobQueue.on('global:progress', (_jobId, progress: WebhookResponse) => {
this.activeExecutions.resolveResponsePromise( this.activeExecutions.resolveResponsePromise(
progress.executionId, progress.executionId,
this.decodeWebhookResponse(progress.response), this.decodeWebhookResponse(progress.response),

View file

@ -13,7 +13,6 @@ import type {
} from '@/Interfaces'; } from '@/Interfaces';
import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData'; import * as WorkflowExecuteAdditionalData from '@/WorkflowExecuteAdditionalData';
import { ExecutionRepository } from '@db/repositories/execution.repository'; import { ExecutionRepository } from '@db/repositories/execution.repository';
import { OwnershipService } from './services/ownership.service';
import { Logger } from '@/Logger'; import { Logger } from '@/Logger';
import { ConflictError } from './errors/response-errors/conflict.error'; import { ConflictError } from './errors/response-errors/conflict.error';
import { NotFoundError } from './errors/response-errors/not-found.error'; import { NotFoundError } from './errors/response-errors/not-found.error';
@ -26,7 +25,6 @@ export class WaitingWebhooks implements IWebhookManager {
protected readonly logger: Logger, protected readonly logger: Logger,
private readonly nodeTypes: NodeTypes, private readonly nodeTypes: NodeTypes,
private readonly executionRepository: ExecutionRepository, private readonly executionRepository: ExecutionRepository,
private readonly ownershipService: OwnershipService,
) {} ) {}
// TODO: implement `getWebhookMethods` for CORS support // TODO: implement `getWebhookMethods` for CORS support

View file

@ -385,7 +385,7 @@ export class Worker extends BaseCommand {
app.get( app.get(
'/healthz', '/healthz',
async (req: express.Request, res: express.Response) => { async (_req: express.Request, res: express.Response) => {
this.logger.debug('Health check started!'); this.logger.debug('Health check started!');
const connection = Db.getConnection(); const connection = Db.getConnection();

View file

@ -13,7 +13,7 @@ export class TagsController {
// TODO: move this into a new decorator `@IfEnabled('workflowTagsDisabled')` // TODO: move this into a new decorator `@IfEnabled('workflowTagsDisabled')`
@Middleware() @Middleware()
workflowsEnabledMiddleware(req: Request, res: Response, next: NextFunction) { workflowsEnabledMiddleware(_req: Request, _res: Response, next: NextFunction) {
if (this.config.getEnv('workflowTagsDisabled')) if (this.config.getEnv('workflowTagsDisabled'))
throw new BadRequestError('Workflow tags are disabled'); throw new BadRequestError('Workflow tags are disabled');
next(); next();

View file

@ -3,7 +3,7 @@ import { Container } from 'typedi';
import { isSourceControlLicensed } from '../sourceControlHelper.ee'; import { isSourceControlLicensed } from '../sourceControlHelper.ee';
import { SourceControlPreferencesService } from '../sourceControlPreferences.service.ee'; import { SourceControlPreferencesService } from '../sourceControlPreferences.service.ee';
export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (req, res, next) => { export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (_req, res, next) => {
const sourceControlPreferencesService = Container.get(SourceControlPreferencesService); const sourceControlPreferencesService = Container.get(SourceControlPreferencesService);
if (sourceControlPreferencesService.isSourceControlLicensedAndEnabled()) { if (sourceControlPreferencesService.isSourceControlLicensedAndEnabled()) {
next(); next();
@ -19,7 +19,7 @@ export const sourceControlLicensedAndEnabledMiddleware: RequestHandler = (req, r
} }
}; };
export const sourceControlLicensedMiddleware: RequestHandler = (req, res, next) => { export const sourceControlLicensedMiddleware: RequestHandler = (_req, res, next) => {
if (isSourceControlLicensed()) { if (isSourceControlLicensed()) {
next(); next();
} else { } else {

View file

@ -6,7 +6,7 @@ export function islogStreamingLicensed(): boolean {
return Container.get(License).isLogStreamingEnabled(); return Container.get(License).isLogStreamingEnabled();
} }
export const logStreamingLicensedMiddleware: RequestHandler = (req, res, next) => { export const logStreamingLicensedMiddleware: RequestHandler = (_req, res, next) => {
if (islogStreamingLicensed()) { if (islogStreamingLicensed()) {
next(); next();
} else { } else {

View file

@ -17,7 +17,7 @@ const xmlParser = new XmlParser({
}); });
const payloadSizeMax = config.getEnv('endpoints.payloadSizeMax'); const payloadSizeMax = config.getEnv('endpoints.payloadSizeMax');
export const rawBodyReader: RequestHandler = async (req, res, next) => { export const rawBodyReader: RequestHandler = async (req, _res, next) => {
parseIncomingMessage(req); parseIncomingMessage(req);
req.readRawBody = async () => { req.readRawBody = async () => {
@ -70,7 +70,7 @@ export const parseBody = async (req: Request) => {
} }
}; };
export const bodyParser: RequestHandler = async (req, res, next) => { export const bodyParser: RequestHandler = async (req, _res, next) => {
await parseBody(req); await parseBody(req);
if (!req.body) req.body = {}; if (!req.body) req.body = {};
next(); next();

View file

@ -77,7 +77,7 @@ export class MetricsService extends EventEmitter {
} }
mountMetricsEndpoint(app: express.Application) { mountMetricsEndpoint(app: express.Application) {
app.get('/metrics', async (req: express.Request, res: express.Response) => { app.get('/metrics', async (_req: express.Request, res: express.Response) => {
const metrics = await promClient.register.metrics(); const metrics = await promClient.register.metrics();
res.setHeader('Content-Type', promClient.register.contentType); res.setHeader('Content-Type', promClient.register.contentType);
res.send(metrics).end(); res.send(metrics).end();

View file

@ -91,4 +91,4 @@ export function rightDiff<T1, T2>(
* Can be used to make sure the type is exhausted * Can be used to make sure the type is exhausted
* in switch statements or if/else chains. * in switch statements or if/else chains.
*/ */
export const assertNever = (value: never) => {}; export const assertNever = (_value: never) => {};

View file

@ -240,7 +240,7 @@ describe('POST /external-secrets/providers/:provider', () => {
const resp = await authOwnerAgent.post('/external-secrets/providers/dummy').send(testData); const resp = await authOwnerAgent.post('/external-secrets/providers/dummy').send(testData);
expect(resp.status).toBe(200); expect(resp.status).toBe(200);
const confirmResp = await authOwnerAgent.get('/external-secrets/providers/dummy'); await authOwnerAgent.get('/external-secrets/providers/dummy');
expect((await getExternalSecretsSettings())?.dummy.settings).toEqual({ expect((await getExternalSecretsSettings())?.dummy.settings).toEqual({
username: 'newuser', username: 'newuser',
password: 'testpass', password: 'testpass',

View file

@ -26,7 +26,6 @@ import {
import type { User } from '@/databases/entities/User'; import type { User } from '@/databases/entities/User';
import type { UserInvitationResult } from '../../shared/utils/users'; import type { UserInvitationResult } from '../../shared/utils/users';
import { ProjectRepository } from '@/databases/repositories/project.repository';
import { ProjectRelationRepository } from '@/databases/repositories/projectRelation.repository'; import { ProjectRelationRepository } from '@/databases/repositories/projectRelation.repository';
describe('InvitationController', () => { describe('InvitationController', () => {
@ -38,12 +37,10 @@ describe('InvitationController', () => {
let instanceOwner: User; let instanceOwner: User;
let userRepository: UserRepository; let userRepository: UserRepository;
let projectRepository: ProjectRepository;
let projectRelationRepository: ProjectRelationRepository; let projectRelationRepository: ProjectRelationRepository;
beforeAll(async () => { beforeAll(async () => {
userRepository = Container.get(UserRepository); userRepository = Container.get(UserRepository);
projectRepository = Container.get(ProjectRepository);
projectRelationRepository = Container.get(ProjectRelationRepository); projectRelationRepository = Container.get(ProjectRelationRepository);
instanceOwner = await createOwner(); instanceOwner = await createOwner();
}); });

View file

@ -536,7 +536,7 @@ describe('PUT /credentials/:id/share', () => {
test('should respond 200 for non-owned credentials for owners', async () => { test('should respond 200 for non-owned credentials for owners', async () => {
const savedCredential = await saveCredential(randomCredentialPayload(), { user: member }); const savedCredential = await saveCredential(randomCredentialPayload(), { user: member });
const response = await authOwnerAgent await authOwnerAgent
.put(`/credentials/${savedCredential.id}/share`) .put(`/credentials/${savedCredential.id}/share`)
.send({ shareWithIds: [anotherMemberPersonalProject.id] }) .send({ shareWithIds: [anotherMemberPersonalProject.id] })
.expect(200); .expect(200);

View file

@ -9,7 +9,6 @@ import { ProjectRepository } from '@db/repositories/project.repository';
import type { Project } from '@db/entities/Project'; import type { Project } from '@db/entities/Project';
import { CredentialsRepository } from '@db/repositories/credentials.repository'; import { CredentialsRepository } from '@db/repositories/credentials.repository';
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository'; import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
import { ProjectService } from '@/services/project.service';
import * as testDb from '../shared/testDb'; import * as testDb from '../shared/testDb';
import { setupTestServer } from '../shared/utils'; import { setupTestServer } from '../shared/utils';
@ -44,7 +43,6 @@ let authMemberAgent: SuperAgentTest;
let projectRepository: ProjectRepository; let projectRepository: ProjectRepository;
let sharedCredentialsRepository: SharedCredentialsRepository; let sharedCredentialsRepository: SharedCredentialsRepository;
let projectService: ProjectService;
beforeEach(async () => { beforeEach(async () => {
await testDb.truncate(['SharedCredentials', 'Credentials']); await testDb.truncate(['SharedCredentials', 'Credentials']);
@ -65,7 +63,6 @@ beforeEach(async () => {
projectRepository = Container.get(ProjectRepository); projectRepository = Container.get(ProjectRepository);
sharedCredentialsRepository = Container.get(SharedCredentialsRepository); sharedCredentialsRepository = Container.get(SharedCredentialsRepository);
projectService = Container.get(ProjectService);
}); });
type GetAllResponse = { body: { data: ListQuery.Credentials.WithOwnedByAndSharedWith[] } }; type GetAllResponse = { body: { data: ListQuery.Credentials.WithOwnedByAndSharedWith[] } };

View file

@ -130,6 +130,5 @@ const DEFAULT_POST_RESPONSE: { data: ILicensePostResponse } = {
}, },
}; };
const UNAUTHORIZED_RESPONSE = { status: 'error', message: 'Unauthorized' };
const ACTIVATION_FAILED_MESSAGE = 'Failed to activate license'; const ACTIVATION_FAILED_MESSAGE = 'Failed to activate license';
const GENERIC_ERROR_MESSAGE = 'Something went wrong'; const GENERIC_ERROR_MESSAGE = 'Something went wrong';

View file

@ -912,7 +912,7 @@ describe('PATCH /users/:id/role', () => {
createTeamProject(), createTeamProject(),
]); ]);
const [credential1, credential2, credential3] = await Promise.all([ await Promise.all([
saveCredential(randomCredentialPayload(), { saveCredential(randomCredentialPayload(), {
user, user,
role: 'credential:owner', role: 'credential:owner',

View file

@ -306,7 +306,7 @@ describe('PATCH /variables/:id', () => {
}); });
test('should not modify existing variable if one with the same key exists', async () => { test('should not modify existing variable if one with the same key exists', async () => {
const [var1, var2] = await Promise.all([ const [var1] = await Promise.all([
createVariable('test1', 'value1'), createVariable('test1', 'value1'),
createVariable(toModify.key, toModify.value), createVariable(toModify.key, toModify.value),
]); ]);
@ -327,7 +327,7 @@ describe('PATCH /variables/:id', () => {
// ---------------------------------------- // ----------------------------------------
describe('DELETE /variables/:id', () => { describe('DELETE /variables/:id', () => {
test('should delete a single variable for an owner', async () => { test('should delete a single variable for an owner', async () => {
const [var1, var2, var3] = await Promise.all([ const [var1] = await Promise.all([
createVariable('test1', 'value1'), createVariable('test1', 'value1'),
createVariable('test2', 'value2'), createVariable('test2', 'value2'),
createVariable('test3', 'value3'), createVariable('test3', 'value3'),
@ -344,7 +344,7 @@ describe('DELETE /variables/:id', () => {
}); });
test('should not delete a single variable for a member', async () => { test('should not delete a single variable for a member', async () => {
const [var1, var2, var3] = await Promise.all([ const [var1] = await Promise.all([
createVariable('test1', 'value1'), createVariable('test1', 'value1'),
createVariable('test2', 'value2'), createVariable('test2', 'value2'),
createVariable('test3', 'value3'), createVariable('test3', 'value3'),

View file

@ -91,7 +91,7 @@ describe('GET /workflow-history/:workflowId', () => {
), ),
); );
const versions2 = await Promise.all( await Promise.all(
new Array(10).fill(undefined).map(async (_) => await createWorkflowHistoryItem(workflow2.id)), new Array(10).fill(undefined).map(async (_) => await createWorkflowHistoryItem(workflow2.id)),
); );

View file

@ -63,7 +63,7 @@ export class DummyProvider extends SecretsProvider {
test2: 'value2', test2: 'value2',
}; };
async init(settings: SecretsProviderSettings<IDataObject>): Promise<void> {} async init(_settings: SecretsProviderSettings<IDataObject>): Promise<void> {}
async connect(): Promise<void> { async connect(): Promise<void> {
this.state = 'connected'; this.state = 'connected';
@ -101,7 +101,7 @@ export class ErrorProvider extends SecretsProvider {
state: SecretsProviderState = 'initializing'; state: SecretsProviderState = 'initializing';
async init(settings: SecretsProviderSettings<IDataObject>): Promise<void> { async init(_settings: SecretsProviderSettings<IDataObject>): Promise<void> {
throw new Error(); throw new Error();
} }
@ -122,11 +122,11 @@ export class ErrorProvider extends SecretsProvider {
throw new Error(); throw new Error();
} }
getSecret(name: string): IDataObject | undefined { getSecret(_name: string): IDataObject | undefined {
throw new Error(); throw new Error();
} }
hasSecret(name: string): boolean { hasSecret(_name: string): boolean {
throw new Error(); throw new Error();
} }
@ -144,7 +144,7 @@ export class FailedProvider extends SecretsProvider {
state: SecretsProviderState = 'initializing'; state: SecretsProviderState = 'initializing';
async init(settings: SecretsProviderSettings<IDataObject>): Promise<void> {} async init(_settings: SecretsProviderSettings<IDataObject>): Promise<void> {}
async connect(): Promise<void> { async connect(): Promise<void> {
this.state = 'error'; this.state = 'error';
@ -185,7 +185,7 @@ export class TestFailProvider extends SecretsProvider {
test2: 'value2', test2: 'value2',
}; };
async init(settings: SecretsProviderSettings<IDataObject>): Promise<void> {} async init(_settings: SecretsProviderSettings<IDataObject>): Promise<void> {}
async connect(): Promise<void> { async connect(): Promise<void> {
this.state = 'connected'; this.state = 'connected';

View file

@ -44,7 +44,7 @@ describe('CollaborationService', () => {
workflowId, workflowId,
}; };
const expectActiveUsersChangedMessage = (userIds: string[]) => { const expectActiveUsersChangedMessage = () => {
expect(push.sendToUsers).toHaveBeenCalledWith( expect(push.sendToUsers).toHaveBeenCalledWith(
'activeWorkflowUsersChanged', 'activeWorkflowUsersChanged',
{ {
@ -77,7 +77,7 @@ describe('CollaborationService', () => {
mockUserRepository.getByIds.mockResolvedValueOnce([{ id: userId } as User]); mockUserRepository.getByIds.mockResolvedValueOnce([{ id: userId } as User]);
await collaborationService.handleUserMessage(userId, message); await collaborationService.handleUserMessage(userId, message);
expectActiveUsersChangedMessage([userId]); expectActiveUsersChangedMessage();
}); });
}); });
@ -102,7 +102,7 @@ describe('CollaborationService', () => {
mockUserRepository.getByIds.mockResolvedValueOnce([{ id: userId } as User]); mockUserRepository.getByIds.mockResolvedValueOnce([{ id: userId } as User]);
await collaborationService.handleUserMessage(userId, message); await collaborationService.handleUserMessage(userId, message);
expectActiveUsersChangedMessage([userId]); expectActiveUsersChangedMessage();
}); });
}); });
}); });

View file

@ -5,12 +5,11 @@ import { mock } from 'jest-mock-extended';
describe('OnShutdown', () => { describe('OnShutdown', () => {
let shutdownService: ShutdownService; let shutdownService: ShutdownService;
let registerSpy: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
shutdownService = new ShutdownService(mock()); shutdownService = new ShutdownService(mock());
Container.set(ShutdownService, shutdownService); Container.set(ShutdownService, shutdownService);
registerSpy = jest.spyOn(shutdownService, 'register'); jest.spyOn(shutdownService, 'register');
}); });
it('should register a methods that is decorated with OnShutdown', () => { it('should register a methods that is decorated with OnShutdown', () => {
@ -49,6 +48,7 @@ describe('OnShutdown', () => {
}); });
it('should use the given priority', () => { it('should use the given priority', () => {
// @ts-expect-error We are checking the decorator.
class TestClass { class TestClass {
@OnShutdown(10) @OnShutdown(10)
async onShutdown() { async onShutdown() {

View file

@ -12,8 +12,6 @@ function setDefaultConfig() {
} }
const PUBSUB_CHANNEL = 'testchannel'; const PUBSUB_CHANNEL = 'testchannel';
const LIST_CHANNEL = 'testlist';
const STREAM_CHANNEL = 'teststream';
describe('RedisService', () => { describe('RedisService', () => {
beforeAll(async () => { beforeAll(async () => {
@ -41,7 +39,7 @@ describe('RedisService', () => {
expect(sub).toBeDefined(); expect(sub).toBeDefined();
const mockHandler = jest.fn(); const mockHandler = jest.fn();
mockHandler.mockImplementation((channel: string, message: string) => {}); mockHandler.mockImplementation((_channel: string, _message: string) => {});
sub.addMessageHandler(PUBSUB_CHANNEL, mockHandler); sub.addMessageHandler(PUBSUB_CHANNEL, mockHandler);
await sub.subscribe(PUBSUB_CHANNEL); await sub.subscribe(PUBSUB_CHANNEL);
await pub.publish(PUBSUB_CHANNEL, 'test'); await pub.publish(PUBSUB_CHANNEL, 'test');

View file

@ -3,11 +3,10 @@ import config from '@/config';
import { getWorkflowHistoryPruneTime } from '@/workflows/workflowHistory/workflowHistoryHelper.ee'; import { getWorkflowHistoryPruneTime } from '@/workflows/workflowHistory/workflowHistoryHelper.ee';
import { mockInstance } from '../shared/mocking'; import { mockInstance } from '../shared/mocking';
let licenseMock: License;
let licensePruneTime = -1; let licensePruneTime = -1;
beforeAll(async () => { beforeAll(async () => {
licenseMock = mockInstance(License, { mockInstance(License, {
getWorkflowHistoryPruneLimit() { getWorkflowHistoryPruneLimit() {
return licensePruneTime; return licensePruneTime;
}, },