diff --git a/packages/validation-station/README.md b/packages/validation-station/README.md
index 55a4440c..45f3bf27 100644
--- a/packages/validation-station/README.md
+++ b/packages/validation-station/README.md
@@ -1,890 +1,245 @@
# @uipath/ui-widgets-validation-station
-A React wrapper for the UiPath Document Understanding **Validation Station**. It handles web component loading and bucket artifact fetching, and exposes a declarative props API for every Validation Station feature.
+React component for the UiPath Document Understanding **Validation Station**, the screen where a reviewer checks and corrects the values extracted from a document, side by side with the document itself. Give it the output of an extraction and it fetches the document, shows it for review, and saves the reviewer's changes. It runs in any React app, typically a [Coded Action App](https://uipath.github.io/uipath-typescript/coded-action-apps/getting-started/) whose task includes a review step; completing that task stays with your app.
-## Installation
+## Pick your path
-```bash
-npm install @uipath/ui-widgets-validation-station
-```
-
-### Peer dependencies
-
-```bash
-npm install react@^19.2.0 react-dom@^19.2.0 @uipath/uipath-typescript@^1.5.1
-```
+
-## Quick start
+Your workflow decides the contract:
-> **Note: Theming**
-> Add either a `light` or `dark` class to your HTML `
` element to enable proper theming.
-
-```tsx
-import {
- configureValidationStationWc,
- ValidationStation,
-} from "@uipath/ui-widgets-validation-station";
-import { UiPath } from "@uipath/uipath-typescript/core";
-import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
-import { useEffect, useState } from "react";
+- **A Document Understanding workflow** hands over the `ContentValidationData` that its _Create Document Validation Artifacts_ activity outputs (IntelligentOCR, DocumentUnderstanding.Activities). Pass it as `data`.
+- **A Flow IDP extract node** hands over a `ProcessedDocument` (IXP). Pass it as `processedDocument`.
-// Once, at app startup — loads the web component from `du-vs-wc`, next to
-// your app's own root by default. See "Hosting the web component" below.
-configureValidationStationWc();
+Send it as **① one payload**, with `sdk` + `data` or `sdk` + `processedDocument`, and the widget fetches the rest and saves the review. Or send **② the individual inputs** you already hold as `artifacts`, and save the review yourself. The quick start below takes ①.
-function App({ task }: { task: { data: DuFramework.ContentValidationData } }) {
- const [sdk, setSdk] = useState(null);
+| Widget | DU ① | DU ② | IXP ① | IXP ② |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--: | :--: | :---: | :---: |
+| `ValidationStation`, the whole screen | ✓ | ✓ | ✓ | ✓ |
+| [Subcomponents](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md) `CompactFieldsForm`, `CompactTableEditor`, `DocumentViewer` | ✓ | ✓ | ✓ | ✓ |
+| [Subcomponents](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md) `CompactBusinessRules`, `CompactDocTypeField` | ✓ | ✓ | — | — |
- useEffect(() => {
- const init = async () => {
- const uipath = new UiPath({
- baseUrl: "https://api.uipath.com",
- orgName: "your-org",
- tenantName: "your-tenant",
- clientId: "your-client-id",
- // `OR.Buckets` is the widget's own need; `OR.Tasks` is for the host
- // code that fetches the task and completes it after submit.
- scope: "OR.Buckets OR.Tasks",
- redirectUri: "http://localhost:3000/callback",
- });
- await uipath.initialize();
- setSdk(uipath);
- };
- init();
- }, []);
+Start with `ValidationStation`. Reach for the subcomponents only when the standard screen does not fit your layout.
- if (!sdk) return
Loading...
;
+## Install
- return ;
-}
+```bash
+npm install @uipath/ui-widgets-validation-station @uipath/uipath-typescript @uipath/coded-action-app react@^19.2.0 react-dom@^19.2.0
+npm install --save-dev @uipath/du-validation-station-wc@1.0.0-rc.6
```
-> **Note: `initialize()` drives the OAuth redirect**
-> Under OAuth, `initialize()` navigates the browser to the identity provider and completes the flow when it returns, so keep it inside an effect rather than at module scope, and serve `redirectUri` as a route of this same app — it must match a URI registered on the external application exactly, scheme and path included.
+`@uipath/uipath-typescript` `>= 1.5.1` is required. `@uipath/coded-action-app` is only for a Coded Action App. The package is written in TypeScript, and every type it uses is exported from its root.
-`theme` defaults to `"light"` and `language` defaults to `ValidationStationLanguage.English`, so the minimal mount just needs `sdk` and `data`.
+## Host the web component
-> **Warning: Call `configureValidationStationWc` first**
-> You must call it once before rendering any widget from this package, and host the web component's files where it expects them. A `deploymentUrl` default handles this for most hosts — override it if yours doesn't. See [Hosting the web component](#hosting-the-web-component).
+The widget renders the Validation Station web component, which is loaded at runtime from your app's own files rather than bundled. There is no bundler configuration to write. Three steps:
-## Data sources
+1. **Stage it.** Copy `node_modules/@uipath/du-validation-station-wc` into `public/du-vs-wc` before every `dev` and `build`. Take the [`stage-du-wc.mjs`](https://github.com/UiPath/uipath-typescript/blob/main/samples/document-validation-app/scripts/stage-du-wc.mjs) script from the samples as-is:
-The widget needs a taxonomy, an extraction result and a document DOM. There are three mutually exclusive ways to give it those:
-
-| Mode | Pass | Who fetches | Who writes back |
-| ---------------------- | ---------------------------- | ------------------------------------------------------------- | ----------------------------------------------------- |
-| **Self-fetching** | `sdk` + `data` | The widget, from the bucket paths on `ContentValidationData` | The widget, to `ValidatedExtractionResultsPath` |
-| **Self-fetching, IXP** | `sdk` + `processedDocument` | The widget, through the Flow run that produced the document | The widget, as a review recorded against the Flow run |
-| **Pre-fetched** | `artifacts` (+ `documentId`) | You — hand it a `DuDocumentArtifacts` object you already hold | You, from the request the widget emits |
-
-If both `data` and `processedDocument` are set, `data` wins.
-
-**The outputs do not change with the mode.** `onSubmit`, `onSaveAsDraft` and `onReportException` fire for every user action either way, and always carry the request the web component produced. The only difference is a second argument: when the widget persisted the data itself, it passes the outcome too.
-
-Pre-fetched mode is what you want when the document does not live in a storage bucket, when the artifacts are already in memory (e.g. fetched once and shared with the [subcomponents](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md)), or when persistence goes somewhere other than `ValidatedExtractionResultsPath`.
-
-```tsx
-import {
- ValidationStation,
- type DuDocumentArtifacts,
-} from "@uipath/ui-widgets-validation-station";
+ ```json title="package.json"
+ {
+ "scripts": {
+ "stage-du-wc": "node scripts/stage-du-wc.mjs",
+ "predev": "npm run stage-du-wc",
+ "prebuild": "npm run stage-du-wc"
+ }
+ }
+ ```
-function App({ artifacts }: { artifacts: DuDocumentArtifacts }) {
- return (
- persistItYourself(request)}
- />
- );
-}
-```
+2. **Load it once,** at startup, before rendering any widget:
-Every bucket call is scoped to the folder `data` names — `FolderId`, or `FolderKey` when both are present. The activity that produces the `ContentValidationData` sets one of them; if neither is there, the widget renders an error instead of fetching.
+ ```ts title="src/main.tsx"
+ import { configureValidationStationWc } from "@uipath/ui-widgets-validation-station";
-The two modes can be mixed: pass `artifacts` **and** `sdk` + `data` to skip the fetch while keeping the built-in write-back — `onSubmit` then receives the outcome as well.
+ configureValidationStationWc({ includeFonts: true }).catch((error) => {
+ console.error("Validation Station web component failed to load", error);
+ });
+ ```
-> **Info: `DuDocumentArtifacts`**
-> `{ taxonomy, extractionResult, predictedExtractionResult?, dom, text, customizationInfo, original }` — `original` is the base64-encoded document the viewer renders. In `DuDocumentArtifacts`, `taxonomy` and `extractionResult` are UiPath DU contracts. `ValidationStation` also takes `IxpDocumentArtifacts`, the same shape with all three in the IXP representation (an `IXPTaxonomy` JSON Schema, an `IXPReviewedExtraction` — an `IXPExtraction` plus optional `confirmations` — and an optional `IXPExtraction` prediction). So do the `CompactFieldsForm`, `CompactTableEditor` and `DocumentViewer` subcomponents; `CompactBusinessRules` and `CompactDocTypeField` take `DuDocumentArtifacts` only.
+3. **Keep `public/du-vs-wc` out of git.** It is generated, and about 35 MB.
-### Comparing against the prediction
+> **Note: Keep the `.catch`**
+> The returned promise is the only place a load failure surfaces. Without it, a missing or misplaced `du-vs-wc` leaves the widget on its loading state with no error.
-`predictedExtractionResult` is the model's prediction — the extraction output nobody edited — as opposed to `extractionResult`, the result the user reviews. Self-fetching fills it from `AutomaticExtractionResultsPath`; in pre-fetched mode it is optional, and a hand-built `DuDocumentArtifacts` without it is still valid. Supply it in the same representation as `extractionResult`: an `IXPExtraction` on `IxpDocumentArtifacts`. A Flow `ProcessedDocument` carries no prediction, so self-fetching one leaves it unset.
+The default location works for a Coded App and for a plain host alike. For another location, CSP and version skew, see [Hosting in depth](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/hosting.md).
-> **Warning: Change it together with `extractionResult`**
-> Once the element has paired a prediction with the loaded values, assigning a different `predictedExtractionResult` (or `null`) on its own reloads the last `extractionResult` it was fed and drops unsaved edits. With `EnablePredictionDiff` on, the element also inserts predicted rows and values the result lacks, as unconfirmed values the user confirms or deletes.
+## Quick start: a Coded Action App
-By itself it changes nothing visible. It drives the `EnablePredictionDiff` customization flag (compact mode, on `ValidationStation`, `CompactFieldsForm` and `CompactTableEditor`): where the prediction differs from the current values, the element shows the predicted value with a button that takes it over. Like every customization flag, it lives under `FeatureCustomization` in `customizationInfo` — typed by the exported `ICustomizationInfoDTO` / `IFeatureCustomization`:
+A Document Understanding workflow raises a validation action; Action Center opens your app on it. The app reads the task, renders the widget, and completes the task once the reviewer submits. This is a cut-down version of the [`action-app-with-document-validation`](https://github.com/UiPath/uipath-typescript/tree/main/samples/coded-action-apps/action-app-with-document-validation) sample, whose action schema declares one input, `contentValidationData`, and one outcome, `Submit`.
-```ts
-import type { ICustomizationInfoDTO } from "@uipath/ui-widgets-validation-station";
+```ts title="src/uipath.ts"
+import { UiPath } from "@uipath/uipath-typescript/core";
+import { CodedActionApp } from "@uipath/coded-action-app";
-// Merge over what the bucket supplied rather than replacing it.
-const fetched = artifacts.customizationInfo as
- | ICustomizationInfoDTO
- | undefined;
-const withDiff = {
- ...artifacts,
- customizationInfo: {
- ...fetched,
- FeatureCustomization: {
- ...fetched?.FeatureCustomization,
- EnablePredictionDiff: true,
- },
- } satisfies ICustomizationInfoDTO,
-};
+// No arguments and no initialize(): Action Center supplies the auth.
+export const sdk = new UiPath();
+export const codedActionApp = new CodedActionApp();
```
-### Owning the round-trip
-
-Pre-fetched mode does not mean writing the bucket plumbing yourself. Everything the widget does internally is exported, so a host can drive the same flow:
-
-| Export | Use |
-| ---------------------------------------------- | ---------------------------------------------------------------------------------------- |
-| `fetchDuDocumentArtifacts(sdk, data)` | Fetch `DuDocumentArtifacts` imperatively — outside render, ahead of time, or in a loader |
-| `useDuDocumentArtifacts(sdk, data)` | The same fetch as a hook, for when the fetch belongs to a component's lifecycle |
-| `submitValidatedData(sdk, data, request)` | The submit flow: `ProcessExtractedData`, then upload to `ValidatedExtractionResultsPath` |
-| `saveValidatedDataAsDraft(sdk, data, request)` | The draft flow: upload `validatedData` straight to the bucket |
-
-```tsx
+```tsx title="src/Validation.tsx"
+import { useEffect, useMemo, useState } from "react";
import {
- fetchDuDocumentArtifacts,
- submitValidatedData,
- saveValidatedDataAsDraft,
ValidationStation,
- type DuDocumentArtifacts,
+ type IValidationStationOptions,
} from "@uipath/ui-widgets-validation-station";
+import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
+import { MessageSeverity } from "@uipath/coded-action-app";
+import { codedActionApp, sdk } from "./uipath";
-function HostOwnedReview({ sdk, data }) {
- const [artifacts, setArtifacts] = useState(null);
-
- useEffect(() => {
- fetchDuDocumentArtifacts(sdk, data).then(setArtifacts);
- }, [sdk, data]);
-
- if (!artifacts) return
Loading document…
;
-
- return (
- {
- const result = await submitValidatedData(sdk, data, request);
- afterSubmit(result);
- }}
- onSaveAsDraft={(request) => saveValidatedDataAsDraft(sdk, data, request)}
- />
- );
+interface ActionInputs {
+ contentValidationData?: DuFramework.ContentValidationData;
}
-```
-
-> **Warning: Handle both callbacks**
-> The widget always offers **Save as draft**, so leaving `onSaveAsDraft` unwired means a draft click persists nothing.
-
-The request payloads are exported too — `IVsSaveValidatedDataRequest`, `IVsSaveValidatedDataAsDraftRequest` and `IVsSaveExceptionReportRequest` — so handlers declared outside JSX can name their parameter.
-
-### IXP (`ProcessedDocument`)
-
-A Flow IDP node emits a `ProcessedDocument` rather than a `ContentValidationData`. It carries the taxonomy (an `IXPTaxonomy`) and the result (an `IXPExtraction`) inline, plus `metadata` naming the run that produced it — `traceId`, `spanId` and `folderKey`. The document, its DOM and its OCR text are read through that run's trace.
-
-```tsx
- completeTask(result?.processedDocument)}
-/>
-```
-- **Loading.** The document opens on the result last saved against the producing span (a draft), else on the payload's `result`. A draft reopens with the values the reviewer had confirmed. `documentId` defaults to `metadata.traceId`.
-- **Saving.** Submit and draft record the review against the producing span; report-as-exception records a rejection with the reason. `onSubmit`, `onSaveAsDraft` and `onReportException` receive the outcome as their second argument. `request.validatedData` is an `IXPExtraction` on submit, and an `IXPReviewedExtraction` — the same plus the reviewer's `confirmations` — on a draft.
-- **Record format.** A review is stored as the `ProcessedDocument` the widget was given, with its `result` replaced by the validated one and `metadata.hitl.draft` set — `true` for a draft, `false` for a submit. This is the shape the Angular Validation Station uses, so either reopens a review the other saved. A record in any other shape — including the `{ draft, extraction }` envelope both used before — is ignored on load, and the document opens on the payload's `result`.
-- **Completing the task is yours.** The downstream Flow node reads the validated document from the task completion. A submit's `result.processedDocument` is that document — the same one the record holds, a `ValidatedProcessedDocument` — so complete the task with it, verbatim, whatever `result.success` says: a failed record write must not block the review. `toValidatedProcessedDocument(processedDocument, validatedData, draft)` builds it when you persist yourself.
-- **Subcomponents.** `CompactFieldsForm`, `CompactTableEditor` and `DocumentViewer` take `processedDocument` or `IxpDocumentArtifacts` too, and `CompactFieldsForm` saves a Flow document as `ValidationStation` does. `CompactBusinessRules` and `CompactDocTypeField` are Document Understanding-only. See the [subcomponents guide](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md#ixp-documents).
-- **OAuth scopes.** The `sdk`'s token needs `Traces.Api` (the run's spans, and the review record) and `OR.Buckets.Read` (the document, DOM and OCR text, via ECS). A coded action app completing the task also needs `OR.Tasks`. A missing scope surfaces as a 401/403 in the load or save error.
-- **Hosting.** The artifacts are downloaded in the browser from pre-signed ECS storage URLs, so the host's origin must be in the ECS storage account's CORS rules. Coded apps (`https://{org}.{env}.uipath.host`) are.
-
-The widget does this through exported functions, so a host that fetches up front runs exactly the same code:
-
-| Export | Use |
-| ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| `fetchProcessedDocumentArtifacts(sdk, processedDocument)` | Fetch the `IxpDocumentArtifacts` — what the widget fetches given `processedDocument` |
-| `useProcessedDocumentArtifacts(sdk, processedDocument)` | The same fetch as a hook, for when the fetch belongs to a component's lifecycle |
-| `submitProcessedDocument(sdk, processedDocument, request)` | Record a submitted review; its result carries the `processedDocument` to complete the task with |
-| `saveProcessedDocumentAsDraft(sdk, processedDocument, request)` | Record a draft — the one the next load opens on |
-| `reportProcessedDocumentException(sdk, processedDocument, request)` | Record a rejection with the reviewer's reason. Replaces a saved draft |
+const OPTIONS: IValidationStationOptions = {
+ emitDtoStateChanges: true, // without it, "Save as draft" saves nothing
+ hideReportAsExceptionButton: true, // it needs a DU validation task, not an app task
+};
-```tsx
-const artifacts = await fetchProcessedDocumentArtifacts(sdk, processedDocument);
+export function Validation() {
+ const [task, setTask] = useState<{
+ data: ActionInputs;
+ folderId: number;
+ isReadOnly: boolean;
+ } | null>(null);
- {
- const result = await submitProcessedDocument(
- sdk,
- processedDocument,
- request,
+ useEffect(() => {
+ codedActionApp.getTask().then((t) =>
+ setTask({
+ data: (t.data as ActionInputs) ?? {},
+ folderId: t.folderId,
+ isReadOnly: t.isReadOnly,
+ }),
);
- // Undefined only for a payload the station could not have reviewed.
- if (result.processedDocument) completeTask(result.processedDocument);
- }}
- onSaveAsDraft={(request) =>
- saveProcessedDocumentAsDraft(sdk, processedDocument, request)
- }
-/>;
-```
-
-The save functions are stateless: each one edits the span's newest review record, or creates it when there is none, so the widget and a host saving outside it always land on the same record.
-
-## Props
-
-| Prop | Type | Required | Default | Description |
-| -------------------------------- | --------------------------------------------- | -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `sdk` | `UiPath` | No\* | — | UiPath SDK instance for authentication and API calls. Required for self-fetching / persistence |
-| `data` | `ContentValidationData` | No\* | — | Document data containing the bucket paths, document ID, and the folder they live in — `FolderId` or `FolderKey`, whichever the producing activity set. Required for self-fetching / persistence |
-| `processedDocument` | `ProcessedDocument` | No\* | — | A Flow IDP node's output. With `sdk`, the widget fetches its artifacts and records reviews through the producing run — see [IXP documents](#ixp-documents-processeddocument). Ignored when `data` is set |
-| `artifacts` | `DuDocumentArtifacts \| IxpDocumentArtifacts` | No\* | — | Pre-fetched document artifacts. When supplied, no fetch is performed. \*Either `artifacts`, `sdk` + `data` or `sdk` + `processedDocument` must be provided |
-| `documentId` | `string` | No | — | Document ID forwarded to the web component. Falls back to `data.DocumentId`, else `processedDocument.metadata.traceId` — pass it in pre-fetched mode |
-| `theme` | `DuTheme` | No | `'light'` | Visual theme: `'light'`, `'dark'`, `'light-hc'`, `'dark-hc'`, or the Apollo Modern `'future-light'` / `'future-dark'` |
-| `language` | `ValidationStationLanguage` | No | `English` | UI language (see [the enum](#language-enum)) |
-| `isReadonly` | `boolean` | No | `false` | When `true`, renders in read-only mode |
-| `persistent` | `boolean` | No | `false` | Render the persistent element variant, which survives portal/DOM detachment (e.g. tab switches) |
-| `options` | `IValidationStationOptions` | No | — | Fine-grained UI feature flags, passed through to the element as given |
-| `save={{ validate: false }}` | `{ validate: boolean }` | No | — | Trigger **save as draft** |
-| `save={{ validate: true }}` | `{ validate: boolean }` | No | — | Trigger **submit** — runs validation first, then saves |
-| `discardChanges` | `{ value: boolean }` | No | — | Trigger a discard-changes operation. Call `setDiscardChanges({ value: true })` (or `false` — the boolean is ignored) every time you want it to fire. Each call creates a brand-new object even if the content looks identical, and that is what the widget watches for |
-| `setFieldValueByPath` | `SetFieldValueByPath` | No | — | Set a field value addressed by a path of `{ fieldName, valueIndex }` segments |
-| `selectAndFocusFieldValueByPath` | `SelectAndFocusFieldValueByPath` | No | — | Select and focus a field value addressed by a path; focuses the document reference if any |
-| `deleteFieldValueByPath` | `DeleteFieldValueByPath` | No | — | Delete a field value addressed by a path |
-
-The three save callbacks (`onSubmit`, `onSaveAsDraft`, `onReportException`) are documented [below](#reacting-to-save-draft-and-exception-flows); the state callbacks in [Reading the document state](#reading-the-document-state).
-
-## Reacting to save, draft and exception flows
-
-The widget surfaces three user-initiated flows and reports each through exactly one callback, whichever mode it is in. Every callback receives the raw request; `result` is filled in only for the flows the widget persisted itself.
-
-| Callback | User action | Signature | What the widget does | What the host does |
-| ------------------- | ----------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
-| `onSubmit` | **Submit** | `(request, result?) => void` | With `sdk` + `data`: `processExtractedData`, then uploads to `ValidatedExtractionResultsPath`, and passes the outcome as `result`. Without: emits the request only | React to `result`, or — when it is absent — persist the request yourself (`submitValidatedData` does exactly what the widget would have) |
-| `onSaveAsDraft` | **Save as draft** | `(request, result?) => void` | With `sdk` + `data`: uploads `validatedData` straight to the bucket (no `processExtractedData`). Without: emits the request only | Same as above; the host-side equivalent is `saveValidatedDataAsDraft` |
-| `onReportException` | **Report as exception** | `(request, result?) => void` | With `sdk` + `processedDocument`: records the rejection against the Flow run and passes the outcome as `result`. Otherwise nothing — the reason is at `request.exceptionReport.Reason` | For any other source, persist it yourself — call `OrchestratorDuModule.submitExceptionReport(...)` |
-
-Submit and draft hand you a `SaveValidatedDataResult` (`{ success, error? }`) — the host owns all UI feedback (toast, retry, etc.); the widget does not surface failures itself. The exception callback hands you `documentId` and `reason` strings ready to forward to the SDK.
+ }, []);
-All three fire on every user action, regardless of mode — that is the contract. Only `result` varies.
+ // The widget reads the bucket in the folder the payload names; fall back to the task's folder.
+ const data = useMemo(() => {
+ const payload = task?.data.contentValidationData;
+ if (!payload) return null;
+ return payload.FolderId != null || payload.FolderKey != null
+ ? payload
+ : { ...payload, FolderId: task.folderId };
+ }, [task]);
-```tsx
-import {
- ValidationStation,
- type SaveValidatedDataResult,
-} from "@uipath/ui-widgets-validation-station";
-import { OrchestratorDuModule } from "@uipath/uipath-typescript/orchestrator-du-module";
-
-function App({ sdk, data, task }) {
- // `sdk` + `data` are set, so the widget persisted it and `result` is present.
- const handleSubmit = async (request, result?: SaveValidatedDataResult) => {
- if (!result?.success) {
- console.warn("Submit failed:", result?.error);
- return;
- }
- await task.complete({ action: "Completed", type: "DocumentValidation" });
- };
-
- const handleSaveAsDraft = (request, result?: SaveValidatedDataResult) => {
- if (!result?.success) console.warn("Draft save failed:", result?.error);
- };
-
- const handleReportException = async (request) => {
- const reason = request.exceptionReport?.Reason ?? "";
- const response = await new OrchestratorDuModule(sdk).submitExceptionReport(
- task.id,
- request.documentId,
- reason || "Reported via Validation Station",
- { folderId: task.folderId },
- );
- if (!response.IsSuccessful) {
- console.error("submitExceptionReport failed:", response.ErrorMessage);
- }
- };
+ if (!task) return
Loading the action…
;
+ if (!data) return
This action has no contentValidationData input.
;
return (
{
+ if (!result?.success) {
+ codedActionApp.showMessage(
+ result?.error ?? "Failed to submit the document.",
+ MessageSeverity.Error,
+ );
+ return;
+ }
+ // completeTask replaces the task's data: pass all of it back, not just your changes.
+ await codedActionApp.completeTask("Submit", task.data);
+ }}
+ onSaveAsDraft={(_request, result) =>
+ codedActionApp.showMessage(
+ result?.success
+ ? "Draft saved."
+ : (result?.error ?? "Failed to save the draft."),
+ result?.success ? MessageSeverity.Success : MessageSeverity.Error,
+ )
+ }
/>
);
}
```
-> **Warning: Failures are silent if you skip the callbacks**
-> All three callbacks are optional, but the widget surfaces no errors on its own. Outside a `processedDocument`, `onReportException` is the only place the report goes — without it, the user's **Report as exception** click is a no-op.
-
-## Reading the document state
-
-These callbacks report the rest of the element's `IValidationStationStandaloneWcEventMap`; the three save flows are above.
-
-| Prop | Fires when |
-| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `onExtractionResultChanged` | Any change to the extraction result — needs `options={{ emitDtoStateChanges: true }}`. An IXP document reports an `IXPReviewedExtraction`, with its `confirmations` |
-| `onLoaded` | The element finished loading |
-| `onDirtyChange` | Unsaved changes appear or are cleared |
-| `onIsValidChange` | Validity flips (`true` = no Must rule broken, no invalid values) |
-| `onDocumentTypeChanged` | The user picks another document type |
-| `onFieldValueSelected` | The user selects a field value |
-| `onFieldValueChanged` | The user edits a field value |
-| `onBusinessRulesEvaluated` | Validation errors and business rules are re-evaluated |
-| `onSaveResult` | A `save` command completes |
-| `onSetFieldValueByPathResult` | A `setFieldValueByPath` command completes |
-| `onSelectAndFocusFieldValueByPathResult` | A `selectAndFocusFieldValueByPath` command completes |
-| `onDeleteFieldValueByPathResult` | A `deleteFieldValueByPath` command completes |
-| `onFieldsPanelWidthChanged` | The fields panel is resized (width in px) |
-| `onFieldsPanelSideChanged` | The panel moves to the other side of the viewer |
-| `onWcMessage` | The element publishes a message on its bus (`ui-du-vs-wc-message`) — see below |
-
-> **Attention: Commands need a loaded document**
-> `setFieldValueByPath`, `selectAndFocusFieldValueByPath` and `deleteFieldValueByPath` resolve their `path` against the taxonomy and the current extraction result, so one issued before those arrive fails to resolve. Gate on `onLoaded`, and wire the matching `*Result` callback — it carries the reason (`No field value found at path …`), which is otherwise invisible.
-
-The subcomponents report subsets of this set — see [subcomponents](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md).
-
-### Rendering your own value-indicator overlay
+> **Note: Theming**
+> Add a `light` or `dark` class to ``; the widget's stylesheets key off it. `theme` and `language` default to `"light"` and English. The sample maps Action Center's theme onto both.
-Hovering a value's confidence indicator opens a built-in popover. `onWcMessage` receives an `IVsWcMessage`, discriminated on `type`: `indicator-overlay-show` carries the value's confidence, thresholds, confirmation and broken-rule state (`IVsIndicatorOverlayContext`) plus the trigger's viewport rect to position against, and `indicator-overlay-hide` closes it. Hide the built-in popover with CSS, then render your own:
+### From a Flow IDP extract node (IXP)
-```css
-ui-du-validation-station-standalone-wc-element::part(indicator-overlay) {
- display: none;
-}
-```
+Pass the `ProcessedDocument` instead of `data`, and complete the task with the validated document the widget hands back:
```tsx
{
- if (message.type === "indicator-overlay-show") showPopover(message.context);
- else hidePopover();
+ processedDocument={processedDocument}
+ onSubmit={(_request, result) => {
+ // The node downstream reads this document as its output. Complete with it
+ // verbatim, even when result.success is false: a failed record write must
+ // not block the review.
+ completeTask(result?.processedDocument);
}}
/>
```
-`message.instanceId` tells elements apart when several report to one handler. `CompactFieldsForm`, `CompactTableEditor` and `CompactBusinessRules` take `onWcMessage` too.
+The full IXP behaviour, from loading drafts to the record format, is in [Data sources](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/data-sources.md#ixp-processeddocument).
-### Opening a field in your taxonomy editor
+### As a standalone web app
-An annotation host — one that sets `options={{ intendedUse: "document-annotation" }}` — gets an _Edit instructions_ link on each prediction-diff warning. Clicking it publishes `taxonomy-field-focus-request` on the same bus, naming the field group or table (`fieldId`) and its `documentTypeId`:
+Outside Action Center, construct the SDK with your external application and sign in first: `new UiPath({ baseUrl, orgName, tenantName, clientId, redirectUri, scope })`, then `await sdk.initialize()` inside an effect, since under OAuth it navigates to the identity provider and back. Serve `redirectUri` from the same app. The [`document-validation-app`](https://github.com/UiPath/uipath-typescript/tree/main/samples/document-validation-app) sample is a full inbox built this way.
-```tsx
- {
- if (message.type === "taxonomy-field-focus-request")
- openTaxonomyField(message.documentTypeId, message.fieldId);
- }}
-/>
-```
-
-`ValidationStation` and `CompactFieldsForm` publish it; the table editor does not. Since `IVsWcMessage` gained this member, an exhaustive `switch` over `message.type` needs a new case.
-
-## Language enum
-
-`ValidationStationLanguage` provides all supported locales:
-
-```ts
-import { ValidationStationLanguage } from "@uipath/ui-widgets-validation-station";
-
-ValidationStationLanguage.English; // "en"
-ValidationStationLanguage.German; // "de"
-ValidationStationLanguage.Spanish; // "es"
-ValidationStationLanguage.SpanishMexico; // "es-MX"
-ValidationStationLanguage.French; // "fr"
-ValidationStationLanguage.Japanese; // "ja"
-ValidationStationLanguage.Korean; // "ko"
-ValidationStationLanguage.Portuguese; // "pt"
-ValidationStationLanguage.PortugueseBrazil; // "pt-BR"
-ValidationStationLanguage.Romanian; // "ro"
-ValidationStationLanguage.Russian; // "ru"
-ValidationStationLanguage.Turkish; // "tr"
-ValidationStationLanguage.ChineseSimplified; // "zh-CN"
-ValidationStationLanguage.ChineseTraditional; // "zh-TW"
-```
-
-## Exported types
-
-All parameter types are re-exported from the package for convenience:
-
-```ts
-import {
- configureValidationStationWc,
- DU_WC_TAGS,
- joinDeploymentUrl,
- VALIDATION_STATION_TAG,
- ValidationStationLanguage,
-} from "@uipath/ui-widgets-validation-station";
-import type {
- ValidationStationProps,
- ValidationStationWcConfig,
- DuArtifactsSource,
- ValidationStationArtifactsSource,
- DuDocumentArtifacts,
- IxpDocumentArtifacts,
- ValidationStationArtifacts,
- IXPTaxonomy,
- IXPExtraction,
- IXPReviewedExtraction,
- ProcessedDocument,
- ValidatedProcessedDocument,
- DuTheme,
- ValidationStationIntendedUse,
- IValidationStationOptions,
- FieldFilterOptions,
- DocumentViewerOptions,
- ICustomizationInfoDTO,
- IFeatureCustomization,
- IVsWcMessage,
- IVsIndicatorOverlayContext,
- IVsTaxonomyFieldFocusRequestMessage,
- IVsSaveValidatedDataRequest,
- IVsSaveValidatedDataAsDraftRequest,
- IVsSaveExceptionReportRequest,
- SaveValidatedDataResult,
- SetFieldValueByPath,
- SelectAndFocusFieldValueByPath,
- DeleteFieldValueByPath,
- ValidationStationEventProps,
- VsStateEventProps,
- VsAnyRepresentationStateEventProps,
- VsSaveResultEventProps,
- IFieldValueDetailsDto,
- EvaluatedBusinessRulesForFieldValueDto,
- ISaveResult,
- SetFieldValueByPathResult,
- SelectAndFocusFieldValueByPathResult,
- DeleteFieldValueByPathResult,
-} from "@uipath/ui-widgets-validation-station";
-```
-
-`DU_WC_TAGS` and `VALIDATION_STATION_TAG` are the custom-element tag names the loader registers — useful for `document.querySelector` or asserting readiness in tests. The wrappers in this package render them for you.
-
-## Examples
-
-### Setting a field value by path
-
-Address fields by path when you have nested groups or table rows. Each segment is `{ fieldName, valueIndex }`.
-
-> **Note: Paths resolve only after the document loads**
-> See [Reading the document state](#reading-the-document-state). Wire `onSetFieldValueByPathResult` while you are building this, or a mistimed command fails silently.
-
-```tsx
-import { useState } from "react";
-import {
- ValidationStation,
- type SetFieldValueByPath,
-} from "@uipath/ui-widgets-validation-station";
-
-function App({ sdk, data }) {
- const [fieldValueByPath, setFieldValueByPath] = useState<
- SetFieldValueByPath | undefined
- >(undefined);
-
- return (
- <>
-
-
- >
- );
-}
-```
-
-### Focusing a field by path
-
-```tsx
-import { useState } from "react";
-import {
- ValidationStation,
- type SelectAndFocusFieldValueByPath,
-} from "@uipath/ui-widgets-validation-station";
-
-function App({ sdk, data }) {
- const [focus, setFocus] = useState<
- SelectAndFocusFieldValueByPath | undefined
- >(undefined);
-
- return (
- <>
-
-
- >
- );
-}
-```
-
-### Triggering save
+## Saving
-```tsx
-const [save, setSave] = useState<{ validate: boolean } | undefined>(undefined);
+The widget's own action bar offers **Submit**, **Save as draft** and **Report as exception**. Each fires one callback, with the request the web component produced and, when the widget saved it itself (①), the outcome as `result`. The widget shows no errors of its own; tell the reviewer from the callback.
-
-
-```
+| Callback | With `sdk` + `data`, the widget… | Left to you |
+| ------------------- | ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
+| `onSubmit` | runs `ProcessExtractedData` and uploads to `ValidatedExtractionResultsPath` | **Completing the task**, and only when `result.success` is true |
+| `onSaveAsDraft` | uploads the in-progress values; the next load opens on them | Telling the reviewer. Needs `options={{ emitDtoStateChanges: true }}` |
+| `onReportException` | does nothing for a DU document; records a rejection for a `ProcessedDocument` | For DU, persisting it yourself, or hiding the button with `hideReportAsExceptionButton` |
-## Hosting the web component
+With ② (`artifacts`, no `sdk`), every callback carries only the request and the saving is yours; the exported `submitValidatedData` and `saveValidatedDataAsDraft` do what the widget would have. See [Data sources](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/data-sources.md#owning-the-round-trip).
-The widgets in this package render the Validation Station **web component**, which ships as a prebuilt Angular bundle in [`@uipath/du-validation-station-wc`](https://www.npmjs.com/package/@uipath/du-validation-station-wc). The bundle is **not** imported by the package — it is loaded at runtime from a URL you host, via [`@uipath/du-utils`](https://www.npmjs.com/package/@uipath/du-utils).
+**OAuth scopes.** The token needs `OR.Buckets` for a DU document, and `Traces.Api` plus `OR.Buckets.Read` for a `ProcessedDocument`. The app needs `OR.Tasks` to read and complete the task. In a Coded Action App, set them as `scope` in `uipath.json`, on an external application that grants them.
-That means there is no bundler configuration to write. You need two things:
+## Core props
-1. Serve the contents of `node_modules/@uipath/du-validation-station-wc` as static files at `du-vs-wc`, next to your app's own root (see the default below — pass an explicit `deploymentUrl` if you host it somewhere else).
-2. Call `configureValidationStationWc` once, before rendering any widget.
+| Prop | Type | Description |
+| ------------------------------------------------ | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
+| `sdk` | `UiPath` | The SDK instance. Needed whenever the widget fetches or saves (①) |
+| `data` | `ContentValidationData` | A Document Understanding workflow's output. Wins over `processedDocument` when both are set |
+| `processedDocument` | `ProcessedDocument` | A Flow IDP extract node's output |
+| `artifacts` | `DuDocumentArtifacts \| IxpDocumentArtifacts` | The individual inputs you already hold (②). No fetch happens. Pass `documentId` with them |
+| `theme` | `DuTheme` | `'light'` (default), `'dark'`, `'light-hc'`, `'dark-hc'`, `'future-light'`, `'future-dark'` |
+| `language` | `ValidationStationLanguage` | Defaults to `ValidationStationLanguage.English` |
+| `isReadonly` | `boolean` | Read-only review. Pass the task's `isReadOnly` |
+| `options` | `IValidationStationOptions` | UI flags, such as `emitDtoStateChanges`, `hideReportAsExceptionButton`, `hideDiscardButton`, `fieldFilterOptions` |
+| `onSubmit`, `onSaveAsDraft`, `onReportException` | `(request, result?) => void` | See [Saving](#saving) |
-```ts
-import { configureValidationStationWc } from "@uipath/ui-widgets-validation-station";
+Every other prop, the state callbacks (`onLoaded`, `onDirtyChange`, `onFieldValueChanged`, …) and the commands that set or focus a value by path are in [Props, events and commands](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/events-and-commands.md).
-configureValidationStationWc({
- // Set true unless your app already loads Material Icons globally —
- // otherwise every icon renders as its ligature text. See "Fonts" below.
- includeFonts: true,
-}).catch((error) => {
- console.error("Validation Station web component failed to load", error);
-});
-```
+## Troubleshooting
-`deploymentUrl` defaults to `du-vs-wc` joined onto `getAppBase()` — `/du-vs-wc` on a plain host, or the deployed app's own base path if you are running as a UiPath Coded App. Most integrations need nothing more than the call above. Pass an explicit `deploymentUrl` only when the web component is hosted somewhere that default doesn't reach:
+| Symptom | Likely cause |
+| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
+| The widget stays on its loading state | The web component did not load: check the `.catch` on `configureValidationStationWc`, and that `du-vs-wc` is in your build |
+| `basedomain query parameter is missing` | The app was opened directly, not from an Action Center task. Open it from the task |
+| An error naming a missing folder (`FolderId` / `FolderKey`) | The payload has neither. Fill it from `task.folderId`, as in the quick start |
+| A 401 or 403 when loading or saving | A missing scope. See [Saving](#saving) |
+| **Save as draft** does nothing | `options={{ emitDtoStateChanges: true }}` is not set |
+| The completed task has empty data | `completeTask` was given only part of the task's data. Pass all of it back |
+| Icons render as words such as `expand_more` | Material Icons are not loaded. Pass `includeFonts: true` |
+| With `artifacts`: "document format unknown not supported" | `original` is bare base64. It must be a data URI: `data:application/pdf;base64,…` |
+| With `artifacts`: no line items in a DU document | The tables are in `ResultsDocument.Tables`, which is ignored. Put them in `ResultsDocument.Fields` as Table fields |
+| Subcomponents: fields show "Is missing", or panels don't sync | The `instanceId`: use the same one across one document's panels, and a different one per document and per contract (DU / IXP) |
-```ts
-import {
- configureValidationStationWc,
- joinDeploymentUrl,
-} from "@uipath/ui-widgets-validation-station";
+## Going further
-configureValidationStationWc({
- // A literal, a build-time constant, or a resolver — see "Notes" below.
- deploymentUrl: joinDeploymentUrl(
- "https://cdn.example.com/my-app",
- "du-vs-wc",
- ),
- includeFonts: true,
-});
-```
+- [Data sources and the round trip](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/data-sources.md): pre-fetched artifacts, loading and saving from your own code, and IXP documents in full.
+- [Props, events and commands](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/events-and-commands.md): every prop and callback, setting and focusing values by path, a custom confidence popover, the language list.
+- [Hosting in depth](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/hosting.md): the served folder's layout, `deploymentUrl`, fonts, CSP and version skew.
+- [Subcomponents](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/docs/validation-station-subcomponents.md): build your own layout from the fields form, table editor, document viewer, business rules and document type panels.
+- [Upgrading](https://github.com/UiPath/uipath-ui-widgets/blob/develop/packages/validation-station/UPGRADING.md): what each web component release changed, and moving off `1.0.x`.
+- Sample apps, each with setup steps, also in the [Sample Apps Gallery](https://uipath.github.io/uipath-typescript/samples/):
-`joinDeploymentUrl(base, path)` exists because hand-rolled string concatenation is an easy way to end up with a doubled or missing slash — it strips any trailing slash from `base` and any leading slash from `path` before joining them, regardless of which one supplied it (or neither).
-
-The served directory must keep the package's own layout, because the bundle resolves these against its own `import.meta.url`:
-
-```
-/du-vs-wc/
-├── main.js ← entry, plus its hashed chunk-*.js siblings
-├── polyfills.js ← must load before main.js (the loader handles ordering)
-├── styles.css ← fetched as raw CSS and adopted into the shadow root
-├── fonts.css ← Material Icons only (opt-in via includeFonts)
-├── media/ ← the font files fonts.css references
-└── du-assets/ ← pdf.js scripts, cmaps, wasm decoders, translations,
- the business-rules executor
-```
-
-Copying the package directory verbatim satisfies this.
-
-### Serving it with Vite
-
-> **Success: No `vite.config.ts` changes are needed**
-> Since `1.1.0` the web component is fetched at runtime instead of imported, so it never enters the module graph. The `optimizeDeps.exclude`, asset-copy plugin and dev-server middleware that `1.0.x` required are all obsolete — delete them (see [Migrating from 1.0.x](#migrating-from-10x)). A Vite app needs nothing in its config beyond whatever it already has.
-
-What it does need is the package copied into `public/`, which Vite serves verbatim in dev and copies to `dist/` on build. The four samples below all do it with one script wired to the `predev` and `prebuild` hooks, so a plain `npm run dev` or `npm run build` stages it:
-
-```json title="package.json"
-{
- "scripts": {
- "stage-du-wc": "node scripts/stage-du-wc.mjs",
- "predev": "npm run stage-du-wc",
- "prebuild": "npm run stage-du-wc"
- },
- "devDependencies": {
- "@uipath/du-validation-station-wc": "1.0.0-rc.6"
- }
-}
-```
-
-The script copies `node_modules/@uipath/du-validation-station-wc` to `public/du-vs-wc` — which is exactly where the `deploymentUrl` default looks — skipping the npm metadata, verifying that `main.js`, `polyfills.js`, `styles.css`, `fonts.css` and `du-assets/` all landed, and stamping the staged version so a repeat run is a no-op. Take it as-is: [`scripts/stage-du-wc.mjs`](https://github.com/UiPath/uipath-typescript/blob/main/samples/document-validation-app/scripts/stage-du-wc.mjs).
-
-> **Tip: Keep `public/du-vs-wc` out of git**
-> It is generated, and it is tens of megabytes — the fonts alone are most of it. Add it to `.gitignore` and let the `predev` / `prebuild` hooks produce it.
-
-### Fonts
-
-The `fonts.css` in `@uipath/du-validation-station-wc` carries **Material Icons
-only** — the one font the component cannot do without. The Apollo text fonts
-(Poppins, Noto Sans, Inconsolata) are not in the package, so the component's
-text inherits your app's own font stack. A UiPath-styled host already loads
-them; to get the UiPath typography otherwise, install
-[`@uipath/apollo-fonts`](https://www.npmjs.com/package/@uipath/apollo-fonts) and
-import its `font.css` in your app. That file contains Material Icons as well, so
-`includeFonts` can then stay off.
-
-A UiPath-hosted deployment of the web component is built with the full font set,
-so `includeFonts: true` against one of those links the Apollo fonts too.
-
-### Notes
-
-- **Call it once.** Loading is cached per page, so a second call with a different `deploymentUrl` is ignored. A _failed_ load is not cached — call again to retry.
-- **The returned promise is the error channel.** Components only observe success; a bad URL or a 404 surfaces on the promise, so attach a `.catch`. Without it, a load failure leaves the widgets showing their loading state.
-- **`du-assets/` and `media/` are outside that promise.** The loader only ever touches `polyfills.js`, `main.js`, `styles.css` and `fonts.css`; the web component fetches those two directories itself, at render time. Without `du-assets/`, PDF rendering and translations 404 silently while business-rules validation rejects outright — its executor is pulled in with a dynamic `import()`, so it fails loudly where the rest degrades quietly. Without `media/`, `fonts.css` resolves but every `url()` inside it 404s, so `includeFonts: true` loads no fonts.
-- **`deploymentUrl` accepts a resolver.** Pass `() => string | Promise` instead of a plain string for cases where the URL isn't known synchronously — it is called lazily, at most once per load.
-- **`deploymentUrl` is a script source.** The loader injects `