43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
/**
|
|
* Categories file dumps by topic, and give each topic its own feed on the
|
|
* index. This module types them for the server and the client, with the bodies
|
|
* that create and change them. Only admins manage categories, through the API,
|
|
* since no page does it. The client lists them in its `CategoriesProvider`.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
/**
|
|
* Returned by the category routes. A category's feed lives at `/<slug>` on the
|
|
* client, and a dump names its categories by `id` in `categoryIds`.
|
|
*/
|
|
export interface Category {
|
|
id: string;
|
|
slug: string;
|
|
name: string;
|
|
/** Sorts the categories, lowest first. */
|
|
position: number;
|
|
createdAt: Date;
|
|
updatedAt?: Date;
|
|
}
|
|
|
|
/**
|
|
* Passed to `POST /api/categories`. The slug must be free and not reserved by
|
|
* a route.
|
|
*/
|
|
export interface CreateCategoryRequest {
|
|
slug: string;
|
|
name: string;
|
|
/** 0 when left out. */
|
|
position?: number;
|
|
}
|
|
|
|
/**
|
|
* Passed to `PUT /api/categories/:id`. A field left out keeps its value.
|
|
*/
|
|
export interface UpdateCategoryRequest {
|
|
slug?: string;
|
|
name?: string;
|
|
position?: number;
|
|
}
|