@@ -1475,6 +1475,70 @@ WOQLClient.prototype.getDiff = function (before, after) {
14751475 ) . then ( ( response ) => response ) ;
14761476} ;
14771477
1478+ /**
1479+ * Get the patch of difference between two documents.
1480+ * @param {string } id - The object id to be diffed
1481+ * @param {string } beforeVersion - The version from which to compare the object
1482+ * @param {object } after - The updated state of JSON document
1483+ * @returns {Promise } A promise that returns the call response object, or an Error if rejected.
1484+ * @example
1485+ * const diff = await client.getVersionObjectDiff(
1486+ * "Person/Jane",
1487+ * "branch:a73ssscfx0kke7z76083cgswszdxy6l",
1488+ * { "@id ": "Person/Jane", "@type": "Person", name: "Janine" }
1489+ * );
1490+ */
1491+ WOQLClient . prototype . getVersionObjectDiff = function ( id , beforeVersion , after ) {
1492+ if ( typeof id !== 'string' || typeof beforeVersion !== 'string' || typeof after !== 'object' ) {
1493+ const errmsg = '"id", "beforeVersion" or "after" parameter error - you must specify a valid after json document and valid id and version' ;
1494+
1495+ return Promise . reject (
1496+ new Error ( ErrorMessage . getInvalidParameterMessage ( CONST . GET_DIFF , errmsg ) ) ,
1497+ ) ;
1498+ }
1499+
1500+ const payload = { document_id : id , before_data_version : beforeVersion , after } ;
1501+ return this . dispatch (
1502+ CONST . POST ,
1503+ this . connectionConfig . diffURL ( ) ,
1504+ payload ,
1505+ ) . then ( ( response ) => response ) ;
1506+ } ;
1507+
1508+ /**
1509+ * Get the patch of difference between two documents.
1510+ * @param {string } id - The object id to be diffed
1511+ * @param {string } beforeVersion - The version from which to compare the object
1512+ * @param {object } afterVersion - The version to which to compare the object
1513+ * @returns {Promise } A promise that returns the call response object, or an Error if rejected.
1514+ * @example
1515+ * const diff = await client.getVersionDiff(
1516+ * "Person/Jane",
1517+ * "branch:a73ssscfx0kke7z76083cgswszdxy6l",
1518+ * "branch:73rqpooz65kbsheuno5dsayh71x7wf4"
1519+ * );
1520+ */
1521+ WOQLClient . prototype . getVersionDiff = function ( id , beforeVersion , afterVersion ) {
1522+ if ( typeof id !== 'string' || typeof beforeVersion !== 'string' || typeof afterVersion !== 'string' ) {
1523+ const errmsg = '"id", "beforeVersion" or "after" parameter error - you must specify a valid after json document and valid id and version' ;
1524+
1525+ return Promise . reject (
1526+ new Error ( ErrorMessage . getInvalidParameterMessage ( CONST . GET_DIFF , errmsg ) ) ,
1527+ ) ;
1528+ }
1529+
1530+ const payload = {
1531+ document_id : id ,
1532+ before_data_version : beforeVersion ,
1533+ after_data_version : afterVersion ,
1534+ } ;
1535+ return this . dispatch (
1536+ CONST . POST ,
1537+ this . connectionConfig . diffURL ( ) ,
1538+ payload ,
1539+ ) . then ( ( response ) => response ) ;
1540+ } ;
1541+
14781542/**
14791543 * Patch the difference between two documents.
14801544 * @param {object } before - The current state of JSON document
0 commit comments