mirror of
https://github.com/strapi/strapi.git
synced 2025-09-21 06:22:30 +00:00

* feat: add drag-and-drop to relations Co-Authored-By: Marc Roig <20578351+Marc-Roig@users.noreply.github.com> * chore: spelling mistakes * chore: fix mainField accessing * chore: remove comment code Co-Authored-By: Marc Roig <marc12info@gmail.com> --------- Co-authored-by: Marc Roig <20578351+Marc-Roig@users.noreply.github.com> Co-authored-by: Marc Roig <marc12info@gmail.com>
81 lines
1.8 KiB
TypeScript
81 lines
1.8 KiB
TypeScript
import { Documents, Entity, EntityService } from '@strapi/types';
|
|
import { errors } from '@strapi/utils';
|
|
|
|
type PaginationQuery = EntityService.Params.Pagination.PageNotation;
|
|
|
|
export interface RelationResult {
|
|
documentId: Documents.ID;
|
|
id: number;
|
|
status: Documents.Params.PublicationStatus.Kind;
|
|
locale?: Documents.Params.Locale;
|
|
[key: string]: any;
|
|
}
|
|
|
|
export interface Pagination {
|
|
page: NonNullable<PaginationQuery['page']>;
|
|
pageSize: NonNullable<PaginationQuery['pageSize']>;
|
|
pageCount: number;
|
|
total: number;
|
|
}
|
|
|
|
type RelationResponse =
|
|
| {
|
|
results: RelationResult[];
|
|
pagination: Pagination;
|
|
error?: never;
|
|
}
|
|
| {
|
|
results?: never;
|
|
pagination?: never;
|
|
error: errors.ApplicationError | errors.YupValidationError;
|
|
};
|
|
|
|
/**
|
|
* GET /relations/:model/:targetField
|
|
*/
|
|
export declare namespace FindAvailable {
|
|
export interface Params {
|
|
model: string;
|
|
targetField: string;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* GET /relations/:model/:id/:targetField
|
|
*/
|
|
export declare namespace FindExisting {
|
|
export interface Params {
|
|
model: string;
|
|
targetField: string;
|
|
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[];
|
|
};
|
|
}
|
|
|
|
export type Response = RelationResponse;
|
|
}
|