UNPKG

@prismicio/client

Version:

The official JavaScript + TypeScript client library for Prismic

1 lines 1.52 kB
{"version":3,"file":"createClient.cjs","sources":["../../src/createClient.ts"],"sourcesContent":["import type { PrismicDocument } from \"./types/value/document\"\n\nimport type { ClientConfig } from \"./Client\"\nimport { Client } from \"./Client\"\n\n/**\n * Type definitions for the `createClient()` function. May be augmented by\n * third-party libraries.\n */\nexport interface CreateClient {\n\t<TDocuments extends PrismicDocument>(\n\t\t...args: ConstructorParameters<typeof Client>\n\t): Client<TDocuments>\n}\n\n/**\n * Creates a Prismic client that can be used to query a repository.\n *\n * @example\n *\n * ```ts\n * // With a repository name.\n * createClient(\"qwerty\")\n *\n * // Or with a full Prismic Rest API V2 endpoint.\n * createClient(\"https://qwerty.cdn.prismic.io/api/v2\")\n * ```\n *\n * @typeParam TDocuments - A union of Prismic document types for the repository.\n *\n * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest\n * API V2 endpoint for the repository.\n * @param options - Configuration that determines how content will be queried\n * from the Prismic repository.\n *\n * @returns A client that can query content from the repository.\n */\nexport const createClient: CreateClient = <TDocuments extends PrismicDocument>(\n\trepositoryNameOrEndpoint: string,\n\toptions?: ClientConfig,\n) => new Client<TDocuments>(repositoryNameOrEndpoint, options)\n"],"names":["Client"],"mappings":";;;AAqCO,MAAM,eAA6B,CACzC,0BACA,YACI,IAAIA,OAAA,OAAmB,0BAA0B,OAAO;;"}