@docmana/sdk 0.20.0 → 0.21.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/CHANGELOG.md +11 -0
- package/README.md +27 -11
- package/dist/cli.mjs +16 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/client.d.ts +6 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -12
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +49 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.21.0 - 2026-08-05
|
|
4
|
+
|
|
5
|
+
- Relay the native Fraud job identifier through Consumer Edge while preserving
|
|
6
|
+
the existing high-level polling workflow.
|
|
7
|
+
- Add local file, named byte, and readable stream inputs to `detectFraud` and
|
|
8
|
+
`detectFraudAsync` through the existing `FileInput` contract.
|
|
9
|
+
- Stop sending organization correlation on Fraud requests. The deprecated
|
|
10
|
+
organization arguments remain accepted and ignored for source compatibility.
|
|
11
|
+
- Expose Consumer Edge's BI-friendly Fraud result contract: aggregate `summary`,
|
|
12
|
+
referenced `findings`, and detection `layers` keyed by their unique names.
|
|
13
|
+
|
|
3
14
|
## 0.20.0 - 2026-08-04
|
|
4
15
|
|
|
5
16
|
- Add `detectFraud` to start a Consumer Edge fraud-detection job, poll its
|
package/README.md
CHANGED
|
@@ -38,13 +38,12 @@ result:
|
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
40
|
const fraud = await docmana.detectFraud({
|
|
41
|
-
|
|
42
|
-
filename: "claim.pdf",
|
|
41
|
+
file: "./claim.pdf",
|
|
43
42
|
analystContext: "Travel claim; verify the invoice total.",
|
|
44
|
-
organization: "acme",
|
|
45
43
|
});
|
|
46
44
|
|
|
47
|
-
console.log(fraud.verdict, fraud.
|
|
45
|
+
console.log(fraud.verdict, fraud.summary.highestSeverity);
|
|
46
|
+
console.log(fraud.layers.pixel?.findingReferences, fraud.findings);
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
## Authentication
|
|
@@ -143,21 +142,38 @@ use `RunFlowParams` for request data:
|
|
|
143
142
|
- `runFlow(flowId, params, options?)` starts async execution, polls status, fetches the
|
|
144
143
|
result, respects `X-Poll-After` and `429 Retry-After` while polling, and throws
|
|
145
144
|
`DocmanaExecutionError` if the result status is `FAILED`.
|
|
146
|
-
- `detectFraud(params, options?)` starts fraud detection from `documentUrl
|
|
147
|
-
|
|
145
|
+
- `detectFraud(params, options?)` starts fraud detection from either `documentUrl`
|
|
146
|
+
plus `filename`, or a local `file` using the standard `FileInput` contract. It polls
|
|
147
|
+
Consumer until `COMPLETED` or `FAILED` and returns the normalized verdict, aggregate
|
|
148
|
+
`summary`, `findings` with job-local references, and detection `layers` keyed by name.
|
|
148
149
|
- `detectFraudAsync(params, options?)` starts fraud detection and immediately returns
|
|
149
150
|
`{ jobId, status }` without polling.
|
|
150
|
-
- `getFraudDetectionStatus(jobId, signal
|
|
151
|
-
`getFraudDetectionResult(jobId, signal
|
|
152
|
-
polling workflow.
|
|
151
|
+
- `getFraudDetectionStatus(jobId, signal?)` and
|
|
152
|
+
`getFraudDetectionResult(jobId, signal?)` provide the lower-level polling workflow.
|
|
153
153
|
|
|
154
154
|
Consumer is the polling authority. When `GET /status` returns `X-Poll-After`,
|
|
155
155
|
the SDK waits that many milliseconds before the next status call. If the header
|
|
156
156
|
is absent, the SDK falls back to capped exponential full jitter between
|
|
157
157
|
`pollIntervalMs` and `pollMaxIntervalMs`. `Retry-After` on `429` always wins.
|
|
158
158
|
|
|
159
|
-
The SDK does not log or return `documentUrl
|
|
160
|
-
only in the JSON request body to Consumer Edge.
|
|
159
|
+
The SDK does not log or return `documentUrl` or uploaded file contents. Signed
|
|
160
|
+
query parameters are sent only in the JSON request body to Consumer Edge. Fraud
|
|
161
|
+
jobs are not organization-scoped; the legacy `organization` inputs are accepted
|
|
162
|
+
but ignored for compatibility with SDK 0.20 callers.
|
|
163
|
+
|
|
164
|
+
URL and local-file inputs use the same methods:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
const fromUrl = await docmana.detectFraudAsync({
|
|
168
|
+
documentUrl: "https://downloads.example.com/claim.pdf?token=...",
|
|
169
|
+
filename: "claim.pdf",
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const fromFile = await docmana.detectFraudAsync({
|
|
173
|
+
file: { path: "./claim.pdf" },
|
|
174
|
+
analystContext: "Check the invoice total.",
|
|
175
|
+
});
|
|
176
|
+
```
|
|
161
177
|
|
|
162
178
|
```ts
|
|
163
179
|
const partial = await docmana.runPartialFlow("<flow-id>", {
|
package/dist/cli.mjs
CHANGED
|
@@ -379,8 +379,19 @@ async function getResult(http, executionResultId, signal, language, organization
|
|
|
379
379
|
|
|
380
380
|
// src/sdk/api/fraud-detection.ts
|
|
381
381
|
async function startFraudDetection(http, params, signal) {
|
|
382
|
+
if (params.file !== void 0) {
|
|
383
|
+
const [part] = await resolveInputs({ files: [params.file] });
|
|
384
|
+
const form = new FormData();
|
|
385
|
+
form.append("file", new File([part.data], part.filename, { type: part.contentType }));
|
|
386
|
+
if (params.analystContext !== void 0) {
|
|
387
|
+
form.append("analystContext", params.analystContext);
|
|
388
|
+
}
|
|
389
|
+
return http.requestJson("POST", "/fraud-detections", {
|
|
390
|
+
body: form,
|
|
391
|
+
signal
|
|
392
|
+
});
|
|
393
|
+
}
|
|
382
394
|
return http.requestJson("POST", "/fraud-detections", {
|
|
383
|
-
query: organizationQuery(params.organization),
|
|
384
395
|
headers: { "content-type": "application/json" },
|
|
385
396
|
body: JSON.stringify({
|
|
386
397
|
documentUrl: params.documentUrl,
|
|
@@ -391,11 +402,11 @@ async function startFraudDetection(http, params, signal) {
|
|
|
391
402
|
});
|
|
392
403
|
}
|
|
393
404
|
async function getFraudDetectionStatus(http, jobId, signal, organization) {
|
|
405
|
+
void organization;
|
|
394
406
|
const res = await http.requestRaw(
|
|
395
407
|
"GET",
|
|
396
408
|
`/fraud-detections/${encodeURIComponent(jobId)}/status`,
|
|
397
409
|
{
|
|
398
|
-
query: organizationQuery(organization),
|
|
399
410
|
signal
|
|
400
411
|
}
|
|
401
412
|
);
|
|
@@ -409,14 +420,11 @@ async function getFraudDetectionStatus(http, jobId, signal, organization) {
|
|
|
409
420
|
return pollAfterMs === void 0 ? normalized : { ...normalized, pollAfterMs };
|
|
410
421
|
}
|
|
411
422
|
async function getFraudDetectionResult(http, jobId, signal, organization) {
|
|
423
|
+
void organization;
|
|
412
424
|
return http.requestJson("GET", `/fraud-detections/${encodeURIComponent(jobId)}/result`, {
|
|
413
|
-
query: organizationQuery(organization),
|
|
414
425
|
signal
|
|
415
426
|
});
|
|
416
427
|
}
|
|
417
|
-
function organizationQuery(organization) {
|
|
418
|
-
return organization ? { organization } : void 0;
|
|
419
|
-
}
|
|
420
428
|
function parsePositiveInt2(value) {
|
|
421
429
|
if (!value) return void 0;
|
|
422
430
|
const parsed = Number(value);
|
|
@@ -644,11 +652,7 @@ var Docmana = class {
|
|
|
644
652
|
check: async () => {
|
|
645
653
|
attempt += 1;
|
|
646
654
|
try {
|
|
647
|
-
const statusResult = await this.getFraudDetectionStatus(
|
|
648
|
-
jobId,
|
|
649
|
-
options.signal,
|
|
650
|
-
params.organization
|
|
651
|
-
);
|
|
655
|
+
const statusResult = await this.getFraudDetectionStatus(jobId, options.signal);
|
|
652
656
|
const nextPollAfterMs = isTerminalStatus(statusResult.status) ? void 0 : statusResult.pollAfterMs;
|
|
653
657
|
options.onPoll?.({
|
|
654
658
|
jobId,
|
|
@@ -676,7 +680,7 @@ var Docmana = class {
|
|
|
676
680
|
signal: options.signal,
|
|
677
681
|
shouldRetryError: isTransientPollingError
|
|
678
682
|
});
|
|
679
|
-
const result = await this.getFraudDetectionResult(jobId, options.signal
|
|
683
|
+
const result = await this.getFraudDetectionResult(jobId, options.signal);
|
|
680
684
|
if (isFailedStatus(result.status)) {
|
|
681
685
|
throw new DocmanaFraudDetectionError(
|
|
682
686
|
result.error?.message ?? `Fraud detection ${jobId} failed`,
|