import { GraphQLSchema } from 'graphql'; import { TrustedDocument } from './extract'; export { TrustedDocumentError, buildTrustedDocuments, hashDocument } from './extract'; export type { TrustedDocument } from './extract'; /** The reserved list holding everything the Admin UI can send. */ export declare const ADMIN_UI_ALLOW_LIST = "admin-ui"; /** The query the Admin UI introspects the schema with, added only when it's switched on. */ export declare const ADMIN_UI_METADATA_QUERY = "_graphweaver"; /** * Whether this project serves the Admin UI. * * Projects that pass `adminMetadata: { enabled: false }` to Graphweaver don't get the * `_graphweaver` query, and the Admin UI can't do anything without it, so its absence from the * built schema is the same thing as "nobody is running the Admin UI against this API". Those * projects shouldn't have a few hundred generated documents they'll never send trusted on their * behalf. * * Without a schema we can't tell, and silently trusting documents is the worse mistake of the * two, so we say no. */ export declare const servesAdminUi: (schema?: GraphQLSchema) => boolean; export declare const GENERATED_FILE: string; export declare const MANIFEST_DIRECTORY: string; /** * The metadata the Admin UI would receive from `_graphweaver`. * * We call the resolver directly rather than executing the query. Going through GraphQL would * boot the whole request pipeline, which needs a live database connection we don't have at build * time, and would be subject to whatever access control list the project puts on `_graphweaver`. * The resolver itself reads nothing but the static entity metadata, so it's safe to call cold. * * Core has to be resolved from the user's project, not ours: the metadata lives in a module * level registry, so a different copy of the package would hand us an empty one. */ export declare const readAdminUiMetadata: () => Promise; export type GenerateOptions = { schema?: GraphQLSchema; /** The `_graphweaver` metadata, used to enumerate the Admin UI's documents. */ metadata?: unknown; /** * Whether to generate the Admin UI allow list. Defaults to whether the schema serves the * Admin UI's metadata query, so projects that have turned the Admin UI off don't safelist * its documents. */ includeAdminUi?: boolean; }; export type GeneratedTrustedDocuments = { allowLists: Record; total: number; }; export declare const generateTrustedDocuments: ({ schema, metadata, includeAdminUi, }?: GenerateOptions) => Promise; /** The module the backend imports, so the manifest ends up inside the server bundle. */ export declare const writeGeneratedManifest: ({ allowLists }: GeneratedTrustedDocuments) => string; /** * One manifest per allow list, so each client only ever ships the ids it's allowed to use and * we don't leak one client's operations to another. */ export declare const writeClientManifests: ({ allowLists }: GeneratedTrustedDocuments) => string[]; /** * Write the manifest we can build without a schema, before we build the backend that imports it. * * There's a chicken and egg here: the full manifest needs the schema and the Admin UI metadata, * which we only get by building and importing the backend, which can't build until this file * exists. So we do the part that needs nothing first - scanning the developer's own globs - and * fill in schema validation and the Admin UI list once the backend has been built. * * Deliberately not a stub: an empty manifest would be enforced, locking every client out. */ export declare const generateStaticTrustedDocuments: () => Promise;