@uipath/maestro-builder-sdk 6.31.7 → 6.31.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/check.js CHANGED
@@ -10,7 +10,7 @@ import { FlowNode } from './core/node-classes.js';
10
10
  import { planContributionBindings } from './core/contribution-bindings.js';
11
11
  import { definitionHasErrorPort, errorPortRefusal } from './core/error-port.js';
12
12
  import { actionVersion, bundledActionNodeType, bundledContainerDefinition, bundledDefinition, perCallDefinition, resolveContributionDefinition } from './serialize.js';
13
- import { FORM_FIELD_TYPES, formFieldTypeHint, formFieldTypeWhy } from './core/form-field-type.js';
13
+ import { FORM_FIELD_TYPES, formFieldOptionsProblem, formFieldOptionsWhy, formFieldTypeHint, formFieldTypeWhy, validFormFieldTypesText } from './core/form-field-type.js';
14
14
  import { AGENTIC_PROCESS_FORMS } from './core/agentic-process-forms.js';
15
15
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from './core/event-checks.js';
16
16
  import { checkCookedEscapes } from './flow-expr-check.js';
@@ -3416,7 +3416,17 @@ function checkInlineAgent(step, inputs, diags, opts = {}) {
3416
3416
  if (!FORM_FIELD_TYPES.includes(String(f?.type))) {
3417
3417
  at('INLINE_AGENT_ESCALATION_FIELD_TYPE_UNKNOWN', `Inline agent step "${step}"'s quick-form escalation gives the field "${String(f?.id ?? '?')}" the type `
3418
3418
  + `${JSON.stringify(f?.type)}, ${formFieldTypeWhy(f?.type, `which the form does not recognize — it would `
3419
- + `be published as a plain string`)}. Valid: ${FORM_FIELD_TYPES.join(', ')}.`, formFieldTypeHint(f?.type));
3419
+ + `be published as a plain string`)}. Valid: ${validFormFieldTypesText()}.`, formFieldTypeHint(f?.type));
3420
+ }
3421
+ const optionsProblem = formFieldOptionsProblem(f?.type, f?.options);
3422
+ if (optionsProblem !== undefined) {
3423
+ const message = `Inline agent step "${step}"'s quick-form escalation field "${String(f?.id ?? '?')}" `
3424
+ + `${formFieldOptionsWhy(optionsProblem, f?.type)}.`;
3425
+ if (optionsProblem === 'ignored')
3426
+ warn('INLINE_AGENT_ESCALATION_FIELD_OPTIONS_IGNORED', message);
3427
+ else {
3428
+ at('INLINE_AGENT_ESCALATION_FIELD_OPTIONS', message, `options: [{ id: 'opt-1', value: 'high', label: 'High' }, { id: 'opt-2', value: 'low', label: 'Low' }]`);
3429
+ }
3420
3430
  }
3421
3431
  }
3422
3432
  continue;
@@ -55,11 +55,53 @@ export interface ConnectorOpts {
55
55
  object?: string;
56
56
  }
57
57
  /**
58
- * A form field's type. The platform does not recognize a type outside this set:
59
- * older runtimes read it as text (so a number field becomes a text box), newer
60
- * ones reject the form. That is why `check` rejects anything outside this set.
58
+ * The platform's 11 canonical quick-form field types (`@uipath/hitl-schema-types`
59
+ * `fieldType`), which the designer saves. Each has its own value shape:
60
+ * `integer` → a JSON integer, `date` → `'2026-10-15'`, `datetime` → an ISO
61
+ * date-time, `file` → a binary-format string, `object` / `array` → JSON.
61
62
  */
