import { $ as applyContentTypeChange, $t as ContentValidationError, A as resolveContentType, At as contentImportJournal, B as ContentBackupTypeDefinitionSnapshot, Bt as ContentEntryCompletion, C as ContentTypePatch, Ct as ContentSchema, D as defineContentType, Dt as NormalizedContentRegistryRecord, E as createContentType, Et as FlatContentEntry, F as ContentBackupPayload, Ft as contentStatusDefinitions, G as ContentDefinitionEffects, Gt as ContentRevision, H as ContentDefinitionAction, Ht as ContentMediaRef, I as ContentBackupRestoreResult, It as contentTombstones, J as ContentDefinitionOutbox, Jt as ContentStatus, K as ContentDefinitionEvent, Kt as ContentSanitizationError, L as ContentBackupSnapshot, Lt as contentTypeDefinitions, M as CodeContentRegistrySnapshot, Mt as contentMigrationCheckpoints, N as ContentBackupEntrySnapshot, Nt as contentMigrationWriteJournal, O as isContentDefinitionError, Ot as contentDefinitionVersions, P as ContentBackupManifest, Pt as contentSchema, Q as applyContentStatusChange, Qt as ContentUpdatePatch, R as ContentBackupStatusDefinitionSnapshot, Rt as ContentCommentStatus, S as ContentTypeLabels, St as ContentMigrationPhase, T as ResolvedContentType, Tt as ContentTransaction, U as ContentDefinitionAudit, Ut as ContentPasswordAdapter, V as ContentCodeReconciliationPlan, Vt as ContentInput, W as ContentDefinitionAuthorization, Wt as ContentPingStatus, X as ContentTypeChangeStrategy, Xt as ContentTemplateKey, Y as ContentDestructiveDependencies, Yt as ContentTemplateDescriptor, Z as applyContentCodeReconciliation, Zt as ContentTemplateRegistry, _ as ContentFeature, _t as ContentDefinitionKind, a as ContentAuthorizationOperation, at as CodeContentStatus, b as ContentTypeCapabilities, bt as ContentEntryCompletionRow, c as assertCanManageTaxonomy, ct as ContentStatusDefinition, d as authorizeContentAction, dt as ResolvedContentStatus, en as ContentVisibility, et as contentBackupDestinationHash, f as resolveRequiredContentCapabilities, ft as createContentStatus, g as ContentDefinitionExecutor, gt as resolveContentStatuses, h as ContentDefinitionErrorCode, ht as resolveContentStatus, i as ContentAuthorizationInput, in as ProtectedContentRead, it as restoreContentBackup, j as resolveContentTypes, jt as contentLifecycleJournal, k as normalizeContentTypeDefinition, kt as contentEntries, l as assertCanModify, ln as normalizeContentInput, lt as ContentStatusPatch, m as ContentDefinitionError, mt as normalizeContentStatusDefinition, n as ContentAction, nn as FinalContentEntry, nt as previewContentStatusChange, o as ContentAuthzError, ot as ContentStatusChangeStrategy, p as CodeContentType, pt as defineContentStatus, q as ContentDefinitionImpact, qt as ContentSchemaSnapshot, r as ContentAuthorizationError, rn as NormalizedContentInput, rt as previewContentTypeChange, s as ContentPrincipal, sn as Sanitize, st as ContentStatusDateLabel, t as Actor, tn as ContentWriteInput, tt as previewContentCodeReconciliation, u as assertCanPublish, ut as ContentStatusTransitionInput, v as ContentTemplateBlock, vt as ContentDefinitionOrigin, w as ContentTypeRewrite, wt as ContentSchemaValue, x as ContentTypeDefinition, xt as ContentMigrationAdapter, y as ContentTemplateValue, yt as ContentDefinitionVersion, z as ContentBackupStore, zt as ContentEntry } from "./authz-CFBezbW-.js";
import { C as restore, D as unpublish, E as trash, S as remove, T as setVisibility, _ as list, a as ContentStoreContractError, b as put, c as ListQuery, d as assertSanitize, f as contentEntriesBaseMigrationSql, g as isContentStoreContractError, h as getBySlug, i as ContentNotFoundError, l as StoreOpts, m as getById, n as ContentConflictError, o as ContentStoreErrorCode, p as contentVisibilityMigrationSql, r as ContentFlatCorpusReader, s as EntityRef, t as ContentAdapterKind, u as assertContentTransactionIdentity, v as promoteScheduled, w as schedule, x as readFlatContentEntries, y as publish } from "./store-CgZzJTY3.js";
import { contentRevisionsMigrationSql } from "./revisions.js";
import { contentTaxonomyMigrationSql } from "./taxonomy.js";
import { SQL, SQLWrapper } from "drizzle-orm";
import { Querier } from "@platform-modules/db";
import { D1Client, D1PreparedContribution } from "@platform-modules/db/sqlite/d1";
import { SearchProvider } from "@platform-modules/search";
//#region src/hierarchy.d.ts
declare class ContentHierarchyError extends Error {
  readonly code: 'invalid-parent' | 'cycle' | 'stale-plan' | 'access-denied';
  readonly detail: string;
  readonly name = "ContentHierarchyError";
  constructor(code: 'invalid-parent' | 'cycle' | 'stale-plan' | 'access-denied', detail: string);
}
declare function validateContentParent(tx: ContentDefinitionExecutor, input: {
  entryId?: string;
  type: ResolvedContentType;
  parentId: string | null;
}): Promise<void>;
interface ContentPermanentDeleteItem {
  readonly id: string;
  readonly expectedUpdatedAt: Date;
}
interface ContentPermanentDeletePlan {
  readonly token: string;
  readonly selected: readonly ContentPermanentDeleteItem[];
  readonly reparent: readonly {
    childId: string;
    fromParentId: string;
    toParentId: string | null;
    expectedUpdatedAt: Date;
  }[];
  readonly corpusVersion: string;
  readonly authorizationVersion: string;
}
declare function preparePermanentContentDelete(tx: ContentTransaction, items: readonly ContentPermanentDeleteItem[], principal: ContentPrincipal): Promise<ContentPermanentDeletePlan>;
//#endregion
//#region src/lifecycle.d.ts
type ContentLifecycleErrorCode = 'validation' | 'access-denied' | 'not-found' | 'conflict' | 'capability-unavailable' | 'stale-version' | 'operation-conflict' | 'integrity';
declare class ContentLifecycleError extends Error {
  readonly code: ContentLifecycleErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentLifecycleError";
  constructor(code: ContentLifecycleErrorCode, detail: string, field?: string | undefined);
}
interface ContentAuthorAuthority {
  assertAssign(principal: ContentPrincipal, targetAuthorId: string): Promise<void> | void;
  assertTransfer(principal: ContentPrincipal, fromAuthorId: string, targetAuthorId: string): Promise<void> | void;
}
interface ContentMutationContext {
  operationId: string;
  principal: ContentPrincipal;
  type: ResolvedContentType;
  before: Readonly<ContentEntry | null>;
  proposed: Readonly<ContentEntry | null>;
}
interface ContentHooks {
  beforeValidate?(ctx: ContentMutationContext): Promise<void> | void;
  afterValidate?(ctx: ContentMutationContext): Promise<void> | void;
  beforeCommit?(ctx: ContentMutationContext): Promise<void> | void;
}
interface ContentOutbox {
  enqueue(tx: ContentTransaction, event: {
    id: string;
    version: 1;
    operationId: string;
    kind: 'written' | 'transitioned' | 'deleted' | 'reparented';
    entryId: string;
    occurredAt: Date;
  }): Promise<void>;
}
interface ContentCapabilityAdapters {
  validateMediaRef?(ref: ContentMediaRef, principal: ContentPrincipal): Promise<void>;
}
interface ContentWriteDependencies {
  sanitize: Sanitize;
  templates: ContentTemplateRegistry;
  authors?: ContentAuthorAuthority;
  capabilities?: ContentCapabilityAdapters;
  hooks?: ContentHooks;
  outbox: ContentOutbox;
}
interface ContentTransitionRule {
  from: string | '*';
  to: string;
  capability: keyof ResolvedContentType['capabilities'];
  requiresScheduleAt?: boolean;
}
interface ContentTransitionDependencies {
  types: readonly ResolvedContentType[];
  statuses: readonly ResolvedContentStatus[];
  rules: readonly ContentTransitionRule[];
  hooks?: ContentHooks;
  outbox: ContentOutbox;
}
interface ContentPermanentDeleteDependencies {
  hooks?: ContentHooks;
  outbox: ContentOutbox;
}
interface ContentPermanentDeleteResult {
  id: string;
  parentDeletionRevisionId: string;
}
interface ContentAutosave {
  id: string;
  entryId: string;
  parentRevisionId: string;
  snapshot: ContentUpdatePatch;
  createdAt: Date;
  createdBy: string;
}
interface ContentD1RevisionContributionResult {
  readonly revisionId: string;
  readonly entryId: string;
  readonly expectedUpdatedAt: string;
}
interface ContentD1RevisionInput {
  /** Caller-held authorized snapshot from the preceding content read. */
  readonly entry: ContentEntry;
  readonly type: ResolvedContentType;
  readonly status: ResolvedContentStatus;
}
/**
 * Prepare a parent content revision for one host-owned D1 batch. This function
 * performs authorization against caller-held evidence before preflight reads;
 * no mutation is executed here.
 */
