fix!: improve collection / global slugs type-safety in various places (#8311)

**BREAKING:**
Improves type-safety of collection / global slugs by using `CollectionSlug` / `UploadCollectionSlug` and `GlobalSlug` types instead of `string` in these places:
Adds `UploadCollectionSlug` and `TypedUploadCollection` utility types

This also changes how we suggest to add an upload collection to a cloud-storage adapter:
Before:
```ts
azureStorage({
  collections: {
    [Media.slug]: true,
  },
}) 
``` 

After:
```ts
azureStorage({
  collections: {
    media: true,
  },
}) 
```
This commit is contained in:
Sasha
2024-11-15 21:33:26 +02:00
committed by GitHub
parent a5cae077cc
commit 810c29b189
26 changed files with 92 additions and 65 deletions

View File

@@ -1,3 +1,5 @@
import type { CollectionSlug } from 'payload'
export type Breadcrumb = {
doc: string
label: string
@@ -22,7 +24,7 @@ export type NestedDocsPluginConfig = {
/**
* The slugs of the collections this plugin should extend. If you need different configs for different collections, this plugin can be added to your config more than once having different collections.
*/
collections: string[]
collections: CollectionSlug[]
generateLabel?: GenerateLabel
generateURL?: GenerateURL
/**