@arbidocs/sdk 0.4.80 → 0.4.81

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/dist/index.cjs CHANGED
@@ -6803,7 +6803,8 @@ __export(workflow_steps_exports, {
6803
6803
  stepFields: () => stepFields,
6804
6804
  stepPhase: () => stepPhase,
6805
6805
  stepStatesFromActivity: () => stepStatesFromActivity,
6806
- stepsPlan: () => stepsPlan
6806
+ stepsPlan: () => stepsPlan,
6807
+ waitingForDocumentsText: () => waitingForDocumentsText
6807
6808
  });
6808
6809
  var STEP_KINDS = ["form", "upload", "agent", "review"];
6809
6810
  var PERSON_STEP_KINDS = ["form", "upload", "review"];
@@ -6820,7 +6821,8 @@ var EMPTY_STATE = {
6820
6821
  error: null,
6821
6822
  sentBack: false,
6822
6823
  hasNote: false,
6823
- announcedTo: null
6824
+ announcedTo: null,
6825
+ waitingDocuments: []
6824
6826
  };
6825
6827
  var str = (v2) => typeof v2 === "string" ? v2 : null;
6826
6828
  var isFinished = (state) => state?.status === "done" || state?.status === "skipped";
@@ -6849,6 +6851,15 @@ function reopenedBy(detail) {
6849
6851
  const listed = Array.isArray(detail.reopened) ? detail.reopened : to ? [to] : [];
6850
6852
  return listed.filter((id) => typeof id === "string");
6851
6853
  }
6854
+ function waitingDocumentsOf(detail) {
6855
+ const waiting = detail.waiting;
6856
+ if (!waiting || typeof waiting !== "object" || Array.isArray(waiting)) return null;
6857
+ const documents = waiting.documents;
6858
+ return Array.isArray(documents) ? documents.filter((id) => typeof id === "string") : null;
6859
+ }
6860
+ function waitingForDocumentsText(count) {
6861
+ return `Waiting for ${count} ${count === 1 ? "document" : "documents"} to finish processing`;
6862
+ }
6852
6863
  function stepStatesFromActivity(events) {
6853
6864
  const states = {};
6854
6865
  for (const e of events) {
@@ -6869,6 +6880,12 @@ function stepStatesFromActivity(events) {
6869
6880
  states[step] = { ...states[step] ?? EMPTY_STATE, announcedTo: str(detail.to) };
6870
6881
  continue;
6871
6882
  }
6883
+ if (e.kind === "step_waiting" || e.kind === "step_progress") {
6884
+ const documents = waitingDocumentsOf(detail);
6885
+ if (documents)
6886
+ states[step] = { ...states[step] ?? EMPTY_STATE, waitingDocuments: documents };
6887
+ continue;
6888
+ }
6872
6889
  const status = STEP_EVENTS[e.kind];
6873
6890
  if (!status) continue;
6874
6891
  states[step] = {
@@ -6944,7 +6961,8 @@ function runSteps(steps, events) {
6944
6961
  hasNote: state.hasNote,
6945
6962
  timesSentBack: backs.filter((b2) => b2.to === s2.id).length,
6946
6963
  signals: [...new Set(signals.filter((x2) => x2.step === s2.id).map((x2) => x2.signal))],
6947
- linkedRuns: links.filter((l2) => l2.step === s2.id)
6964
+ linkedRuns: links.filter((l2) => l2.step === s2.id),
6965
+ waitingDocuments: state.waitingDocuments
6948
6966
  };
6949
6967
  });
6950
6968
  }