diff --git a/docs/api/woqlclient.md b/docs/api/woqlclient.md index 2bbdb51d..bffe86b2 100644 --- a/docs/api/woqlclient.md +++ b/docs/api/woqlclient.md @@ -1123,7 +1123,7 @@ async funtion callGetUserOrganizations(){ ``` ## getDiff -##### woqlClient.getDiff(before, after) ⇒ Promise +##### woqlClient.getDiff(before, after, options) ⇒ Promise Get the patch of difference between two documents. **Returns**: Promise - A promise that returns the call response object, or an Error if rejected. @@ -1132,6 +1132,7 @@ Get the patch of difference between two documents. | --- | --- | --- | | before | object | The current state of JSON document | | after | object | The updated state of JSON document | +| options | object | [{}] - Options to send to the diff endpoint | **Example** ```javascript @@ -1142,7 +1143,7 @@ const diff = await client.getDiff( ``` ## getVersionObjectDiff -##### woqlClient.getVersionObjectDiff(id, beforeVersion, after) ⇒ Promise +##### woqlClient.getVersionObjectDiff(id, beforeVersion, after, options) ⇒ Promise Get the patch of difference between two documents. **Returns**: Promise - A promise that returns the call response object, or an Error if rejected. @@ -1152,6 +1153,7 @@ Get the patch of difference between two documents. | id | string | The object id to be diffed | | beforeVersion | string | The version from which to compare the object | | after | object | The updated state of JSON document | +| options | object | [{}] - Options to send to the diff endpoint | **Example** ```javascript @@ -1163,7 +1165,7 @@ const diff = await client.getVersionObjectDiff( ``` ## getVersionDiff -##### woqlClient.getVersionDiff(id, beforeVersion, afterVersion) ⇒ Promise +##### woqlClient.getVersionDiff(id, beforeVersion, afterVersion, options) ⇒ Promise Get the patch of difference between two documents. **Returns**: Promise - A promise that returns the call response object, or an Error if rejected. @@ -1173,6 +1175,7 @@ Get the patch of difference between two documents. | id | string | The object id to be diffed | | beforeVersion | string | The version from which to compare the object | | afterVersion | string | The version to which to compare the object | +| options | object | [{}] - Options to send to the diff endpoint | **Example** ```javascript diff --git a/lib/woqlClient.js b/lib/woqlClient.js index 44dec83f..ed9aa17f 100644 --- a/lib/woqlClient.js +++ b/lib/woqlClient.js @@ -1468,6 +1468,7 @@ WOQLClient.prototype.userOrganizations = function (orgList) { * Get the patch of difference between two documents. * @param {object} before - The current state of JSON document * @param {object} after - The updated state of JSON document + * @param {object} options [{}] - Options to send to the diff endpoint * @returns {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const diff = await client.getDiff( @@ -1475,7 +1476,7 @@ WOQLClient.prototype.userOrganizations = function (orgList) { * { "@id": "Person/Jane", "@type": "Person", name: "Janine" } * ); */ -WOQLClient.prototype.getDiff = function (before, after) { +WOQLClient.prototype.getDiff = function (before, after, options) { if (typeof before !== 'object' || typeof after !== 'object') { const errmsg = '"before" or "after" parameter error - you must specify a valid before or after json document'; @@ -1483,8 +1484,9 @@ WOQLClient.prototype.getDiff = function (before, after) { new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)), ); } + const opt = (typeof options === 'undefined') ? {} : options; + const payload = { before, after, ...opt }; - const payload = { before, after }; return this.dispatch( CONST.POST, `${this.connectionConfig.apiURL()}diff`, @@ -1497,6 +1499,7 @@ WOQLClient.prototype.getDiff = function (before, after) { * @param {string} id - The object id to be diffed * @param {string} beforeVersion - The version from which to compare the object * @param {object} after - The updated state of JSON document + * @param {object} options [{}] - Options to send to the diff endpoint * @returns {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const diff = await client.getVersionObjectDiff( @@ -1505,7 +1508,7 @@ WOQLClient.prototype.getDiff = function (before, after) { * { "@id": "Person/Jane", "@type": "Person", name: "Janine" } * ); */ -WOQLClient.prototype.getVersionObjectDiff = function (id, beforeVersion, after) { +WOQLClient.prototype.getVersionObjectDiff = function (id, beforeVersion, after, options) { if (typeof id !== 'string' || typeof beforeVersion !== 'string' || typeof after !== 'object') { const errmsg = '"id", "beforeVersion" or "after" parameter error - you must specify a valid after json document and valid id and version'; @@ -1513,8 +1516,10 @@ WOQLClient.prototype.getVersionObjectDiff = function (id, beforeVersion, after) new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)), ); } - - const payload = { document_id: id, before_data_version: beforeVersion, after }; + const opt = (typeof options === 'undefined') ? {} : options; + const payload = { + document_id: id, before_data_version: beforeVersion, after, ...opt, + }; return this.dispatch( CONST.POST, this.connectionConfig.diffURL(), @@ -1527,6 +1532,7 @@ WOQLClient.prototype.getVersionObjectDiff = function (id, beforeVersion, after) * @param {string} id - The object id to be diffed * @param {string} beforeVersion - The version from which to compare the object * @param {string} afterVersion - The version to which to compare the object + * @param {object} options [{}] - Options to send to the diff endpoint * @returns {Promise} A promise that returns the call response object, or an Error if rejected. * @example * const diff = await client.getVersionDiff( @@ -1535,7 +1541,7 @@ WOQLClient.prototype.getVersionObjectDiff = function (id, beforeVersion, after) * "branch:73rqpooz65kbsheuno5dsayh71x7wf4" * ); */ -WOQLClient.prototype.getVersionDiff = function (id, beforeVersion, afterVersion) { +WOQLClient.prototype.getVersionDiff = function (id, beforeVersion, afterVersion, options) { if (typeof id !== 'string' || typeof beforeVersion !== 'string' || typeof afterVersion !== 'string') { const errmsg = '"id", "beforeVersion" or "after" parameter error - you must specify a valid after json document and valid id and version'; @@ -1543,11 +1549,12 @@ WOQLClient.prototype.getVersionDiff = function (id, beforeVersion, afterVersion) new Error(ErrorMessage.getInvalidParameterMessage(CONST.GET_DIFF, errmsg)), ); } - + const opt = (typeof options === 'undefined') ? {} : options; const payload = { document_id: id, before_data_version: beforeVersion, after_data_version: afterVersion, + ...opt, }; return this.dispatch( CONST.POST,