@arbidocs/sdk 0.4.125 → 0.4.127
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/{browser-B_tpz4Ta.d.cts → browser-Ds-drrLp.d.cts} +97 -7
- package/dist/{browser-B_tpz4Ta.d.ts → browser-Ds-drrLp.d.ts} +97 -7
- package/dist/browser.cjs +74 -5
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +74 -5
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +74 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +74 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4907,6 +4907,7 @@ __export(documents_exports, {
|
|
|
4907
4907
|
SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
|
|
4908
4908
|
deleteDocuments: () => deleteDocuments,
|
|
4909
4909
|
downloadDocument: () => downloadDocument,
|
|
4910
|
+
finaliseTranslation: () => finaliseTranslation,
|
|
4910
4911
|
getDocuments: () => getDocuments,
|
|
4911
4912
|
getParsedContent: () => getParsedContent,
|
|
4912
4913
|
getThumbnails: () => getThumbnails,
|
|
@@ -5065,6 +5066,14 @@ async function listVersions(arbi, docId) {
|
|
|
5065
5066
|
"Failed to fetch document versions"
|
|
5066
5067
|
);
|
|
5067
5068
|
}
|
|
5069
|
+
async function finaliseTranslation(arbi, docId) {
|
|
5070
|
+
return requireData(
|
|
5071
|
+
await arbi.fetch.POST("/v1/document/{document_ext_id}/finalise-translation", {
|
|
5072
|
+
params: { path: { document_ext_id: docId } }
|
|
5073
|
+
}),
|
|
5074
|
+
"Failed to finalise the translation"
|
|
5075
|
+
);
|
|
5076
|
+
}
|
|
5068
5077
|
async function deleteDocuments(arbi, externalIds) {
|
|
5069
5078
|
requireOk(
|
|
5070
5079
|
await arbi.fetch.DELETE("/v1/document/", { body: { external_ids: externalIds } }),
|
|
@@ -7234,6 +7243,7 @@ __export(workflow_steps_exports, {
|
|
|
7234
7243
|
PERSON_STEP_KINDS: () => PERSON_STEP_KINDS,
|
|
7235
7244
|
PlanStepsError: () => PlanStepsError,
|
|
7236
7245
|
SIGNAL_NAME_PATTERN: () => SIGNAL_NAME_PATTERN,
|
|
7246
|
+
STEP_ACTION_TYPES: () => STEP_ACTION_TYPES,
|
|
7237
7247
|
STEP_FIELD_OPTION_TONES: () => STEP_FIELD_OPTION_TONES,
|
|
7238
7248
|
STEP_FIELD_TYPES: () => STEP_FIELD_TYPES,
|
|
7239
7249
|
STEP_ID_PATTERN: () => STEP_ID_PATTERN,
|
|
@@ -7258,7 +7268,8 @@ __export(workflow_steps_exports, {
|
|
|
7258
7268
|
stepsPlan: () => stepsPlan,
|
|
7259
7269
|
waitingForDocumentsText: () => waitingForDocumentsText
|
|
7260
7270
|
});
|
|
7261
|
-
var STEP_KINDS = ["form", "upload", "agent", "review"];
|
|
7271
|
+
var STEP_KINDS = ["form", "upload", "agent", "review", "action"];
|
|
7272
|
+
var STEP_ACTION_TYPES = ["sign", "email_draft", "tabular_review"];
|
|
7262
7273
|
var PERSON_STEP_KINDS = ["form", "upload", "review"];
|
|
7263
7274
|
var STEP_ID_PATTERN = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
7264
7275
|
var STEP_EVENTS = {
|
|
@@ -7274,7 +7285,9 @@ var EMPTY_STATE = {
|
|
|
7274
7285
|
sentBack: false,
|
|
7275
7286
|
hasNote: false,
|
|
7276
7287
|
announcedTo: null,
|
|
7277
|
-
waitingDocuments: []
|
|
7288
|
+
waitingDocuments: [],
|
|
7289
|
+
waitingAction: null,
|
|
7290
|
+
waitingDocument: null
|
|
7278
7291
|
};
|
|
7279
7292
|
var str = (v2) => typeof v2 === "string" ? v2 : null;
|
|
7280
7293
|
var isFinished = (state) => state?.status === "done" || state?.status === "skipped";
|
|
@@ -7336,6 +7349,14 @@ function stepStatesFromActivity(events) {
|
|
|
7336
7349
|
const documents = waitingDocumentsOf(detail);
|
|
7337
7350
|
if (documents)
|
|
7338
7351
|
states[step] = { ...states[step] ?? EMPTY_STATE, waitingDocuments: documents };
|
|
7352
|
+
const action = str(detail.action);
|
|
7353
|
+
const waiting = detail.waiting;
|
|
7354
|
+
if (action && waiting && typeof waiting === "object" && !documents)
|
|
7355
|
+
states[step] = {
|
|
7356
|
+
...states[step] ?? EMPTY_STATE,
|
|
7357
|
+
waitingAction: action,
|
|
7358
|
+
waitingDocument: str(waiting.doc_ext_id)
|
|
7359
|
+
};
|
|
7339
7360
|
continue;
|
|
7340
7361
|
}
|
|
7341
7362
|
const status = STEP_EVENTS[e.kind];
|
|
@@ -7389,6 +7410,7 @@ function sendBacks(events) {
|
|
|
7389
7410
|
}
|
|
7390
7411
|
function stepPhase(steps, states, id) {
|
|
7391
7412
|
const state = states[id];
|
|
7413
|
+
if (state?.status === "running" && state.waitingAction) return "waiting";
|
|
7392
7414
|
if (state && state.status !== "pending") return state.status;
|
|
7393
7415
|
return stepDependencies(steps, id).every((d2) => isFinished(states[d2])) ? "ready" : "pending";
|
|
7394
7416
|
}
|
|
@@ -7414,7 +7436,9 @@ function runSteps(steps, events) {
|
|
|
7414
7436
|
timesSentBack: backs.filter((b2) => b2.to === s2.id).length,
|
|
7415
7437
|
signals: [...new Set(signals.filter((x2) => x2.step === s2.id).map((x2) => x2.signal))],
|
|
7416
7438
|
linkedRuns: links.filter((l2) => l2.step === s2.id),
|
|
7417
|
-
waitingDocuments: state.waitingDocuments
|
|
7439
|
+
waitingDocuments: state.waitingDocuments,
|
|
7440
|
+
waitingAction: state.waitingAction,
|
|
7441
|
+
waitingDocument: state.waitingDocument
|
|
7418
7442
|
};
|
|
7419
7443
|
});
|
|
7420
7444
|
}
|
|
@@ -7574,8 +7598,22 @@ var STEP_KEYS = /* @__PURE__ */ new Set([
|
|
|
7574
7598
|
"signals",
|
|
7575
7599
|
"assignee",
|
|
7576
7600
|
"remind_after_hours",
|
|
7577
|
-
"fields"
|
|
7601
|
+
"fields",
|
|
7602
|
+
"action",
|
|
7603
|
+
"edit_document"
|
|
7578
7604
|
]);
|
|
7605
|
+
var isDocumentRef = (v2) => typeof v2 === "string" && /^doc-[a-zA-Z0-9]{8}(?:@v[0-9]+)?$/.test(v2) || isRecord(v2) && Object.keys(v2).length === 1 && (typeof v2.step === "string" && STEP_ID_PATTERN.test(v2.step) || typeof v2.input === "string");
|
|
7606
|
+
var DOCUMENT_REF_HINT = "a doc- id, {step: <step id>} or {input: <field>}";
|
|
7607
|
+
function checkAction(action, at2, problems) {
|
|
7608
|
+
if (!isRecord(action) || !STEP_ACTION_TYPES.includes(action.type)) {
|
|
7609
|
+
problems.push(`${at2}.type: must be one of ${STEP_ACTION_TYPES.join(", ")}`);
|
|
7610
|
+
return;
|
|
7611
|
+
}
|
|
7612
|
+
if (action.type === "sign" && !isDocumentRef(action.document))
|
|
7613
|
+
problems.push(`${at2}.document: the document to sign, ${DOCUMENT_REF_HINT}`);
|
|
7614
|
+
if (isSet(action.attachments) && (!Array.isArray(action.attachments) || !action.attachments.every(isDocumentRef)))
|
|
7615
|
+
problems.push(`${at2}.attachments: a list of documents, each ${DOCUMENT_REF_HINT}`);
|
|
7616
|
+
}
|
|
7579
7617
|
var SIGNAL_NAME_PATTERN = /^[a-z0-9][a-z0-9_.-]{0,63}$/;
|
|
7580
7618
|
var FIELD_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;
|
|
7581
7619
|
var WHEN_KEYS = ["field", "equals", "contains", "matches", "approved"];
|
|
@@ -7724,6 +7762,20 @@ function checkStep(raw, at2, problems) {
|
|
|
7724
7762
|
if (!STEP_KEYS.has(key))
|
|
7725
7763
|
problems.push(`${at2}.${key}: unknown field (allowed: ${[...STEP_KEYS].join(", ")})`);
|
|
7726
7764
|
const { id, title, kind, after, skill, prompt, inputs, branch, ui } = raw;
|
|
7765
|
+
const { action, edit_document: editDocument } = raw;
|
|
7766
|
+
if (kind === "action") {
|
|
7767
|
+
if (!isSet(action))
|
|
7768
|
+
problems.push(
|
|
7769
|
+
`${at2}.action: an action step needs an action (${STEP_ACTION_TYPES.join(", ")})`
|
|
7770
|
+
);
|
|
7771
|
+
else checkAction(action, `${at2}.action`, problems);
|
|
7772
|
+
} else if (isSet(action)) problems.push(`${at2}.action: only an action step has an action`);
|
|
7773
|
+
if (isSet(editDocument)) {
|
|
7774
|
+
if (kind !== "agent" || branch)
|
|
7775
|
+
problems.push(`${at2}.edit_document: belongs to an agent step on the main line`);
|
|
7776
|
+
else if (!isDocumentRef(editDocument))
|
|
7777
|
+
problems.push(`${at2}.edit_document: ${DOCUMENT_REF_HINT}`);
|
|
7778
|
+
}
|
|
7727
7779
|
if (typeof id !== "string" || !STEP_ID_PATTERN.test(id))
|
|
7728
7780
|
problems.push(
|
|
7729
7781
|
`${at2}.id: must be lowercase letters, digits, "_" or "-", starting with a letter (got ${JSON.stringify(id)})`
|
|
@@ -7810,7 +7862,9 @@ function checkStep(raw, at2, problems) {
|
|
|
7810
7862
|
...isSet(signals) ? { signals } : {},
|
|
7811
7863
|
...isSet(assignee) ? { assignee } : {},
|
|
7812
7864
|
...isSet(remind) ? { remind_after_hours: remind } : {},
|
|
7813
|
-
...isSet(stepFieldsRaw) ? { fields: normalFields(stepFieldsRaw) } : {}
|
|
7865
|
+
...isSet(stepFieldsRaw) ? { fields: normalFields(stepFieldsRaw) } : {},
|
|
7866
|
+
...isSet(action) ? { action } : {},
|
|
7867
|
+
...isSet(editDocument) ? { edit_document: editDocument } : {}
|
|
7814
7868
|
};
|
|
7815
7869
|
}
|
|
7816
7870
|
function parsePlanSteps(value) {
|
|
@@ -7978,9 +8032,11 @@ __export(workflows_exports, {
|
|
|
7978
8032
|
createWorkflow: () => createWorkflow,
|
|
7979
8033
|
deleteWorkflow: () => deleteWorkflow,
|
|
7980
8034
|
getWorkflow: () => getWorkflow,
|
|
8035
|
+
grantWorkflowAgentAccess: () => grantWorkflowAgentAccess,
|
|
7981
8036
|
listWorkflowRuns: () => listWorkflowRuns,
|
|
7982
8037
|
listWorkflows: () => listWorkflows,
|
|
7983
8038
|
runWorkflow: () => runWorkflow,
|
|
8039
|
+
runsUnattended: () => runsUnattended,
|
|
7984
8040
|
updateWorkflow: () => updateWorkflow
|
|
7985
8041
|
});
|
|
7986
8042
|
var byId2 = (workflowId) => ({ params: { path: { workflow_id: workflowId } } });
|
|
@@ -8020,6 +8076,19 @@ async function listWorkflowRuns(arbi, workflowId) {
|
|
|
8020
8076
|
"Failed to list automation executions"
|
|
8021
8077
|
);
|
|
8022
8078
|
}
|
|
8079
|
+
var runsUnattended = (w2) => !w2.on_demand;
|
|
8080
|
+
async function grantWorkflowAgentAccess(agents, workflow, grant) {
|
|
8081
|
+
if (workflow.auth_mode !== "scheduled_permanent" || !runsUnattended(workflow) || !workflow.agent_ext_id)
|
|
8082
|
+
return null;
|
|
8083
|
+
const email = agents.find((a2) => a2.external_id === workflow.agent_ext_id)?.email;
|
|
8084
|
+
if (!email) return null;
|
|
8085
|
+
try {
|
|
8086
|
+
await grant(email);
|
|
8087
|
+
} catch (err) {
|
|
8088
|
+
if (!/already|no users found to add/i.test(String(err?.message ?? err))) throw err;
|
|
8089
|
+
}
|
|
8090
|
+
return email;
|
|
8091
|
+
}
|
|
8023
8092
|
|
|
8024
8093
|
// src/operations/facts.ts
|
|
8025
8094
|
var facts_exports = {};
|