Skip to content

Commit

Permalink
docs(content-releases): add missing endpoints to backend docs (#19302)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Feranchz and markkaylor committed Jan 30, 2024
1 parent 3844395 commit 1df99d4
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
47 changes: 47 additions & 0 deletions docs/docs/docs/01-core/admin/05-features/hooks/use-document.mdx
Original file line number Diff line number Diff line change
@@ -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.
49 changes: 48 additions & 1 deletion docs/docs/docs/01-core/content-releases/01-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand All @@ -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`
Expand Down Expand Up @@ -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.

0 comments on commit 1df99d4

Please sign in to comment.