import { RegistryEntry } from '../model/contentTypeRegistry.js'; import { AnyProperty } from '../model/properties.js'; /** Which Rich Text representation(s) a query selects. */ export type RichTextFormat = 'html' | 'json' | 'both'; /** * Settings that are fixed for a whole query. * * These must hold identically everywhere in one document. Shared fragments such * as `ICompositionNode` are emitted once per experience under a single global * name, so a value that differed between two levels of recursion would produce * two conflicting definitions and Graph would reject the query. * * Every field is **required** on purpose. Recursion passes this object through * unchanged rather than rebuilding it, and required fields mean a site that * rebuilds it and forgets one fails to compile instead of silently falling back * to a default. */ export type QueryContext = { /** * Enable Digital Asset Management (DAM) support for contentReference properties. * Auto-detected from GraphQL schema introspection. */ damEnabled: boolean; /** * Maximum number of fragments allowed before throwing an error. * Prevents excessive GraphQL query complexity from unrestricted content types. */ maxThreshold: number; /** * Enable or disable contract expansion. * When true, contracts are expanded to include all implementing types. * When false, only the contract itself is included without expansion. */ expandContracts: boolean; /** * Enable Optimizely Forms support. * Auto-detected from GraphQL schema introspection. */ formsEnabled: boolean; /** * Enable taxonomy category support in the ItemMetadata fragment. * Auto-detected from GraphQL schema introspection. */ taxonomyEnabled: boolean; /** * Nesting depth for ordinary composition fragments. Configurable via * `config({ compositionDepth })`. */ compositionDepth: number; /** * Optional filter to exclude content types from fragment generation. * Return true to include a content type, false to exclude it. * Useful for skipping content types that have no registered component. */ typeFilter?: (contentTypeKey: string) => boolean; /** * The content types Graph reports as implementing `_ISection`, and so the * ones that actually have a `composition` field. * * Declaring `sectionEnabled` locally does not guarantee it — asking a type * without the interface for `composition` fails the whole query. Read from * the metadata response, which costs no extra round trip. Absent means the * caller could not find out, and only the forms container is assumed to * have the field. */ sectionTypes?: ReadonlySet; /** * Which Rich Text representation(s) to select: `'html'`, `'json'`, or `'both'`. * Configurable via `config({ richTextFormat })`. * @default 'json' */ richTextFormat: RichTextFormat; }; /** * Settings that legitimately differ between one fragment and the next. * * Kept apart from {@linkcode QueryContext} so it stays obvious which values may * vary per call and which may not. */ export type FragmentOptions = { /** * Whether to include CMS base type fragments (e.g., _IContent, _IPage) in generated fragments. * Set to false for component property fragments that don't need base metadata. * @default true */ includeBaseFragments?: boolean; /** * Whether this fragment is being built for a node of a composition tree. * * Such a node already receives its children through that tree, so it must not * fetch its own `composition`. A section reached any other way — as the query * root, or through a content property — has no tree above it and does. * * Deliberately not propagated to nested calls: content referenced by a * composition node is still ordinary linked content. * * @default false */ insideComposition?: boolean; }; /** Fills in the defaults for the settings a caller may leave out. */ export declare const createQueryContext: (options?: Partial) => QueryContext; export type FragmentInfo = { fields: string[]; extraFragments: string[]; includesDamAssetsFragments: boolean; }; export type PropertyHandler = (name: string, property: AnyProperty, rootName: string, suffix: string, visited: Set, ctx: QueryContext) => FragmentInfo; /** * Retrieves cached content type definitions. * * Keyed on the registry version rather than on the cache being empty: the * registry can be added to (by `initForms`) or replaced (by * `initContentTypeRegistry`) after the first query has already been generated. */ export declare const getCachedContentTypes: () => RegistryEntry[]; /** * Refreshes the cached content type definitions. */ export declare const refreshCache: () => void; /** * Checks if a content type is an experience component. */ export declare const isExperienceComponent: (contentType: RegistryEntry) => boolean; /** * True when a content type can hold an Optimizely Forms container in one of its * content properties. * * The `formsOnPage` probe only finds forms placed in an experience's * composition. A form dropped into a content area of an ordinary page is an * ordinary reference, and `_ContentWhereInput` exposes no field to filter on it, * so the content model is consulted instead. This errs towards enabling forms: * a page type that *permits* a form pays for the fragments even when the * particular page has none. */ export declare const contentTypeCanHoldForms: (contentTypeName: string) => boolean; /** * Converts a property definition into GraphQL fields and fragments. */ export declare const convertProperty: PropertyHandler;