docs(content-releases): add missing endpoints to backend docs (#19302)

* docs(content-releases): add missing endpoints to backend docs

* Update docs/docs/docs/01-core/content-releases/01-backend.md

Co-authored-by: markkaylor <mark.kaylor@strapi.io>

* Update docs/docs/docs/01-core/content-releases/01-backend.md

Co-authored-by: markkaylor <mark.kaylor@strapi.io>

* Update docs/docs/docs/01-core/content-releases/01-backend.md

Co-authored-by: markkaylor <mark.kaylor@strapi.io>

* apply marks feedback

---------

Co-authored-by: markkaylor <mark.kaylor@strapi.io>
This commit is contained in:
Fernando Chávez 2024-01-30 09:24:06 +01:00 committed by GitHub
parent 3844395bef
commit 1df99d479d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 95 additions and 1 deletions

View File

@ -0,0 +1,47 @@
---
title: unstable_useDocument
description: API reference for the useDocument hook
tags:
- admin
- hooks
- document
- validations
---
:::caution
This hook is not stable and **likely to change**. Use at your own risk.
:::
A hook that returns utilities to work with documents.
## Usage
```
function Component() {
const { validate } = unstable_useDocument();
}
```
At the moment, useDocument only returns a validate function.
### `validate()`
```ts
const validate(
entry: Entity,
{
contentType: Schema.ContentType,
components: {
[key: Schema.Component['uid']]: Schema.Component;
},
isCreatingEntry?: boolean;
}
): {
errors: { [key: string]: TranslationMessage }
}
```
With this function, you can apply the same validations we use in the admin. Please be aware that for this function to work, you need to ensure the following:
1. If you are validating an entry with relations/components/dynamic zones then it **MUST** be populated. Otherwise, the validations will pass even if there is an error on one populated field.
2. The correct schema for the contentType and the schemas for any components related to that content type are mandatory for this hook to function correctly.

View File

@ -56,6 +56,19 @@ packages/core/content-releases/server/src/routes/release.ts
}
```
**Get all releases with/without an entry**:
- method: `GET`
- endpoint: `/content-releases/`
- params:
```ts
{
contentTypeUid: string;
entryId: number;
hasEntryAttached?: boolean;
}
```
**Get a single release**
- method: `GET`
@ -83,6 +96,11 @@ packages/core/content-releases/server/src/routes/release.ts
}
```
**Delete a release**:
- method: `DELETE`
- endpoint: `/content-releases/:id`
**Publish a release**:
- method: `POST`
@ -100,12 +118,25 @@ packages/core/content-releases/server/src/routes/release.ts
{
entry: {
id: number,
contentType: string
contentType: string,
locale: string,
}
type: 'publish' | 'unpublish'
}
```
**Get release actions from a release**
- method: `GET`
- endpoint: `/content-releases/:releaseId/actions`
- body:
```ts
{
page: number;
pageSize: number;
}
```
**Update a release action**
- method: `PUT`
@ -153,3 +184,19 @@ Exposes validation functions to run before performing operations on a Release
```
packages/core/content-releases/server/src/services/validation.ts
```
## Migrations
We have two migrations that we run every time we sync the content types.
### `deleteActionsOnDisableDraftAndPublish`
When a user disables Draft and Publish in one Content Type we make sure to remove all the release actions related to entries of that content type to avoid errors.
### `deleteActionsOnDeleteContentType`
When a Content Type is deleted, delete all actions containing entries from that Content Type.
## Subscribing to Lifecycles Events
When an entry is deleted delete all actions containing that entry.