@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
1 lines • 1.09 kB
Source Map (JSON)
{"version":3,"file":"getGraphQLEndpoint.cjs","names":["isRepositoryName","PrismicError"],"sources":["../src/getGraphQLEndpoint.ts"],"sourcesContent":["import { PrismicError } from \"./errors\"\n\nimport { isRepositoryName } from \"./isRepositoryName\"\n\n/**\n * Get a repository's Prismic GraphQL endpoint.\n *\n * @typeParam RepositoryName - Name of the Prismic repository.\n *\n * @param repositoryName - Name of the repository.\n *\n * @returns The repository's Prismic REST API V2 endpoint\n */\nexport const getGraphQLEndpoint = <RepositoryName extends string>(\n\trepositoryName: RepositoryName,\n): `https://${RepositoryName}.cdn.prismic.io/graphql` => {\n\tif (isRepositoryName(repositoryName)) {\n\t\treturn `https://${repositoryName}.cdn.prismic.io/graphql` as const\n\t} else {\n\t\tthrow new PrismicError(\n\t\t\t`An invalid Prismic repository name was given: ${repositoryName}`,\n\t\t\tundefined,\n\t\t\tundefined,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,sBACZ,mBACwD;AACxD,KAAIA,0CAAiB,eAAe,CACnC,QAAO,WAAW,eAAe;KAEjC,OAAM,IAAIC,4BACT,iDAAiD,kBACjD,QACA,OACA"}