@haiiro/docuflow 0.0.4 → 0.0.6

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.
@@ -59493,6 +59493,10 @@ var getTask = async (runAs, taskId) => readRestRecord(
59493
59493
  await restClient(runAs).get(`/rest/tasks/${taskId}`)
59494
59494
  );
59495
59495
 
59496
+ // src/shared/log.util.ts
59497
+ var PREFIX = "[docflow]";
59498
+ var logDocflow = (event, details) => console.info(PREFIX, event, details ?? "");
59499
+
59496
59500
  // src/universal-identifiers.ts
59497
59501
  var DOCUMENT_FILE_UNIVERSAL_IDENTIFIER = "cadc1706-80e7-41dd-91dd-9c7324961abb";
59498
59502
  var CAPTURE_FILE_LOGIC_FUNCTION_UNIVERSAL_IDENTIFIER = "f735d9e9-d46a-4527-98c8-c84c2b6dbb7b";
@@ -59516,6 +59520,7 @@ var captureFile = async (capture) => {
59516
59520
  })
59517
59521
  ).records;
59518
59522
  if (existing.length > 0) {
59523
+ logDocflow("capture: already a document", { fileId: capture.fileId });
59519
59524
  return "ALREADY_CAPTURED";
59520
59525
  }
59521
59526
  const attachment = readRestRecord(
@@ -59525,6 +59530,11 @@ var captureFile = async (capture) => {
59525
59530
  (item) => item.fileId === capture.fileId
59526
59531
  );
59527
59532
  if (file?.url === void 0) {
59533
+ logDocflow("capture: file is gone from the attachment", {
59534
+ attachmentId: capture.attachmentId,
59535
+ fileId: capture.fileId,
59536
+ attachmentFound: attachment !== void 0
59537
+ });
59528
59538
  return "FILE_GONE";
59529
59539
  }
59530
59540
  const download = await fetch(file.url);
@@ -59536,7 +59546,7 @@ var captureFile = async (capture) => {
59536
59546
  filename: capture.label,
59537
59547
  fieldMetadataUniversalIdentifier: DOCUMENT_FILE_UNIVERSAL_IDENTIFIER
59538
59548
  });
59539
- const workflowRunId = capture.sourceObjectName === "task" ? (await getTask("application", capture.sourceRecordId))?.smbWorkflowRunId ?? null : null;
59549
+ const workflowRunId = capture.sourceObjectName === "task" ? (await getTask("application", capture.sourceRecordId))?.smbWorkflowRunId || null : null;
59540
59550
  await restClient("application").post("/rest/smbDocuments", {
59541
59551
  name: getDocumentNameFromFile(capture.label),
59542
59552
  file: [{ fileId: uploaded.id, label: capture.label }],
@@ -59551,6 +59561,10 @@ var captureFile = async (capture) => {
59551
59561
  workflowRunId,
59552
59562
  authorId: capture.workspaceMemberId
59553
59563
  });
59564
+ logDocflow("capture: document created", {
59565
+ fileId: capture.fileId,
59566
+ source: `${capture.sourceObjectName}/${capture.sourceRecordId}`
59567
+ });
59554
59568
  return "CREATED";
59555
59569
  };
59556
59570