Skip to content

Commit 58c3c8c

Browse files
Release v1.5.6
1 parent 47b580d commit 58c3c8c

File tree

6 files changed

+66
-18
lines changed

6 files changed

+66
-18
lines changed

dist/dynamics-web-api-callbacks.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dynamics-web-api-callbacks v1.5.5 (c) 2019 Aleksandr Rogov */
1+
/*! dynamics-web-api-callbacks v1.5.6 (c) 2019 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -638,6 +638,13 @@ function convertRequestOptions(request, functionName, url, joinSymbol, config) {
638638
headers['MSCRM.MergeLabels'] = 'true';
639639
}
640640

641+
if (request.contentId) {
642+
ErrorHelper.stringParameterCheck(request.contentId, 'DynamicsWebApi.' + functionName, 'request.contentId');
643+
if (!request.contentId.startsWith('$')) {
644+
headers['Content-ID'] = request.contentId;
645+
}
646+
}
647+
641648
if (request.isBatch) {
642649
ErrorHelper.boolParameterCheck(request.isBatch, 'DynamicsWebApi.' + functionName, 'request.isBatch');
643650
}
@@ -688,6 +695,13 @@ function convertRequest(request, functionName, config) {
688695
ErrorHelper.stringParameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
689696
url = request.collection;
690697

698+
if (request.contentId) {
699+
ErrorHelper.stringParameterCheck(request.contentId, 'DynamicsWebApi.' + functionName, 'request.contentId');
700+
if (request.contentId.startsWith('$')) {
701+
url = request.contentId + '/' + url;
702+
}
703+
}
704+
691705
//add alternate key feature
692706
if (request.key) {
693707
request.key = ErrorHelper.keyParameterCheck(request.key, 'DynamicsWebApi.' + functionName, "request.key");
@@ -1102,6 +1116,7 @@ if (!String.prototype.endsWith || !String.prototype.startsWith) {
11021116
* @property {string} userQuery - A String representing the GUID value of the user query.
11031117
* @property {boolean} mergeLabels - If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false'
11041118
* @property {boolean} isBatch - If set to 'true', DynamicsWebApi treats a request as a part of a batch request. Call ExecuteBatch to execute all requests in a batch. Default value is 'false'.
1119+
* @property {string} contentId - BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set.
11051120
*/
11061121

11071122
/**
@@ -3004,7 +3019,7 @@ var convertToBatch = function (requests) {
30043019

30053020
var batchBody = [];
30063021
var currentChangeSet = null;
3007-
var contentId = 0;
3022+
var contentId = 100000;
30083023

30093024
for (var i = 0; i < requests.length; i++) {
30103025
var request = requests[i];
@@ -3015,7 +3030,7 @@ var convertToBatch = function (requests) {
30153030
batchBody.push('\n--' + currentChangeSet + '--');
30163031

30173032
currentChangeSet = null;
3018-
contentId = 0;
3033+
contentId = 100000;
30193034
}
30203035

30213036
if (!currentChangeSet) {
@@ -3035,10 +3050,19 @@ var convertToBatch = function (requests) {
30353050
batchBody.push('Content-Transfer-Encoding: binary');
30363051

30373052
if (!isGet) {
3038-
batchBody.push('Content-ID: ' + ++contentId);
3053+
var contentIdValue = request.headers.hasOwnProperty('Content-ID')
3054+
? request.headers['Content-ID']
3055+
: ++contentId;
3056+
3057+
batchBody.push('Content-ID: ' + contentIdValue);
30393058
}
30403059

3041-
batchBody.push('\n' + request.method + ' ' + request.config.webApiUrl + request.path + ' HTTP/1.1');
3060+
if (!request.path.startsWith("$")) {
3061+
batchBody.push('\n' + request.method + ' ' + request.config.webApiUrl + request.path + ' HTTP/1.1');
3062+
}
3063+
else {
3064+
batchBody.push('\n' + request.method + ' ' + request.path + ' HTTP/1.1');
3065+
}
30423066

30433067
if (isGet) {
30443068
batchBody.push('Accept: application/json');
@@ -3048,7 +3072,7 @@ var convertToBatch = function (requests) {
30483072
}
30493073

30503074
for (var key in request.headers) {
3051-
if (key === 'Authorization')
3075+
if (key === 'Authorization' || key === 'Content-ID')
30523076
continue;
30533077

30543078
batchBody.push(key + ': ' + request.headers[key]);

dist/dynamics-web-api-callbacks.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dynamics-web-api.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dynamics-web-api v1.5.5 (c) 2019 Aleksandr Rogov */
1+
/*! dynamics-web-api v1.5.6 (c) 2019 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -828,6 +828,7 @@ if (!String.prototype.endsWith || !String.prototype.startsWith) {
828828
* @property {string} userQuery - A String representing the GUID value of the user query.
829829
* @property {boolean} mergeLabels - If set to 'true', DynamicsWebApi adds a request header 'MSCRM.MergeLabels: true'. Default value is 'false'.
830830
* @property {boolean} isBatch - If set to 'true', DynamicsWebApi treats a request as a part of a batch request. Call ExecuteBatch to execute all requests in a batch. Default value is 'false'.
831+
* @property {string} contentId - BATCH REQUESTS ONLY! Sets Content-ID header or references request in a Change Set.
831832
*/
832833

