fix(editor): Fix ts errors across the board (no-changelog) (#9561)

This commit is contained in:
Tomi Turtiainen 2024-05-31 10:48:09 +03:00 committed by GitHub
parent 5887ed6498
commit 93fb9b5393
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 52 deletions

View file

@ -430,8 +430,8 @@ export interface IExecutionsCurrentSummaryExtended {
id: string;
finished?: boolean;
mode: WorkflowExecuteMode;
retryOf?: string;
retrySuccessId?: string;
retryOf?: string | null;
retrySuccessId?: string | null;
startedAt: Date;
stoppedAt?: Date;
workflowId: string;

View file

@ -2,18 +2,26 @@ import type { IRestApiContext } from '@/Interface';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type { IDataObject, MessageEventBusDestinationOptions } from 'n8n-workflow';
export type ApiMessageEventBusDestinationOptions = MessageEventBusDestinationOptions & {
id: string;
};
export function hasDestinationId(
destination: MessageEventBusDestinationOptions,
): destination is ApiMessageEventBusDestinationOptions {
return destination.id !== undefined;
}
export async function saveDestinationToDb(
context: IRestApiContext,
destination: MessageEventBusDestinationOptions,
destination: ApiMessageEventBusDestinationOptions,
subscribedEvents: string[] = [],
) {
if (destination.id) {
const data: IDataObject = {
...destination,
subscribedEvents,
};
return await makeRestApiRequest(context, 'POST', '/eventbus/destination', data);
}
const data: IDataObject = {
...destination,
subscribedEvents,
};
return await makeRestApiRequest(context, 'POST', '/eventbus/destination', data);
}
export async function deleteDestinationFromDb(context: IRestApiContext, destinationId: string) {
@ -22,14 +30,12 @@ export async function deleteDestinationFromDb(context: IRestApiContext, destinat
export async function sendTestMessageToDestination(
context: IRestApiContext,
destination: MessageEventBusDestinationOptions,
destination: ApiMessageEventBusDestinationOptions,
) {
if (destination.id) {
const data: IDataObject = {
...destination,
};
return await makeRestApiRequest(context, 'GET', '/eventbus/testmessage', data);
}
const data: IDataObject = {
...destination,
};
return await makeRestApiRequest(context, 'GET', '/eventbus/testmessage', data);
}
export async function getEventNamesFromBackend(context: IRestApiContext): Promise<string[]> {

View file

@ -1,3 +1,4 @@
import type { RawAxiosRequestHeaders } from 'axios';
import type {
ITemplatesCategory,
ITemplatesCollection,
@ -8,7 +9,6 @@ import type {
IWorkflowTemplate,
TemplateSearchFacet,
} from '@/Interface';
import type { IDataObject } from 'n8n-workflow';
import { get } from '@/utils/apiUtils';
function stringifyArray(arr: number[]) {
@ -21,7 +21,7 @@ export async function testHealthEndpoint(apiEndpoint: string) {
export async function getCategories(
apiEndpoint: string,
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<{ categories: ITemplatesCategory[] }> {
return await get(apiEndpoint, '/templates/categories', undefined, headers);
}
@ -29,12 +29,12 @@ export async function getCategories(
export async function getCollections(
apiEndpoint: string,
query: ITemplatesQuery,
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<{ collections: ITemplatesCollection[] }> {
return await get(
apiEndpoint,
'/templates/collections',
{ category: stringifyArray(query.categories || []), search: query.search },
{ category: query.categories, search: query.search },
headers,
);
}
@ -42,7 +42,7 @@ export async function getCollections(
export async function getWorkflows(
apiEndpoint: string,
query: { page: number; limit: number; categories: number[]; search: string },
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<{
totalWorkflows: number;
workflows: ITemplatesWorkflow[];
@ -64,7 +64,7 @@ export async function getWorkflows(
export async function getCollectionById(
apiEndpoint: string,
collectionId: string,
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<{ collection: ITemplatesCollectionResponse }> {
return await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);
}
@ -72,7 +72,7 @@ export async function getCollectionById(
export async function getTemplateById(
apiEndpoint: string,
templateId: string,
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<{ workflow: ITemplatesWorkflowResponse }> {
return await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);
}
@ -80,7 +80,7 @@ export async function getTemplateById(
export async function getWorkflowTemplate(
apiEndpoint: string,
templateId: string,
headers?: IDataObject,
headers?: RawAxiosRequestHeaders,
): Promise<IWorkflowTemplate> {
return await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);
}

View file

@ -5,7 +5,12 @@ import type {
IWorkflowDb,
NewWorkflowResponse,
} from '@/Interface';
import type { ExecutionFilters, ExecutionOptions, IDataObject } from 'n8n-workflow';
import type {
ExecutionFilters,
ExecutionOptions,
ExecutionSummary,
IDataObject,
} from 'n8n-workflow';
import { makeRestApiRequest } from '@/utils/apiUtils';
export async function getNewWorkflow(context: IRestApiContext, data?: IDataObject) {
@ -40,7 +45,11 @@ export async function getActiveWorkflows(context: IRestApiContext) {
}
export async function getActiveExecutions(context: IRestApiContext, filter: IDataObject) {
const output = await makeRestApiRequest(context, 'GET', '/executions', { filter });
const output = await makeRestApiRequest<{
results: ExecutionSummary[];
count: number;
estimated: boolean;
}>(context, 'GET', '/executions', { filter });
return output.results;
}

View file

@ -63,9 +63,7 @@ describe('BannerStack', () => {
it('should dismiss banner on click', async () => {
const { getByTestId } = renderComponent();
const dismissBannerSpy = vi
.spyOn(uiStore, 'dismissBanner')
.mockImplementation(async (banner, mode) => {});
const dismissBannerSpy = vi.spyOn(uiStore, 'dismissBanner').mockImplementation(async () => {});
expect(getByTestId('banners-V1')).toBeInTheDocument();
const closeTrialBannerButton = getByTestId('banner-V1-close');
expect(closeTrialBannerButton).toBeInTheDocument();
@ -75,9 +73,7 @@ describe('BannerStack', () => {
it('should permanently dismiss banner on click', async () => {
const { getByTestId } = renderComponent();
const dismissBannerSpy = vi
.spyOn(uiStore, 'dismissBanner')
.mockImplementation(async (banner, mode) => {});
const dismissBannerSpy = vi.spyOn(uiStore, 'dismissBanner').mockImplementation(async () => {});
const permanentlyDismissBannerLink = getByTestId('banner-confirm-v1');
expect(permanentlyDismissBannerLink).toBeInTheDocument();

View file

@ -4,6 +4,7 @@ import {
deleteDestinationFromDb,
getDestinationsFromBackend,
getEventNamesFromBackend,
hasDestinationId,
saveDestinationToDb,
sendTestMessageToDestination,
} from '../api/eventbus.ee';
@ -186,29 +187,31 @@ export const useLogStreamingStore = defineStore('logStreaming', {
}
},
async saveDestination(destination: MessageEventBusDestinationOptions): Promise<boolean> {
if (destination.id) {
const rootStore = useRootStore();
const selectedEvents = this.getSelectedEvents(destination.id);
try {
await saveDestinationToDb(rootStore.getRestApiContext, destination, selectedEvents);
this.updateDestination(destination);
return true;
} catch (e) {
return false;
}
if (!hasDestinationId(destination)) {
return false;
}
const rootStore = useRootStore();
const selectedEvents = this.getSelectedEvents(destination.id);
try {
await saveDestinationToDb(rootStore.getRestApiContext, destination, selectedEvents);
this.updateDestination(destination);
return true;
} catch (e) {
return false;
}
return false;
},
async sendTestMessage(destination: MessageEventBusDestinationOptions) {
if (destination.id) {
const rootStore = useRootStore();
const testResult = await sendTestMessageToDestination(
rootStore.getRestApiContext,
destination,
);
return testResult;
if (!hasDestinationId(destination)) {
return false;
}
return false;
const rootStore = useRootStore();
const testResult = await sendTestMessageToDestination(
rootStore.getRestApiContext,
destination,
);
return testResult;
},
async fetchEventNames(): Promise<string[]> {
const rootStore = useRootStore();