2024-03-13 10:25:47 +00:00
|
|
|
import { Documents, Entity, EntityService } from '@strapi/types';
|
2023-11-15 11:08:04 +00:00
|
|
|
import { errors } from '@strapi/utils';
|
|
|
|
|
|
|
|
type PaginationQuery = EntityService.Params.Pagination.PageNotation;
|
|
|
|
|
2023-12-04 16:00:50 +00:00
|
|
|
export interface RelationResult {
|
2024-03-13 10:25:47 +00:00
|
|
|
documentId: Documents.ID;
|
|
|
|
id: number;
|
|
|
|
status: Documents.Params.PublicationStatus.Kind;
|
|
|
|
locale?: Documents.Params.Locale;
|
|
|
|
[key: string]: unknown;
|
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;
|
|
|
|
}
|
|
|
|
|
2024-03-13 10:25:47 +00:00
|
|
|
type RelationResponse =
|
|
|
|
| {
|
|
|
|
results: RelationResult[];
|
|
|
|
pagination: Pagination;
|
|
|
|
error?: never;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
results?: never;
|
|
|
|
pagination?: never;
|
|
|
|
error: errors.ApplicationError | errors.YupValidationError;
|
|
|
|
};
|
|
|
|
|
2023-11-15 11:08:04 +00:00
|
|
|
/**
|
|
|
|
* GET /relations/:model/:targetField
|
|
|
|
*/
|
|
|
|
export declare namespace FindAvailable {
|
|
|
|
export interface Params {
|
|
|
|
model: string;
|
|
|
|
targetField: string;
|
|
|
|
}
|
|
|
|
|
2024-03-13 10:25:47 +00:00
|
|
|
export interface Request {
|
|
|
|
body: {};
|
|
|
|
query: Partial<Pick<Pagination, 'pageSize' | 'page'>> & {
|
|
|
|
id?: Entity.ID;
|
|
|
|
locale?: Documents.Params.Locale;
|
|
|
|
_filter?: string;
|
|
|
|
_q?: string;
|
|
|
|
idsToOmit?: Documents.ID[];
|
|
|
|
idsToInclude?: Documents.ID[];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Response = RelationResponse;
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GET /relations/:model/:id/:targetField
|
|
|
|
*/
|
|
|
|
export declare namespace FindExisting {
|
|
|
|
export interface Params {
|
|
|
|
model: string;
|
|
|
|
targetField: string;
|
2024-03-13 10:25:47 +00:00
|
|
|
id?: Entity.ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Request {
|
|
|
|
body: {};
|
|
|
|
query: Partial<Pick<Pagination, 'pageSize' | 'page'>> & {
|
|
|
|
locale?: string | null;
|
|
|
|
_filter?: string;
|
|
|
|
_q?: string;
|
|
|
|
status?: Documents.Params.PublicationStatus.Kind;
|
|
|
|
idsToOmit?: Documents.ID[];
|
|
|
|
idsToInclude?: Documents.ID[];
|
|
|
|
};
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|
|
|
|
|
2024-03-13 10:25:47 +00:00
|
|
|
export type Response = RelationResponse;
|
2023-11-15 11:08:04 +00:00
|
|
|
}
|