import type { ReviewItem, ReviewValueDescriptor } from "../review-resource.js"; /** * Result of checking an inline edit (`data.workbenchEditedValue` on an * `accept-proposed` decision event) against the ReviewItem it edits. * * - `ok: true` — the edit is allowed; `value` is the value to store. When * `convertedFromText` is true, the stored edit was descriptor-typed text * written by an older workbench (for example `"42"` on a number field) and * `value` is its typed form (`42`). * - `ok: false` — the edit must be refused: the item is not editable, or the * value does not satisfy the item's `valueDescriptor`. */ export type EditedValueCheck = { readonly ok: true; readonly value: unknown; readonly convertedFromText: boolean; } | { readonly ok: false; readonly code: "edited-value-not-editable" | "edited-value-type-mismatch"; readonly message: string; }; /** * True for a `YYYY-MM-DD` string naming a real calendar day. The Y/M/D must * round-trip through a UTC date, so an impossible day such as `2026-02-31` * (which `Date.parse` silently rolls over to March) is refused. */ export declare function isIsoCalendarDate(value: string): boolean; /** * Parses number-field editor text, or returns `undefined` when it is not a * plain decimal or would not survive storage as a JSON number exactly. * * Integer-only text (no `.` and no exponent) is checked by * `Number.isSafeInteger` instead of the digit count: every safe integer * (|value| ≤ 2^53−1, i.e. up to 9007199254740991, 16 digits) round-trips * through a JSON number exactly, so the 15-significant-digit rule would * wrongly refuse `9007199254740991` while accepting some 15-digit values * that are actually less precise. `9007199254740993` is refused: it is * outside the safe range and `Number(...)` rounds it to `9007199254740992`, * a different integer than the text named. * * A fractional value (has `.` or an exponent) keeps the 15-significant-digit * rule: `Number.isSafeInteger` does not apply to it, and IEEE 754 doubles * only guarantee exactness up to 15 significant decimal digits, so anything * longer is refused rather than silently rounded. A value that overflows to * Infinity is refused. `-0` is stored as `0` (JSON has no negative zero). */ export declare function parsePlainDecimal(text: string): number | undefined; /** * Converts a reviewer's editor text to the JSON type the item's descriptor * declares, using the same parsing rules the workbench's `validateProposedValue` * checks. Returns `undefined` when the text does not parse for that type. With * no descriptor, or a type that has no single-line form (string, array, object), * the text is returned unchanged. */ export declare function editedValueFromEditorText(descriptor: ReviewValueDescriptor | undefined, text: string): unknown; /** * Checks an inline edit carried by an `accept-proposed` decision against the * item's `editable` flag and `valueDescriptor`. This is the server-side * counterpart of the browser editor's validation (kontourai/survey#278): the * apply boundary must not trust an edit the workbench would never have let a * reviewer make. * * Legacy sessions: workbenches before this check stored every edit as the * editor's text, so a number or boolean edit arrives as `"42"` / `"true"`. Such * text (and date/enum text with surrounding whitespace, which the old editor * accepted and stored untrimmed) is converted to its typed value when it parses * cleanly under the workbench's own rules (`convertedFromText: true`, reported as a warning by the * apply derivation); text that does not parse is refused. */ export declare function checkEditedValueForItem(item: ReviewItem, value: unknown): EditedValueCheck;