/** * Build an authored {@link EntityField} from the same field-type vocabulary * `uip df entities create` takes, so one payload shape serves both authors. * * Two vocabularies meet here. The CLI and the SDK speak * `EntityFieldDataType` (`STRING`, `DECIMAL`, `BOOLEAN`, …) in camelCase API * bodies; the authored document speaks entity-modeler's * `(FieldDisplayType, SqlTypeName)` pairs in PascalCase. This module is the * translation, and it is deliberately the only place that knows both — the * shapes differ for the same reason `@uipath/common/entity-name-rules` is * shape-agnostic. * * The emitted field mirrors what Studio Web's modeller writes for a custom * field, nulls included, so an entity authored here and one authored there are * the same document. */ import { type EntityField } from "@uipath/entity-modeler/schema"; /** A field as a caller describes it — the `addFields` entry shape, minus the * keys only a relationship or choice-set field needs. */ export interface AuthoredFieldSpec { name: string; /** An `EntityFieldDataType` name. See {@link AUTHORABLE_FIELD_TYPES}. */ type: string; displayName?: string; description?: string; isRequired?: boolean; isUnique?: boolean; /** NVARCHAR / MULTILINE character cap; MULTILINE_MAX counts BYTES. */ lengthLimit?: number | null; /** DECIMAL and AUTO_NUMBER only. */ decimalPrecision?: number | null; maxValue?: number | null; minValue?: number | null; /** * What this module writes is a STRING for every field type — a DECIMAL * default is `"0"` and a BOOLEAN one is `"true"` — and a caller must * supply it that way. Typed as `EntityField`'s own `DefaultValue` * (`string | boolean | null`) because an update re-supplies the stored * value, and a document written elsewhere may hold a boolean; that * round-trips unchanged. Null clears it. */ defaultValue?: EntityField["DefaultValue"]; } /** The field types an authored entity may declare, in the CLI's own * vocabulary. Use for a `--type` choice list so help text and validation * cannot drift from what this module can emit. */ export declare const AUTHORABLE_FIELD_TYPES: readonly string[]; /** Thrown for a spec this module cannot turn into a valid field. Carries no * diagnostic code: these are caller mistakes caught before a document exists, * not document defects, which are `validateEntity`'s job. */ export declare class AuthoredFieldError extends Error { readonly instructions: string; constructor(message: string, instructions: string); } /** * `defaultValue` was the one field property nothing type-checked, so * `{"defaultValue":{"a":1}}` went into the document verbatim — past * `validateEntity`, which judges names and type pairs, and past pack, to fail * at deploy where the diagnosis is hardest. * * The check is "is it a string the field's type can hold", not "is it a * boolean for BOOLEAN": this module writes text for every type, and Data * Fabric round-trips a DECIMAL default as `"0"`. Typing * it as the JS value would reject the document's own content on the next * update, which is exactly how the AUTO_NUMBER/`decimalPrecision` rule went * wrong. */ /** How `authorField` was reached, for the few checks that depend on whether a * value is the caller's or the document's own. */ export interface AuthorFieldOptions { /** False when `defaultValue` was inherited from the existing field rather * than supplied. Its content is then not the caller's to answer for. */ defaultValueFromCaller?: boolean; } /** * Turn a caller's field spec into an authored `EntityField`. * * Name rules are NOT checked here — `validateEntity` owns them, against the * whole document, so a caller sees every problem at once rather than the first. * Throws {@link AuthoredFieldError} only for a type this module cannot emit. */ export declare function authorField(spec: AuthoredFieldSpec, options?: AuthorFieldOptions): EntityField;