import type { FdtoChangeLog } from '@feedmepos/zod-inventory'; /** A domain the changelog browser lists generically (backend `changelog/domains`). */ export interface BrowsableChangelogDomain { domain: string; labelKey: string; } /** A resolved value tree the server attaches to a change's from/to when explain=1 (mirrors kit's ValueNode). */ export interface ValueNode { label?: string; value?: string; display?: string; list?: boolean; bookkeeping?: boolean; kids?: ValueNode[]; } /** The `schema` query param for explain=1 — field-trail labels/identity, mirroring kit httpapi's explainOptions. */ export interface ExplainSchema { array_keys?: Record; identity_fields?: string[]; name_fields?: string[]; ignored_fields?: string[]; names?: Record; label_keys?: { prefix: string; fields: string[]; }; } /** * Domain-agnostic explain schema for domains without their own: keyed-array * pairing falls back to `_id`/`id`, and field labels reuse the inventory i18n * keys — consistent with the differ, whose label resolver is registered once * app-wide, so stored human paths already use these keys in every domain. */ export declare const DEFAULT_EXPLAIN_SCHEMA: ExplainSchema; /** * Inventory domain's explain schema: the default plus the nested-array * identity declarations the `_id`/`id` fallback can't express, and the same * field labels the differ already translates (LABELED_FIELDS, * apps/inventory-backend/src/inventory/changelog-labels.ts) so a resolved * value tree's field labels go through the same i18n keys as field-level diffs. */ export declare const INVENTORY_EXPLAIN_SCHEMA: ExplainSchema; /** The keyed-array element a kit-dialect change sits inside (mirrors kit's Element). */ export interface ChangelogElement { trail?: string[]; name?: string; id?: string; } /** Resolved display names for id-valued from/to (mirrors kit's Display). */ export interface ChangelogDisplay { from?: string; to?: string; } /** One diff line within a commit (mirrors the changelog server's Change). */ export interface ChangelogChange { at?: string; actor?: string; path: string; kind: string; from?: string; to?: string; from_value?: ValueNode; to_value?: ValueNode; /** kit-dialect only: human label trail of the changed field, relative to element when set. */ field?: string[]; /** kit-dialect only: set when the change sits inside a keyed array element. */ element?: ChangelogElement; /** kit-dialect only: resolved display names when from/to are known ids. */ display?: ChangelogDisplay; } /** One sealed commit for a record (the server's CommitEnvelope). */ export interface ChangelogCommit { doc_id: string; id: string; parent: string; at: string; authors: string[]; message?: string; changes: ChangelogChange[]; } /** * True when an API call rejected with a 409 — the backend's changelog/state * passthrough answers this way when the document's history has any pre-kit * (legacy-dialect) commit, since kit's state replay cannot fold those. */ export declare function isStateConflict(error: unknown): boolean; export declare const useChangelogApi: () => { /** * Commits for one record. recordId is the changelog docId, `${dbName}/${id}`. * The dbName scopes the (access-checked) backend route; only the bare id is * sent — the backend rebuilds the docId server-side. */ getRecordChangelog(recordId: string, limit?: number, explain?: ExplainSchema, before?: string): Promise; /** * Purchase orders in a date range, each with when it last changed. The * backend joins the orders to their newest commit, so no ids travel and the * browser makes one request instead of list-then-ask-for-timestamps. */ listPurchaseOrders(dbName: string, start: string, end: string): Promise; /** * Closing drafts created in a date range, each with when it last changed. * Closing groups come back as rows of their own — their submit/approve/ * reject is recorded against the group document, not its parent. */ listClosingDrafts(dbName: string, start: string, end: string): Promise; /** * A kit-dialect record's whole document, at HEAD or as of (and including) * commit `at`. Same dbName/id split as getRecordChangelog. Rejects with a * 409 (see isStateConflict) when the record's history predates the kit * write path — the backend passthrough for kit httpapi's GET /api/state. */ getState(dbName: string, docId: string, at?: string): Promise>; /** * The domains the browser lists generically, declared in * changelog-domains-pkg and served by the backend — a new browsable domain * becomes a tab without a portal change. Backends predating the route * yield an error the caller treats as "no extra domains". */ listDomains(businessId: string): Promise; /** * One generic domain's records, each with when it last changed. Business- * scoped: the generic domains are configuration documents of the business * db, not of a location. */ listDomainRecords(businessId: string, domain: string): Promise; /** * One inventory module's records, each with when it last changed. Business- * scoped, so the db is `business_` — the same prefixed name the record's * own changelog docId carries. */ listInventory(businessId: string, module: 'sku' | 'recipe' | 'unit'): Promise; };