@docmana/sdk 0.36.0-hitl.2 → 0.37.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.37.0 - 2026-11-05
4
+
5
+ - Support upstream field and classification corrections through the existing `continue` decision.
6
+ The backend recalculates dependent steps and selects the next checkpoint.
7
+ - Type correction provenance (`origin`, `originalValue`), document downstream steps, and
8
+ dossier context and results. `reviews.get()` returns an empty `documents` array when a
9
+ decided review's held data has been released.
10
+
11
+ ## 0.36.0 - 2026-10-30
12
+
13
+ - Promote the additive review and execution-event client APIs to a stable release.
14
+ Unused review APIs require no additional backend configuration.
15
+ - Align native pending-list envelopes (documents are read on task detail), and
16
+ support confirmations, correction reasons and human review duration.
17
+ - Preserve DOC-2558 review conflict metadata through Consumer Edge: `decidedBy`,
18
+ `decidedAt` and `currentVersion`, with the exported `ReviewConflictDetails` type.
19
+ Keep deprecated legacy aliases and bounded metadata; decision conflicts are
20
+ never retried automatically. Normal executions and final callbacks are unchanged.
21
+
3
22
  ## 0.36.0-hitl.2 - 2026-10-23 (HITL prerelease)
4
23
 
5
24
  - Add `executionEvents.list()` and typed, non-consuming sequence-paged node
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Docmana
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Docmana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -526,6 +526,25 @@ confirm that action with the user. Import and deletion do not use operation IDs.
526
526
 
527
527
  ## Human review of formula executions
528
528
 
529
+ The native pending queue omits documents: load the selected task with `reviews.get()`
530
+ before displaying its values and documents. Decided tasks leave this queue; resume
531
+ progress belongs to the execution. `ReviewDecision` also supports `confirmations`,
532
+ per-correction `reason`, and `durationSeconds`. Conflict details identify an already
533
+ submitted decision or the current version; no decision is retried automatically.
534
+
535
+ To correct an upstream result, read the current task and select the `itemId`
536
+ of a field or classification in `documents[].context`. Submit
537
+ `decision: "continue"` with the current review version and
538
+ `corrections: [{ itemId, value }]`. Confirmations name current `items` only.
539
+ DocMana API validates eligibility, recalculates dependent steps and selects the
540
+ next checkpoint. After the accepted response, read the current task again.
541
+
542
+ `documents[].downstream` and `dossierResults` expose read-only calculated steps.
543
+ `dossierContext` carries the captured JSON context. `origin` and `originalValue`
544
+ describe applied human changes. These fields are optional for older backends.
545
+ When the backend releases a decided task's held data, `reviews.get()` returns
546
+ `documents: []` with the remaining task metadata.
547
+
529
548
  Read calculation metadata repeatedly with
530
549
  `client.reviews.calculation(executionId, { organization })`. It returns
531
550
  `executionResultId`, normalized `executionStatus` and `calculation` (null for
@@ -595,13 +614,20 @@ options. It returns 200/206/304/416 without consuming the body.
595
614
 
596
615
  A decision receipt means **recorded and resume queued**, never final completion.
597
616
  On 409 inspect `DocmanaError.reviewConflict` and `apiCode`, then re-read the task.
617
+ `REVIEW_ALREADY_SUBMITTED` can include `reviewConflict.decidedBy` (`id`, `name`,
618
+ `source: "integrator" | "token"`) and `decidedAt`.
619
+ `REVIEW_VERSION_STALE` can include `reviewConflict.currentVersion`.
620
+ Missing metadata remains `null`; only bounded, whitelisted fields are retained.
621
+ The previous `version`, `submittedBy` and `submittedAt` properties remain as
622
+ deprecated compatibility aliases. Never replace the submitted version with the
623
+ new version and retry automatically: let the user inspect the refreshed task.
598
624
  On 503 re-read first: the decision may already be recorded. The SDK does not retry
599
625
  a decision after a conflict, 503 or uncertain transport outcome. The standard one-time
600
626
  401 token-refresh retry still applies. Keep the existing final callback/polling result owner;
601
627
  opening a review must not consume the single-use execution result.
602
628
 
603
629
  Release order: compatible Document API, Consumer, published SDK, then Arcana's
604
- exact pinned dependency. This local 0.33.0 candidate is not published by these steps.
630
+ exact pinned dependency. Preparing this change does not publish or deploy it.
605
631
 
606
632
  ## License
607
633
 
package/dist/cli.mjs CHANGED
@@ -211,6 +211,11 @@ var Reviews = class {
211
211
  return this.http.requestJson("GET", `/executions/${segment(executionId)}/review`, {
212
212
  signal: options.signal,
213
213
  query: { organization: options.organization }
214
+ }).then((task) => {
215
+ if (typeof task?.status === "string" && task.status !== "pending" && task.documents === void 0) {
216
+ return { ...task, documents: [] };
217
+ }
218
+ return task;
214
219
  });
215
220
  }
216
221
  decide(executionId, decision, options) {
@@ -544,13 +549,9 @@ var HttpClient = class {
544
549
  const data = await res.clone().json().catch(() => null);
545
550
  if (typeof data?.code === "string" && /^[A-Za-z][A-Za-z0-9_]{0,99}$/.test(data.code))
546
551
  Object.defineProperty(error, "apiCode", { value: data.code, enumerable: true });
547
- if (res.status === 409 && data?.details)
552
+ if (res.status === 409 && isRecord(data?.details))
548
553
  Object.defineProperty(error, "reviewConflict", {
549
- value: {
550
- version: Number.isInteger(data.details.version) ? data.details.version : null,
551
- submittedBy: typeof data.details.submittedBy === "string" ? data.details.submittedBy.slice(0, 200) : null,
552
- submittedAt: typeof data.details.submittedAt === "string" ? data.details.submittedAt.slice(0, 40) : null
553
- },
554
+ value: reviewConflictDetails(data.details),
554
555
  enumerable: true
555
556
  });
556
557
  throw error;
@@ -596,6 +597,32 @@ var HttpClient = class {
596
597
  }
597
598
  }
598
599
  };
600
+ function isRecord(value) {
601
+ return typeof value === "object" && value !== null && !Array.isArray(value);
602
+ }
603
+ function reviewConflictDetails(raw) {
604
+ const text = (value, limit) => typeof value === "string" ? value.slice(0, limit) : null;
605
+ const version = (value) => Number.isSafeInteger(value) && Number(value) >= 1 ? value : null;
606
+ const actor = isRecord(raw.decidedBy) ? raw.decidedBy : {};
607
+ const id = text(actor.id, 200);
608
+ const name = text(actor.name, 200);
609
+ const source = actor.source === "integrator" || actor.source === "token" ? actor.source : null;
610
+ const decidedBy = id !== null || name !== null || source !== null ? {
611
+ ...id !== null ? { id } : {},
612
+ ...name !== null ? { name } : {},
613
+ ...source ? { source } : {}
614
+ } : null;
615
+ const currentVersion = version(raw.currentVersion) ?? version(raw.version);
616
+ const decidedAt = text(raw.decidedAt, 40) ?? text(raw.submittedAt, 40);
617
+ return {
618
+ currentVersion,
619
+ decidedBy,
620
+ decidedAt,
621
+ version: currentVersion,
622
+ submittedBy: id ?? name ?? text(raw.submittedBy, 200),
623
+ submittedAt: decidedAt
624
+ };
625
+ }
599
626
  function parseRetryAfterMs(value) {
600
627
  if (!value) return void 0;
601
628
  const seconds = Number(value);