diff --git a/packages/core/data-transfer/src/engine/index.ts b/packages/core/data-transfer/src/engine/index.ts index 2787953bc7..2f04bce86e 100644 --- a/packages/core/data-transfer/src/engine/index.ts +++ b/packages/core/data-transfer/src/engine/index.ts @@ -346,7 +346,7 @@ class TransferEngine< keys.forEach((key) => { const sourceSchema = sourceSchemas[key]; const destinationSchema = destinationSchemas[key]; - const schemaDiffs = compareSchemas(destinationSchema, sourceSchema, strategy); + const schemaDiffs = compareSchemas(sourceSchema, destinationSchema, strategy); if (schemaDiffs.length) { diffs[key] = schemaDiffs; @@ -364,15 +364,19 @@ class TransferEngine< const path = diff.path.join('.'); if (diff.kind === 'added') { - return `Added "${path}": "${diff.value}" (${diff.type})`; + return `${path} exists in destination schema but not in source schema`; } if (diff.kind === 'deleted') { - return `Removed "${path}"`; + return `${path} exists in source schema but not in destination schema`; } if (diff.kind === 'modified') { - return `Modified "${path}": "${diff.values[0]}" (${diff.types[0]}) => "${diff.values[1]}" (${diff.types[1]})`; + if (diff.types[0] === diff.types[1]) { + return `Schema value changed at "${path}": "${diff.values[0]}" (${diff.types[0]}) => "${diff.values[1]}" (${diff.types[1]})`; + } + + return `Schema has differing data types at "${path}": "${diff.values[0]}" (${diff.types[0]}) => "${diff.values[1]}" (${diff.types[1]})`; } throw new TransferEngineValidationError(`Invalid diff found for "${uid}"`, { diff --git a/packages/core/data-transfer/src/utils/json.ts b/packages/core/data-transfer/src/utils/json.ts index d305ee1cab..42001f48a2 100644 --- a/packages/core/data-transfer/src/utils/json.ts +++ b/packages/core/data-transfer/src/utils/json.ts @@ -38,14 +38,6 @@ export const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Di return diffs; }; - if (aType === 'undefined') { - return added(); - } - - if (bType === 'undefined') { - return deleted(); - } - if (isArray(a) && isArray(b)) { let k = 0; @@ -77,6 +69,14 @@ export const diff = (a: unknown, b: unknown, ctx: Context = createContext()): Di } if (!isEqual(a, b)) { + if (aType === 'undefined') { + return added(); + } + + if (bType === 'undefined') { + return deleted(); + } + return modified(); }