/** * The `fields=` sub-selection needed to read custom fields usefully. * * Nothing here may contain a `{`. See note 1 above; `customFields.test.ts` * enforces it, because getting this wrong breaks every matter and contact read * at once rather than degrading one column. */ export declare const CUSTOM_FIELD_VALUE_FIELDS = "custom_field_values{id,field_name,field_type,value,custom_field,picklist_option}"; /** The `fields=` selection for custom field *definitions* at /custom_fields.json. */ export declare const CUSTOM_FIELD_DEFINITION_FIELDS = "id,name,field_type,parent_type,required,displayed,deleted,picklist_options{id,option}"; /** * What Clio says when a custom field read is refused, and what we actually know * about why. Deliberately does not name a settings screen: the two candidate * causes point at different places, and neither has been reproduced by us. */ export declare const CUSTOM_FIELD_PERMISSION_HINT: string; /** Shorter form, embedded in a successful response whose values came back stripped. */ export declare const CUSTOM_FIELD_STRIPPED_WARNING: string; export interface MappedCustomField { /** Composite value-instance id, e.g. "text_line-55001". Needed to update or clear this value. */ id: string | null; /** The field *definition* id (a plain integer). Stable across records. */ field_id: number | null; name: string | null; type: string | null; /** Raw value exactly as Clio returned it. For picklists this is the option id. */ value: unknown; /** Human-readable value. Identical to `value` except for picklists, where it is the option label. */ display_value: unknown; /** * Set only on a picklist whose option label could not be resolved. Its * `display_value` is null rather than the option id, so a caller never mistakes * an internal id for the selection a lawyer sees in Clio. */ label_unresolved?: true; } /** Picklist option id (as a string) -> the option's label. */ export type PicklistLabelMap = ReadonlyMap; /** * Normalises Clio's `custom_field_values` array into a flat, name-first shape. * Returns [] for a missing or non-array input so callers never branch on it. * * `labels` is optional and only consulted for picklists whose label did not * arrive inline. See `resolvePicklistLabelsFor`. */ export declare function mapCustomFieldValues(raw: unknown, labels?: PicklistLabelMap): MappedCustomField[]; /** True if any mapped picklist is missing its label and could be filled in from the definitions. */ export declare function hasUnresolvedPicklistLabels(groups: readonly MappedCustomField[][]): boolean; /** * Fills in picklist labels that did not arrive inline, in place. * * Costs one read of the field definitions, and only on a response that actually * needs it: when Clio's bare `picklist_option` association carries the label, * this never makes a request at all. A failure (the 403 above is the expected * one) leaves the labels unresolved rather than guessing, because a wrong label * on a case-vetting field is worse than a missing one. * * Deliberately not cached across calls: the HTTP transport is multi-tenant, and * a process-wide picklist map would put one firm's field labels into another * firm's response. */ export declare function resolvePicklistLabelsFor(groups: MappedCustomField[][], parentType: "Matter" | "Contact"): Promise; /** * True if any mapped value looks permission-stripped: Clio returned a composite * id but null name, type and value. A field that simply has no value set does * not appear in `custom_field_values` at all, so this shape means the attributes * were dropped rather than the field being empty. */ export declare function hasStrippedCustomFieldValues(mapped: MappedCustomField[]): boolean; /** One custom field write as the caller expresses it, before Clio's shape rules are applied. */ export interface CustomFieldWriteInput { custom_field_id: number; value?: string | number | boolean; /** Clear this field's value instead of setting it. Requires an existing value. */ clear?: boolean; } /** * Turns caller intent plus the record's current values into Clio's write payload. * * `existing` is the record's `custom_field_values` as returned by Clio (raw or * already mapped). Fields found there are updated in place by composite id; * fields not found are created with `custom_field: {id}`. * * Throws when asked to clear a field that has no value, because Clio has no * composite id to target and would silently do nothing. */ export declare function buildCustomFieldWrites(inputs: CustomFieldWriteInput[], existing: MappedCustomField[]): Record[]; /** * Audit-safe summary of a custom field write: which fields were touched, never * what they were set to. Custom fields are where firms keep case-vetting data * (loss amounts, incident dates, names), so values must not reach the log. */ export declare function customFieldIdsForAudit(inputs?: CustomFieldWriteInput[]): number[] | undefined; //# sourceMappingURL=customFields.d.ts.map