import type { GlobalSlug, PayloadTypesShape, SelectType, TypedLocale } from 'payload' import type { PayloadSDK } from '../index.js' import type { PopulateType, SelectFromGlobalSlug, TransformGlobalWithSelect } from '../types.js' export type FindGlobalOptions< T extends PayloadTypesShape, TSlug extends GlobalSlug, TSelect = SelectFromGlobalSlug, > = { /** * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields. */ depth?: number /** * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api) */ draft?: boolean /** * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents. */ fallbackLocale?: false | TypedLocale /** * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents. */ locale?: 'all' | TypedLocale /** * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents. */ populate?: PopulateType /** * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result. */ select?: TSelect /** * the Global slug to operate against. */ slug: TSlug } export async function findGlobal< T extends PayloadTypesShape, TSlug extends GlobalSlug, TSelect extends SelectFromGlobalSlug, >( sdk: PayloadSDK, options: FindGlobalOptions, init?: RequestInit, ): Promise> { const response = await sdk.request({ args: options, init, method: 'GET', path: `/globals/${options.slug}`, }) return response.json() }