my-typescript-library-rahul52us 2.5.0 → 2.5.1

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.
@@ -2111,18 +2111,25 @@ export async function updateComment(id: string, data: Partial<IDocument>) : Prom
2111
2111
  }
2112
2112
  }
2113
2113
 
2114
- export async function updateStatus(data: Partial<IDocument>) : Promise<any>{
2114
+
2115
+ export async function updateStatus(
2116
+ data: { documentId: string; key?: string; value: any }
2117
+ ): Promise<any> {
2115
2118
  try {
2119
+ const { documentId, key = "status", value } = data;
2120
+ if (!documentId) return null;
2121
+ const updatePayload = {
2122
+ [`originalValues.${key}`]: value,
2123
+ };
2124
+
2116
2125
  const result = await Document.updateOne(
2117
- { documentId: data.documentId },
2118
- { $set: { "originalValues.status": data.status } }
2126
+ { documentId },
2127
+ { $set: updatePayload }
2119
2128
  );
2120
- if (result.matchedCount === 0) {
2121
- return null;
2122
- } else {
2123
- return result;
2124
- }
2129
+
2130
+ return result.matchedCount === 0 ? null : result;
2125
2131
  } catch (err) {
2132
+ console.error("Update failed:", err);
2126
2133
  return null;
2127
2134
  }
2128
2135
  }
@@ -1410,6 +1410,7 @@ export async function getcountDocumentsWorkflowService(
1410
1410
 
1411
1411
  return {
1412
1412
  ...result.data,
1413
+ _id : workflow?._id,
1413
1414
  workflowName: workflow?.workFlowName
1414
1415
  };
1415
1416
  })