62
- export type FormFieldType = 'text' | 'number' | 'boolean' | 'date-time';
63
+ export type CanonicalFormFieldType = 'string' | 'number' | 'integer' | 'float' | 'double' | 'boolean' | 'date' | 'datetime' | 'file' | 'object' | 'array';
64
+ /**
65
+ * The platform's choice-control spellings of a field type. Each names the data
66
+ * the field holds AND how it renders (`@uipath/hitl-schema-types`
67
+ * `resolveFieldType` + `controlForDeclaredType`): `singleSelect` is a `string`
68
+ * shown as a dropdown, `multiSelect` an `array` shown as a multi-select, and
69
+ * `enum` (what the designer's variable picker writes for a closed set) a
70
+ * `string` shown as a dropdown. The choices are the field's `options`.
71
+ */
72
+ export type ControlFormFieldType = 'singleSelect' | 'multiSelect' | 'enum';
73
+ /**
74
+ * A form field's type: one of the platform's canonical types; `'text'` /
75
+ * `'date-time'`, the SDK's older spellings of `'string'` / `'datetime'` (the
76
+ * platform resolves both); or a choice-control spelling (`'singleSelect'`,
77
+ * `'multiSelect'`, `'enum'`), which the form renders as a picker over the
78
+ * field's `options`. A quick form with any other type fails the platform's
79
+ * validation, which is why `check` rejects it.
80
+ *
81
+ * @example
82
+ * hitl({ fields: [{ id: 'dueOn', type: 'date', direction: 'output' }], outcomes: ['Done'] })
83
+ * hitl({
84
+ * fields: [{
85
+ * id: 'priority', type: 'singleSelect', direction: 'output',
86
+ * options: [{ id: 'opt-1', value: 'high', label: 'High' }, { id: 'opt-2', value: 'low', label: 'Low' }],
87
+ * }],
88
+ * outcomes: ['Done'],
89
+ * })
90
+ */
91
+ export type FormFieldType = CanonicalFormFieldType | 'text' | 'date-time' | ControlFormFieldType;
92
+ /**
93
+ * One choice of a picker field (`@uipath/hitl-schema-types` `optionShape`):
94
+ * `value` is what the answer holds, `label` what the reviewer sees, and `id`
95
+ * the option's own stable id. All three are required by the platform.
96
+ */
97
+ export interface FormFieldOption {
98
+ /** The option's own stable id, e.g. `'opt-1'`. */
99
+ id: string;
100
+ /** What the answer holds when the reviewer picks it, e.g. `'high'`. */
101
+ value: string;
102
+ /** What the reviewer sees, e.g. `'High'`. */
103
+ label: string;
104
+ }
63
105
  /** A value the reviewer READS: shown on the form, filled in from the flow. */
