@uipath/ui-widgets-validation-station 1.0.0
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/README.md +453 -0
- package/dist/ValidationStation.d.ts +3 -0
- package/dist/ValidationStation.d.ts.map +1 -0
- package/dist/ValidationStation.js +53 -0
- package/dist/ValidationStation.js.map +1 -0
- package/dist/ValidationStation.stories.d.ts +14 -0
- package/dist/ValidationStation.stories.d.ts.map +1 -0
- package/dist/ValidationStation.stories.js +225 -0
- package/dist/ValidationStation.stories.js.map +1 -0
- package/dist/bucketArtifactsUtil.d.ts +5 -0
- package/dist/bucketArtifactsUtil.d.ts.map +1 -0
- package/dist/bucketArtifactsUtil.js +67 -0
- package/dist/bucketArtifactsUtil.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/loadValidationStationWc.d.ts +7 -0
- package/dist/loadValidationStationWc.d.ts.map +1 -0
- package/dist/loadValidationStationWc.js +16 -0
- package/dist/loadValidationStationWc.js.map +1 -0
- package/dist/saveValidatedDataUtil.d.ts +10 -0
- package/dist/saveValidatedDataUtil.d.ts.map +1 -0
- package/dist/saveValidatedDataUtil.js +73 -0
- package/dist/saveValidatedDataUtil.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/dist/useBucketArtifacts.d.ts +8 -0
- package/dist/useBucketArtifacts.d.ts.map +1 -0
- package/dist/useBucketArtifacts.js +39 -0
- package/dist/useBucketArtifacts.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
# @uipath/ui-widgets-validation-station
|
|
2
|
+
|
|
3
|
+
A React wrapper for the UiPath Document Understanding Validation Station. It handles web component loading, bucket artifact fetching, and exposes a declarative props API for all Validation Station features.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @uipath/ui-widgets-validation-station
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Peer dependencies
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
react >= 19.2.0
|
|
15
|
+
react-dom >= 19.2.0
|
|
16
|
+
@uipath/uipath-typescript >= 1.4.2
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
> **Note:** Add either `light` or `dark` class to your HTML `<body>` element to enable proper theming.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import {
|
|
25
|
+
ValidationStation,
|
|
26
|
+
ValidationStationLanguage,
|
|
27
|
+
} from "@uipath/ui-widgets-validation-station";
|
|
28
|
+
import { UiPath } from "@uipath/uipath-typescript/core";
|
|
29
|
+
import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
30
|
+
|
|
31
|
+
const sdk = new UiPath({
|
|
32
|
+
baseUrl: "https://cloud.uipath.com",
|
|
33
|
+
orgName: "your-org",
|
|
34
|
+
tenantName: "your-tenant",
|
|
35
|
+
secret: "your-secret",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await sdk.initialize();
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return (
|
|
42
|
+
<ValidationStation
|
|
43
|
+
sdk={sdk}
|
|
44
|
+
data={selectedTask.data as DuFramework.ContentValidationData}
|
|
45
|
+
folderId={12345}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> `theme` defaults to `"light"` and `language` defaults to `ValidationStationLanguage.English`, so the minimal mount just needs `sdk`, `data`, and a folder.
|
|
52
|
+
|
|
53
|
+
> See [Static assets & runtime stylesheets](#static-assets--runtime-stylesheets)
|
|
54
|
+
> below — you must copy the web component's `du-assets/` folder **and its stylesheets**
|
|
55
|
+
> into your build output (and serve raw CSS in dev), or PDF rendering,
|
|
56
|
+
> translations, and **icons** will silently break with no build error.
|
|
57
|
+
|
|
58
|
+
## Props
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Required | Default | Description |
|
|
61
|
+
| -------------------------------- | ---------------------------------------------- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| `sdk` | `UiPath` | Yes | — | UiPath SDK instance for authentication and API calls |
|
|
63
|
+
| `data` | `ContentValidationData` | Yes | — | Document data containing bucket paths, document ID, and folder references |
|
|
64
|
+
| `folderId` | `number` | No\* | — | Storage bucket folder ID. Falls back to `data.FolderId`. **One of the two must resolve to a value** — otherwise the widget show an error. |
|
|
65
|
+
| `theme` | `'light' \| 'dark' \| 'light-hc' \| 'dark-hc'` | No | `'light'` | Visual theme |
|
|
66
|
+
| `language` | `ValidationStationLanguage` | No | `English` | UI language (see enum below) |
|
|
67
|
+
| `isReadonly` | `boolean` | No | `false` | When `true`, renders in read-only mode |
|
|
68
|
+
| `options` | `IValidationStationOptions` | No | — | Fine-grained UI feature flags |
|
|
69
|
+
| `save={{ validate: false }}` | `{ validate: boolean }` | No | — | Trigger **save as draft**. ⚠ Requires `options.emitDtoStateChanges: true` — otherwise the web component won't surface the latest in-memory extraction state and the save will be a no-op. |
|
|
70
|
+
| `save={{ validate: true }}` | `{ validate: boolean }` | No | — | Trigger **submit** — runs validation first, then saves. |
|
|
71
|
+
| `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's what the widget watches for — so calling it repeatedly with the same `{ value: true }` works just fine. |
|
|
72
|
+
| `setFieldValueByPath` | `SetFieldValueByPath` | No | — | Set a field value addressed by a path of `{ fieldName, valueIndex }` segments |
|
|
73
|
+
| `selectAndFocusFieldValueByPath` | `SelectAndFocusFieldValueByPath` | No | — | Select and focus a field value addressed by a path; focuses the document reference if any |
|
|
74
|
+
| `deleteFieldValueByPath` | `DeleteFieldValueByPath` | No | — | Delete a field value addressed by a path |
|
|
75
|
+
|
|
76
|
+
> Three additional callback props (`onSubmitComplete`, `onSaveAsDraftComplete`, `onReportExceptionComplete`) are documented in the next section.
|
|
77
|
+
|
|
78
|
+
### Reacting to save / draft / exception flows
|
|
79
|
+
|
|
80
|
+
The widget surfaces three user-initiated flows. Submit and draft are owned end-to-end by the widget; exception reporting is forwarded to the host so it can call the SDK directly.
|
|
81
|
+
|
|
82
|
+
| Callback | User action | Signature | What the widget does | What the host does |
|
|
83
|
+
| --------------------------- | ----------------------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
84
|
+
| `onSubmitComplete` | **Submit** | `(result: SaveValidatedDataResult) => void` | Calls `OrchestratorDuModule.processExtractedData(...)`, then uploads the merged result to `ValidatedExtractionResultsPath`. Fires the callback with the persistence result. | (optional) react to success/failure (complete the task, retry, log, etc.). |
|
|
85
|
+
| `onSaveAsDraftComplete` | **Save as draft** | `(result: SaveValidatedDataResult) => void` | Uploads the in-progress `validatedData` straight to `ValidatedExtractionResultsPath` (no `processExtractedData` call). Fires the callback with the persistence result. | (optional) react to success/failure. |
|
|
86
|
+
| `onReportExceptionComplete` | **Report as exception** | `(documentId: string, reason: string) => void` | Extracts `documentId` and `reason` from the web component's exception DTO and hands them to the host. **No API call.** | Required if you want the report persisted — call `OrchestratorDuModule.submitExceptionReport(...)` yourself. |
|
|
87
|
+
|
|
88
|
+
Submit/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.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import {
|
|
92
|
+
ValidationStation,
|
|
93
|
+
type SaveValidatedDataResult,
|
|
94
|
+
} from "@uipath/ui-widgets-validation-station";
|
|
95
|
+
import { OrchestratorDuModule } from "@uipath/uipath-typescript/orchestrator-du-module";
|
|
96
|
+
|
|
97
|
+
function App({ sdk, data, task }) {
|
|
98
|
+
const handleSubmitComplete = async (result: SaveValidatedDataResult) => {
|
|
99
|
+
if (!result.success) {
|
|
100
|
+
console.warn("Submit failed:", result.error);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await task.complete({ action: "Completed", type: "DocumentValidation" });
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const handleDraftComplete = (result: SaveValidatedDataResult) => {
|
|
107
|
+
if (!result.success) console.warn("Draft save failed:", result.error);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleReportException = async (documentId: string, reason: string) => {
|
|
111
|
+
const response = await new OrchestratorDuModule(sdk).submitExceptionReport(
|
|
112
|
+
task.id,
|
|
113
|
+
documentId,
|
|
114
|
+
reason || "Reported via Validation Station",
|
|
115
|
+
{ folderId: task.folderId },
|
|
116
|
+
);
|
|
117
|
+
if (!response.IsSuccessful) {
|
|
118
|
+
console.error("submitExceptionReport failed:", response.ErrorMessage);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<ValidationStation
|
|
124
|
+
sdk={sdk}
|
|
125
|
+
data={data}
|
|
126
|
+
folderId={task.folderId}
|
|
127
|
+
onSubmitComplete={handleSubmitComplete}
|
|
128
|
+
onSaveAsDraftComplete={handleDraftComplete}
|
|
129
|
+
onReportExceptionComplete={handleReportException}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
> Submit and draft callbacks are optional, but failures are silent if you skip them — the widget does not surface errors on its own. The exception callback is the only place the report goes; without it the user's "Report as exception" click is a no-op.
|
|
136
|
+
|
|
137
|
+
## Language enum
|
|
138
|
+
|
|
139
|
+
`ValidationStationLanguage` provides all supported locales:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { ValidationStationLanguage } from "@uipath/ui-widgets-validation-station";
|
|
143
|
+
|
|
144
|
+
ValidationStationLanguage.English; // "en"
|
|
145
|
+
ValidationStationLanguage.German; // "de"
|
|
146
|
+
ValidationStationLanguage.Spanish; // "es"
|
|
147
|
+
ValidationStationLanguage.SpanishMexico; // "es-MX"
|
|
148
|
+
ValidationStationLanguage.French; // "fr"
|
|
149
|
+
ValidationStationLanguage.Japanese; // "ja"
|
|
150
|
+
ValidationStationLanguage.Korean; // "ko"
|
|
151
|
+
ValidationStationLanguage.Portuguese; // "pt"
|
|
152
|
+
ValidationStationLanguage.PortugueseBrazil; // "pt-BR"
|
|
153
|
+
ValidationStationLanguage.Romanian; // "ro"
|
|
154
|
+
ValidationStationLanguage.Russian; // "ru"
|
|
155
|
+
ValidationStationLanguage.Turkish; // "tr"
|
|
156
|
+
ValidationStationLanguage.ChineseSimplified; // "zh-CN"
|
|
157
|
+
ValidationStationLanguage.ChineseTraditional; // "zh-TW"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Exported types
|
|
161
|
+
|
|
162
|
+
All parameter types are re-exported from the package for convenience:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { ValidationStationLanguage } from "@uipath/ui-widgets-validation-station";
|
|
166
|
+
import type {
|
|
167
|
+
ValidationStationProps,
|
|
168
|
+
IValidationStationOptions,
|
|
169
|
+
SaveValidatedDataResult,
|
|
170
|
+
SetFieldValueByPath,
|
|
171
|
+
SelectAndFocusFieldValueByPath,
|
|
172
|
+
DeleteFieldValueByPath,
|
|
173
|
+
} from "@uipath/ui-widgets-validation-station";
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Examples
|
|
177
|
+
|
|
178
|
+
### Setting a field value by path
|
|
179
|
+
|
|
180
|
+
Address fields by path when you have nested groups or table rows. Each segment is `{ fieldName, valueIndex }`.
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { useState } from "react";
|
|
184
|
+
import {
|
|
185
|
+
ValidationStation,
|
|
186
|
+
type SetFieldValueByPath,
|
|
187
|
+
} from "@uipath/ui-widgets-validation-station";
|
|
188
|
+
|
|
189
|
+
function App({ sdk, data }) {
|
|
190
|
+
const [fieldValueByPath, setFieldValueByPath] = useState<
|
|
191
|
+
SetFieldValueByPath | undefined
|
|
192
|
+
>(undefined);
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<>
|
|
196
|
+
<button
|
|
197
|
+
onClick={() =>
|
|
198
|
+
setFieldValueByPath({
|
|
199
|
+
path: [
|
|
200
|
+
{ fieldName: "Invoice", valueIndex: 0 }, // parent field name
|
|
201
|
+
{ fieldName: "Amount", valueIndex: 0 }, // child field name
|
|
202
|
+
],
|
|
203
|
+
update: { Value: "100.00", OperatorConfirmed: true },
|
|
204
|
+
})
|
|
205
|
+
}
|
|
206
|
+
>
|
|
207
|
+
Set Amount by path
|
|
208
|
+
</button>
|
|
209
|
+
<ValidationStation
|
|
210
|
+
sdk={sdk}
|
|
211
|
+
data={data}
|
|
212
|
+
folderId={67}
|
|
213
|
+
setFieldValueByPath={fieldValueByPath}
|
|
214
|
+
/>
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Focusing a field by path
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
import { useState } from "react";
|
|
224
|
+
import {
|
|
225
|
+
ValidationStation,
|
|
226
|
+
type SelectAndFocusFieldValueByPath,
|
|
227
|
+
} from "@uipath/ui-widgets-validation-station";
|
|
228
|
+
|
|
229
|
+
function App({ sdk, data }) {
|
|
230
|
+
const [focus, setFocus] = useState<
|
|
231
|
+
SelectAndFocusFieldValueByPath | undefined
|
|
232
|
+
>(undefined);
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<>
|
|
236
|
+
<button
|
|
237
|
+
onClick={() =>
|
|
238
|
+
setFocus({
|
|
239
|
+
path: [
|
|
240
|
+
{ fieldName: "Invoice", valueIndex: 0 }, // parent field name
|
|
241
|
+
{ fieldName: "Amount", valueIndex: 0 }, // child field name
|
|
242
|
+
],
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
>
|
|
246
|
+
Focus Amount by path
|
|
247
|
+
</button>
|
|
248
|
+
<ValidationStation
|
|
249
|
+
sdk={sdk}
|
|
250
|
+
data={data}
|
|
251
|
+
folderId={67}
|
|
252
|
+
selectAndFocusFieldValueByPath={focus}
|
|
253
|
+
/>
|
|
254
|
+
</>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Triggering save
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
const [save, setSave] = useState<{ validate: boolean } | undefined>(undefined);
|
|
263
|
+
|
|
264
|
+
<button onClick={() => setSave({ validate: true })}>Save</button>
|
|
265
|
+
<ValidationStation sdk={sdk} data={data} folderId={1} save={save} />
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Static assets & runtime stylesheets
|
|
269
|
+
|
|
270
|
+
The underlying web component resolves several files **at runtime**, relative
|
|
271
|
+
to where its main bundle is served (via `import.meta.url`):
|
|
272
|
+
|
|
273
|
+
- **`du-assets/`** — PDF.js worker, cmaps, wasm, and i18n translations.
|
|
274
|
+
- **`styles.css`** — fetched as raw CSS text and adopted into the component's
|
|
275
|
+
**shadow root**. This is what styles the icons (`<mat-icon>`) and everything
|
|
276
|
+
else _inside_ the shadow boundary.
|
|
277
|
+
- **`fonts.css`** + **`media/`** — the Apollo / Material Icons `@font-face`
|
|
278
|
+
declarations and the font files they reference.
|
|
279
|
+
|
|
280
|
+
> **The React wrapper already imports `styles.css` and `fonts.css` as ES
|
|
281
|
+
> modules for you**, so the _light DOM_ concerns (`@font-face` registration,
|
|
282
|
+
> plus CDK overlays like menus/tooltips that portal to `document.body`) are
|
|
283
|
+
> handled automatically — you do **not** add those imports yourself. What you
|
|
284
|
+
> still have to handle is making the same files reachable by the web component's
|
|
285
|
+
> **runtime `fetch`**, covered below.
|
|
286
|
+
|
|
287
|
+
**These files must be deployed at the same path level as your output bundle.**
|
|
288
|
+
If they're missing there's no build error — they silently 404 at runtime:
|
|
289
|
+
PDFs fail to render, and because the shadow root never receives `styles.css`,
|
|
290
|
+
**icons fall back to a system font and render as empty boxes or raw text**.
|
|
291
|
+
|
|
292
|
+
There are two things to get right:
|
|
293
|
+
|
|
294
|
+
1. **Build** — copy `du-assets/`, `styles.css`, `fonts.css`, and `media/` next
|
|
295
|
+
to your emitted JS chunks.
|
|
296
|
+
2. **Dev server** — if your dev server rewrites `.css` requests into JS modules
|
|
297
|
+
(Vite does this), the web component's `fetch("styles.css")` receives JavaScript instead
|
|
298
|
+
of CSS, `CSSStyleSheet.replaceSync()` parses nothing, and the shadow-root
|
|
299
|
+
styles never load (→ broken icons). You must serve the **raw CSS** for that
|
|
300
|
+
fetch. Bundlers that serve copied files verbatim in dev (e.g.
|
|
301
|
+
webpack-dev-server) don't have this problem — copying alone is enough.
|
|
302
|
+
|
|
303
|
+
### Vite
|
|
304
|
+
|
|
305
|
+
Two plugins: one copies the runtime files after a build, one serves raw CSS to
|
|
306
|
+
the web component's `fetch` during dev. `optimizeDeps.exclude` is also required — Vite's
|
|
307
|
+
pre-bundler rewrites `import.meta.url`, which breaks the web component's runtime
|
|
308
|
+
resolution.
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
// vite.config.ts
|
|
312
|
+
import react from "@vitejs/plugin-react";
|
|
313
|
+
import { cp, readFile } from "node:fs/promises";
|
|
314
|
+
import { createRequire } from "node:module";
|
|
315
|
+
import { dirname, resolve } from "node:path";
|
|
316
|
+
import { defineConfig, type Plugin } from "vite";
|
|
317
|
+
|
|
318
|
+
const require = createRequire(import.meta.url);
|
|
319
|
+
|
|
320
|
+
const WC_ROOT = dirname(
|
|
321
|
+
require.resolve("@uipath/du-validation-station-wc/package.json"),
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// Stylesheets the web component fetches (as raw CSS) at runtime to adopt into its
|
|
325
|
+
// shadow root.
|
|
326
|
+
const WC_RUNTIME_CSS = ["styles.css", "fonts.css"];
|
|
327
|
+
|
|
328
|
+
// BUILD: place the web component's runtime files next to the emitted JS chunks, where
|
|
329
|
+
// `import.meta.url` will resolve them.
|
|
330
|
+
function copyDuValidationStationAssets(): Plugin {
|
|
331
|
+
let assetsDir = "";
|
|
332
|
+
return {
|
|
333
|
+
name: "copy-du-validation-station-assets",
|
|
334
|
+
apply: "build",
|
|
335
|
+
configResolved(config) {
|
|
336
|
+
assetsDir = resolve(
|
|
337
|
+
config.root,
|
|
338
|
+
config.build.outDir,
|
|
339
|
+
config.build.assetsDir,
|
|
340
|
+
);
|
|
341
|
+
},
|
|
342
|
+
async closeBundle() {
|
|
343
|
+
await cp(resolve(WC_ROOT, "du-assets"), resolve(assetsDir, "du-assets"), {
|
|
344
|
+
recursive: true,
|
|
345
|
+
});
|
|
346
|
+
await cp(resolve(WC_ROOT, "media"), resolve(assetsDir, "media"), {
|
|
347
|
+
recursive: true,
|
|
348
|
+
});
|
|
349
|
+
for (const css of WC_RUNTIME_CSS) {
|
|
350
|
+
await cp(resolve(WC_ROOT, css), resolve(assetsDir, css));
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// DEV: Vite serves any `.css` request as a JS module. Return the real CSS to
|
|
357
|
+
// the web component's raw `fetch` (identified by `Sec-Fetch-Dest: empty`), while letting
|
|
358
|
+
// genuine ES-module imports (`Sec-Fetch-Dest: script`) pass through to Vite.
|
|
359
|
+
function serveDuValidationStationRawCss(): Plugin {
|
|
360
|
+
const pattern = new RegExp(
|
|
361
|
+
`/@uipath/du-validation-station-wc/(${WC_RUNTIME_CSS.join("|")})$`,
|
|
362
|
+
);
|
|
363
|
+
return {
|
|
364
|
+
name: "serve-du-validation-station-raw-css",
|
|
365
|
+
apply: "serve",
|
|
366
|
+
configureServer(server) {
|
|
367
|
+
server.middlewares.use((req, res, next) => {
|
|
368
|
+
if (req.headers["sec-fetch-dest"] !== "empty") return next();
|
|
369
|
+
const match = pattern.exec((req.url ?? "").split("?")[0]);
|
|
370
|
+
if (!match) return next();
|
|
371
|
+
readFile(resolve(WC_ROOT, match[1]), "utf8").then((css) => {
|
|
372
|
+
res.setHeader("Content-Type", "text/css");
|
|
373
|
+
res.end(css);
|
|
374
|
+
}, next);
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export default defineConfig({
|
|
381
|
+
plugins: [
|
|
382
|
+
react(),
|
|
383
|
+
copyDuValidationStationAssets(),
|
|
384
|
+
serveDuValidationStationRawCss(),
|
|
385
|
+
],
|
|
386
|
+
optimizeDeps: {
|
|
387
|
+
exclude: ["@uipath/du-validation-station-wc"],
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### webpack
|
|
393
|
+
|
|
394
|
+
Use [`copy-webpack-plugin`](https://github.com/webpack-contrib/copy-webpack-plugin) to copy `du-assets/`, the stylesheets, and `media/` next to your bundle, **and** opt the web component bundle out of webpack's `new URL(..., import.meta.url)` parsing — the web component uses that pattern for its runtime resolution, and webpack will otherwise try to bundle the directory and fail with `Module not found: Error: Can't resolve './du-assets/'`. webpack-dev-server serves the copied files verbatim, so no separate raw-CSS handling is needed.
|
|
395
|
+
|
|
396
|
+
```js
|
|
397
|
+
// webpack.config.js
|
|
398
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
|
399
|
+
const path = require("path");
|
|
400
|
+
|
|
401
|
+
const wcRoot = path.dirname(
|
|
402
|
+
require.resolve("@uipath/du-validation-station-wc/package.json"),
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
module.exports = {
|
|
406
|
+
module: {
|
|
407
|
+
rules: [
|
|
408
|
+
// Don't parse runtime URL / dynamic-require expressions inside the web component —
|
|
409
|
+
// its assets and stylesheets are resolved at runtime from `import.meta.url`.
|
|
410
|
+
{
|
|
411
|
+
test: /node_modules[\\/]@uipath[\\/]du-validation-station-wc[\\/].*\.js$/,
|
|
412
|
+
parser: {
|
|
413
|
+
url: false,
|
|
414
|
+
exprContextCritical: false,
|
|
415
|
+
unknownContextCritical: false,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
},
|
|
420
|
+
plugins: [
|
|
421
|
+
new CopyPlugin({
|
|
422
|
+
patterns: [
|
|
423
|
+
{ from: `${wcRoot}/du-assets`, to: "assets/du-assets" },
|
|
424
|
+
{ from: `${wcRoot}/media`, to: "assets/media" },
|
|
425
|
+
{ from: `${wcRoot}/styles.css`, to: "assets/styles.css" },
|
|
426
|
+
{ from: `${wcRoot}/fonts.css`, to: "assets/fonts.css" },
|
|
427
|
+
],
|
|
428
|
+
}),
|
|
429
|
+
],
|
|
430
|
+
};
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Other bundlers
|
|
434
|
+
|
|
435
|
+
Any asset-copy mechanism works — Angular's `assets` array,
|
|
436
|
+
`rollup-plugin-copy`, a `postbuild` npm script with `cp -r`, etc. The
|
|
437
|
+
requirement is the same: the final deployed layout must have `du-assets/`,
|
|
438
|
+
`styles.css`, `fonts.css`, and `media/` sitting next to the JS chunks that
|
|
439
|
+
import the web component. If your dev server transforms `.css` into JS modules, also make
|
|
440
|
+
sure the web component's runtime `fetch` for `styles.css`/`fonts.css` receives raw CSS.
|
|
441
|
+
|
|
442
|
+
## Development
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# Build
|
|
446
|
+
npm run build
|
|
447
|
+
|
|
448
|
+
# Run tests
|
|
449
|
+
npm run test
|
|
450
|
+
|
|
451
|
+
# Run tests in watch mode
|
|
452
|
+
npm run test:watch
|
|
453
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationStation.d.ts","sourceRoot":"","sources":["../src/ValidationStation.tsx"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAkH9D,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { toast, Toaster } from "@uipath/apollo-wind";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { validationStationWcReady } from "./loadValidationStationWc.js";
|
|
5
|
+
import { submitValidatedData, saveValidatedDataAsDraft, } from "./saveValidatedDataUtil.js";
|
|
6
|
+
import { ValidationStationLanguage, } from "./types.js";
|
|
7
|
+
import { useBucketArtifacts } from "./useBucketArtifacts.js";
|
|
8
|
+
export const ValidationStation = ({ sdk, data, folderId, theme = "light", language = ValidationStationLanguage.English, isReadonly = false, options, save, discardChanges, setFieldValueByPath, selectAndFocusFieldValueByPath, deleteFieldValueByPath, onSubmitComplete, onSaveAsDraftComplete, onReportExceptionComplete, }) => {
|
|
9
|
+
const { artifacts, error } = useBucketArtifacts(sdk, data, folderId);
|
|
10
|
+
const [wcReady, setWcReady] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let cancelled = false;
|
|
13
|
+
validationStationWcReady.then(() => {
|
|
14
|
+
if (!cancelled)
|
|
15
|
+
setWcReady(true);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
cancelled = true;
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
if (error) {
|
|
22
|
+
return _jsxs("div", { children: ["Failed to load document artifacts: ", error] });
|
|
23
|
+
}
|
|
24
|
+
if (!artifacts || !wcReady) {
|
|
25
|
+
return _jsx("div", { children: "Loading..." });
|
|
26
|
+
}
|
|
27
|
+
const resolvedFolderId = folderId ?? data.FolderId;
|
|
28
|
+
const refCallback = (el) => {
|
|
29
|
+
if (!el)
|
|
30
|
+
return;
|
|
31
|
+
if (!resolvedFolderId) {
|
|
32
|
+
toast.error("folderId of Storage bucket is required. Provide it as a prop or ensure data.FolderId is set.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const onSubmitRequest = (event) => submitValidatedData(sdk, data, resolvedFolderId, event.detail).then(onSubmitComplete);
|
|
36
|
+
const onSaveAsDraftRequest = (event) => saveValidatedDataAsDraft(sdk, data, resolvedFolderId, event.detail).then(onSaveAsDraftComplete);
|
|
37
|
+
const onExceptionRequest = (event) => {
|
|
38
|
+
const { documentId, exceptionReport } = event.detail;
|
|
39
|
+
const reason = exceptionReport?.Reason ?? "";
|
|
40
|
+
onReportExceptionComplete?.(documentId, reason);
|
|
41
|
+
};
|
|
42
|
+
el.addEventListener("saveValidatedDataRequest", onSubmitRequest);
|
|
43
|
+
el.addEventListener("saveValidatedDataAsDraftRequest", onSaveAsDraftRequest);
|
|
44
|
+
el.addEventListener("saveExceptionReportRequest", onExceptionRequest);
|
|
45
|
+
return () => {
|
|
46
|
+
el.removeEventListener("saveValidatedDataRequest", onSubmitRequest);
|
|
47
|
+
el.removeEventListener("saveValidatedDataAsDraftRequest", onSaveAsDraftRequest);
|
|
48
|
+
el.removeEventListener("saveExceptionReportRequest", onExceptionRequest);
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx("ui-du-validation-station-standalone-wc-element", { ...{ ref: refCallback }, theme: theme, language: language, isReadonly: isReadonly, enableSaveAsDraft: true, documentId: data.DocumentId, taxonomy: artifacts.taxonomy, extractionResult: artifacts.extractionResult, dom: artifacts.dom, text: artifacts.text, customizationInfo: artifacts.customizationInfo, original: artifacts.original, options: options, save: save, discardChanges: discardChanges, setFieldValueByPath: setFieldValueByPath, selectAndFocusFieldValueByPath: selectAndFocusFieldValueByPath, deleteFieldValueByPath: deleteFieldValueByPath }), _jsx(Toaster, { position: "top-right" })] }));
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=ValidationStation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationStation.js","sourceRoot":"","sources":["../src/ValidationStation.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,yBAAyB,GAE1B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,EAClE,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,KAAK,GAAG,OAAO,EACf,QAAQ,GAAG,yBAAyB,CAAC,OAAO,EAC5C,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,IAAI,EACJ,cAAc,EACd,mBAAmB,EACnB,8BAA8B,EAC9B,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,GAC1B,EAAE,EAAE;IACH,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,wBAAwB,CAAC,IAAI,CAAC,GAAG,EAAE;YACjC,IAAI,CAAC,SAAS;gBAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,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QACF,EAAE,CAAC,gBAAgB,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC;QAEtE,OAAO,GAAG,EAAE;YACV,EAAE,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,eAAe,CAAC,CAAC;YACpE,EAAE,CAAC,mBAAmB,CACpB,iCAAiC,EACjC,oBAAoB,CACrB,CAAC;YACF,EAAE,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC;QAC3E,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,8BACE,4DACO,EAAE,GAAG,EAAE,WAAW,EAErB,EACF,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,IAAI,EACvB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,EAC5C,GAAG,EAAE,SAAS,CAAC,GAAG,EAClB,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,EAC9C,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,cAAc,EAAE,cAAc,EAC9B,mBAAmB,EAAE,mBAAmB,EACxC,8BAA8B,EAAE,8BAA8B,EAC9D,sBAAsB,EAAE,sBAAsB,GAC9C,EACF,KAAC,OAAO,IAAC,QAAQ,EAAC,WAAW,GAAG,IAC/B,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import type { ValidationStationProps } from "./types";
|
|
3
|
+
interface ValidationStationStoryArgs extends Omit<ValidationStationProps, "sdk"> {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
orgName: string;
|
|
6
|
+
tenantName: string;
|
|
7
|
+
secret: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ValidationStationWithSdk: ({ baseUrl, orgName, tenantName, secret, ...props }: ValidationStationStoryArgs) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare const meta: Meta<typeof ValidationStationWithSdk>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
export declare const Default: Story;
|
|
14
|
+
//# sourceMappingURL=ValidationStation.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationStation.stories.d.ts","sourceRoot":"","sources":["../src/ValidationStation.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,UAAU,0BAA2B,SAAQ,IAAI,CAC/C,sBAAsB,EACtB,KAAK,CACN;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,wBAAwB,GAAI,oDAM/B,0BAA0B,4CAoE5B,CAAC;AAiBF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,wBAAwB,CAwJ/C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KASrB,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { ValidationStation } from "./ValidationStation";
|
|
5
|
+
import { ValidationStationLanguage } from "./types";
|
|
6
|
+
const ValidationStationWithSdk = ({ baseUrl, orgName, tenantName, secret, ...props }) => {
|
|
7
|
+
const [state, setState] = useState({ sdk: null, error: null });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!baseUrl || !orgName || !tenantName || !secret) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
let cancelled = false;
|
|
13
|
+
const initSdk = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const normalizedBaseUrl = baseUrl.match(/^https?:\/\//)
|
|
16
|
+
? baseUrl
|
|
17
|
+
: `https://${baseUrl}`;
|
|
18
|
+
const uipath = new UiPath({
|
|
19
|
+
baseUrl: normalizedBaseUrl,
|
|
20
|
+
orgName,
|
|
21
|
+
tenantName,
|
|
22
|
+
secret,
|
|
23
|
+
});
|
|
24
|
+
await uipath.initialize();
|
|
25
|
+
if (!cancelled) {
|
|
26
|
+
setState({ sdk: uipath, error: null });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (!cancelled) {
|
|
31
|
+
setState({
|
|
32
|
+
sdk: null,
|
|
33
|
+
error: err instanceof Error ? err.message : "Failed to initialize SDK",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
initSdk();
|
|
39
|
+
return () => {
|
|
40
|
+
cancelled = true;
|
|
41
|
+
};
|
|
42
|
+
}, [baseUrl, orgName, tenantName, secret]);
|
|
43
|
+
const { sdk, error } = state;
|
|
44
|
+
if (!baseUrl || !orgName || !tenantName || !secret) {
|
|
45
|
+
return (_jsx("div", { style: { padding: 24, color: "#666" }, children: "Please provide baseUrl, orgName, tenantName, and secret in the controls panel below." }));
|
|
46
|
+
}
|
|
47
|
+
if (error) {
|
|
48
|
+
return (_jsxs("div", { style: { padding: 24, color: "#d32f2f" }, children: ["SDK initialization failed: ", error] }));
|
|
49
|
+
}
|
|
50
|
+
if (!sdk) {
|
|
51
|
+
return _jsx("div", { style: { padding: 24 }, children: "Initializing SDK..." });
|
|
52
|
+
}
|
|
53
|
+
return _jsx(ValidationStation, { sdk: sdk, ...props });
|
|
54
|
+
};
|
|
55
|
+
const mockData = {
|
|
56
|
+
BucketName: "",
|
|
57
|
+
BucketId: 0,
|
|
58
|
+
FolderId: 0,
|
|
59
|
+
FolderKey: "",
|
|
60
|
+
DocumentId: "",
|
|
61
|
+
EncodedDocumentPath: "",
|
|
62
|
+
TextPath: "",
|
|
63
|
+
DocumentObjectModelPath: "",
|
|
64
|
+
TaxonomyPath: "",
|
|
65
|
+
AutomaticExtractionResultsPath: "",
|
|
66
|
+
ValidatedExtractionResultsPath: "",
|
|
67
|
+
CustomizationInfoPath: "",
|
|
68
|
+
};
|
|
69
|
+
const meta = {
|
|
70
|
+
title: "Components/ValidationStation",
|
|
71
|
+
component: ValidationStationWithSdk,
|
|
72
|
+
decorators: [
|
|
73
|
+
(Story) => (_jsx("div", { style: { height: "800px" }, children: _jsx(Story, {}) })),
|
|
74
|
+
],
|
|
75
|
+
parameters: {
|
|
76
|
+
layout: "fullscreen",
|
|
77
|
+
docs: {
|
|
78
|
+
description: {
|
|
79
|
+
component: `
|
|
80
|
+
A React wrapper for the UiPath Document Understanding Validation Station standalone web component.
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
- Renders the DU Validation Station for document validation
|
|
85
|
+
- Standalone mode: consumer provides document data directly and handles save operations via event callbacks
|
|
86
|
+
- Supports light, dark, and high-contrast themes
|
|
87
|
+
- Configurable language, read-only mode, and save-as-draft
|
|
88
|
+
- Event-driven props for field/table cell manipulation
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
\`\`\`bash
|
|
93
|
+
npm install @uipath/ui-widgets-validation-station
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
## Usage
|
|
97
|
+
|
|
98
|
+
> **Note:** Add either \`light\` or \`dark\` class to your HTML \`<body>\` element to enable proper theming.
|
|
99
|
+
|
|
100
|
+
The component loads the underlying Validation Station web component on mount —
|
|
101
|
+
consumers do not need to call \`loadValidationStationWebComponent\` themselves.
|
|
102
|
+
By default it expects the web component assets to be served at
|
|
103
|
+
\`node_modules/@uipath/du-validation-station-wc\` (which works with Vite's
|
|
104
|
+
dev server). For production, copy the contents of
|
|
105
|
+
\`node_modules/@uipath/du-validation-station-wc\` into your public assets and
|
|
106
|
+
point \`wcAssetsUrl\` at that location.
|
|
107
|
+
|
|
108
|
+
\`\`\`tsx
|
|
109
|
+
import { ValidationStation } from '@uipath/ui-widgets-validation-station';
|
|
110
|
+
import { UiPath } from '@uipath/uipath-typescript/core';
|
|
111
|
+
|
|
112
|
+
const sdk = new UiPath({
|
|
113
|
+
baseUrl: 'https://cloud.uipath.com',
|
|
114
|
+
orgName: 'your-org',
|
|
115
|
+
tenantName: 'your-tenant',
|
|
116
|
+
secret: 'your-secret'
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await sdk.initialize();
|
|
120
|
+
|
|
121
|
+
function App() {
|
|
122
|
+
return (
|
|
123
|
+
<ValidationStation
|
|
124
|
+
sdk={sdk}
|
|
125
|
+
data={myContentValidationData}
|
|
126
|
+
folderId={12345}
|
|
127
|
+
theme="light"
|
|
128
|
+
language="en"
|
|
129
|
+
save={{ validate: true }}
|
|
130
|
+
// wcAssetsUrl="/assets/du-validation-station-wc"
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
## Requirements
|
|
137
|
+
|
|
138
|
+
- React 19.2.0+
|
|
139
|
+
- React DOM 19.2.0+
|
|
140
|
+
- @uipath/du-validation-station-wc
|
|
141
|
+
- @uipath/uipath-typescript`,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
tags: ["autodocs"],
|
|
146
|
+
argTypes: {
|
|
147
|
+
baseUrl: {
|
|
148
|
+
description: "UiPath API base URL",
|
|
149
|
+
control: "text",
|
|
150
|
+
table: { category: "SDK Configuration" },
|
|
151
|
+
},
|
|
152
|
+
orgName: {
|
|
153
|
+
description: "UiPath organization name",
|
|
154
|
+
control: "text",
|
|
155
|
+
table: { category: "SDK Configuration" },
|
|
156
|
+
},
|
|
157
|
+
tenantName: {
|
|
158
|
+
description: "UiPath tenant name",
|
|
159
|
+
control: "text",
|
|
160
|
+
table: { category: "SDK Configuration" },
|
|
161
|
+
},
|
|
162
|
+
secret: {
|
|
163
|
+
description: "UiPath API secret for authentication",
|
|
164
|
+
control: "text",
|
|
165
|
+
table: { category: "SDK Configuration" },
|
|
166
|
+
},
|
|
167
|
+
data: {
|
|
168
|
+
description: "ContentValidationData object containing bucket paths, document ID, and folder references.",
|
|
169
|
+
control: "object",
|
|
170
|
+
},
|
|
171
|
+
folderId: {
|
|
172
|
+
description: "Storage bucket folder ID. Falls back to data.folderId if not provided.",
|
|
173
|
+
control: "number",
|
|
174
|
+
},
|
|
175
|
+
theme: {
|
|
176
|
+
description: "Visual theme for the validation station",
|
|
177
|
+
control: "select",
|
|
178
|
+
options: ["light", "dark", "light-hc", "dark-hc"],
|
|
179
|
+
},
|
|
180
|
+
language: {
|
|
181
|
+
description: "Language/locale for the validation station UI",
|
|
182
|
+
control: "select",
|
|
183
|
+
options: Object.keys(ValidationStationLanguage),
|
|
184
|
+
mapping: ValidationStationLanguage,
|
|
185
|
+
},
|
|
186
|
+
isReadonly: {
|
|
187
|
+
description: "When true, the validation station is in read-only mode",
|
|
188
|
+
control: "boolean",
|
|
189
|
+
},
|
|
190
|
+
options: {
|
|
191
|
+
description: "Additional configuration options for the validation station",
|
|
192
|
+
control: "object",
|
|
193
|
+
},
|
|
194
|
+
save: {
|
|
195
|
+
description: "Trigger save with optional validation",
|
|
196
|
+
control: "object",
|
|
197
|
+
},
|
|
198
|
+
discardChanges: {
|
|
199
|
+
description: "Trigger discard changes",
|
|
200
|
+
control: "object",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
args: {
|
|
204
|
+
baseUrl: "alpha.uipath.com",
|
|
205
|
+
orgName: "",
|
|
206
|
+
tenantName: "",
|
|
207
|
+
secret: "",
|
|
208
|
+
data: mockData,
|
|
209
|
+
folderId: 0,
|
|
210
|
+
theme: "light",
|
|
211
|
+
language: ValidationStationLanguage.English,
|
|
212
|
+
isReadonly: false,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
export default meta;
|
|
216
|
+
export const Default = {
|
|
217
|
+
parameters: {
|
|
218
|
+
docs: {
|
|
219
|
+
description: {
|
|
220
|
+
story: "Default standalone validation station. Fill in the SDK configuration and data fields in the controls panel to load a document.",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
//# sourceMappingURL=ValidationStation.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationStation.stories.js","sourceRoot":"","sources":["../src/ValidationStation.stories.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAapD,MAAM,wBAAwB,GAAG,CAAC,EAChC,OAAO,EACP,OAAO,EACP,UAAU,EACV,MAAM,EACN,GAAG,KAAK,EACmB,EAAE,EAAE;IAC/B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAG/B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC;YACnD,OAAO;QACT,CAAC;QAED,IAAI,SAAS,GA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E,kBAAkB;QAC3B,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,yBAAyB,CAAC,OAAO;QAC3C,UAAU,EAAE,KAAK;KAClB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAGpB,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,WAAW,EAAE;gBACX,KAAK,EACH,gIAAgI;aACnI;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
2
|
+
import type { BucketService } from "@uipath/uipath-typescript/buckets";
|
|
3
|
+
import type { BucketArtifacts } from "./types.js";
|
|
4
|
+
export declare function fetchBucketArtifacts(bucketService: BucketService, data: DuFramework.ContentValidationData, folderId: number): Promise<BucketArtifacts>;
|
|
5
|
+
//# sourceMappingURL=bucketArtifactsUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucketArtifactsUtil.d.ts","sourceRoot":"","sources":["../src/bucketArtifactsUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgElD,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CA2D1B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { unzipSync } from "fflate";
|
|
2
|
+
/** Fetch a URI, unzip the first file in the archive, and return the raw text. */
|
|
3
|
+
async function fetchAndUnzip(uri) {
|
|
4
|
+
const res = await fetch(uri);
|
|
5
|
+
const buf = await res.arrayBuffer();
|
|
6
|
+
const files = unzipSync(new Uint8Array(buf));
|
|
7
|
+
const firstFile = Object.values(files)[0];
|
|
8
|
+
return new TextDecoder().decode(firstFile);
|
|
9
|
+
}
|
|
10
|
+
async function fetchAndUnzipJson(uri) {
|
|
11
|
+
const text = await fetchAndUnzip(uri);
|
|
12
|
+
return JSON.parse(text);
|
|
13
|
+
}
|
|
14
|
+
/** Get URI then immediately fetch + unzip as JSON. */
|
|
15
|
+
async function fetchArtifactJson(bucketService, bucketId, folderId, path) {
|
|
16
|
+
const r = await bucketService.getReadUri({ bucketId, folderId, path });
|
|
17
|
+
return fetchAndUnzipJson(r.uri);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the validated extraction result if it exists in the bucket, otherwise
|
|
21
|
+
* fall back to the automatic extraction result.
|
|
22
|
+
*/
|
|
23
|
+
async function fetchExtractionResult(bucketService, bucketId, folderId, validatedPath, automaticPath) {
|
|
24
|
+
if (validatedPath) {
|
|
25
|
+
try {
|
|
26
|
+
return await fetchArtifactJson(bucketService, bucketId, folderId, validatedPath);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Validated result not saved yet — fall through to automatic.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return fetchArtifactJson(bucketService, bucketId, folderId, automaticPath);
|
|
33
|
+
}
|
|
34
|
+
/** Get URI then immediately fetch + unzip as text. */
|
|
35
|
+
async function fetchArtifactText(bucketService, bucketId, folderId, path) {
|
|
36
|
+
const r = await bucketService.getReadUri({ bucketId, folderId, path });
|
|
37
|
+
return await fetchAndUnzip(r.uri);
|
|
38
|
+
}
|
|
39
|
+
export async function fetchBucketArtifacts(bucketService, data, folderId) {
|
|
40
|
+
const { BucketId, TextPath, TaxonomyPath, EncodedDocumentPath, CustomizationInfoPath, DocumentObjectModelPath, AutomaticExtractionResultsPath, ValidatedExtractionResultsPath, } = data;
|
|
41
|
+
if (!BucketId ||
|
|
42
|
+
!TextPath ||
|
|
43
|
+
!TaxonomyPath ||
|
|
44
|
+
!EncodedDocumentPath ||
|
|
45
|
+
!CustomizationInfoPath ||
|
|
46
|
+
!DocumentObjectModelPath ||
|
|
47
|
+
!AutomaticExtractionResultsPath) {
|
|
48
|
+
throw new Error("ContentValidationData is missing required bucket artifact fields.");
|
|
49
|
+
}
|
|
50
|
+
const [taxonomy, extractionResult, dom, text, customizationInfo, original] = await Promise.all([
|
|
51
|
+
fetchArtifactJson(bucketService, BucketId, folderId, TaxonomyPath),
|
|
52
|
+
fetchExtractionResult(bucketService, BucketId, folderId, ValidatedExtractionResultsPath, AutomaticExtractionResultsPath),
|
|
53
|
+
fetchArtifactJson(bucketService, BucketId, folderId, DocumentObjectModelPath),
|
|
54
|
+
fetchArtifactText(bucketService, BucketId, folderId, TextPath),
|
|
55
|
+
fetchArtifactJson(bucketService, BucketId, folderId, CustomizationInfoPath),
|
|
56
|
+
fetchArtifactText(bucketService, BucketId, folderId, EncodedDocumentPath),
|
|
57
|
+
]);
|
|
58
|
+
return {
|
|
59
|
+
taxonomy: taxonomy,
|
|
60
|
+
extractionResult: extractionResult,
|
|
61
|
+
dom: dom,
|
|
62
|
+
text,
|
|
63
|
+
customizationInfo,
|
|
64
|
+
original,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=bucketArtifactsUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucketArtifactsUtil.js","sourceRoot":"","sources":["../src/bucketArtifactsUtil.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,iFAAiF;AACjF,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,GAAG,GAA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;QAClD,gBAAgB,EAAE,gBAAgD;QAClE,GAAG,EAAE,GAAiC;QACtC,IAAI;QACJ,iBAAiB;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ValidationStationLanguage } from "./types.js";
|
|
2
|
+
export type { DeleteFieldValueByPath, IValidationStationOptions, SaveValidatedDataResult, SelectAndFocusFieldValueByPath, SetFieldValueByPath, ValidationStationProps, } from "./types.js";
|
|
3
|
+
export { ValidationStation } from "./ValidationStation.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EACV,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AASvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "@uipath/du-validation-station-wc/polyfills";
|
|
2
|
+
import "@uipath/du-validation-station-wc/main";
|
|
3
|
+
import "@uipath/du-validation-station-wc/styles.css";
|
|
4
|
+
import "@uipath/du-validation-station-wc/fonts.css";
|
|
5
|
+
export declare const VALIDATION_STATION_TAG = "ui-du-validation-station-standalone-wc-element";
|
|
6
|
+
export declare const validationStationWcReady: Promise<void>;
|
|
7
|
+
//# sourceMappingURL=loadValidationStationWc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadValidationStationWc.d.ts","sourceRoot":"","sources":["../src/loadValidationStationWc.ts"],"names":[],"mappings":"AAGA,OAAO,4CAA4C,CAAC;AACpD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,6CAA6C,CAAC;AAKrD,OAAO,4CAA4C,CAAC;AAEpD,eAAO,MAAM,sBAAsB,mDACe,CAAC;AAEnD,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,IAAI,CAG2B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Polyfills (zone.js, etc.) MUST load before main, or the Angular Element
|
|
2
|
+
// inside `main` will not bootstrap. Kept in its own module so import sorters
|
|
3
|
+
// can't reorder the side-effect imports relative to each other.
|
|
4
|
+
import "@uipath/du-validation-station-wc/polyfills";
|
|
5
|
+
import "@uipath/du-validation-station-wc/main";
|
|
6
|
+
import "@uipath/du-validation-station-wc/styles.css";
|
|
7
|
+
// Apollo fonts + Material Icons are shipped as a separate, opt-in stylesheet
|
|
8
|
+
// (their @font-face rules must apply in the light DOM — they're ignored inside
|
|
9
|
+
// the WC's shadow root). Without this, text falls back to system fonts and
|
|
10
|
+
// icon glyphs render as empty boxes.
|
|
11
|
+
import "@uipath/du-validation-station-wc/fonts.css";
|
|
12
|
+
export const VALIDATION_STATION_TAG = "ui-du-validation-station-standalone-wc-element";
|
|
13
|
+
export const validationStationWcReady = typeof window === "undefined"
|
|
14
|
+
? Promise.resolve()
|
|
15
|
+
: window.customElements.whenDefined(VALIDATION_STATION_TAG).then(() => { });
|
|
16
|
+
//# sourceMappingURL=loadValidationStationWc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadValidationStationWc.js","sourceRoot":"","sources":["../src/loadValidationStationWc.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6EAA6E;AAC7E,gEAAgE;AAChE,OAAO,4CAA4C,CAAC;AACpD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,6CAA6C,CAAC;AACrD,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,qCAAqC;AACrC,OAAO,4CAA4C,CAAC;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GACjC,gDAAgD,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GACnC,OAAO,MAAM,KAAK,WAAW;IAC3B,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;IACnB,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IVsSaveValidatedDataAsDraftRequest, IVsSaveValidatedDataRequest } from "@uipath/du-validation-station-wc";
|
|
2
|
+
import type { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import { type DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
4
|
+
export interface SaveValidatedDataResult {
|
|
5
|
+
success: boolean;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function submitValidatedData(sdk: UiPath, data: DuFramework.ContentValidationData, folderId: number, request: IVsSaveValidatedDataRequest): Promise<SaveValidatedDataResult>;
|
|
9
|
+
export declare function saveValidatedDataAsDraft(sdk: UiPath, data: DuFramework.ContentValidationData, folderId: number, request: IVsSaveValidatedDataAsDraftRequest): Promise<SaveValidatedDataResult>;
|
|
10
|
+
//# sourceMappingURL=saveValidatedDataUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saveValidatedDataUtil.d.ts","sourceRoot":"","sources":["../src/saveValidatedDataUtil.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAIpF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAmCD,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC,CAoClC;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAyBlC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BucketService } from "@uipath/uipath-typescript/buckets";
|
|
2
|
+
import { OrchestratorDuModule } from "@uipath/uipath-typescript/orchestrator-du-module";
|
|
3
|
+
import { strToU8, zipSync } from "fflate";
|
|
4
|
+
async function uploadResultToBucket(bucketService, bucketId, folderId, path, data, documentId) {
|
|
5
|
+
// The bucket stores a .zip containing a single JSON file. The inner
|
|
6
|
+
// filename is derived from the upload path's basename (e.g.
|
|
7
|
+
// "results/output.zip" → "output.json"). If the path has no basename
|
|
8
|
+
// (e.g. "results/"), fall back to a documentId-scoped name so concurrent
|
|
9
|
+
// saves for different documents don't collide on the same inner key.
|
|
10
|
+
const fallbackFileName = documentId
|
|
11
|
+
? `${documentId}/output_results.json`
|
|
12
|
+
: "output_results.json";
|
|
13
|
+
const basename = path.split("/").pop() ?? "";
|
|
14
|
+
const fileName = basename
|
|
15
|
+
? basename.replace(/\.zip$/i, ".json")
|
|
16
|
+
: fallbackFileName;
|
|
17
|
+
const zipped = zipSync({ [fileName]: strToU8(JSON.stringify(data)) });
|
|
18
|
+
const blob = new Blob([new Uint8Array(zipped)], { type: "application/zip" });
|
|
19
|
+
const result = await bucketService.uploadFile({
|
|
20
|
+
bucketId,
|
|
21
|
+
folderId,
|
|
22
|
+
path,
|
|
23
|
+
content: blob,
|
|
24
|
+
});
|
|
25
|
+
if (!result.success) {
|
|
26
|
+
throw new Error(`Bucket upload failed with status ${result.statusCode}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export async function submitValidatedData(sdk, data, folderId, request) {
|
|
30
|
+
const { BucketId, ValidatedExtractionResultsPath, DocumentId } = data;
|
|
31
|
+
if (!BucketId || !ValidatedExtractionResultsPath) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
error: "ContentValidationData is missing BucketId or ValidatedExtractionResultsPath.",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const du = new OrchestratorDuModule(sdk);
|
|
39
|
+
const processedResult = await du.processExtractedData({
|
|
40
|
+
AutomaticExtractedResults: request.automaticExtractionResult,
|
|
41
|
+
ValidatedExtractedResults: request.validatedData,
|
|
42
|
+
Taxonomy: request.taxonomy,
|
|
43
|
+
}, { folderId });
|
|
44
|
+
await uploadResultToBucket(new BucketService(sdk), BucketId, folderId, ValidatedExtractionResultsPath, processedResult, DocumentId);
|
|
45
|
+
return { success: true };
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return {
|
|
49
|
+
success: false,
|
|
50
|
+
error: error instanceof Error ? error.message : String(error),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function saveValidatedDataAsDraft(sdk, data, folderId, request) {
|
|
55
|
+
const { BucketId, ValidatedExtractionResultsPath, DocumentId } = data;
|
|
56
|
+
if (!BucketId || !ValidatedExtractionResultsPath) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: "ContentValidationData is missing BucketId or ValidatedExtractionResultsPath.",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
await uploadResultToBucket(new BucketService(sdk), BucketId, folderId, ValidatedExtractionResultsPath, request.validatedData, DocumentId);
|
|
64
|
+
return { success: true };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
error: error instanceof Error ? error.message : String(error),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=saveValidatedDataUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saveValidatedDataUtil.js","sourceRoot":"","sources":["../src/saveValidatedDataUtil.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAO1C,KAAK,UAAU,oBAAoB,CACjC,aAA4B,EAC5B,QAAgB,EAChB,QAAgB,EAChB,IAAY,EACZ,IAAa,EACb,UAAmB;IAEnB,oEAAoE;IACpE,4DAA4D;IAC5D,qEAAqE;IACrE,yEAAyE;IACzE,qEAAqE;IACrE,MAAM,gBAAgB,GAAG,UAAU;QACjC,CAAC,CAAC,GAAG,UAAU,sBAAsB;QACrC,CAAC,CAAC,qBAAqB,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;IAC7C,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC;QACtC,CAAC,CAAC,gBAAgB,CAAC;IACrB,MAAM,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,C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CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,GAAW,EACX,IAAuC,EACvC,QAAgB,EAChB,OAA2C;IAE3C,MAAM,EAAE,QAAQ,EAAE,8BAA8B,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACtE,IAAI,CAAC,QAAQ,IAAI,CAAC,8BAA8B,EAAE,CAAC;QACjD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EACH,8EAA8E;SACjF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,MAAM,oBAAoB,CACxB,IAAI,aAAa,CAAC,GAAG,CAAC,EACtB,QAAQ,EACR,QAAQ,EACR,8BAA8B,EAC9B,OAAO,CAAC,aAAa,EACrB,UAAU,CACX,CAAC;QACF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { DeleteFieldValueByPath, IValidationStationOptions, SelectAndFocusFieldValueByPath, SetFieldValueByPath } from "@uipath/du-validation-station-wc";
|
|
2
|
+
import type { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
4
|
+
import type { SaveValidatedDataResult } from "./saveValidatedDataUtil.js";
|
|
5
|
+
export type { DeleteFieldValueByPath, IValidationStationOptions, SaveValidatedDataResult, SelectAndFocusFieldValueByPath, SetFieldValueByPath, };
|
|
6
|
+
export declare enum ValidationStationLanguage {
|
|
7
|
+
German = "de",
|
|
8
|
+
English = "en",
|
|
9
|
+
Spanish = "es",
|
|
10
|
+
SpanishMexico = "es-MX",
|
|
11
|
+
French = "fr",
|
|
12
|
+
Japanese = "ja",
|
|
13
|
+
Korean = "ko",
|
|
14
|
+
Portuguese = "pt",
|
|
15
|
+
PortugueseBrazil = "pt-BR",
|
|
16
|
+
Romanian = "ro",
|
|
17
|
+
Russian = "ru",
|
|
18
|
+
Turkish = "tr",
|
|
19
|
+
ChineseSimplified = "zh-CN",
|
|
20
|
+
ChineseTraditional = "zh-TW"
|
|
21
|
+
}
|
|
22
|
+
export interface BucketArtifacts {
|
|
23
|
+
taxonomy: DuFramework.DocumentTaxonomy;
|
|
24
|
+
extractionResult: DuFramework.ExtractionResult;
|
|
25
|
+
dom: DuFramework.DocumentEntity;
|
|
26
|
+
text: string | undefined;
|
|
27
|
+
customizationInfo: unknown;
|
|
28
|
+
original: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface ValidationStationProps {
|
|
31
|
+
sdk: UiPath;
|
|
32
|
+
data: DuFramework.ContentValidationData;
|
|
33
|
+
folderId?: number;
|
|
34
|
+
theme?: "light" | "dark" | "light-hc" | "dark-hc";
|
|
35
|
+
language?: ValidationStationLanguage;
|
|
36
|
+
isReadonly?: boolean;
|
|
37
|
+
options?: IValidationStationOptions;
|
|
38
|
+
save?: {
|
|
39
|
+
validate: boolean;
|
|
40
|
+
};
|
|
41
|
+
discardChanges?: {
|
|
42
|
+
value: boolean;
|
|
43
|
+
};
|
|
44
|
+
setFieldValueByPath?: SetFieldValueByPath;
|
|
45
|
+
selectAndFocusFieldValueByPath?: SelectAndFocusFieldValueByPath;
|
|
46
|
+
deleteFieldValueByPath?: DeleteFieldValueByPath;
|
|
47
|
+
/**
|
|
48
|
+
* Fired after the submit flow (`save={{ validate: true }}`) finishes
|
|
49
|
+
* (ProcessExtractedData + bucket upload). `result.success` is `false` on
|
|
50
|
+
* any failure — the host app decides whether to retry, complete the task,
|
|
51
|
+
* surface an error, etc.
|
|
52
|
+
*/
|
|
53
|
+
onSubmitComplete?: (result: SaveValidatedDataResult) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Fired after the save-as-draft flow (`save={{ validate: false }}`)
|
|
56
|
+
* finishes (uploads `validatedData` straight to the bucket, no
|
|
57
|
+
* `ProcessExtractedData` call).
|
|
58
|
+
*/
|
|
59
|
+
onSaveAsDraftComplete?: (result: SaveValidatedDataResult) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Fired when the user reports the document as an exception. The widget does
|
|
62
|
+
* NOT call any API for this flow — the host owns persistence (typically a
|
|
63
|
+
* `OrchestratorDuModule.submitExceptionReport(taskId, documentId, reason, ...)`
|
|
64
|
+
* call).
|
|
65
|
+
*/
|
|
66
|
+
onReportExceptionComplete?: (documentId: string, reason: string) => void;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AACpF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,YAAY,EACV,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAC9B,mBAAmB,GACpB,CAAC;AAEF,oBAAY,yBAAyB;IACnC,MAAM,OAAO;IACb,OAAO,OAAO;IACd,OAAO,OAAO;IACd,aAAa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AI,CAAC;IAClE;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var ValidationStationLanguage;
|
|
2
|
+
(function (ValidationStationLanguage) {
|
|
3
|
+
ValidationStationLanguage["German"] = "de";
|
|
4
|
+
ValidationStationLanguage["English"] = "en";
|
|
5
|
+
ValidationStationLanguage["Spanish"] = "es";
|
|
6
|
+
ValidationStationLanguage["SpanishMexico"] = "es-MX";
|
|
7
|
+
ValidationStationLanguage["French"] = "fr";
|
|
8
|
+
ValidationStationLanguage["Japanese"] = "ja";
|
|
9
|
+
ValidationStationLanguage["Korean"] = "ko";
|
|
10
|
+
ValidationStationLanguage["Portuguese"] = "pt";
|
|
11
|
+
ValidationStationLanguage["PortugueseBrazil"] = "pt-BR";
|
|
12
|
+
ValidationStationLanguage["Romanian"] = "ro";
|
|
13
|
+
ValidationStationLanguage["Russian"] = "ru";
|
|
14
|
+
ValidationStationLanguage["Turkish"] = "tr";
|
|
15
|
+
ValidationStationLanguage["ChineseSimplified"] = "zh-CN";
|
|
16
|
+
ValidationStationLanguage["ChineseTraditional"] = "zh-TW";
|
|
17
|
+
})(ValidationStationLanguage || (ValidationStationLanguage = {}));
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAN,IAAY,yBAeX;AAfD,WAAY,yBAAyB;IACnC,0CAAa,CAAA;IACb,2CAAc,CAAA;IACd,2CAAc,CAAA;IACd,oDAAuB,CAAA;IACvB,0CAAa,CAAA;IACb,4CAAe,CAAA;IACf,0CAAa,CAAA;IACb,8CAAiB,CAAA;IACjB,uDAA0B,CAAA;IAC1B,4CAAe,CAAA;IACf,2CAAc,CAAA;IACd,2CAAc,CAAA;IACd,wDAA2B,CAAA;IAC3B,yDAA4B,CAAA;AAC9B,CAAC,EAfW,yBAAyB,KAAzB,yBAAyB,QAepC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
2
|
+
import type { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import type { BucketArtifacts } from "./types.js";
|
|
4
|
+
export declare function useBucketArtifacts(sdk: UiPath, data: DuFramework.ContentValidationData, folderId: number | undefined): {
|
|
5
|
+
artifacts: BucketArtifacts | null;
|
|
6
|
+
error: string | null;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useBucketArtifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBucketArtifacts.d.ts","sourceRoot":"","sources":["../src/useBucketArtifacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAEpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,QAAQ,EAAE,MAAM,GAAG,SAAS;;;EA0C7B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BucketService } from "@uipath/uipath-typescript/buckets";
|
|
2
|
+
import { useEffect, useState, useRef } from "react";
|
|
3
|
+
import { fetchBucketArtifacts } from "./bucketArtifactsUtil.js";
|
|
4
|
+
export function useBucketArtifacts(sdk, data, folderId) {
|
|
5
|
+
const bucketServiceRef = useRef(new BucketService(sdk));
|
|
6
|
+
const [artifacts, setArtifacts] = useState(null);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
const resolvedFolderId = folderId || data.FolderId;
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (resolvedFolderId) {
|
|
11
|
+
let cancelled = false;
|
|
12
|
+
fetchBucketArtifacts(bucketServiceRef.current, data, resolvedFolderId)
|
|
13
|
+
.then((result) => {
|
|
14
|
+
if (!cancelled) {
|
|
15
|
+
setArtifacts(result);
|
|
16
|
+
setError(null);
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
.catch((er) => {
|
|
20
|
+
if (!cancelled) {
|
|
21
|
+
setArtifacts(null);
|
|
22
|
+
setError(er instanceof Error ? er.message : String(er));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return () => {
|
|
26
|
+
cancelled = true;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}, [data, resolvedFolderId]);
|
|
30
|
+
// Derive error for missing folderId at render time, not inside the effect
|
|
31
|
+
if (!resolvedFolderId) {
|
|
32
|
+
return {
|
|
33
|
+
artifacts: null,
|
|
34
|
+
error: "folderId of Storage bucket is required. Provide it as a prop or ensure data.FolderId is set.",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return { artifacts, error };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=useBucketArtifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBucketArtifacts.js","sourceRoot":"","sources":["../src/useBucketArtifacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,IAAuC,EACvC,QAA4B;IAE5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ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uipath/ui-widgets-validation-station",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A React component for UiPath Document Understanding Validation Station.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prepack": "rimraf *.tgz",
|
|
20
|
+
"build": "npm run clean && tsc",
|
|
21
|
+
"clean": "rimraf dist",
|
|
22
|
+
"test": "vitest --run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"test:ui": "vitest --ui",
|
|
25
|
+
"test:coverage": "vitest --coverage --run"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"react",
|
|
29
|
+
"validation-station",
|
|
30
|
+
"validation",
|
|
31
|
+
"ui-widgets"
|
|
32
|
+
],
|
|
33
|
+
"author": "",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/UiPath/uipath-ui-widgets.git",
|
|
38
|
+
"directory": "packages/validation-station"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"registry": "https://npm.pkg.github.com"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@uipath/uipath-typescript": "^1.4.2",
|
|
45
|
+
"react": "^19.2.0",
|
|
46
|
+
"react-dom": "^19.2.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@tailwindcss/oxide": "^4.1.18",
|
|
50
|
+
"@testing-library/dom": "^10.4.0",
|
|
51
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
52
|
+
"@testing-library/react": "^16.1.0",
|
|
53
|
+
"@testing-library/user-event": "^14.5.2",
|
|
54
|
+
"@types/react": "^19.2.5",
|
|
55
|
+
"@types/react-dom": "^19.2.3",
|
|
56
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
57
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
58
|
+
"@vitest/ui": "^4.0.18",
|
|
59
|
+
"jsdom": "^25.0.1",
|
|
60
|
+
"lightningcss": "^1.30.2",
|
|
61
|
+
"rimraf": "^6.0.1",
|
|
62
|
+
"rollup": "^4.55.1",
|
|
63
|
+
"typescript": "~5.9.3",
|
|
64
|
+
"vite": "^6.0.3",
|
|
65
|
+
"vitest": "^4.0.18"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@uipath/apollo-wind": "^0.10.0",
|
|
69
|
+
"@uipath/du-validation-station-wc": "1.0.0-rc.1",
|
|
70
|
+
"fflate": "^0.8.2"
|
|
71
|
+
}
|
|
72
|
+
}
|