import type * as StackbitTypes from '@stackbit/types'; import type * as HGManageTypes from './gql-types/gql-management-types.js'; import type * as HGContentTypes from './gql-types/gql-content-types.js'; import type { ModelWithContext } from './hygraph-schema-converter.js'; /** * Union of all Hygraph fields */ export type HygraphField = HGManageTypes.SimpleField | HGManageTypes.EnumerableField | HGManageTypes.ComponentField | HGManageTypes.ComponentUnionField | HGManageTypes.RelationalField | HGManageTypes.UniDirectionalRelationalField | HGManageTypes.UnionField | HGManageTypes.RemoteField; /** * The Hygraph entry object fetched from Hygraph */ export type HygraphEntry = { __typename: string; id: string; createdAt: string; createdBy?: HygraphUser; updatedAt: string; updatedBy?: HygraphUser; publishedAt: string | null; publishedBy: HygraphUser | null; stage: HGContentTypes.Stage; documentInStages: { stage: HGContentTypes.Stage; updatedAt: string; }[]; scheduledIn?: HGContentTypes.ScheduledOperation[]; history?: HGContentTypes.Version[]; localizations?: { locale: string; [key: string]: any; }[]; [key: string]: any; }; /** * The Asset object fetched from Hygraph */ export type HygraphAsset = Pick & { __typename: 'Asset'; documentInStages: Pick[]; upload?: HGContentTypes.Maybe>; }; /** * The minimal Webhook object fetched from Hygraph */ export type HygraphWebhook = Pick; export type HygraphWebhookPayload = { operation: 'create' | 'update' | 'publish' | 'unpublish' | 'delete'; data: HygraphEntry | HygraphAsset; }; /** * The minimal User object fetched from Hygraph */ export type HygraphUser = Pick; export interface HygraphApiClientOptions { projectId: string; environment: string; contentApi: string; managementApi: string; managementToken: string; componentQueryNestingLevel?: number; debugGraphQLQueries?: boolean; logger: StackbitTypes.Logger; } export declare class HygraphApiClient { private contentClient; private managementClient; private projectId; private environment; private logger; private debugGraphQLQueries; private componentQueryNestingLevel; constructor(options: HygraphApiClientOptions); getSchema(): Promise<{ models: HGManageTypes.IModel[]; components: HGManageTypes.Component[]; enumerations: HGManageTypes.Enumeration[]; locales: HGManageTypes.Locale[]; assetModelId: string | null; maxPaginationSize: number; }>; getWebhooks(): Promise<{ environmentId: string; webhooks: HygraphWebhook[]; }>; createWebhook({ url, environmentId, name }: { url: string; environmentId: string; name: string; }): Promise; updateWebhook({ webhookId, name }: { webhookId: string; name: string; }): Promise; getEntries({ models, paginationSize, entriesFilter, splitEntryRequestsPerModel }: { models: ModelWithContext[]; paginationSize?: number; entriesFilter?: Record; splitEntryRequestsPerModel?: boolean; }): Promise; private fetchEntries; getEntryById({ entryId, modelName, getModelByName }: { entryId: string; modelName: string; getModelByName: (modelName: string) => ModelWithContext | undefined; }): Promise; createEntry({ modelName, data }: { modelName: string; data: Record; }): Promise<{ id: string; }>; updateEntry({ entryId, modelName, data }: { entryId: string; modelName: string; data: Record; }): Promise; deleteEntry({ entryId, modelName }: { entryId: string; modelName: string; }): Promise; publishEntry({ entryId, modelName }: { entryId: string; modelName: string; }): Promise; unpublishEntry({ entryId, modelName }: { entryId: string; modelName: string; }): Promise; publishEntries(entryMap: Record): Promise; unpublishEntries(entryMap: Record): Promise; getAssets(options?: { paginationSize?: number; }): Promise; getAssetById(assetId: string): Promise; publishAssets(assetIds: string[]): Promise; unpublishAssets(assetIds: string[]): Promise; uploadAsset(options: { fileName: string; mimeType: string; base64?: string; url?: string; }): Promise; private createAssetWithURL; private createAssetWithPostData; } export declare function wrapEnumValue(value: string): { __enum: string; }; /** * Generates a GraphQL query to fetch an entry and its fields. * The query is generated with system fields as well as user-defined fields. * Uses the entry's model to generate the entry's user-defined fields. * * @example * ```graphql * query { * posts { * __typename * id * createdAt * createdBy { id name kind } * updatedAt * updatedBy { id name kind } * publishedAt * publishedBy { id name kind } * stage * documentInStages(stages: PUBLISHED) { stage updatedAt } * <...entry fields generated using convertFieldsToQueryAST()> * } * } * ``` */ export declare function defaultDocumentQueryFields(options: { model: ModelWithContext; getModelByName: (modelName: string) => ModelWithContext | undefined; componentQueryNestingLevel: number; logger: StackbitTypes.Logger; }): { __typename: number; id: number; createdAt: number; createdBy: { id: number; name: number; kind: number; }; updatedAt: number; updatedBy: { id: number; name: number; kind: number; }; publishedAt: number; publishedBy: { id: number; name: number; kind: number; }; stage: number; documentInStages: { __arguments: { stages: { __enum: string; }; }; stage: number; updatedAt: number; }; }; export declare function convertASTToQuery(queryAST: Record, level?: never | 0): string; export declare function convertASTToQuery(queryAST: Record, level: number): string[]; export declare function removeSchemaAliases(entity: Type): Type; //# sourceMappingURL=hygraph-api-client.d.ts.map