2024-03-01 14:41:47 +01:00
|
|
|
import { Modules, Data } from '@strapi/types';
|
2023-11-15 11:08:04 +00:00
|
|
|
import { errors } from '@strapi/utils';
|
|
|
|
|
2024-03-01 14:41:47 +01:00
|
|
|
type PaginationQuery = Modules.EntityService.Params.Pagination.PageNotation;
|
2023-11-15 11:08:04 +00:00
|
|
|
|
2023-12-04 16:00:50 +00:00
|
|
|
export interface RelationResult {
|
2024-03-01 14:41:47 +01:00
|
|
|
id: Data.ID;
|
2023-11-15 11:08:04 +00:00
|
|
|
publishedAt: string | null;
|
2023-12-04 16:00:50 +00:00
|
|
|
}
|
2023-11-15 11:08:04 +00:00
|
|
|
|
2024-01-22 09:32:03 +00:00
|
|
|
export interface Pagination {
|
|
|
|
page: NonNullable<PaginationQuery['page']>;
|
|
|
|
pageSize: NonNullable<PaginationQuery['pageSize']>;
|
|
|
|
pageCount: number;
|
|
|
|
total: number;
|
|
|
|
}
|
|
|
|
|
2023-11-15 11:08:04 +00:00
|
|
|
/**
|
|
|
|
* GET /relations/:model/:targetField
|
|
|
|
*/
|
|
|
|
export declare namespace FindAvailable {
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
2024-01-22 09:32:03 +00:00
|
|
|
query: Partial<Pick<Pagination, 'pageSize' | 'page'>> & { _q?: string; _filter?: string };
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Params {
|
|
|
|
model: string;
|
|
|
|
targetField: string;
|
|
|
|
}
|
|
|
|
|
2023-12-04 16:00:50 +00:00
|
|
|
export type Response =
|
|
|
|
| {
|
|
|
|
results: RelationResult[];
|
2024-01-22 09:32:03 +00:00
|
|
|
pagination: Pagination;
|
2023-12-04 16:00:50 +00:00
|
|
|
error?: never;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
results?: never;
|
|
|
|
pagination?: never;
|
|
|
|
error?: errors.ApplicationError | errors.YupValidationError;
|
2023-11-15 11:08:04 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GET /relations/:model/:id/:targetField
|
|
|
|
*/
|
|
|
|
export declare namespace FindExisting {
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
2024-01-22 09:32:03 +00:00
|
|
|
query: Partial<Pick<Pagination, 'pageSize' | 'page'>>;
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Params {
|
|
|
|
model: string;
|
|
|
|
targetField: string;
|
2024-01-22 09:32:03 +00:00
|
|
|
id: string;
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|
|
|
|
|
2023-12-04 16:00:50 +00:00
|
|
|
export type Response =
|
|
|
|
| {
|
|
|
|
results: RelationResult[];
|
2024-01-22 09:32:03 +00:00
|
|
|
pagination: Pagination;
|
2023-12-04 16:00:50 +00:00
|
|
|
error?: never;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
data: RelationResult;
|
|
|
|
error?: never;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
data?: never;
|
|
|
|
error: errors.ApplicationError | errors.YupValidationError;
|
|
|
|
};
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|