64
106
  export interface ShownField {
65
107
  /** Field id — the key the answer object uses. Must be unique on the form. */
@@ -68,6 +110,11 @@ export interface ShownField {
68
110
  label?: string;
69
111
  type: FormFieldType;
70
112
  direction: 'input';
113
+ /**
114
+ * The choices of a picker field — a `singleSelect` / `enum` dropdown or a
115
+ * `multiSelect`. Written to the form verbatim, in order.
116
+ */
117
+ options?: FormFieldOption[];
71
118
  /**
72
119
  * What to show — a reference, e.g. `input('amount')` or
73
120
  * `out('fetchInvoice', 'body.total')`. Required: a shown field with nothing
@@ -84,6 +131,11 @@ export interface AskedField {
84
131
  label?: string;
85
132
  type: FormFieldType;
86
133
  direction: 'output';
134
+ /**
135
+ * The choices of a picker field — a `singleSelect` / `enum` dropdown or a
136
+ * `multiSelect`. Written to the form verbatim, in order.
137
+ */
138
+ options?: FormFieldOption[];
87
139
  /** Reviewer must fill it in before the task can be completed. */
88
140
  required?: boolean;
89
141
  }
@@ -100,6 +152,11 @@ export interface InOutField {
100
152
  label?: string;
101
153
  type: FormFieldType;
102
154
  direction: 'inOut';
155
+ /**
156
+ * The choices of a picker field — a `singleSelect` / `enum` dropdown or a
157
+ * `multiSelect`. Written to the form verbatim, in order.
158
+ */
159
+ options?: FormFieldOption[];
103
160
  /** What to pre-fill — a reference, e.g. `out('fetchInvoice', 'body.total')`. */
104
161
  value: Expr;
105
162
  /** Reviewer must confirm/fill it before the task can be completed. */
@@ -1,49 +1,160 @@
1
1
  /**
2
- * The product's spellings of the form-field types the SDK models.
2
+ * The quick-form field-type vocabulary: the product's own, transcribed.
3
3
  *
4
4
  * A quick form's field `type` is read by the product through
5
- * `@uipath/hitl-schema-types` `normalizeFieldType`. Its canonical stored values
6
- * are `string`, `number`, `boolean`, `datetime`, … and it accepts aliases for
7
- * each: `text` is an alias of `string`, `date-time` of `datetime`, and .NET
8
- * names such as `System.String` resolve too. The designer saves the canonical
9
- * value, so a canvas-built form says `"string"`; the SDK (like flow-v1's
10
- * serializer and `uip maestro flow hitl add`) writes `text`.
5
+ * `@uipath/hitl-schema-types` (`fieldType`, `resolveFieldType`,
6
+ * `FIELD_TYPE_TO_JSON_SCHEMA`). It has 11 canonical stored values — `string`,
7
+ * `number`, `integer`, `float`, `double`, `boolean`, `date`, `datetime`, `file`,
8
+ * `object`, `array` — and it resolves aliases onto them: `text` is a legacy
9
+ * alias of `string`, `date-time` of `datetime`, and .NET names such as
10
+ * `System.Int32` resolve too. A `quick` form whose type resolves to none of the
11
+ * 11 fails the product's validation.
11
12
  *
12
- * So `"string"` and `"text"` are the same field on the wire. This table maps
13
- * each product spelling of the four types {@link FormFieldType} models to the
14
- * SDK's spelling, so decompile hands the author source `check` accepts.
15
- * A type the SDK does not model (`integer`, `date`,
16
- * `file`, …) has no entry: it stays as written, and `check` reports it.
13
+ * That package is published only to GitHub Packages, so the SDK cannot depend
14
+ * on it at runtime. This module is a transcription, and
15
+ * `tests/hitl-field-type-contract.test.ts` runs the real package against it:
16
+ * the canonical set, each type's JSON Schema, and every alias below must agree
17
+ * with the pinned `@uipath/hitl-schema-types`. A canonical-set, JSON Schema or
18
+ * control-spelling change upstream fails there; a new data alias does not.
17
19
  *
18
- * Mirrors `resolveFieldType` in `@uipath/hitl-schema-types` 1.1.6, restricted
19
- * to the groups that resolve to `string`, `number`, `boolean` and `datetime`
20
- * (minus `singleSelect` / `enum` / `union` / …, which resolve to `string` but
21
- * are not a plain text box).
20
+ * Besides data types, the product accepts three CHOICE-CONTROL spellings —
21
+ * `singleSelect`, `multiSelect`, `enum` — which name both the data the field
22
+ * holds and the control it renders with (#1235). The SDK accepts them in
23
+ * source and writes them as written, so a canvas dropdown stays a dropdown.
24
+ *
25
+ * Every SDK path reads field types from here: `check` (human tasks and inline
26
+ * agent quick-form escalations), decompile, and the serializers' output
27
+ * schemas.
22
28
  */
23
- import type { FormFieldType } from './actions.js';
29
+ import type { CanonicalFormFieldType, ControlFormFieldType, FormFieldOption } from './actions.js';
30
+ /** The product's 11 canonical quick-form field types, in its own order. */
31
+ export declare const CANONICAL_FORM_FIELD_TYPES: CanonicalFormFieldType[];
32
+ /** The SDK's legacy spellings (`text`, `date-time`), for diagnostics that list them. */
33
+ export declare const LEGACY_FORM_FIELD_TYPES: string[];
34
+ /** The choice-control spellings, for `check`'s messages and the contract test. */
35
+ export declare const CONTROL_FORM_FIELD_TYPES: ControlFormFieldType[];
24
36
  /**
25
- * The SDK's spelling of a wire form-field type, or `undefined` when the SDK
26
- * does not model that type.
37
+ * Every form-field type the SDK accepts in source: the 11 canonical ones, the
38
+ * SDK's legacy aliases, and the three choice-control spellings.
39
+ */
40
+ export declare const FORM_FIELD_TYPES: string[];
41
+ /**
42
+ * The tail of a "Valid: …" diagnostic: the canonical types, then the legacy
43
+ * spellings and the choice controls in parentheses.
27
44
  *
28
45
  * @example
29
- * sdkFormFieldType('string') // 'text'
30
- * sdkFormFieldType('datetime') // 'date-time'
31
- * sdkFormFieldType('integer') // undefined
46
+ * validFormFieldTypesText() // 'string, …, array (or the older text, date-time; or a choice control: singleSelect, …)'
32
47
  */
33
- export declare function sdkFormFieldType(wire: unknown): FormFieldType | undefined;
48
+ export declare function validFormFieldTypesText(): string;
34
49
  /**
35
- * Why a form-field type is refused: a product spelling of a type the SDK
36
- * models (`"string"` is the platform's own name for text), or a type
37
- * the SDK does not model at all. `unknownWhy` is the caller's reason for the
38
- * second case; the default is a human task's.
50
+ * The data type and control a choice-control spelling names, or `undefined`
51
+ * for any other type.
52
+ *
53
+ * @example
54
+ * controlFormFieldType('singleSelect') // { data: 'string', control: 'dropdown' }
55
+ * controlFormFieldType('multiSelect') // { data: 'array', control: 'multiSelect' }
56
+ * controlFormFieldType('string') // undefined
57
+ */
58
+ export declare function controlFormFieldType(type: unknown): {
59
+ data: CanonicalFormFieldType;
60
+ control: string;
61
+ } | undefined;
62
+ /** The product aliases, for the contract test. */
63
+ export declare const FORM_FIELD_TYPE_ALIASES: Readonly<Record<string, CanonicalFormFieldType>>;
64
+ /**
65
+ * The canonical type a wire or source spelling names, or `undefined` when it
66
+ * names none the SDK models. A choice-control spelling is its own wire
67
+ * spelling, so it is `undefined` here too — its data type is
68
+ * `controlFormFieldType(t).data`; resolving it here would let a caller write
69
+ * `string` for a dropdown.
70
+ *
71
+ * @example
72
+ * canonicalFormFieldType('integer') // 'integer'
73
+ * canonicalFormFieldType('text') // 'string'
74
+ * canonicalFormFieldType('System.Int32') // 'integer'
75
+ * canonicalFormFieldType('string[]') // 'array'
76
+ * canonicalFormFieldType('string | null') // 'string'
77
+ * canonicalFormFieldType('singleSelect') // undefined
78
+ */
79
+ export declare function canonicalFormFieldType(type: unknown): CanonicalFormFieldType | undefined;
80
+ /**
81
+ * The spelling decompile writes into source for a wire field type: a canonical
82
+ * type or an SDK alias stays as written, so a canvas form (`"integer"`,
83
+ * `"date"`) and a classic-CLI form (`"text"`) both compile back to the bytes
84
+ * they came from; a product alias the SDK does not accept in source
85
+ * (`"System.Int32"`, `"string[]"`) becomes its canonical type; anything else
86
+ * stays verbatim for `check` to report.
87
+ *
88
+ * @example
89
+ * sourceFormFieldType('date') // 'date'
90
+ * sourceFormFieldType('text') // 'text'
91
+ * sourceFormFieldType('System.String') // 'string'
92
+ * sourceFormFieldType('string[]') // 'array'
93
+ * sourceFormFieldType('singleSelect') // 'singleSelect'
94
+ */
95
+ export declare function sourceFormFieldType(wire: unknown): string;
96
+ /**
97
+ * Why a form-field type is refused: a product alias the SDK does not accept in
98
+ * source (`"System.Int32"` is the platform's .NET name for `integer`), or a type
99
+ * the product does not recognize at all. `unknownWhy` is the caller's reason for
100
+ * the second case; the default is a human task's.
39
101
  */
40
102
  export declare function formFieldTypeWhy(type: unknown, unknownWhy?: string): string;
41
- /** The form-field types the SDK models. */
42
- export declare const FORM_FIELD_TYPES: string[];
43
- /** The `suggestion` for an unknown form-field type: the nearest valid one, else `type: 'text'`. */
103
+ /** The `suggestion` for an unknown form-field type: its canonical type, the nearest valid one, else `type: 'string'`. */
44
104
  export declare function formFieldTypeHint(type: unknown): string;
45
- /** JSON-Schema type per form-field type, as flow-v1's form serializer maps them (quick-form escalations and human tasks). */
46
- export declare const FORM_FIELD_JSON_TYPE: Record<FormFieldType, {
105
+ /**
106
+ * The JSON Schema of a field's value, for the output (and escalation input)
107
+ * schemas the serializers write; `undefined` for a type the SDK does not model.
108
+ *
109
+ * @example
110
+ * formFieldJsonSchema('date') // { type: 'string', format: 'date' }
111
+ * formFieldJsonSchema('text') // { type: 'string' }
112
+ * formFieldJsonSchema('multiSelect') // { type: 'array' }
113
+ */
114
+ export declare function formFieldJsonSchema(type: unknown): {
47
115
  type: string;
48
116
  format?: string;
49
- }>;
117
+ } | undefined;
118
+ /**
119
+ * A picker field's choices as the form row carries them (`options`, each
120
+ * `{ id, value, label }` — the product's `optionShape`), copied so the wire
121
+ * never aliases the author's array. `undefined` when the field has none.
122
+ * Both serializers (human task, quick-form escalation) write through this.
123
+ */
124
+ export declare function formFieldOptionsWire(options: readonly FormFieldOption[] | undefined): FormFieldOption[] | undefined;
125
+ /**
126
+ * A form row's `options` read back for source: the well-formed choices
127
+ * (string `id`, `value`, `label` — all three the product requires), or
128
+ * `undefined` when the row has no `options` array. A malformed entry is left
129
+ * out, not coerced: `{ id: 'o1', value: 1 }` is not rewritten to
130
+ * `value: '1', label: ''`. Decompile (human task and quick-form escalation)
131
+ * reads through this, so a canvas dropdown's choices survive an edit.
132
+ *
133
+ * @example
134
+ * liftFormFieldOptions([{ id: 'o1', value: 'a', label: 'A' }, { id: 'o2', value: 2 }])
135
+ * // [{ id: 'o1', value: 'a', label: 'A' }]
136
+ */
137
+ export declare function liftFormFieldOptions(raw: unknown): FormFieldOption[] | undefined;
138
+ /**
139
+ * What is wrong with a form field's `options`, or `undefined` when nothing is.
140
+ * `check` reports each (human task and quick-form escalation):
141
+ *
142
+ * - `'malformed'`: `options` is there but is not an array of `{ id, value,
143
+ * label }` strings. Serialize would throw or write rows the platform refuses.
144
+ * - `'missing'`: a choice-control type (`singleSelect`, `multiSelect`, `enum`)
145
+ * with no choices. The form publishes an empty picker.
146
+ * - `'ignored'`: choices on a type that is not a choice control. The form
147
+ * renders a plain input and never shows them.
148
+ *
149
+ * @example
150
+ * formFieldOptionsProblem('singleSelect', undefined) // 'missing'
151
+ * formFieldOptionsProblem('singleSelect', {}) // 'malformed'
152
+ * formFieldOptionsProblem('string', [{ id: 'o1', value: 'a', label: 'A' }]) // 'ignored'
153
+ * formFieldOptionsProblem('enum', [{ id: 'o1', value: 'a', label: 'A' }]) // undefined
154
+ */
155
+ export declare function formFieldOptionsProblem(type: unknown, options: unknown): 'malformed' | 'missing' | 'ignored' | undefined;
156
+ /**
157
+ * The reason text for a `formFieldOptionsProblem`, worded for a diagnostic
158
+ * that starts "… the field "<id>" …".
159
+ */
160
+ export declare function formFieldOptionsWhy(problem: 'malformed' | 'missing' | 'ignored', type: unknown): string;