/** * This Source Code is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright (c) Infonomic Company Limited */ import type { DocumentLifecycleContext } from './context.js'; export interface CreateDocumentResult { revision: number; documentId: string; documentVersionId: string; } /** * Create a new document. * * Flow: * 1. Default-locale enforcement: reject if `params.locale` is anything * other than the configured default content locale (a brand-new * document's canonical `path` lives in the default locale). * 2. Normalize date and numeric fields * 3. `hooks.beforeCreate({ data, collectionPath })`, then normalize numerics again * 4. Resolve `path` — explicit `params.path` → derive via `useAsPath` * → UUID fallback. * 5. `db.commands.documents.createDocumentVersion(...)` (action = 'create') * 6. `hooks.afterCreate({ data, collectionPath, documentId, documentVersionId })` */ export declare function createDocument(ctx: DocumentLifecycleContext, params: { data: Record; locale?: string; status?: string; /** * Explicit, user-supplied path (e.g. from the admin sidebar widget * or an SDK caller importing legacy content). When omitted, the * lifecycle derives the value from `definition.useAsPath`. */ path?: string; /** * The editorial advertised-locale set (from the admin available-locales * sidebar widget). Document-grain and sticky like `path`: passed straight * to the storage primitive, which replaces the document's rows wholesale. * `undefined` writes nothing (a new document starts with an empty set — * the safe opt-in default); `[]` clears it. See docs/08-internationalization/index.md. */ availableLocales?: string[]; }): Promise;