import type { EnvironmentConfiguration } from "../../config/types.js"; import { type WebhookRequestOptions } from "./graphql.js"; import { type WebhookTemplateResolver } from "./templates.js"; /** * Authoring GraphQL operations for the Sitecore webhook content tree. * * Webhooks in XM Cloud are content items, not a dedicated API surface. * This client wraps `createItem` / `updateItem` / `deleteItem` against * `/sitecore/system/Webhooks` (event handlers) and the workflow * `Actions` subtree (submit/validation actions). See * `templates.ts` for the runtime template ID + event-type catalog * resolution. */ export declare const DEFAULT_WEBHOOK_HANDLERS_ROOT = "/sitecore/system/Webhooks"; export declare const WEBHOOK_FIELD_DESCRIPTION = "Description"; export declare const WEBHOOK_FIELD_URL = "Url"; export declare const WEBHOOK_FIELD_EVENTS = "Events"; export declare const WEBHOOK_FIELD_ENABLED = "Enabled"; export declare const WEBHOOK_FIELD_AUTHORIZATION = "Authorization"; export declare const WEBHOOK_FIELD_SERIALIZATION_TYPE = "Serialization Type"; export type WebhookSerializationType = "JSON" | "XML"; export interface WebhookHandlerSummary { itemId: string; name: string; path: string; templateName: string | null; } export interface WebhookHandlerFieldsMap { description: string | null; url: string | null; /** Raw multilist field — pipe-delimited list of event-type item IDs. */ eventsRaw: string | null; /** Resolved event-type display names (e.g. `item:saved`), best-effort. */ events: string[]; enabled: boolean; authorizationItemId: string | null; serializationType: string | null; } export interface WebhookHandlerDetail extends WebhookHandlerSummary { fields: WebhookHandlerFieldsMap; } export interface CreateEventHandlerInput { /** Sitecore item name for the new handler. */ name: string; url: string; /** Event-type display names (`item:saved`, `publish:end`, …). Resolved to catalog GUIDs at create time. */ events: readonly string[]; enabled?: boolean; description?: string; /** Absolute path to an existing Authorization item, e.g. `/sitecore/system/Settings/Webhooks/Authorizations/CI Bearer`. */ authorizationPath?: string; serializationType?: WebhookSerializationType; /** Override the default `/sitecore/system/Webhooks` parent. */ parentPath?: string; } export interface CreateWorkflowActionInput { /** Sitecore item name for the new action item (e.g. `Notify Reviewer`). */ name: string; url: string; /** * Absolute path to the workflow state OR command under which the * action's `Actions` subfolder lives. The action item itself is * created at `/Actions/`; the `Actions` * folder is expected to exist already (created automatically by * Sitecore when the state/command is added). */ stateOrCommandPath: string; description?: string; enabled?: boolean; authorizationPath?: string; serializationType?: WebhookSerializationType; } export type WebhookEventTypeCategory = "item" | "publish"; export interface WebhookEventTypeSummary { /** Event-type display name (e.g. `item:saved`, `publish:end`). */ name: string; /** Catalog item GUID. Stable per tenant; not a Sitecore-published contract. */ itemId: string; /** Catalog branch the item lives under. */ category: WebhookEventTypeCategory; /** Full content-tree path of the catalog item. */ path: string; } export interface WebhookApiClient { /** * List webhook event handler items under the given root (default * `/sitecore/system/Webhooks`). Walks direct children. Items whose * template is `Webhook Event Handler` are returned; folder items are * walked one level deeper. */ listEventHandlers(options?: { rootPath?: string; enabledOnly?: boolean; }): Promise; /** Fetch a single handler item with all configuration fields. */ getEventHandler(input: { itemId?: string; path?: string; }): Promise; /** * Create a Webhook Event Handler item (for item/publish events). * Resolves event-name strings to catalog GUIDs and the template ID * via runtime lookups (cached per client instance). */ createEventHandler(input: CreateEventHandlerInput): Promise; /** Create a Webhook Submit Action under a workflow state's `Actions` folder. */ createWorkflowSubmitAction(input: CreateWorkflowActionInput): Promise; /** Create a Webhook Validation Action under a workflow command's `Actions` folder. */ createWorkflowValidationAction(input: CreateWorkflowActionInput): Promise; /** Delete any webhook item by ID or path. */ deleteWebhookItem(input: { itemId?: string; path?: string; }): Promise; /** * List event-type catalog items the tenant exposes — the strings * callers pass to `createEventHandler({ events: [...] })`. Walks * `/sitecore/system/Settings/Webhooks/Event Types/{Item,Publish}` and * returns each catalog item's display name + GUID + category. The * catalog is per-tenant (Sitecore base content seeds it, customers * can extend it); resolve at runtime rather than baking a static * union into the SDK. */ listEventTypes(options?: { category?: WebhookEventTypeCategory; }): Promise; /** Underlying template resolver, exposed for testing and cross-task use. */ readonly templates: WebhookTemplateResolver; } export interface WebhookClientOptions { environment: EnvironmentConfiguration; request?: WebhookRequestOptions; } export declare const createWebhookApiClient: (options: WebhookClientOptions) => WebhookApiClient;