refactor(core): Separate list query entities from request types (#15015)

This commit is contained in:
Iván Ovejero
2025-04-30 13:34:50 +02:00
committed by GitHub
parent b4a06aaff9
commit 442cd094ee
28 changed files with 120 additions and 135 deletions

View File

@@ -11,7 +11,8 @@ import type {
import type { Project } from '@/databases/entities/project';
import type { User } from '@/databases/entities/user';
import type { WorkflowHistory } from '@/databases/entities/workflow-history';
import type { ListQuery } from '@/types-db';
import type { ListQueryDb } from './types-db';
export type APIRequest<
RouteParams = {},
@@ -42,13 +43,35 @@ export type AuthenticatedRequest<
};
};
export namespace ListQuery {
export type Request = AuthenticatedRequest<{}, {}, {}, Params> & {
listQueryOptions?: Options;
};
export type Params = {
filter?: string;
skip?: string;
take?: string;
select?: string;
sortBy?: string;
};
export type Options = {
filter?: Record<string, unknown>;
select?: Record<string, true>;
skip?: number;
take?: number;
sortBy?: string;
};
}
// ----------------------------------
// list query
// ----------------------------------
export function hasSharing(
workflows: ListQuery.Workflow.Plain[] | ListQuery.Workflow.WithSharing[],
): workflows is ListQuery.Workflow.WithSharing[] {
workflows: ListQueryDb.Workflow.Plain[] | ListQueryDb.Workflow.WithSharing[],
): workflows is ListQueryDb.Workflow.WithSharing[] {
return workflows.some((w) => 'shared' in w);
}