@uipath/ui-widgets-validation-station 1.2.0 → 1.3.0-rc.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 +272 -214
- package/dist/ValidationStation.d.ts +5 -2
- package/dist/ValidationStation.d.ts.map +1 -1
- package/dist/ValidationStation.js +8 -4
- package/dist/ValidationStation.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/ixpUtil.d.ts +6 -0
- package/dist/ixpUtil.d.ts.map +1 -0
- package/dist/ixpUtil.js +9 -0
- package/dist/ixpUtil.js.map +1 -0
- package/dist/payloadSource.d.ts +19 -0
- package/dist/payloadSource.d.ts.map +1 -0
- package/dist/payloadSource.js +12 -0
- package/dist/payloadSource.js.map +1 -0
- package/dist/processedDocument/artifacts.d.ts +15 -0
- package/dist/processedDocument/artifacts.d.ts.map +1 -0
- package/dist/processedDocument/artifacts.js +86 -0
- package/dist/processedDocument/artifacts.js.map +1 -0
- package/dist/processedDocument/dom.d.ts +7 -0
- package/dist/processedDocument/dom.d.ts.map +1 -0
- package/dist/processedDocument/dom.js +43 -0
- package/dist/processedDocument/dom.js.map +1 -0
- package/dist/processedDocument/errors.d.ts +20 -0
- package/dist/processedDocument/errors.d.ts.map +1 -0
- package/dist/processedDocument/errors.js +27 -0
- package/dist/processedDocument/errors.js.map +1 -0
- package/dist/processedDocument/payload.d.ts +14 -0
- package/dist/processedDocument/payload.d.ts.map +1 -0
- package/dist/processedDocument/payload.js +34 -0
- package/dist/processedDocument/payload.js.map +1 -0
- package/dist/processedDocument/platformClient.d.ts +22 -0
- package/dist/processedDocument/platformClient.d.ts.map +1 -0
- package/dist/processedDocument/platformClient.js +131 -0
- package/dist/processedDocument/platformClient.js.map +1 -0
- package/dist/processedDocument/review.d.ts +20 -0
- package/dist/processedDocument/review.d.ts.map +1 -0
- package/dist/processedDocument/review.js +28 -0
- package/dist/processedDocument/review.js.map +1 -0
- package/dist/processedDocument/save.d.ts +22 -0
- package/dist/processedDocument/save.d.ts.map +1 -0
- package/dist/processedDocument/save.js +73 -0
- package/dist/processedDocument/save.js.map +1 -0
- package/dist/processedDocument/spans.d.ts +4 -0
- package/dist/processedDocument/spans.d.ts.map +1 -0
- package/dist/processedDocument/spans.js +65 -0
- package/dist/processedDocument/spans.js.map +1 -0
- package/dist/processedDocument/types.d.ts +45 -0
- package/dist/processedDocument/types.d.ts.map +1 -0
- package/dist/processedDocument/types.js +2 -0
- package/dist/processedDocument/types.js.map +1 -0
- package/dist/saveHandlers.d.ts +3 -1
- package/dist/saveHandlers.d.ts.map +1 -1
- package/dist/saveHandlers.js +40 -11
- package/dist/saveHandlers.js.map +1 -1
- package/dist/saveValidatedDataUtil.d.ts.map +1 -1
- package/dist/saveValidatedDataUtil.js +9 -0
- package/dist/saveValidatedDataUtil.js.map +1 -1
- package/dist/subcomponents/shared.d.ts +4 -4
- package/dist/subcomponents/shared.d.ts.map +1 -1
- package/dist/subcomponents/shared.js.map +1 -1
- package/dist/subcomponents/useWcElement.d.ts +2 -2
- package/dist/subcomponents/useWcElement.d.ts.map +1 -1
- package/dist/subcomponents/useWcElement.js +1 -1
- package/dist/subcomponents/useWcElement.js.map +1 -1
- package/dist/types.d.ts +42 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/useResolvedArtifacts.d.ts +26 -7
- package/dist/useResolvedArtifacts.d.ts.map +1 -1
- package/dist/useResolvedArtifacts.js +42 -29
- package/dist/useResolvedArtifacts.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Traces } from "@uipath/uipath-typescript/traces";
|
|
2
|
+
import { joinDeploymentUrl } from "../urlUtil.js";
|
|
3
|
+
import { PlatformCallError } from "./errors.js";
|
|
4
|
+
const FOLDER_KEY_HEADER = "x-uipath-folderkey";
|
|
5
|
+
const LLM_OPS_SERVICE = "llmopstenant_";
|
|
6
|
+
const ECS_SERVICE = "ecs_";
|
|
7
|
+
const IDP_EXTRACTION_FEEDBACK_TYPE = "idpExtraction";
|
|
8
|
+
// Newest by timestamp rather than by position: the list's order is not part of the contract.
|
|
9
|
+
const newest = (records) => records.reduce((latest, record) => !latest || Date.parse(record.createdAt) > Date.parse(latest.createdAt)
|
|
10
|
+
? record
|
|
11
|
+
: latest, undefined);
|
|
12
|
+
// Ids from service responses go into URL paths, where encoding alone would
|
|
13
|
+
// still let a bare `..` segment through.
|
|
14
|
+
const pathSegment = (value, what) => {
|
|
15
|
+
if (!/^[A-Za-z0-9_-]+$/.test(value)) {
|
|
16
|
+
// Not the value itself: a failed load's message goes to telemetry.
|
|
17
|
+
throw new Error(`Refusing an unexpected ${what}`);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
const feedbackBody = (write) => ({
|
|
22
|
+
feedbackType: IDP_EXTRACTION_FEEDBACK_TYPE,
|
|
23
|
+
isPositive: write.isPositive,
|
|
24
|
+
metadata: write.metadata ?? null,
|
|
25
|
+
comment: write.comment ?? null,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* The Traces, ECS and Feedback calls a `ProcessedDocument` needs, all on public
|
|
29
|
+
* routes, so they work with an external-app token (e.g. a coded action app's).
|
|
30
|
+
* Spans come through the SDK's Traces service. The ECS and Feedback calls are
|
|
31
|
+
* made directly with the SDK's token: the SDK has no ECS bucket service, and
|
|
32
|
+
* its Feedback service cannot set the `feedbackType` a review needs.
|
|
33
|
+
*/
|
|
34
|
+
export function createPlatformClient(sdk) {
|
|
35
|
+
const serviceUrl = (service, endpoint) => {
|
|
36
|
+
const { baseUrl, orgName, tenantName } = sdk.config;
|
|
37
|
+
return [orgName, tenantName, service, endpoint].reduce(joinDeploymentUrl, baseUrl);
|
|
38
|
+
};
|
|
39
|
+
// A host-delegated token (e.g. Action Center's) is only fetched, and
|
|
40
|
+
// refreshed, by the SDK's own service calls: `getToken()` is undefined before
|
|
41
|
+
// the first one and again once the token expires. A one-span read of the
|
|
42
|
+
// trace is the cheapest such call the Flow path is already scoped for.
|
|
43
|
+
// Replace with an async token getter if the SDK exposes one.
|
|
44
|
+
const ensureToken = async (traceId) => {
|
|
45
|
+
const loaded = sdk.getToken();
|
|
46
|
+
if (loaded)
|
|
47
|
+
return loaded;
|
|
48
|
+
await new Traces(sdk).getById(traceId, { pageSize: 1 });
|
|
49
|
+
const fetched = sdk.getToken();
|
|
50
|
+
if (!fetched) {
|
|
51
|
+
throw new Error("The SDK is not authenticated.");
|
|
52
|
+
}
|
|
53
|
+
return fetched;
|
|
54
|
+
};
|
|
55
|
+
const send = async (operation, url, scope, init = {}) => {
|
|
56
|
+
const token = await ensureToken(scope.traceId);
|
|
57
|
+
const method = init.method ?? "GET";
|
|
58
|
+
const response = await fetch(url, {
|
|
59
|
+
method,
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: `Bearer ${token}`,
|
|
62
|
+
[FOLDER_KEY_HEADER]: scope.folderKey,
|
|
63
|
+
...(init.body === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: { "Content-Type": "application/json" }),
|
|
66
|
+
},
|
|
67
|
+
body: init.body === undefined ? undefined : JSON.stringify(init.body),
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
// The service's message tells a rejected payload apart from a missing
|
|
71
|
+
// permission; it travels on `detail`, short, and never in the message.
|
|
72
|
+
const detail = (await response.text().catch(() => "")).slice(0, 300);
|
|
73
|
+
throw new PlatformCallError(operation, response.status, detail);
|
|
74
|
+
}
|
|
75
|
+
return response;
|
|
76
|
+
};
|
|
77
|
+
const getJson = async (operation, url, scope) => (await send(operation, url, scope)).json();
|
|
78
|
+
const postJson = async (operation, url, scope, body) => (await send(operation, url, scope, { method: "POST", body })).json();
|
|
79
|
+
return {
|
|
80
|
+
getSpans: async (traceId) => (await new Traces(sdk).getById(traceId)).map((span) => ({
|
|
81
|
+
id: span.id,
|
|
82
|
+
spanType: span.spanType,
|
|
83
|
+
attributes: span.attributes,
|
|
84
|
+
attachments: span.attachments?.map((a) => ({ id: a.id, fileName: a.fileName })) ??
|
|
85
|
+
null,
|
|
86
|
+
})),
|
|
87
|
+
getEcsReadUri: async (ref, scope) => {
|
|
88
|
+
// An OData string literal: `'` doubles, then the path's own slashes are
|
|
89
|
+
// encoded so they do not read as further route segments.
|
|
90
|
+
const path = encodeURIComponent(ref.fileName.replace(/'/g, "''"));
|
|
91
|
+
const bucketId = pathSegment(ref.bucketId, "bucket id");
|
|
92
|
+
const endpoint = `v2.0/Buckets/${bucketId}/GetReadUri(path='${path}')`;
|
|
93
|
+
const { uri } = await getJson("Reading an artifact's link", serviceUrl(ECS_SERVICE, endpoint), scope);
|
|
94
|
+
return uri;
|
|
95
|
+
},
|
|
96
|
+
// Pre-signed: no token goes to the storage host.
|
|
97
|
+
readBytes: async (uri) => {
|
|
98
|
+
const response = await fetch(uri);
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
throw new Error(`Reading an artifact failed with status ${response.status}`);
|
|
101
|
+
}
|
|
102
|
+
return response.arrayBuffer();
|
|
103
|
+
},
|
|
104
|
+
findFeedback: async (anchor) => {
|
|
105
|
+
const params = new URLSearchParams({
|
|
106
|
+
traceId: anchor.traceId,
|
|
107
|
+
spanId: anchor.spanId,
|
|
108
|
+
folderKey: anchor.folderKey,
|
|
109
|
+
feedbackType: IDP_EXTRACTION_FEEDBACK_TYPE,
|
|
110
|
+
});
|
|
111
|
+
const records = await getJson("Looking up the saved review", `${serviceUrl(LLM_OPS_SERVICE, "api/Feedback")}?${params}`, anchor);
|
|
112
|
+
const record = newest(records);
|
|
113
|
+
return record
|
|
114
|
+
? { id: record.id, metadata: record.metadata ?? undefined }
|
|
115
|
+
: null;
|
|
116
|
+
},
|
|
117
|
+
createFeedback: async (anchor, write) => {
|
|
118
|
+
const { id } = await postJson("Creating the review", serviceUrl(LLM_OPS_SERVICE, "api/Feedback"), anchor, {
|
|
119
|
+
traceId: anchor.traceId,
|
|
120
|
+
spanId: anchor.spanId,
|
|
121
|
+
...feedbackBody(write),
|
|
122
|
+
});
|
|
123
|
+
return id;
|
|
124
|
+
},
|
|
125
|
+
editFeedback: async (anchor, id, write) => {
|
|
126
|
+
const response = await postJson("Editing the review", serviceUrl(LLM_OPS_SERVICE, `api/Feedback/${pathSegment(id, "feedback id")}`), anchor, feedbackBody(write));
|
|
127
|
+
return response.id;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=platformClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformClient.js","sourceRoot":"","sources":["../../src/processedDocument/platformClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAShD,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC/C,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,4BAA4B,GAAG,eAAe,CAAC;AAWrD,6FAA6F;AAC7F,MAAM,MAAM,GAAG,CAAC,OAA2B,EAAgC,EAAE,CAC3E,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACjB,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;IACpE,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,MAAM,EACZ,SAAS,CACV,CAAC;AAEJ,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,IAAY,EAAU,EAAE;IAC1D,IAAI,CAAC,kBAAkB,CA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AC3C,MAAM,EACN;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,YAAY,CAAC,KAAK,CAAC;aACvB,CACF,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,YAAY,EAAE,KAAK,EACjB,MAAsB,EACtB,EAAU,EACV,KAAoB,EACH,EAAE;YACnB,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAC7B,oBAAoB,EACpB,UAAU,CACR,eAAe,EACf,gBAAgB,WAAW,CAAC,EAAE,EAAE,aAAa,CAAC,EAAE,CACjD,EACD,MAAM,EACN,YAAY,CAAC,KAAK,CAAC,CACpB,CAAC;YACF,OAAO,QAAQ,CAAC,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IXPExtraction } from "@uipath/du-validation-station-wc";
|
|
2
|
+
/**
|
|
3
|
+
* What a review's Feedback record holds as `metadata`, serialized — the shape
|
|
4
|
+
* the Angular Validation Station writes (`ValidatedFlowExtraction`), so either
|
|
5
|
+
* reopens a review the other saved. `draft` tells a saved draft from a
|
|
6
|
+
* submitted result; both reopen on `extraction`.
|
|
7
|
+
*/
|
|
8
|
+
export interface RecordedReview {
|
|
9
|
+
draft: boolean;
|
|
10
|
+
extraction: IXPExtraction;
|
|
11
|
+
}
|
|
12
|
+
/** Serializes a review of `validatedData`, which must be an IXP extraction. */
|
|
13
|
+
export declare function serializeReview(validatedData: unknown, draft: boolean): string;
|
|
14
|
+
/**
|
|
15
|
+
* The extraction a review's record holds, draft or submitted, or `null` when
|
|
16
|
+
* the metadata is not a {@link RecordedReview} — the document then opens on the
|
|
17
|
+
* payload's result, as the Angular Validation Station does.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseReview(metadata: string): IXPExtraction | null;
|
|
20
|
+
//# sourceMappingURL=review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/processedDocument/review.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGtE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,aAAa,CAAC;CAC3B;AAQD,+EAA+E;AAC/E,wBAAgB,eAAe,CAC7B,aAAa,EAAE,OAAO,EACtB,KAAK,EAAE,OAAO,GACb,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAOlE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isIXPExtraction } from "../ixpUtil.js";
|
|
2
|
+
const isRecordedReview = (value) => !!value &&
|
|
3
|
+
typeof value === "object" &&
|
|
4
|
+
typeof value.draft === "boolean" &&
|
|
5
|
+
isIXPExtraction(value.extraction);
|
|
6
|
+
/** Serializes a review of `validatedData`, which must be an IXP extraction. */
|
|
7
|
+
export function serializeReview(validatedData, draft) {
|
|
8
|
+
if (!isIXPExtraction(validatedData)) {
|
|
9
|
+
throw new Error("validatedData is not an IXP extraction, so it cannot be recorded against a ProcessedDocument.");
|
|
10
|
+
}
|
|
11
|
+
const review = { draft, extraction: validatedData };
|
|
12
|
+
return JSON.stringify(review);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The extraction a review's record holds, draft or submitted, or `null` when
|
|
16
|
+
* the metadata is not a {@link RecordedReview} — the document then opens on the
|
|
17
|
+
* payload's result, as the Angular Validation Station does.
|
|
18
|
+
*/
|
|
19
|
+
export function parseReview(metadata) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(metadata);
|
|
22
|
+
return isRecordedReview(parsed) ? parsed.extraction : null;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/processedDocument/review.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAahD,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA2B,EAAE,CACnE,CAAC,CAAC,KAAK;IACP,OAAO,KAAK,KAAK,QAAQ;IACzB,OAAQ,KAA6B,CAAC,KAAK,KAAK,SAAS;IACzD,eAAe,CAAE,KAAkC,CAAC,UAAU,CAAC,CAAC;AAElE,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAC7B,aAAsB,EACtB,KAAc;IAEd,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAmB,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IACpE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IVsSaveExceptionReportRequest, IVsSaveValidatedDataAsDraftRequest, IVsSaveValidatedDataRequest } from "@uipath/du-validation-station-wc";
|
|
2
|
+
import type { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
|
+
import type { SaveValidatedDataResult } from "../saveValidatedDataUtil.js";
|
|
4
|
+
import type { ProcessedDocument } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Records a submitted {@link ProcessedDocument} review. The downstream Flow
|
|
7
|
+
* node reads the result from the task completion, so complete the task with
|
|
8
|
+
* `request.validatedData` whatever the outcome.
|
|
9
|
+
*/
|
|
10
|
+
export declare function submitProcessedDocument(sdk: UiPath, processedDocument: ProcessedDocument, request: IVsSaveValidatedDataRequest): Promise<SaveValidatedDataResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Saves a draft of a {@link ProcessedDocument} review; the next load opens on
|
|
13
|
+
* it. Writes the same record as a submit, flagged `draft` — what makes a
|
|
14
|
+
* submit final is the host completing the task.
|
|
15
|
+
*/
|
|
16
|
+
export declare function saveProcessedDocumentAsDraft(sdk: UiPath, processedDocument: ProcessedDocument, request: IVsSaveValidatedDataAsDraftRequest): Promise<SaveValidatedDataResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Records a {@link ProcessedDocument} rejected as an exception, replacing any
|
|
19
|
+
* saved draft. As with a submit, completing the task is yours.
|
|
20
|
+
*/
|
|
21
|
+
export declare function reportProcessedDocumentException(sdk: UiPath, processedDocument: ProcessedDocument, request: IVsSaveExceptionReportRequest): Promise<SaveValidatedDataResult>;
|
|
22
|
+
//# sourceMappingURL=save.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../src/processedDocument/save.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAK3E,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAyCnE;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC,CAKlC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAKlC;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,uBAAuB,CAAC,CAQlC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { describeForHost } from "./errors.js";
|
|
2
|
+
import { validateProcessedDocument } from "./payload.js";
|
|
3
|
+
import { createPlatformClient } from "./platformClient.js";
|
|
4
|
+
import { serializeReview } from "./review.js";
|
|
5
|
+
// Saves for one span run one at a time: find-then-create is not atomic, so two
|
|
6
|
+
// quick saves would otherwise both find no record and both create one.
|
|
7
|
+
const savesBySpan = new Map();
|
|
8
|
+
function oneAtATime(key, task) {
|
|
9
|
+
const next = (savesBySpan.get(key) ?? Promise.resolve()).then(task, task);
|
|
10
|
+
savesBySpan.set(key, next);
|
|
11
|
+
const release = () => {
|
|
12
|
+
if (savesBySpan.get(key) === next)
|
|
13
|
+
savesBySpan.delete(key);
|
|
14
|
+
};
|
|
15
|
+
next.then(release, release);
|
|
16
|
+
return next;
|
|
17
|
+
}
|
|
18
|
+
// Edits the span's newest record, or creates one, so the widget and a host
|
|
19
|
+
// saving outside it always land on the record the next load reopens.
|
|
20
|
+
async function recordReview(sdk, processedDocument, write) {
|
|
21
|
+
try {
|
|
22
|
+
const { anchor } = validateProcessedDocument(processedDocument);
|
|
23
|
+
const body = write();
|
|
24
|
+
const client = createPlatformClient(sdk);
|
|
25
|
+
await oneAtATime(`${anchor.traceId}/${anchor.spanId}`, async () => {
|
|
26
|
+
const existing = await client.findFeedback(anchor);
|
|
27
|
+
await (existing
|
|
28
|
+
? client.editFeedback(anchor, existing.id, body)
|
|
29
|
+
: client.createFeedback(anchor, body));
|
|
30
|
+
});
|
|
31
|
+
return { success: true };
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
// The result goes to the host's callbacks, not telemetry, so it may carry
|
|
35
|
+
// the service's detail.
|
|
36
|
+
return { success: false, error: describeForHost(error) };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Records a submitted {@link ProcessedDocument} review. The downstream Flow
|
|
41
|
+
* node reads the result from the task completion, so complete the task with
|
|
42
|
+
* `request.validatedData` whatever the outcome.
|
|
43
|
+
*/
|
|
44
|
+
export function submitProcessedDocument(sdk, processedDocument, request) {
|
|
45
|
+
return recordReview(sdk, processedDocument, () => ({
|
|
46
|
+
isPositive: true,
|
|
47
|
+
metadata: serializeReview(request.validatedData, false),
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Saves a draft of a {@link ProcessedDocument} review; the next load opens on
|
|
52
|
+
* it. Writes the same record as a submit, flagged `draft` — what makes a
|
|
53
|
+
* submit final is the host completing the task.
|
|
54
|
+
*/
|
|
55
|
+
export function saveProcessedDocumentAsDraft(sdk, processedDocument, request) {
|
|
56
|
+
return recordReview(sdk, processedDocument, () => ({
|
|
57
|
+
isPositive: true,
|
|
58
|
+
metadata: serializeReview(request.validatedData, true),
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Records a {@link ProcessedDocument} rejected as an exception, replacing any
|
|
63
|
+
* saved draft. As with a submit, completing the task is yours.
|
|
64
|
+
*/
|
|
65
|
+
export function reportProcessedDocumentException(sdk, processedDocument, request) {
|
|
66
|
+
const reason = request.exceptionReport?.Reason ??
|
|
67
|
+
"";
|
|
68
|
+
return recordReview(sdk, processedDocument, () => ({
|
|
69
|
+
isPositive: false,
|
|
70
|
+
comment: reason,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/processedDocument/save.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,+EAA+E;AAC/E,uEAAuE;AACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;AAExD,SAAS,UAAU,CAAI,GAAW,EAAE,IAAsB;IACxD,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1E,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI;YAAE,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2EAA2E;AAC3E,qEAAqE;AACrE,KAAK,UAAU,YAAY,CACzB,GAAW,EACX,iBAAoC,EACpC,KAA0B;IAE1B,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;QAChE,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;QACrB,MAAM,MAAM,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AED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,GAAW,EACX,iBAAoC,EACpC,OAAsC;IAEtC,MAAM,MAAM,GACT,OAAO,CAAC,eAAqD,EAAE,MAAM;QACtE,EAAE,CAAC;IACL,OAAO,YAAY,CAAC,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,CAAC;QACjD,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,MAAM;KAChB,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DocumentArtifactRefs, TraceSpan } from "./types.js";
|
|
2
|
+
/** The document and its DOM are required to render; the OCR text is not. */
|
|
3
|
+
export declare function resolveDocumentArtifacts(spans: TraceSpan[]): DocumentArtifactRefs;
|
|
4
|
+
//# sourceMappingURL=spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../src/processedDocument/spans.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,oBAAoB,EACpB,SAAS,EAEV,MAAM,YAAY,CAAC;AAsCpB,4EAA4E;AAC5E,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,EAAE,GACjB,oBAAoB,CAiDtB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { refuse } from "./payload.js";
|
|
2
|
+
const DIGITIZATION_SPAN_TYPE = "idpDigitization";
|
|
3
|
+
// The service sends attributes as a JSON string; take an object as it is too.
|
|
4
|
+
const parseAttributes = (attributes) => {
|
|
5
|
+
let parsed = attributes;
|
|
6
|
+
if (typeof attributes === "string") {
|
|
7
|
+
try {
|
|
8
|
+
parsed = JSON.parse(attributes);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return parsed && typeof parsed === "object"
|
|
15
|
+
? parsed
|
|
16
|
+
: null;
|
|
17
|
+
};
|
|
18
|
+
// The ids on `digitizationArtifacts` are bucket *paths*; the bucket holding
|
|
19
|
+
// each one is only on the span's attachment list, matched by that path.
|
|
20
|
+
const toArtifactRef = (attachments, fileName) => {
|
|
21
|
+
if (!fileName)
|
|
22
|
+
return null;
|
|
23
|
+
const attachment = attachments.find((a) => a.fileName === fileName);
|
|
24
|
+
return attachment ? { bucketId: attachment.id, fileName } : null;
|
|
25
|
+
};
|
|
26
|
+
/** The document and its DOM are required to render; the OCR text is not. */
|
|
27
|
+
export function resolveDocumentArtifacts(spans) {
|
|
28
|
+
// Nothing on a span ties it to the extraction it fed, so with more than one
|
|
29
|
+
// the document could belong to another extraction: refuse rather than guess.
|
|
30
|
+
const digitizations = spans.filter((s) => s.spanType === DIGITIZATION_SPAN_TYPE);
|
|
31
|
+
if (digitizations.length > 1) {
|
|
32
|
+
refuse(`the trace carries ${digitizations.length} ${DIGITIZATION_SPAN_TYPE} spans, so the document cannot be matched to this extraction`);
|
|
33
|
+
}
|
|
34
|
+
const span = digitizations[0];
|
|
35
|
+
if (!span) {
|
|
36
|
+
refuse(`the trace carries no ${DIGITIZATION_SPAN_TYPE} span`);
|
|
37
|
+
}
|
|
38
|
+
const attributes = parseAttributes(span.attributes);
|
|
39
|
+
if (!attributes) {
|
|
40
|
+
refuse(`the ${DIGITIZATION_SPAN_TYPE} span carries no readable attributes`);
|
|
41
|
+
}
|
|
42
|
+
const artifacts = attributes["digitizationArtifacts"];
|
|
43
|
+
if (!Array.isArray(artifacts) || artifacts.length === 0) {
|
|
44
|
+
refuse(`the ${DIGITIZATION_SPAN_TYPE} span declares no digitizationArtifacts`);
|
|
45
|
+
}
|
|
46
|
+
if (artifacts.length > 1) {
|
|
47
|
+
refuse(`the run digitized ${artifacts.length} documents, and only one can be validated`);
|
|
48
|
+
}
|
|
49
|
+
const artifact = artifacts[0];
|
|
50
|
+
const attachments = span.attachments ?? [];
|
|
51
|
+
const document = toArtifactRef(attachments, artifact?.normalizedPdfAttachmentId);
|
|
52
|
+
const dom = toArtifactRef(attachments, artifact?.domAttachmentId);
|
|
53
|
+
if (!document) {
|
|
54
|
+
refuse("the run produced no document artifact");
|
|
55
|
+
}
|
|
56
|
+
if (!dom) {
|
|
57
|
+
refuse("the run produced no dom artifact");
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
document,
|
|
61
|
+
dom,
|
|
62
|
+
text: toArtifactRef(attachments, artifact?.textAttachmentId),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spans.js","sourceRoot":"","sources":["../../src/processedDocument/spans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAQtC,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAQjD,8EAA8E;AAC9E,MAAM,eAAe,GAAG,CACtB,UAAmB,EACa,EAAE;IAClC,IAAI,MAAM,GAAG,UAAU,CAAC;IACxB,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QACzC,CAAC,CAAE,MAAkC;QACrC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC;AAEF,4EAA4E;AAC5E,wEAAwE;AACxE,MAAM,aAAa,GAAG,CACpB,WAAkC,EAClC,QAA4B,EACR,EAAE;IACtB,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACpE,OAAO,UAAU,CAAC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AI,CAAC,WAAW,IAAI,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAC5B,WAAW,EACX,QAAQ,EAAE,yBAAyB,CACpC,CAAC;IACF,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;IAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,CAAC,uCAAuC,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,CAAC,kCAAkC,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,QAAQ;QACR,GAAG;QACH,IAAI,EAAE,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type { ProcessedDocument, ProcessedDocumentMetadata, ProcessedDocumentTaxonomy, ProcessedDocumentType, } from "@uipath/du-utils";
|
|
2
|
+
/** What a review is recorded against, and the folder every call is made in. */
|
|
3
|
+
export interface FeedbackAnchor {
|
|
4
|
+
traceId: string;
|
|
5
|
+
spanId: string;
|
|
6
|
+
folderKey: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TraceSpanAttachment {
|
|
9
|
+
/** The storage bucket holding the file. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The path inside the bucket. */
|
|
12
|
+
fileName: string;
|
|
13
|
+
}
|
|
14
|
+
/** The fields of a trace span the artifact resolver reads. */
|
|
15
|
+
export interface TraceSpan {
|
|
16
|
+
id: string;
|
|
17
|
+
spanType: string | null;
|
|
18
|
+
/** Typed as an object by the SDK, but the service sends a JSON string. */
|
|
19
|
+
attributes: unknown;
|
|
20
|
+
attachments: TraceSpanAttachment[] | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ArtifactRef {
|
|
23
|
+
bucketId: string;
|
|
24
|
+
fileName: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DocumentArtifactRefs {
|
|
27
|
+
/** The normalized PDF. */
|
|
28
|
+
document: ArtifactRef;
|
|
29
|
+
/** Gzipped. */
|
|
30
|
+
dom: ArtifactRef;
|
|
31
|
+
/** Gzipped. */
|
|
32
|
+
text: ArtifactRef | null;
|
|
33
|
+
}
|
|
34
|
+
/** An edit replaces the whole record, so an absent field is sent as `null`. */
|
|
35
|
+
export interface FeedbackWrite {
|
|
36
|
+
isPositive: boolean;
|
|
37
|
+
/** A serialized {@link RecordedReview}. */
|
|
38
|
+
metadata?: string;
|
|
39
|
+
comment?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface FeedbackRecord {
|
|
42
|
+
id: string;
|
|
43
|
+
metadata?: string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/processedDocument/types.ts"],"names":[],"mappings":"AACA,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAI1B,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,0EAA0E;IAC1E,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,mBAAmB,EAAE,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,0BAA0B;IAC1B,QAAQ,EAAE,WAAW,CAAC;IACtB,eAAe;IACf,GAAG,EAAE,WAAW,CAAC;IACjB,eAAe;IACf,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;CAC1B;AAED,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/processedDocument/types.ts"],"names":[],"mappings":""}
|
package/dist/saveHandlers.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IVsSaveExceptionReportRequest, IVsSaveValidatedDataAsDraftRequest, IVsSaveValidatedDataRequest } from "@uipath/du-validation-station-wc";
|
|
2
2
|
import type { UiPath } from "@uipath/uipath-typescript/core";
|
|
3
3
|
import type { DuFramework } from "@uipath/uipath-typescript/document-understanding";
|
|
4
|
+
import type { ProcessedDocument } from "./processedDocument/types.js";
|
|
4
5
|
import { type DuSaveCallbacks } from "./types.js";
|
|
5
6
|
/**
|
|
6
7
|
* Builds the save/draft/exception listeners shared by the two save-capable
|
|
@@ -8,9 +9,10 @@ import { type DuSaveCallbacks } from "./types.js";
|
|
|
8
9
|
* cannot drift: each persists when it can, tracks the flow once, and emits the
|
|
9
10
|
* request with the outcome attached only when it was the one that saved.
|
|
10
11
|
*/
|
|
11
|
-
export declare function createSaveHandlers({ sdk, data }: {
|
|
12
|
+
export declare function createSaveHandlers({ sdk, data, processedDocument, }: {
|
|
12
13
|
sdk?: UiPath;
|
|
13
14
|
data?: DuFramework.ContentValidationData;
|
|
15
|
+
processedDocument?: ProcessedDocument;
|
|
14
16
|
}, { onSubmit, onSaveAsDraft, onReportException }: DuSaveCallbacks): {
|
|
15
17
|
handleSubmit: (request: IVsSaveValidatedDataRequest) => void;
|
|
16
18
|
handleSaveAsDraft: (request: IVsSaveValidatedDataAsDraftRequest) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveHandlers.d.ts","sourceRoot":"","sources":["../src/saveHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"saveHandlers.d.ts","sourceRoot":"","sources":["../src/saveHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,kCAAkC,EAClC,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAOpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,YAAY,CAAC;AAgDpB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,EACE,GAAG,EACH,IAAI,EACJ,iBAAiB,GAClB,EAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,WAAW,CAAC,qBAAqB,CAAC;IACzC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,EACD,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,eAAe;4BAKrC,2BAA2B;iCAgBtB,kCAAkC;+BAUpC,6BAA6B;EAkB3D"}
|
package/dist/saveHandlers.js
CHANGED
|
@@ -1,40 +1,69 @@
|
|
|
1
|
+
import { selectPayload } from "./payloadSource.js";
|
|
2
|
+
import { reportProcessedDocumentException, saveProcessedDocumentAsDraft, submitProcessedDocument, } from "./processedDocument/save.js";
|
|
1
3
|
import { saveValidatedDataAsDraft, submitValidatedData, } from "./saveValidatedDataUtil.js";
|
|
2
4
|
import { TelemetryEvent, TelemetryStatus, } from "./types.js";
|
|
3
5
|
import { trackTelemetry } from "./utils/telemetryUtils.js";
|
|
6
|
+
function resolvePersistence(sdk, dataProp, processedDocumentProp) {
|
|
7
|
+
if (!sdk)
|
|
8
|
+
return null;
|
|
9
|
+
const { data, processedDocument } = selectPayload(dataProp, processedDocumentProp);
|
|
10
|
+
if (data) {
|
|
11
|
+
return data.FolderKey || data.FolderId
|
|
12
|
+
? {
|
|
13
|
+
submit: (request) => submitValidatedData(sdk, data, request),
|
|
14
|
+
saveAsDraft: (request) => saveValidatedDataAsDraft(sdk, data, request),
|
|
15
|
+
}
|
|
16
|
+
: null;
|
|
17
|
+
}
|
|
18
|
+
if (processedDocument) {
|
|
19
|
+
return {
|
|
20
|
+
submit: (request) => submitProcessedDocument(sdk, processedDocument, request),
|
|
21
|
+
saveAsDraft: (request) => saveProcessedDocumentAsDraft(sdk, processedDocument, request),
|
|
22
|
+
reportException: (request) => reportProcessedDocumentException(sdk, processedDocument, request),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
4
27
|
/**
|
|
5
28
|
* Builds the save/draft/exception listeners shared by the two save-capable
|
|
6
29
|
* widgets, `ValidationStation` and `CompactFieldsForm`, so their behaviour
|
|
7
30
|
* cannot drift: each persists when it can, tracks the flow once, and emits the
|
|
8
31
|
* request with the outcome attached only when it was the one that saved.
|
|
9
32
|
*/
|
|
10
|
-
export function createSaveHandlers({ sdk, data }, { onSubmit, onSaveAsDraft, onReportException }) {
|
|
11
|
-
|
|
12
|
-
// bucket is scoped to.
|
|
13
|
-
const canPersist = !!sdk && !!data && !!(data.FolderKey || data.FolderId);
|
|
33
|
+
export function createSaveHandlers({ sdk, data, processedDocument, }, { onSubmit, onSaveAsDraft, onReportException }) {
|
|
34
|
+
const persistence = resolvePersistence(sdk, data, processedDocument);
|
|
14
35
|
return {
|
|
15
36
|
handleSubmit: (request) => {
|
|
16
|
-
if (!
|
|
37
|
+
if (!persistence) {
|
|
17
38
|
// No outcome to wait for, so the event records the attempt.
|
|
18
39
|
trackTelemetry(TelemetryEvent.Submit, TelemetryStatus.Success);
|
|
19
40
|
onSubmit?.(request);
|
|
20
41
|
return;
|
|
21
42
|
}
|
|
22
|
-
|
|
43
|
+
persistence.submit(request).then((result) => {
|
|
23
44
|
trackTelemetry(TelemetryEvent.Submit, result.success ? TelemetryStatus.Success : TelemetryStatus.Error);
|
|
24
45
|
onSubmit?.(request, result);
|
|
25
46
|
});
|
|
26
47
|
},
|
|
27
48
|
handleSaveAsDraft: (request) => {
|
|
28
|
-
if (!
|
|
49
|
+
if (!persistence) {
|
|
29
50
|
onSaveAsDraft?.(request);
|
|
30
51
|
return;
|
|
31
52
|
}
|
|
32
|
-
|
|
53
|
+
persistence
|
|
54
|
+
.saveAsDraft(request)
|
|
55
|
+
.then((result) => onSaveAsDraft?.(request, result));
|
|
33
56
|
},
|
|
34
|
-
// Never persisted by either widget — the host owns it.
|
|
35
57
|
handleException: (request) => {
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
if (!persistence?.reportException) {
|
|
59
|
+
trackTelemetry(TelemetryEvent.ExceptionRequest, TelemetryStatus.Success);
|
|
60
|
+
onReportException?.(request);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
persistence.reportException(request).then((result) => {
|
|
64
|
+
trackTelemetry(TelemetryEvent.ExceptionRequest, result.success ? TelemetryStatus.Success : TelemetryStatus.Error);
|
|
65
|
+
onReportException?.(request, result);
|
|
66
|
+
});
|
|
38
67
|
},
|
|
39
68
|
};
|
|
40
69
|
}
|
package/dist/saveHandlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveHandlers.js","sourceRoot":"","sources":["../src/saveHandlers.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"saveHandlers.js","sourceRoot":"","sources":["../src/saveHandlers.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAe3D,SAAS,kBAAkB,CACzB,GAAuB,EACvB,QAAuD,EACvD,qBAAoD;IAEpD,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,aAAa,CAC/C,QAAQ,EACR,qBAAqB,CACtB,CAAC;IACF,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ;YACpC,CAAC,CAAC;gBACE,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC;gBAC5D,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CACvB,wBAAwB,CAAC,GAAG,EAAE,IAAI,EAAE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|
|
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;AAKpF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,uBAAuB,CAAC,CA4BlC;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,CAAC,qBAAqB,EACvC,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAoBlC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BucketService } from "@uipath/uipath-typescript/buckets";
|
|
2
2
|
import { OrchestratorDuModule } from "@uipath/uipath-typescript/orchestrator-du-module";
|
|
3
3
|
import { strToU8, zipSync } from "fflate";
|
|
4
|
+
import { isIXPExtraction } from "./ixpUtil.js";
|
|
4
5
|
/**
|
|
5
6
|
* Where a validated result is written, as described by `data`: the bucket, the
|
|
6
7
|
* path, and the folder both are scoped to. Throws when a piece is missing, so
|
|
@@ -51,6 +52,10 @@ async function uploadResultToBucket(bucketService, { bucketId, path, scope, docu
|
|
|
51
52
|
}
|
|
52
53
|
export async function submitValidatedData(sdk, data, request) {
|
|
53
54
|
try {
|
|
55
|
+
// DU post-processing takes the UiPath contracts only.
|
|
56
|
+
if (isIXPExtraction(request.validatedData)) {
|
|
57
|
+
throw new Error("An IXP extraction cannot be submitted through ContentValidationData. Submit it with submitProcessedDocument.");
|
|
58
|
+
}
|
|
54
59
|
const target = bucketTarget(data);
|
|
55
60
|
const du = new OrchestratorDuModule(sdk);
|
|
56
61
|
const processedResult = await du.processExtractedData({
|
|
@@ -70,6 +75,10 @@ export async function submitValidatedData(sdk, data, request) {
|
|
|
70
75
|
}
|
|
71
76
|
export async function saveValidatedDataAsDraft(sdk, data, request) {
|
|
72
77
|
try {
|
|
78
|
+
// The next bucket load reads this file as an `ExtractionResult`.
|
|
79
|
+
if (isIXPExtraction(request.validatedData)) {
|
|
80
|
+
throw new Error("An IXP extraction cannot be saved through ContentValidationData. Save it with saveProcessedDocumentAsDraft.");
|
|
81
|
+
}
|
|
73
82
|
await uploadResultToBucket(new BucketService(sdk), bucketTarget(data), request.validatedData);
|
|
74
83
|
return { success: true };
|
|
75
84
|
}
|
|
@@ -1 +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;
|
|
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;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAuC;IAC3D,MAAM,EACJ,QAAQ,EACR,8BAA8B,EAC9B,UAAU,EACV,QAAQ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