declare function prepareContentRevisionD1(db: Pick<D1Client, 'execute' | 'prepare'>, input: ContentD1RevisionInput, principal: ContentPrincipal): Promise<D1PreparedContribution<ContentD1RevisionContributionResult>>;
declare function createContentEntry(tx: ContentTransaction, input: ContentWriteInput & {
  operationId: string;
}, principal: ContentPrincipal, deps: ContentWriteDependencies): Promise<ContentEntry>;
declare function updateContentEntry(tx: ContentTransaction, id: string, input: {
  patch: ContentUpdatePatch;
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentWriteDependencies): Promise<ContentEntry>;
declare function transitionContent(tx: ContentTransaction, id: string, input: {
  to: string;
  scheduleAt?: Date;
  publishedAt?: Date;
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentTransitionDependencies): Promise<ContentEntry>;
declare function trashContent(tx: ContentTransaction, id: string, input: {
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: Omit<ContentTransitionDependencies, 'rules'>): Promise<ContentEntry>;
declare function restoreContent(tx: ContentTransaction, id: string, input: {
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: Omit<ContentTransitionDependencies, 'rules'>): Promise<ContentEntry>;
interface ContentPasswordDependencies {
  passwords: ContentPasswordAdapter;
  hooks?: ContentHooks;
  outbox: ContentOutbox;
}
declare function changeContentPassword(tx: ContentTransaction, id: string, input: {
  operation: 'set';
  password: string;
  expectedUpdatedAt: Date;
  operationId: string;
} | {
  operation: 'clear';
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentPasswordDependencies): Promise<ContentEntry>;
declare function verifyContentPassword(tx: ContentTransaction, id: string, password: string, adapter: ContentPasswordAdapter): Promise<string | null>;
declare function readProtectedContent(tx: ContentTransaction, id: string, principal: ContentPrincipal, adapter: ContentPasswordAdapter, proof?: string): Promise<ProtectedContentRead | null>;
declare function applyPermanentContentDelete(tx: ContentTransaction, plan: ContentPermanentDeletePlan, operationIdInput: string, principal: ContentPrincipal, deps: ContentPermanentDeleteDependencies): Promise<readonly ContentPermanentDeleteResult[]>;
declare function listContentRevisions(tx: ContentTransaction, entryId: string, principal: ContentPrincipal, input?: {
  before?: number;
  limit?: number;
}): Promise<{
  items: readonly ContentRevision[];
  nextCursor: number | null;
}>;
declare function getContentRevision(tx: ContentTransaction, entryId: string, revisionId: string, principal: ContentPrincipal): Promise<ContentRevision>;
declare function restoreContentRevision(tx: ContentTransaction, entryId: string, revisionId: string, input: {
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentWriteDependencies): Promise<ContentEntry>;
declare function createContentAutosave(tx: ContentTransaction, entryId: string, input: {
  snapshot: ContentUpdatePatch;
  parentRevisionId: string;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentWriteDependencies): Promise<ContentAutosave>;
declare function getContentAutosave(tx: ContentTransaction, entryId: string, autosaveId: string, principal: ContentPrincipal): Promise<ContentAutosave>;
declare function restoreContentAutosave(tx: ContentTransaction, entryId: string, autosaveId: string, input: {
  expectedUpdatedAt: Date;
  operationId: string;
}, principal: ContentPrincipal, deps: ContentWriteDependencies): Promise<ContentEntry>;
//#endregion
//#region src/query.d.ts
type ContentListOrder = 'title' | 'author' | 'createdAt' | 'updatedAt' | 'publishedAt' | 'menuOrder';
interface ContentListQuery {
  types?: string[];
  statuses?: string[];
  authors?: string[];
  parentId?: string | null;
  search?: string;
  taxonomy?: Array<{
    taxonomy: string;
    termIds: string[];
    operator?: 'and' | 'or';
  }>;
  date?: {
    after?: Date;
    before?: Date;
    field?: 'createdAt' | 'updatedAt' | 'publishedAt';
  };
  visibility?: ContentVisibility[];
  includeIds?: string[];
  excludeIds?: string[];
  orderBy?: ContentListOrder;
  direction?: 'asc' | 'desc';
  page?: number;
  pageSize?: number;
}
interface ContentPage<T = ContentEntry> {
  items: T[];
  page: number;
  pageSize: number;
  totalItems: number;
  totalPages: number;
}
interface ContentQueryContext {
  principal: ContentPrincipal;
  types: readonly ResolvedContentType[];
  statuses: readonly ResolvedContentStatus[];
  capabilities?: ContentCapabilityAdapters & {
    search?: ContentSearchAdapter;
  };
}
type ContentCountByStatusQuery = Omit<ContentListQuery, 'statuses'> & {
  statuses?: never;
};
interface ContentSearchAdapter {
  searchPage(db: ContentTransaction, input: ContentListQuery, authorizedPredicate: SQL, principal: ContentPrincipal): Promise<{
    ids: string[];
    totalItems: number;
    rank: Record<string, number>;
  }>;
}
type ContentQueryErrorCode = 'validation' | 'capability-unavailable' | 'integrity';
declare class ContentQueryError extends Error {
  readonly code: ContentQueryErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentQueryError";
  constructor(code: ContentQueryErrorCode, detail: string, field?: string | undefined);
}
declare function decodeContentListQuery(value: unknown): ContentListQuery;
declare function buildContentQueryPredicate(queryInput: ContentListQuery, context: ContentQueryContext): SQL;
declare function count(db: ContentTransaction, queryInput: ContentListQuery, context: ContentQueryContext): Promise<number>;
declare function listPage(db: ContentTransaction, queryInput: ContentListQuery, context: ContentQueryContext): Promise<ContentPage>;
declare function countByStatus(db: ContentTransaction, queryInput: ContentCountByStatusQuery, context: ContentQueryContext): Promise<Record<string, number>>;
//#endregion
//#region src/search.d.ts
/** Additive, idempotent-guarded FTS DDL — host splits on `;` and runs per-statement (neon-http). */
declare const contentSearchMigrationSql: (table?: string, config?: string) => string;
type ContentSearchCtx = {
  db: Querier<ContentSchema>;
  viewer?: Actor | null;
};
declare function createContentSearchProvider(opts?: {
  textSearchConfig?: string;
  types?: string[];
}): SearchProvider<ContentSearchCtx>;
/** Canonical T5 search adapter: caller supplies the already-authorized SQL predicate. */
declare function createContentPostgresSearchAdapter(opts?: {
  textSearchConfig?: string;
}): ContentSearchAdapter;
//#endregion
//#region src/migrations/content-model.d.ts
declare const CONTENT_MODEL_MIGRATION_ID: "content-model-v1";
interface ContentMaterializedDefinition {
  readonly kind: ContentDefinitionKind;
  readonly key: string;
  readonly origin: ContentDefinitionOrigin;
  readonly revision: 1;
  readonly canonicalHash: string;
  readonly definition: ContentSchemaValue;
}
interface ContentMigrationCorpusCheckpoint {
  readonly count: number;
  readonly hash: string;
  readonly lastKey: string | null;
}
interface ContentMigrationEntryProjection extends FlatContentEntry, ContentEntryCompletionRow {}
interface ContentModelMigrationPlan {
  readonly migrationId: typeof CONTENT_MODEL_MIGRATION_ID;
  readonly source: ContentMigrationCorpusCheckpoint;
  readonly target: ContentMigrationCorpusCheckpoint;
  readonly definitions: readonly ContentMaterializedDefinition[];
  readonly entries: readonly ContentMigrationEntryProjection[];
}
declare function canonicalContentMigrationHash(value: unknown): Promise<string>;
declare function snapshotFlatContentCorpus(entries: readonly FlatContentEntry[]): Promise<ContentMigrationCorpusCheckpoint>;
declare function planContentModelMigration(entries: readonly FlatContentEntry[], options: {
  readonly defaultTemplateKey: string;
}): Promise<ContentModelMigrationPlan>;
declare function contentModelForwardMigrationSql(adapter: ContentMigrationAdapter): readonly string[];
declare function contentModelReverseMigrationSql(adapter: ContentMigrationAdapter): readonly string[];
//#endregion
//#region src/routes.d.ts
type ContentRouteMatch = {
  kind: 'single';
  typeKey: string;
  pathSegments: readonly string[];
} | {
  kind: 'archive' | 'feed';
  typeKey: string;
  page: number;
};
type ContentRouteResolution = {
  kind: 'notFound';
} | {
  kind: 'redirect';
  status: 308;
  location: string;
} | {
  kind: 'single';
  match: Extract<ContentRouteMatch, {
    kind: 'single';
  }>;
  content: ProtectedContentRead;
} | {
  kind: 'archive' | 'feed';
  match: Extract<ContentRouteMatch, {
    kind: 'archive' | 'feed';
  }>;
};
interface CompiledContentRoutes {
  match(url: URL): ContentRouteMatch | null;
  canonical(typeKey: string, entryPath?: readonly string[]): {
    pathname: string;
    search?: string;
  };
}
interface ContentPathLookup {
  resolve(typeKey: string, pathSegments: readonly string[], principal: ContentPrincipal, passwordProof?: string): Promise<ProtectedContentRead | null>;
  canonicalPath(entryId: string, principal: ContentPrincipal): Promise<readonly string[] | null>;
}
type ContentTemplateResolution = {
  templateKey: ContentTemplateKey;
  lockedBlocks?: readonly ContentTemplateBlock[];
};
type ContentRouteErrorCode = 'invalid-route' | 'route-conflict' | 'unknown-type' | 'template-resolution';
declare class ContentRouteError extends Error {
  readonly code: ContentRouteErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentRouteError";
  constructor(code: ContentRouteErrorCode, detail: string, field?: string | undefined);
}
declare function compileContentRoutes(types: readonly ResolvedContentType[]): CompiledContentRoutes;
declare function resolveContentRoute(compiled: CompiledContentRoutes, lookup: ContentPathLookup, url: URL, principal: ContentPrincipal, passwordProof?: string): Promise<ContentRouteResolution>;
declare function resolveContentTemplate(registry: ContentTemplateRegistry, type: ResolvedContentType, match: ContentRouteMatch, entry?: ContentEntry): ContentTemplateResolution;
//#endregion
//#region src/headless.d.ts
interface ResolvedTaxonomySchema {
  key: string;
  version: string;
  schema: ContentSchemaValue;
}
interface ContentRevisionPage {
  items: readonly ContentRevision[];
  nextCursor: number | null;
}
interface ContentOperationContracts {
  list: {
    input: ContentListQuery;
    output: ContentPage;
  };
  count: {
    input: ContentListQuery;
    output: number;
  };
  get: {
    input: {
      id: string;
      passwordProof?: string;
    };
    output: ProtectedContentRead;
  };
  create: {
    input: ContentWriteInput & {
      operationId: string;
    };
    output: ContentEntry;
  };
  update: {
    input: {
      id: string;
      patch: ContentUpdatePatch;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
  transition: {
    input: {
      id: string;
      to: string;
      scheduleAt?: Date;
      publishedAt?: Date;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
  trash: {
    input: {
      id: string;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
  restore: {
    input: {
      id: string;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
  delete: {
    input: {
      id: string;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: EntityRef;
  };
  listRevisions: {
    input: {
      id: string;
      before?: number;
      limit?: number;
    };
    output: ContentRevisionPage;
  };
  getRevision: {
    input: {
      id: string;
      revisionId: string;
    };
    output: ContentRevision;
  };
  restoreRevision: {
    input: {
      id: string;
      revisionId: string;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
  createAutosave: {
    input: {
      id: string;
      snapshot: ContentUpdatePatch;
      parentRevisionId: string;
      operationId: string;
    };
    output: ContentAutosave;
  };
  getAutosave: {
    input: {
      id: string;
      autosaveId: string;
    };
    output: ContentAutosave;
  };
  restoreAutosave: {
    input: {
      id: string;
      autosaveId: string;
      expectedUpdatedAt: Date;
      operationId: string;
    };
    output: ContentEntry;
  };
}
type ContentOperationKey = keyof ContentOperationContracts;
type ContentOperationInput<K extends ContentOperationKey> = ContentOperationContracts[K]['input'];
type ContentOperationOutput<K extends ContentOperationKey> = ContentOperationContracts[K]['output'];
type ContentOperationErrorCategory = 'validation' | 'authorization' | 'notFound' | 'conflict' | 'capability' | 'integrity';
interface ContentOperationError {
  code: string;
  category: ContentOperationErrorCategory;
  message: string;
  fieldPath?: string;
}
type ContentOperationResult<K extends ContentOperationKey> = {
  ok: true;
  value: ContentOperationOutput<K>;
} | {
  ok: false;
  error: ContentOperationError;
};
interface ContentHeadlessOperation<K extends ContentOperationKey = ContentOperationKey> {
  typeKey: string;
  key: K;
  capability: string;
  input: ContentSchemaValue;
  output: ContentSchemaValue;
  errors: readonly ContentOperationErrorCategory[];
}
type ContentOperationHandlers = Readonly<Record<string, Partial<{ [K in ContentOperationKey]: (input: ContentOperationInput<K>, principal: ContentPrincipal) => Promise<ContentOperationOutput<K>>; }>>>;
interface ContentHeadlessSchema {
  version: string;
  types: readonly ContentSchemaValue[];
  statuses: readonly ContentSchemaValue[];
  taxonomies: readonly ResolvedTaxonomySchema[];
  operations: readonly ContentHeadlessOperation[];
}
interface ContentFieldsSchemaAdapter {
  schemaForType(typeKey: string): Promise<ContentSchemaValue>;
}
interface ContentSchemaSources {
  types: readonly ResolvedContentType[];
  statuses: readonly ResolvedContentStatus[];
  taxonomies: readonly ResolvedTaxonomySchema[];
  fields?: ContentFieldsSchemaAdapter;
}
interface ContentHeadlessRuntime {
  schema: ContentHeadlessSchema;
  invoke<K extends ContentOperationKey>(typeKey: string, key: K, untrustedInput: unknown, principal: ContentPrincipal): Promise<ContentOperationResult<K>>;
}
type ContentHeadlessErrorCode = 'invalid-schema-source' | 'handler-mismatch' | 'invalid-input';
declare class ContentHeadlessError extends Error {
  readonly code: ContentHeadlessErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentHeadlessError";
  constructor(code: ContentHeadlessErrorCode, detail: string, field?: string | undefined);
}
declare function generateContentSchema(sources: ContentSchemaSources): Promise<ContentHeadlessSchema>;
declare function createContentHeadlessRuntime(sources: ContentSchemaSources, handlers: ContentOperationHandlers): Promise<ContentHeadlessRuntime>;
//#endregion
//#region src/import.d.ts
interface ContentExportBundle {
  readonly version: 1;
  readonly generatedAt: string;
  readonly types: readonly ContentSchemaValue[];
  readonly statuses: readonly ContentSchemaValue[];
  readonly taxonomies: readonly ContentSchemaValue[];
  readonly terms: readonly ContentSchemaValue[];
  readonly entries: readonly ContentSchemaValue[];
  readonly revisions: readonly ContentSchemaValue[];
}
interface ContentImportLimits {
  readonly maxBytes: number;
  readonly maxDefinitions: number;
  readonly maxEntries: number;
  readonly maxRevisions: number;
  readonly batchSize: number;
}
/** Maximum statements one content-import contribution may add to a host-owned D1 batch. Cloudflare's strictest current Workers plan permits 50 D1 queries per invocation. */
declare const CONTENT_IMPORT_D1_STATEMENT_BUDGET: 50;
type ContentImportD1StatementBudget = typeof CONTENT_IMPORT_D1_STATEMENT_BUDGET;
type ContentImportConflictPolicy = 'reject' | 'preserve' | 'mappedReplacement';
type ContentImportMappingNamespace = 'type' | 'status' | 'taxonomy' | 'term' | 'entry' | 'revision';
type ContentImportMappingKey = `${ContentImportMappingNamespace}:${string}`;
type ContentImportMappings = Readonly<Partial<Record<ContentImportMappingKey, string>>>;
type ContentImportCapabilityBranch = keyof ContentTypeCapabilities;
interface ContentImportRequiredAuthority {
  readonly typeKey: string;
  readonly branches: readonly ContentImportCapabilityBranch[];
}
interface ContentImportScope {
  readonly tenantKey: string;
  readonly typeKeys: readonly string[];
}
interface ContentImportPlan {
  readonly planHash: string;
  readonly manifestHash: string;
  readonly destinationCorpusVersion: string;
  readonly authorizationPolicyVersion: string;
  readonly scope: ContentImportScope;
  readonly conflictPolicy: ContentImportConflictPolicy;
  readonly requiredAuthority: readonly ContentImportRequiredAuthority[];
  readonly counts: Readonly<Record<string, number>>;
  readonly mappings: ContentImportMappings;
  readonly conflicts: readonly ContentOperationError[];
  readonly estimatedBytes: number;
}
interface ContentImportStaging {
  readonly hostSessionId: string;
  readonly visibility: 'hiddenUntilPublish';
}
type ContentImportSection = ContentImportMappingNamespace;
interface ContentImportSession {
  readonly id: string;
  readonly planHash: string;
  readonly manifestHash: string;
  readonly state: 'validated' | 'applying' | 'staged' | 'published' | 'failed' | 'rolledBack' | 'reversing' | 'reversed';
  readonly staging: ContentImportStaging;
  readonly scope: ContentImportScope;
  readonly conflictPolicy: ContentImportConflictPolicy;
  readonly requiredAuthority: readonly ContentImportRequiredAuthority[];
  readonly authorizationPolicyVersion: string;
  readonly destinationCorpusVersion: string;
  readonly publishedCorpusVersion?: string;
  readonly mappings: ContentImportMappings;
  readonly appliedBatches: number;
  readonly journalVersion: string;
  readonly nextSection: ContentImportSection | null;
  readonly nextOffset: number;
}
interface ContentImportAuthorizationInput {
  readonly scope: ContentImportScope;
  readonly requiredAuthority: readonly ContentImportRequiredAuthority[];
  readonly expectedPolicyVersion?: string;
}
/** Read capability supplied to import authorization and D1 preparation. It deliberately carries no transaction identity. */
interface ContentImportReadDb {
  execute(query: SQLWrapper): Promise<unknown>;
}
interface ContentImportAuthorization {
  assert(db: ContentImportReadDb, principal: ContentPrincipal, action: 'plan' | 'start' | ContentImportCommandKind, input: ContentImportAuthorizationInput): Promise<{
    policyVersion: string;
  }>;
}
type ContentImportCommandKind = 'resume' | 'publish' | 'rollback' | 'reversePublished';
type ContentImportCommandClaim = {
  kind: 'new';
  session?: ContentImportSession;
} | {
  kind: 'replay';
  session: ContentImportSession;
} | {
  kind: 'conflict';
};
interface ContentImportCommand {
  readonly operationId: string;
  readonly expectedPlanHash: string;
  readonly expectedManifestHash: string;
  readonly scope: ContentImportScope;
  readonly requiredAuthority: readonly ContentImportRequiredAuthority[];
  readonly expectedAuthorizationPolicyVersion: string;
  readonly expectedJournalVersion: string;
  readonly expectedSection: ContentImportSession['nextSection'];
  readonly expectedOffset: number;
}
interface ContentImportJournal {
  claimStart(tx: ContentTransaction, principal: ContentPrincipal, authorizationInput: ContentImportAuthorizationInput, authorization: ContentImportAuthorization, operationId: string, canonicalStartHash: string): Promise<ContentImportCommandClaim>;
  create(plan: ContentImportPlan, staging: ContentImportStaging, principal: ContentPrincipal, operationId: string, tx: ContentTransaction): Promise<ContentImportSession>;
  claimCommand(tx: ContentTransaction, sessionId: string, principal: ContentPrincipal, kind: ContentImportCommandKind, command: ContentImportCommand, canonicalCommandHash: string, authorization: ContentImportAuthorization): Promise<ContentImportCommandClaim>;
  get(tx: ContentTransaction, sessionId: string, principal: ContentPrincipal): Promise<ContentImportSession>;
  recordBatch(sessionId: string, batch: number, beforeImage: ContentSchemaValue, tx: ContentTransaction): Promise<void>;
  readBatchesReverse(tx: ContentTransaction, sessionId: string, expectedPlanHash: string, expectedManifestHash: string): Promise<readonly {
    batch: number;
    beforeImage: ContentSchemaValue;
  }[]>;
  transition(sessionId: string, from: ContentImportSession['state'], to: ContentImportSession['state'], tx: ContentTransaction): Promise<void>;
  completeCommand(tx: ContentTransaction, sessionId: string, kind: ContentImportCommandKind, command: ContentImportCommand, canonicalCommandHash: string, result: ContentImportSession): Promise<void>;
}
interface ContentImportLifecycleEvent {
  readonly id: string;
  readonly version: 1;
  readonly kind: 'published' | 'rolledBack' | 'reversed';
  readonly operationId: string;
  readonly sessionId: string;
  readonly planHash: string;
  readonly manifestHash: string;
  readonly principalId: string;
  readonly scope: ContentImportScope;
  readonly authorizationPolicyVersion: string;
  readonly affectedCounts: Readonly<Record<string, number>>;
}
interface ContentImportD1TerminalContribution extends D1PreparedContribution<ContentImportSession> {
  readonly affectedCounts?: Readonly<Record<string, number>>;
}
interface ContentImportLifecycleEffects {
  audit: {
    record(tx: ContentTransaction, event: ContentImportLifecycleEvent): Promise<void>;
  };
  outbox: {
    enqueue(tx: ContentTransaction, event: ContentImportLifecycleEvent): Promise<void>;
  };
}
interface ContentPublishedReversePlan {
  readonly reversePlanHash: string;
  readonly sessionId: string;
  readonly originalPlanHash: string;
  readonly manifestHash: string;
  readonly publishedCorpusVersion: string;
  readonly beforeImageHash: string;
  readonly affectedCounts: Readonly<Record<string, number>>;
  readonly scope: ContentImportScope;
  readonly requiredAuthority: readonly ContentImportRequiredAuthority[];
  readonly authorizationPolicyVersion: string;
}
interface ContentPublishedReverseCommand extends ContentImportCommand {
  readonly expectedReversePlanHash: string;
  readonly expectedPublishedCorpusVersion: string;
}
type ContentImportErrorCode = 'validation' | 'authorization' | 'conflict' | 'stale-plan' | 'stale-journal' | 'integrity' | 'limit';
declare class ContentImportError extends Error {
  readonly code: ContentImportErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentImportError";
  constructor(code: ContentImportErrorCode, detail: string, field?: string | undefined);
}
declare function isContentImportError(error: unknown): error is ContentImportError;
declare function parseContentImport(input: Uint8Array, limits: ContentImportLimits): Promise<ContentExportBundle>;
declare function createDbContentImportJournal(): ContentImportJournal;
declare function planContentImport(tx: ContentTransaction, authorization: ContentImportAuthorization, principal: ContentPrincipal, bundle: ContentExportBundle, input: {
  scope: ContentImportScope;
  conflictPolicy: ContentImportConflictPolicy;
}): Promise<ContentImportPlan>;
declare function startContentImport(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, principal: ContentPrincipal, bundle: ContentExportBundle, input: {
  plan: ContentImportPlan;
  staging: ContentImportStaging;
  operationId: string;
}): Promise<ContentImportSession>;
/** Prepare a content-import start for one host-owned atomic D1 batch. */
declare function prepareStartContentImportD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, bundle: ContentExportBundle, input: {
  readonly plan: ContentImportPlan;
  readonly staging: ContentImportStaging;
  readonly operationId: string;
}): Promise<D1PreparedContribution<ContentImportSession>>;
/** Prepare a read-only staged-state guard for one host-owned atomic D1 batch. */
declare function prepareStagedContentImportGuardD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, sessionIdInput: string, command: ContentImportCommand): Promise<D1PreparedContribution<ContentImportSession>>;
declare function resumeContentImport(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, principal: ContentPrincipal, bundle: ContentExportBundle, sessionIdInput: string, command: ContentImportCommand): Promise<ContentImportSession>;
/** Prepare one hidden content-import staging batch for a host-owned atomic D1 batch. */
declare function prepareResumeContentImportD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, bundle: ContentExportBundle, sessionIdInput: string, command: ContentImportCommand): Promise<D1PreparedContribution<ContentImportSession>>;
/** Predict the exact semantic corpus hash produced by publishing a retained staged ledger. */
declare function predictPublishedContentImportCorpus(db: Pick<D1Client<ContentSchema>, 'execute'>, session: ContentImportSession): Promise<string>;
declare function preparePublishContentImportD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, sessionIdInput: string, command: ContentImportCommand): Promise<ContentImportD1TerminalContribution>;
declare function publishContentImport(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, effects: ContentImportLifecycleEffects, principal: ContentPrincipal, sessionIdInput: string, command: ContentImportCommand): Promise<ContentImportSession>;
/** Prepare a staged content-import rollback for one host-owned atomic D1 batch. */
declare function prepareRollbackContentImportD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, sessionIdInput: string, command: ContentImportCommand): Promise<ContentImportD1TerminalContribution>;
declare function rollbackContentImport(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, effects: ContentImportLifecycleEffects, principal: ContentPrincipal, sessionIdInput: string, command: ContentImportCommand): Promise<ContentImportSession>;
declare function planPublishedContentImportReverse(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, principal: ContentPrincipal, sessionIdInput: string, authorizationInput: ContentImportAuthorizationInput): Promise<ContentPublishedReversePlan>;
/** Plan reversal of a published content import using read-only native D1 evidence. */
declare function planPublishedContentImportReverseD1(db: Pick<D1Client<ContentSchema>, 'execute'>, authorization: ContentImportAuthorization, principal: ContentPrincipal, sessionIdInput: string, authorizationInput: ContentImportAuthorizationInput): Promise<ContentPublishedReversePlan>;
/** Prepare reversal of a published content import for one host-owned atomic D1 batch. */
declare function prepareReversePublishedContentImportD1(db: D1Client<ContentSchema>, authorization: ContentImportAuthorization, principal: ContentPrincipal, plan: ContentPublishedReversePlan, command: ContentPublishedReverseCommand): Promise<ContentImportD1TerminalContribution>;
declare function reversePublishedContentImport(tx: ContentTransaction, journal: ContentImportJournal, authorization: ContentImportAuthorization, effects: ContentImportLifecycleEffects, principal: ContentPrincipal, plan: ContentPublishedReversePlan, command: ContentPublishedReverseCommand): Promise<ContentImportSession>;
//#endregion
//#region src/export.d.ts
interface ContentExportOverride {
  readonly reason: string;
  readonly operationId: string;
}
interface ContentExportAudit {
  recordOverride(tx: ContentTransaction, principal: ContentPrincipal, typeKeys: readonly string[], override: ContentExportOverride): Promise<void>;
}
type ContentExportErrorCode = 'validation' | 'not-found' | 'forbidden' | 'integrity' | 'limit';
declare class ContentExportError extends Error {
  readonly code: ContentExportErrorCode;
  readonly detail: string;
  readonly field?: string | undefined;
  readonly name = "ContentExportError";
  constructor(code: ContentExportErrorCode, detail: string, field?: string | undefined);
}
declare function isContentExportError(error: unknown): error is ContentExportError;
declare function exportContent(tx: ContentTransaction, principal: ContentPrincipal, input: {
  typeKeys: readonly string[];
  includeRevisions: boolean;
  limits: ContentImportLimits;
  overrideCanExport?: ContentExportOverride;
}, deps: {
  audit: ContentExportAudit;
}): Promise<ContentExportBundle>;
//#endregion
export { type Actor, CONTENT_IMPORT_D1_STATEMENT_BUDGET, CONTENT_MODEL_MIGRATION_ID, type CodeContentRegistrySnapshot, type CodeContentStatus, type CodeContentType, type CompiledContentRoutes, type ContentAction, type ContentAdapterKind, type ContentAuthorAuthority, ContentAuthorizationError, type ContentAuthorizationInput, type ContentAuthorizationOperation, ContentAuthzError, type ContentAutosave, type ContentBackupEntrySnapshot, type ContentBackupManifest, type ContentBackupPayload, type ContentBackupRestoreResult, type ContentBackupSnapshot, type ContentBackupStatusDefinitionSnapshot, type ContentBackupStore, type ContentBackupTypeDefinitionSnapshot, type ContentCapabilityAdapters, type ContentCodeReconciliationPlan, type ContentCommentStatus, ContentConflictError, type ContentCountByStatusQuery, type ContentD1RevisionContributionResult, type ContentD1RevisionInput, type ContentDefinitionAction, type ContentDefinitionAudit, type ContentDefinitionAuthorization, type ContentDefinitionEffects, ContentDefinitionError, type ContentDefinitionErrorCode, type ContentDefinitionEvent, type ContentDefinitionExecutor, type ContentDefinitionImpact, type ContentDefinitionKind, type ContentDefinitionOrigin, type ContentDefinitionOutbox, type ContentDefinitionVersion, type ContentDestructiveDependencies, type ContentEntry, type ContentEntryCompletion, type ContentEntryCompletionRow, type ContentExportAudit, type ContentExportBundle, ContentExportError, type ContentExportErrorCode, type ContentExportOverride, type ContentFeature, type ContentFieldsSchemaAdapter, type ContentFlatCorpusReader, ContentHeadlessError, type ContentHeadlessErrorCode, type ContentHeadlessOperation, type ContentHeadlessRuntime, type ContentHeadlessSchema, ContentHierarchyError, type ContentHooks, type ContentImportAuthorization, type ContentImportAuthorizationInput, type ContentImportCapabilityBranch, type ContentImportCommand, type ContentImportCommandClaim, type ContentImportCommandKind, type ContentImportConflictPolicy, type ContentImportD1StatementBudget, type ContentImportD1TerminalContribution, ContentImportError, type ContentImportErrorCode, type ContentImportJournal, type ContentImportLifecycleEffects, type ContentImportLifecycleEvent, type ContentImportLimits, type ContentImportMappingKey, type ContentImportMappingNamespace, type ContentImportMappings, type ContentImportPlan, type ContentImportRequiredAuthority, type ContentImportScope, type ContentImportSection, type ContentImportSession, type ContentImportStaging, type ContentInput, ContentLifecycleError, type ContentLifecycleErrorCode, type ContentListOrder, type ContentListQuery, type ContentMaterializedDefinition, type ContentMediaRef, type ContentMigrationAdapter, type ContentMigrationCorpusCheckpoint, type ContentMigrationEntryProjection, type ContentMigrationPhase, type ContentModelMigrationPlan, type ContentMutationContext, ContentNotFoundError, type ContentOperationContracts, type ContentOperationError, type ContentOperationErrorCategory, type ContentOperationHandlers, type ContentOperationInput, type ContentOperationKey, type ContentOperationOutput, type ContentOperationResult, type ContentOutbox, type ContentPage, type ContentPasswordAdapter, type ContentPasswordDependencies, type ContentPathLookup, type ContentPermanentDeleteDependencies, type ContentPermanentDeleteItem, type ContentPermanentDeletePlan, type ContentPermanentDeleteResult, type ContentPingStatus, type ContentPrincipal, type ContentPublishedReverseCommand, type ContentPublishedReversePlan, type ContentQueryContext, ContentQueryError, type ContentQueryErrorCode, type ContentRevision, type ContentRevisionPage, ContentRouteError, type ContentRouteErrorCode, type ContentRouteMatch, type ContentRouteResolution, ContentSanitizationError, type ContentSchema, type ContentSchemaSnapshot, type ContentSchemaSources, type ContentSchemaValue, type ContentSearchAdapter, type ContentSearchCtx, type ContentStatus, type ContentStatusChangeStrategy, type ContentStatusDateLabel, type ContentStatusDefinition, type ContentStatusPatch, type ContentStatusTransitionInput, ContentStoreContractError, type ContentStoreErrorCode, type ContentTemplateBlock, type ContentTemplateDescriptor, type ContentTemplateKey, type ContentTemplateRegistry, type ContentTemplateResolution, type ContentTemplateValue, type ContentTransaction, type ContentTransitionDependencies, type ContentTransitionRule, type ContentTypeCapabilities, type ContentTypeChangeStrategy, type ContentTypeDefinition, type ContentTypeLabels, type ContentTypePatch, type ContentTypeRewrite, type ContentUpdatePatch, ContentValidationError, type ContentVisibility, type ContentWriteDependencies, type ContentWriteInput, type EntityRef, type FinalContentEntry, type FlatContentEntry, type ListQuery, type NormalizedContentInput, type NormalizedContentRegistryRecord, type ProtectedContentRead, type ResolvedContentStatus, type ResolvedContentType, type ResolvedTaxonomySchema, type Sanitize, type StoreOpts, applyContentCodeReconciliation, applyContentStatusChange, applyContentTypeChange, applyPermanentContentDelete, assertCanManageTaxonomy, assertCanModify, assertCanPublish, assertContentTransactionIdentity, assertSanitize, authorizeContentAction, buildContentQueryPredicate, canonicalContentMigrationHash, changeContentPassword, compileContentRoutes, contentBackupDestinationHash, contentDefinitionVersions, contentEntries, contentEntriesBaseMigrationSql, contentImportJournal, contentLifecycleJournal, contentMigrationCheckpoints, contentMigrationWriteJournal, contentModelForwardMigrationSql, contentModelReverseMigrationSql, contentRevisionsMigrationSql, contentSchema, contentSearchMigrationSql, contentStatusDefinitions, contentTaxonomyMigrationSql, contentTombstones, contentTypeDefinitions, contentVisibilityMigrationSql, count, countByStatus, createContentAutosave, createContentEntry, createContentHeadlessRuntime, createContentPostgresSearchAdapter, createContentSearchProvider, createContentStatus, createContentType, createDbContentImportJournal, decodeContentListQuery, defineContentStatus, defineContentType, exportContent, generateContentSchema, getById, getBySlug, getContentAutosave, getContentRevision, isContentDefinitionError, isContentExportError, isContentImportError, isContentStoreContractError, list, listContentRevisions, listPage, normalizeContentInput, normalizeContentStatusDefinition, normalizeContentTypeDefinition, parseContentImport, planContentImport, planContentModelMigration, planPublishedContentImportReverse, planPublishedContentImportReverseD1, predictPublishedContentImportCorpus, prepareContentRevisionD1, preparePermanentContentDelete, preparePublishContentImportD1, prepareResumeContentImportD1, prepareReversePublishedContentImportD1, prepareRollbackContentImportD1, prepareStagedContentImportGuardD1, prepareStartContentImportD1, previewContentCodeReconciliation, previewContentStatusChange, previewContentTypeChange, promoteScheduled, publish, publishContentImport, put, readFlatContentEntries, readProtectedContent, remove, resolveContentRoute, resolveContentStatus, resolveContentStatuses, resolveContentTemplate, resolveContentType, resolveContentTypes, resolveRequiredContentCapabilities, restore, restoreContent, restoreContentAutosave, restoreContentBackup, restoreContentRevision, resumeContentImport, reversePublishedContentImport, rollbackContentImport, schedule, setVisibility, snapshotFlatContentCorpus, startContentImport, transitionContent, trash, trashContent, unpublish, updateContentEntry, validateContentParent, verifyContentPassword };