import type * as StackbitTypes from '@stackbit/types'; import { HygraphWebhookPayload } from './hygraph-api-client.js'; import { SchemaContext, ModelContext, ModelWithContext } from './hygraph-schema-converter.js'; import { DocumentContext, DocumentWithContext } from './hygraph-entries-converter.js'; import { AssetContext, AssetWithContext } from './hygraph-assets-converter.js'; interface HygraphContentSourceOptions { /** * Hygraph project ID. Can be found in project settings screen in Hygraph Studio. */ projectId: string; /** * Hygraph project region. Can be found in project settings screen in Hygraph Studio. */ region: string; /** * Hygraph project environment. * @default master */ environment?: string; /** * Hygraph content API endpoint URL. Must match the configured region. * @example * https://{REGION}.cdn.hygraph.com/content/{HASH}/{ENVIRONMENT} */ contentApi: string; /** * Hygraph management API endpoint URL. Must match the configured region. * @example * https://management-{REGION}.hygraph.com/graphql */ managementApi: string; /** * The management token. * * The management token needs to have the following configuration: * - Content API: * - Default stage for content delivery: "Draft" * - Content Permissions: Enable the following permissions for all models, all locales and all stages: * - Read * - Create * - Update * - Publish * - Unpublish * - Delete * - Read Version * - Management API Permissions (total 21 permissions): * - Read existing environments * - Read existing models * - Read existing components * - Read existing fields * - Read existing enumerations * - Read remote sources * - Read stages * - Read locales * - Can see schema view * - Read existing entries * - Update existing non-published entries * - Update published entries * - Publish non-published entries * - Create new entries * - Delete existing entries * - Create new webhooks * - Read existing webhooks * - Update existing webhooks * - Delete an existing webhook * - Can see Role & Permissions Settings * - Can read content permissions */ managementToken: string; /** * The nesting level in GraphQL queries for cyclic components. * This can help reducing query complexity for large content schemas. * Default: 3 */ componentQueryNestingLevel?: number; /** * The `entriesFilter` can be used to filter entries fetched by the * HygraphContentSource. * * The `entriesFilter` is set as the "where" argument of the GraphQL query * used to fetch entries. Because every Hygraph model has different "where" * properties, the `entriesFilter` is an object mapping between model's * API ID and the filter value. * * **⚠️ Warning!**: * You need to ensure that filtered-out entries are not referenced by * entries that passed the provided filter. Otherwise, the visual-editor * will show "Field is missing or inaccessible" errors in places where a * reference field references a filtered-out entry. If your content * architecture doesn't allow you to do so, consider using * [permissionsForDocument]{@link StackbitTypes.StackbitConfig.permissionsForDocument} * method of stackbit.config.ts. * * The entriesFilter` is used in the "where" clause only, therefore you * can't use it to filter locales or stages. * * @see * https://hygraph.com/docs/api-reference/content-api/filtering * * @example * The following entries filter will fetch entries of type "Page" having * their "enumField" set to "foo" and "title" containing "homepage". And * fetch entries of type "Post" having "author" with name "john". * ```js * entriesFilter: { * Page: '{ enumField: foo, title_contains: "homepage" }', * Post: '{ author: { name: "john" } }' * } * ``` */ entriesFilter?: Record; /** * Logs GraphQL queries, and for the entries query also logs the complexity * information. To see the debug logs, run `stackbit dev --log-level=debug`. * https://hygraph.com/docs/api-reference/basics/query-complexity#complexity-tree-json-output */ debugGraphQLQueries?: boolean; /** * Split GraphQL entry requests one per model. This will help reducing query * complexity in case the content schema is too complex for querying multiple * models in a single query request. * * When this flag is set to `false` (the default), a single GraphQL query * request will contain all the models, and as pages of entries are being * fetched the number of models will reduce: * * ```graphql * query { * Pages(stage: DRAFT, first: 100, skip: 0) { * ...PageFragment * } * Posts(stage: DRAFT, first: 100, skip: 0) { * ...PostFragment * } * Authors(stage: DRAFT, first: 100, skip: 0) { * ...AuthorFragment * } * } * ``` * * When this flag is `true`, each GraphQL query request will contain a single * model. The entries will be fetched serially, one model at a time: * * Request 1: * ```graphql * query { * Pages(stage: DRAFT, first: 100, skip: 0) { * ...PageFragment * } * } * ``` * * Request 2: * ```graphql * query { * Posts(stage: DRAFT, first: 100, skip: 0) { * ...PageFragment * } * } * ``` */ splitEntryRequestsPerModel?: boolean; /** * Sets the pagination size for entries and assets queries. * Default is 100 or the `maxPaginationSize` defined on the current project * within Hygraph. * * ```graphql * query { * Pages(stage: DRAFT, first: $paginationSize, skip: 0) { * ...PageFragment * } * } * ``` */ paginationSize?: number; } export declare class HygraphContentSource implements StackbitTypes.ContentSourceInterface { private projectId; private region; private environment; private contentApi; private managementApi; private managementToken; private entriesFilter?; private componentQueryNestingLevel?; private debugGraphQLQueries?; private splitEntryRequestsPerModel?; private paginationSize?; private client; private logger; private userLogger; private cache; private localDev; constructor(options: HygraphContentSourceOptions); getVersion(): Promise; getContentSourceType(): string; getProjectId(): string; getProjectEnvironment(): string; getProjectManageUrl(): string; init(options: StackbitTypes.InitOptions): Promise; reset(): Promise; destroy(): Promise; hasAccess(options: { userContext?: StackbitTypes.User | undefined; }): Promise<{ hasConnection: boolean; hasPermissions: boolean; }>; getSchema(): Promise>; getDocuments(options?: { syncContext?: unknown; } | undefined): Promise; getAssets(): Promise; createWebhookIfNeeded(webhookUrl?: string): Promise; onWebhook({ data, headers }: { data: HygraphWebhookPayload; headers: Record; }): Promise; createDocument(options: { updateOperationFields: Record; model: ModelWithContext; locale?: string | undefined; defaultLocaleDocumentId?: string | undefined; userContext?: StackbitTypes.User | undefined; }): Promise<{ documentId: string; }>; updateDocument(options: { document: DocumentWithContext; operations: StackbitTypes.UpdateOperation[]; userContext?: StackbitTypes.User | undefined; }): Promise; deleteDocument(options: { document: DocumentWithContext; userContext?: StackbitTypes.User | undefined; }): Promise; uploadAsset(options: { url?: string | undefined; base64?: string | undefined; fileName: string; mimeType: string; locale?: string | undefined; userContext?: StackbitTypes.User | undefined; }): Promise; updateAsset?(options: { asset: AssetWithContext; operations: StackbitTypes.UpdateOperation[]; userContext?: StackbitTypes.User | undefined; }): Promise; validateDocuments(options: { documents: DocumentWithContext[]; assets: AssetWithContext[]; locale?: string | undefined; userContext?: StackbitTypes.User | undefined; }): Promise<{ errors: StackbitTypes.ValidationError[]; }>; publishDocuments(options: { documents: DocumentWithContext[]; assets: AssetWithContext[]; userContext?: StackbitTypes.User | undefined; }): Promise; unpublishDocuments?(options: { documents: DocumentWithContext[]; assets: AssetWithContext[]; userContext?: StackbitTypes.User | undefined; }): Promise; _getModelNameForDocumentId(documentId: string): string | undefined; } export {}; //# sourceMappingURL=hygraph-content-source.d.ts.map