Skip to content

Commit dde5981

Browse files
Release v1.4.3
1 parent b6d7965 commit dde5981

File tree

7 files changed

+446
-52
lines changed

7 files changed

+446
-52
lines changed

dist/dwa.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dwa v1.4.2 (c) 2018 Aleksandr Rogov */
1+
/*! dwa v1.4.3 (c) 2018 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();

dist/dynamics-web-api-callbacks.js

Lines changed: 223 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! dynamics-web-api-callbacks v1.4.2 (c) 2018 Aleksandr Rogov */
1+
/*! dynamics-web-api-callbacks v1.4.3 (c) 2018 Aleksandr Rogov */
22
(function webpackUniversalModuleDefinition(root, factory) {
33
if(typeof exports === 'object' && typeof module === 'object')
44
module.exports = factory();
@@ -382,22 +382,34 @@ var buildPreferHeader = __webpack_require__(12);
382382
function convertRequestOptions(request, functionName, url, joinSymbol, config) {
383383
var headers = {};
384384
var requestArray = [];
385-
joinSymbol = joinSymbol != null ? joinSymbol : "&";
385+
joinSymbol = joinSymbol != null ? joinSymbol : '&';
386386

387387
if (request) {
388388
if (request.navigationProperty) {
389-
ErrorHelper.stringParameterCheck(request.navigationProperty, 'DynamicsWebApi.' + functionName, "request.navigationProperty");
390-
url += "/" + request.navigationProperty;
389+
ErrorHelper.stringParameterCheck(request.navigationProperty, 'DynamicsWebApi.' + functionName, 'request.navigationProperty');
390+
url += '/' + request.navigationProperty;
391+
392+
if (request.navigationPropertyKey) {
393+
var navigationKey = ErrorHelper.keyParameterCheck(request.navigationPropertyKey, 'DynamicsWebApi.' + functionName, 'request.navigationPropertyKey');
394+
url += '(' + navigationKey + ')';
395+
}
396+
397+
if (request.navigationProperty === 'Attributes') {
398+
if (request.metadataAttributeType) {
399+
ErrorHelper.stringParameterCheck(request.metadataAttributeType, 'DynamicsWebApi.' + functionName, 'request.metadataAttributeType');
400+
url += '/' + request.metadataAttributeType;
401+
}
402+
}
391403
}
392404

393405
if (request.select != null && request.select.length) {
394-
ErrorHelper.arrayParameterCheck(request.select, 'DynamicsWebApi.' + functionName, "request.select");
406+
ErrorHelper.arrayParameterCheck(request.select, 'DynamicsWebApi.' + functionName, 'request.select');
395407

396-
if (functionName == "retrieve" && request.select.length == 1 && request.select[0].endsWith("/$ref")) {
397-
url += "/" + request.select[0];
408+
if (functionName == 'retrieve' && request.select.length == 1 && request.select[0].endsWith('/$ref')) {
409+
url += '/' + request.select[0];
398410
}
399411
else {
400-
if (request.select[0].startsWith("/") && functionName == "retrieve") {
412+
if (request.select[0].startsWith('/') && functionName == 'retrieve') {
401413
if (request.navigationProperty == null) {
402414
url += request.select.shift();
403415
}
@@ -408,7 +420,7 @@ function convertRequestOptions(request, functionName, url, joinSymbol, config) {
408420

409421
//check if anything left in the array
410422
if (request.select.length) {
411-
requestArray.push("$select=" + request.select.join(','));
423+
requestArray.push('$select=' + request.select.join(','));
412424
}
413425
}
414426
}
@@ -1148,7 +1160,7 @@ function DynamicsWebApi(config) {
11481160
var entityUrl = response.headers['OData-EntityId']
11491161
? response.headers['OData-EntityId']
11501162
: response.headers['odata-entityid'];
1151-
var id = /[0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12}/i.exec(entityUrl)[0];
1163+
var id = /([0-9A-F]{8}[-]?([0-9A-F]{4}[-]?){3}[0-9A-F]{12})\)$/i.exec(entityUrl)[1];
11521164
successCallback(id);
11531165
}
11541166
}
@@ -2065,7 +2077,207 @@ function DynamicsWebApi(config) {
20652077
};
20662078

20672079
_makeRequest('POST', request, 'executeAction', onSuccess, errorCallback);
2068-
}
2080+
};
2081+
2082+
/**
2083+
* Sends an asynchronous request to create an entity definition.
2084+
*
2085+
* @param {string} entityDefinition - Entity Definition.
2086+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2087+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2088+
*/
2089+
this.createEntity = function (entityDefinition, successCallback, errorCallback) {
2090+
2091+
ErrorHelper.parameterCheck(entityDefinition, 'DynamicsWebApi.createEntity', 'entityDefinition');
2092+
2093+
var request = {
2094+
collection: 'EntityDefinitions',
2095+
entity: entityDefinition
2096+
};
2097+
this.createRequest(request, successCallback, errorCallback);
2098+
};
2099+
2100+
/**
2101+
* Sends an asynchronous request to update an entity definition.
2102+
*
2103+
* @param {string} entityDefinition - Entity Definition.
2104+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2105+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2106+
* @param {boolean} [mergeLabels] - Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.
2107+
*/
2108+
this.updateEntity = function (entityDefinition, successCallback, errorCallback, mergeLabels) {
2109+
2110+
ErrorHelper.parameterCheck(entityDefinition, 'DynamicsWebApi.updateEntity', 'entityDefinition');
2111+
ErrorHelper.guidParameterCheck(entityDefinition.MetadataId, 'DynamicsWebApi.updateEntity', 'entityDefinition.MetadataId');
2112+
2113+
var request = {
2114+
collection: 'EntityDefinitions',
2115+
mergeLabels: mergeLabels,
2116+
key: entityDefinition.MetadataId,
2117+
entity: entityDefinition
2118+
};
2119+
this.updateRequest(request, successCallback, errorCallback);
2120+
};
2121+
2122+
/**
2123+
* Sends an asynchronous request to retrieve a specific entity definition.
2124+
*
2125+
* @param {string} entityKey - The Entity MetadataId or Alternate Key (such as LogicalName).
2126+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2127+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2128+
* @param {Array} [select] - Use the $select system query option to limit the properties returned.
2129+
* @param {string|Array} [expand] - A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.
2130+
*/
2131+
this.retrieveEntity = function (entityKey, successCallback, errorCallback, select, expand) {
2132+
2133+
ErrorHelper.keyParameterCheck(entityKey, 'DynamicsWebApi.retrieveEntity', 'entityKey');
2134+
2135+
var request = {
2136+
collection: 'EntityDefinitions',
2137+
key: entityKey,
2138+
select: select,
2139+
expand: expand
2140+
};
2141+
2142+
this.retrieveRequest(request, successCallback, errorCallback);
2143+
};
2144+
2145+
/**
2146+
* Sends an asynchronous request to retrieve entity definitions.
2147+
*
2148+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2149+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2150+
* @param {Array} [select] - Use the $select system query option to limit the properties returned.
2151+
* @param {string} [filter] - Use the $filter system query option to set criteria for which entity definitions will be returned.
2152+
*/
2153+
this.retrieveEntities = function (successCallback, errorCallback, select, filter) {
2154+
var request = {
2155+
collection: 'EntityDefinitions',
2156+
select: select,
2157+
filter: filter
2158+
};
2159+
2160+
this.retrieveRequest(request, successCallback, errorCallback);
2161+
};
2162+
2163+
/**
2164+
* Sends an asynchronous request to create an attribute.
2165+
*
2166+
* @param {string} entityKey - The Entity MetadataId or Alternate Key (such as LogicalName).
2167+
* @param {Object} attributeDefinition - Object that describes the attribute.
2168+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2169+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2170+
*/
2171+
this.createAttribute = function (entityKey, attributeDefinition, successCallback, errorCallback) {
2172+
ErrorHelper.keyParameterCheck(entityKey, 'DynamicsWebApi.createAttribute', 'entityKey');
2173+
ErrorHelper.parameterCheck(attributeDefinition, 'DynamicsWebApi.createAttribute', 'attributeDefinition');
2174+
2175+
var request = {
2176+
collection: 'EntityDefinitions',
2177+
key: entityKey,
2178+
entity: attributeDefinition,
2179+
navigationProperty: 'Attributes'
2180+
};
2181+
2182+
this.createRequest(request, successCallback, errorCallback);
2183+
};
2184+
2185+
/**
2186+
* Sends an asynchronous request to update an attribute.
2187+
*
2188+
* @param {string} entityKey - The Entity MetadataId or Alternate Key (such as LogicalName).
2189+
* @param {Object} attributeDefinition - Object that describes the attribute.
2190+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2191+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2192+
* @param {string} [attributeType] - Use this parameter to cast the Attribute to a specific type.
2193+
* @param {boolean} [mergeLabels] - Sets MSCRM.MergeLabels header that controls whether to overwrite the existing labels or merge your new label with any existing language labels. Default value is false.
2194+
*/
2195+
this.updateAttribute = function (entityKey, attributeDefinition, successCallback, errorCallback, attributeType, mergeLabels) {
2196+
ErrorHelper.keyParameterCheck(entityKey, 'DynamicsWebApi.updateAttribute', 'entityKey');
2197+
ErrorHelper.parameterCheck(attributeDefinition, 'DynamicsWebApi.updateAttribute', 'attributeDefinition');
2198+
ErrorHelper.guidParameterCheck(attributeDefinition.MetadataId, 'DynamicsWebApi.updateAttribute', 'attributeDefinition.MetadataId');
2199+
2200+
if (attributeType) {
2201+
ErrorHelper.stringParameterCheck(attributeType, 'DynamicsWebApi.updateAttribute', 'attributeType');
2202+
}
2203+
2204+
var request = {
2205+
collection: 'EntityDefinitions',
2206+
key: entityKey,
2207+
entity: attributeDefinition,
2208+
navigationProperty: 'Attributes',
2209+
navigationPropertyKey: attributeDefinition.MetadataId,
2210+
mergeLabels: mergeLabels,
2211+
metadataAttributeType: attributeType
2212+
};
2213+
2214+
this.updateRequest(request, successCallback, errorCallback);
2215+
};
2216+
2217+
/**
2218+
* Sends an asynchronous request to retrieve attribute metadata for a specified entity definition.
2219+
*
2220+
* @param {string} entityKey - The Entity MetadataId or Alternate Key (such as LogicalName).
2221+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2222+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2223+
* @param {string} [attributeType] - Use this parameter to cast the Attributes to a specific type.
2224+
* @param {Array} [select] - Use the $select system query option to limit the properties returned.
2225+
* @param {string} [filter] - Use the $filter system query option to set criteria for which attribute definitions will be returned.
2226+
* @param {string|Array} [expand] - A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.
2227+
*/
2228+
this.retrieveAttributes = function (entityKey, successCallback, errorCallback, attributeType, select, filter, expand) {
2229+
2230+
ErrorHelper.keyParameterCheck(entityKey, 'DynamicsWebApi.retrieveAttributes', 'entityKey');
2231+
2232+
if (attributeType) {
2233+
ErrorHelper.stringParameterCheck(attributeType, 'DynamicsWebApi.retrieveAttributes', 'attributeType');
2234+
}
2235+
2236+
var request = {
2237+
collection: 'EntityDefinitions',
2238+
key: entityKey,
2239+
navigationProperty: 'Attributes',
2240+
select: select,
2241+
filter: filter,
2242+
expand: expand,
2243+
metadataAttributeType: attributeType
2244+
};
2245+
2246+
this.retrieveRequest(request, successCallback, errorCallback);
2247+
};
2248+
2249+
/**
2250+
* Sends an asynchronous request to retrieve a specific attribute metadata for a specified entity definition.
2251+
*
2252+
* @param {string} entityKey - The Entity MetadataId or Alternate Key (such as LogicalName).
2253+
* @param {string} attributeKey - The Attribute Metadata id.
2254+
* @param {Function} successCallback - The function that will be passed through and be called by a successful response.
2255+
* @param {Function} errorCallback - The function that will be passed through and be called by a failed response.
2256+
* @param {string} [attributeType] - Use this parameter to cast the Attribute to a specific type.
2257+
* @param {Array} [select] - Use the $select system query option to limit the properties returned.
2258+
* @param {string|Array} [expand] - A String or Array of Expand Objects representing the $expand Query Option value to control which related records need to be returned.
2259+
*/
2260+
this.retrieveAttribute = function (entityKey, attributeKey, successCallback, errorCallback, attributeType, select, expand) {
2261+
2262+
ErrorHelper.keyParameterCheck(entityKey, 'DynamicsWebApi.retrieveAttribute', 'entityKey');
2263+
ErrorHelper.keyParameterCheck(attributeKey, 'DynamicsWebApi.retrieveAttribute', 'attributeKey');
2264+
2265+
if (attributeType) {
2266+
ErrorHelper.stringParameterCheck(attributeType, 'DynamicsWebApi.retrieveAttribute', 'attributeType');
2267+
}
2268+
2269+
var request = {
2270+
collection: 'EntityDefinitions',
2271+
key: entityKey,
2272+
navigationProperty: 'Attributes',
2273+
select: select,
2274+
expand: expand,
2275+
metadataAttributeType: attributeType,
2276+
navigationPropertyKey: attributeKey
2277+
};
2278+
2279+
this.retrieveRequest(request, successCallback, errorCallback);
2280+
};
20692281

20702282
/**
20712283
* Creates a new instance of DynamicsWebApi

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.

0 commit comments

Comments
 (0)