tango-app-api-client 3.4.0-beta.0 → 3.4.0-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.4.0-beta.0",
3
+ "version": "3.4.0-beta.2",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -2655,7 +2655,9 @@ export async function getActivityLogs( req, res ) {
2655
2655
  if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
2656
2656
  const previous = hit?._source?.oldData;
2657
2657
  const current=hit?._source?.newData;
2658
- respo = findDifferences( previous, current );
2658
+ if ( previous && current ) {
2659
+ respo = findDifferences( previous, current );
2660
+ }
2659
2661
  hit._source.updatedValue = respo;
2660
2662
  temp.push( hit?._source );
2661
2663
  // hit._source.changes =logSubType === 'ticketConfig'? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
@@ -2674,16 +2676,25 @@ export async function getActivityLogs( req, res ) {
2674
2676
  }
2675
2677
  }
2676
2678
 
2677
- function findDifferences( obj1, obj2 ) {
2678
- let differences = {};
2679
+ function findDifferences( oldData, newData ) {
2680
+ logger.info( { oldData: oldData, newData: newData } );
2681
+ const allKeys = new Set( [ ...Object.keys( oldData ), ...Object.keys( newData ) ] );
2682
+ const diff = {};
2683
+
2684
+ allKeys.forEach( ( key ) => {
2685
+ const previous = key in oldData ? oldData[key] : null;
2686
+ const current = key in newData ? newData[key] : null;
2679
2687
 
2680
- for ( let key in obj1 ) {
2681
- if ( obj1[key] !== obj2[key] ) {
2682
- differences[splitCamelCase( key )] = { previous: obj1[key], current: obj2[key] };
2688
+ // Only include fields that are added or updated (where previous !== current)
2689
+ if ( previous !== current ) {
2690
+ diff[splitCamelCase( key )] = {
2691
+ previous,
2692
+ current,
2693
+ };
2683
2694
  }
2684
- }
2695
+ } );
2685
2696
 
2686
- return differences;
2697
+ return diff;
2687
2698
  }
2688
2699
 
2689
2700
  function splitCamelCase( text ) {