@resolveio/client-lib-core 15.0.1 → 15.0.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.
@@ -466,31 +466,28 @@ function toDataURL(url, callback) {
466
466
  function getDeepDiffDetails(obj1, obj2) {
467
467
  let diff = detailedDiff(obj2, obj1);
468
468
  let diffString = '';
469
+ const formatValue = (value) => {
470
+ if (moment.isDate(value) || moment(value, moment.ISO_8601, true).isValid()) {
471
+ return moment(value).format('llll');
472
+ }
473
+ return typeof value === 'string' ? `"${value}"` : String(value);
474
+ };
469
475
  const formatObjectDiff = (obj1, obj2) => {
470
- if (!obj1 || !obj2)
471
- return '';
472
- return Object.keys(obj1)
473
- .map(key => {
474
- if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
475
- const arrayDiff = obj1[key].map((item, index) => typeof item === 'object' && obj2[key][index]
476
- ? `{${formatObjectDiff(item, obj2[key][index])}}`
477
- : `"${item}" to "${obj2[key][index]}"`).join(', ');
478
- return `${toTitleCase(key)}: [${arrayDiff}]`;
479
- }
480
- if (typeof obj1[key] === 'object' && obj2[key]) {
476
+ if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
477
+ return `from: ${formatValue(obj1)} to: ${formatValue(obj2)}`;
478
+ }
479
+ return Object.keys(obj1).map(key => {
480
+ if (typeof obj1[key] === 'object' && obj1[key] !== null && obj2[key] !== null) {
481
481
  return `${toTitleCase(key)}: {${formatObjectDiff(obj1[key], obj2[key])}}`;
482
482
  }
483
- return `${toTitleCase(key)}: "${obj1[key]}" to "${obj2[key]}"`;
484
- })
485
- .join(', ');
483
+ return `${toTitleCase(key)}: from: ${formatValue(obj1[key])} to: ${formatValue(obj2[key])}`;
484
+ }).join(', ');
486
485
  };
487
- if (Object.keys(diff['updated']).length > 0) {
486
+ if (Object.keys(diff.updated).length > 0) {
488
487
  diffString += 'Updated:\n';
489
- const updates = Object.keys(diff['updated'])
490
- .filter(key => key.substr(0, 2) !== 'id' && diff['updated'][key] !== obj2[key])
491
- .map(key => moment.isDate(diff['updated'][key])
492
- ? `${toTitleCase(key)}: "${moment(diff['updated'][key]).format('llll')}" to "${moment(obj2[key]).format('llll')}"`
493
- : `${toTitleCase(key)}: {${formatObjectDiff(diff['updated'][key], obj2[key])}}`)
488
+ const updates = Object.keys(diff.updated)
489
+ .filter(key => key.substr(0, 2) !== 'id' && diff.updated[key] !== obj2[key])
490
+ .map(key => `${toTitleCase(key)}: {${formatObjectDiff(diff.updated[key], obj2[key])}}`)
494
491
  .join(',\n');
495
492
  diffString += updates ? `${updates}\n` : '';
496
493
  }