833834
/**
@@ -2548,7 +2549,7 @@ var convertToBatch = function (requests) {
25482549

25492550
var batchBody = [];
25502551
var currentChangeSet = null;
2551-
var contentId = 0;
2552+
var contentId = 100000;
25522553

25532554
for (var i = 0; i < requests.length; i++) {
25542555
var request = requests[i];
@@ -2559,7 +2560,7 @@ var convertToBatch = function (requests) {
25592560
batchBody.push('\n--' + currentChangeSet + '--');
25602561

25612562
currentChangeSet = null;
2562-
contentId = 0;
2563+
contentId = 100000;
25632564
}
25642565

25652566
if (!currentChangeSet) {
@@ -2579,10 +2580,19 @@ var convertToBatch = function (requests) {
25792580
batchBody.push('Content-Transfer-Encoding: binary');
25802581

25812582
if (!isGet) {
2582-
batchBody.push('Content-ID: ' + ++contentId);
2583+
var contentIdValue = request.headers.hasOwnProperty('Content-ID')
2584+
? request.headers['Content-ID']
2585+
: ++contentId;
2586+
2587+
batchBody.push('Content-ID: ' + contentIdValue);
25832588
}
25842589

2585-
batchBody.push('\n' + request.method + ' ' + request.config.webApiUrl + request.path + ' HTTP/1.1');
2590+
if (!request.path.startsWith("$")) {
2591+
batchBody.push('\n' + request.method + ' ' + request.config.webApiUrl + request.path + ' HTTP/1.1');
2592+
}
2593+
else {
2594+
batchBody.push('\n' + request.method + ' ' + request.path + ' HTTP/1.1');
2595+
}
25862596

25872597
if (isGet) {
25882598
batchBody.push('Accept: application/json');
@@ -2592,7 +2602,7 @@ var convertToBatch = function (requests) {
25922602
}
25932603

25942604
for (var key in request.headers) {
2595-
if (key === 'Authorization')
2605+
if (key === 'Authorization' || key === 'Content-ID')
25962606
continue;
25972607

25982608
batchBody.push(key + ': ' + request.headers[key]);
@@ -2790,6 +2800,13 @@ function convertRequestOptions(request, functionName, url, joinSymbol, config) {
27902800
headers['MSCRM.MergeLabels'] = 'true';
27912801
}
27922802

2803+
if (request.contentId) {
2804+
ErrorHelper.stringParameterCheck(request.contentId, 'DynamicsWebApi.' + functionName, 'request.contentId');
2805+
if (!request.contentId.startsWith('$')) {
2806+
headers['Content-ID'] = request.contentId;
2807+
}
2808+
}
2809+
27932810
if (request.isBatch) {
27942811
ErrorHelper.boolParameterCheck(request.isBatch, 'DynamicsWebApi.' + functionName, 'request.isBatch');
27952812
}
@@ -2840,6 +2857,13 @@ function convertRequest(request, functionName, config) {
28402857
ErrorHelper.stringParameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
28412858
url = request.collection;
28422859

2860+
if (request.contentId) {
2861+
ErrorHelper.stringParameterCheck(request.contentId, 'DynamicsWebApi.' + functionName, 'request.contentId');
2862+
if (request.contentId.startsWith('$')) {
2863+
url = request.contentId + '/' + url;
2864+
}
2865+
}
2866+
28432867
//add alternate key feature
28442868
if (request.key) {
28452869
request.key = ErrorHelper.keyParameterCheck(request.key, 'DynamicsWebApi.' + functionName, "request.key");

dist/dynamics-web-api.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dynamics-web-api",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",
55
"keywords": [
66
"crm",

0 commit comments

Comments
 (0)