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
6 changed files with 66 additions and 52 deletions

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;
}