UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

1 lines 3.35 kB
{"version":3,"file":"link.cjs","sources":["../../../../src/types/value/link.ts"],"sourcesContent":["import type { AnyRegularField, FieldState } from \"./types\"\n\nimport type { FilledContentRelationshipField } from \"./contentRelationship\"\nimport type { GroupField } from \"./group\"\nimport type { FilledLinkToMediaField } from \"./linkToMedia\"\nimport type { SliceZone } from \"./sliceZone\"\n\n/**\n * Link types\n */\nexport const LinkType = {\n\tAny: \"Any\",\n\tDocument: \"Document\",\n\tMedia: \"Media\",\n\tWeb: \"Web\",\n} as const\n\n/**\n * A link field.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the\n * `fetchLinks` or `graphQuery` query parameter).\n * @typeParam State - State of the field which determines its shape.\n * @typeParam Variant - Variants of the link.\n */\nexport type LinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tState extends FieldState = FieldState,\n\tVariant = string,\n> = State extends \"empty\"\n\t? EmptyLinkField<typeof LinkType.Any, Variant>\n\t: FilledLinkField<TypeEnum, LangEnum, DataInterface, Variant>\n\n/**\n * A link field that is filled.\n *\n * @typeParam TypeEnum - Type API ID of the document.\n * @typeParam LangEnum - Language API ID of the document.\n * @typeParam DataInterface - Data fields for the document (filled via the\n * `fetchLinks` or `graphQuery` query parameter).\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkField<\n\tTypeEnum = string,\n\tLangEnum = string,\n\tDataInterface extends\n\t\t| Record<string, AnyRegularField | GroupField | SliceZone>\n\t\t| unknown = unknown,\n\tVariant = string,\n> =\n\t| (FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> &\n\t\t\tOptionalLinkProperties<Variant>)\n\t| FilledLinkToMediaField<Variant>\n\t| FilledLinkToWebField<Variant>\n\n/**\n * A link field that is not filled.\n *\n * @typeParam _Unused - THIS PARAMETER IS NOT USED. If you are passing a type,\n * **please remove it**.\n * @typeParam Variant - Variants of the link.\n */\nexport type EmptyLinkField<\n\t_Unused extends\n\t\t(typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,\n\tVariant = string,\n> = {\n\tlink_type: \"Any\"\n} & OptionalLinkProperties<Variant>\n\n/**\n * A link field pointing to a relative or absolute URL.\n *\n * @typeParam Variant - Variants of the link.\n */\nexport type FilledLinkToWebField<Variant = string> = {\n\tlink_type: \"Web\"\n\turl: string\n\ttarget?: string\n} & OptionalLinkProperties<Variant>\n\n/**\n * Optional properties available to link fields. It is used to augment existing\n * link-like fields (like content relationship fields) with field-specific\n * properties.\n *\n * @typeParam Variant - Variants of the link.\n *\n * @internal\n */\n// Remember to update the `getOptionalLinkProperties()` function when updating\n// this type. The function should check for every property.\nexport type OptionalLinkProperties<Variant = string> = {\n\ttext?: string\n\tvariant?: Variant\n}\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW;AAAA,EACvB,KAAK;AAAA,EACL,UAAU;AAAA,EACV,OAAO;AAAA,EACP,KAAK;;;"}