breeze-client
Advanced tools
Comparing version 1.5.6 to 1.5.7
@@ -29,3 +29,3 @@ // jQuery ajax adapter ( JQuery v.>=1.5 ) | ||
// look for the jQuery lib but don't fail immediately if not found | ||
jQuery = core.requireLib("jQuery"); | ||
jQuery = core.requireLib("jQuery;jquery"); | ||
}; | ||
@@ -32,0 +32,0 @@ |
@@ -18,2 +18,4 @@ (function (factory) { | ||
var DataProperty = breeze.DataProperty; | ||
var DataType = breeze.DataType; | ||
var AutoGeneratedKeyType = breeze.AutoGeneratedKeyType; | ||
@@ -39,2 +41,16 @@ var OData; | ||
// Absolute URL is the default as of Breeze 1.5.5. | ||
// To use relative URL (like pre-1.5.5), add adapterInstance.relativeUrl = true: | ||
// | ||
// var ds = breeze.config.initializeAdapterInstance("dataService", "webApiOData"); | ||
// ds.relativeUrl = true; | ||
// | ||
// To use custom url construction, add adapterInstance.relativeUrl = myfunction(dataService, url): | ||
// | ||
// var ds = breeze.config.initializeAdapterInstance("dataService", "webApiOData"); | ||
// ds.relativeUrl = function(dataService, url) { | ||
// return somehowConvert(url); | ||
// } | ||
// | ||
proto.getAbsoluteUrl = function (dataService, url){ | ||
@@ -54,11 +70,55 @@ var serviceName = dataService.qualifyUrl(''); | ||
// getRoutePrefix deprecated in favor of getAbsoluteUrl which seems to work for all OData providers; doubt anyone ever changed it; we'll see | ||
// TODO: Remove from code base soon (15 June 2015) | ||
// proto.getRoutePrefix = function (dataService) { return '';} | ||
proto.getRoutePrefix = function (dataService) { | ||
// Get the routePrefix from a Web API OData service name. | ||
// The routePrefix is presumed to be the pathname within the dataService.serviceName | ||
// Examples of servicename -> routePrefix: | ||
// 'http://localhost:55802/odata/' -> 'odata/' | ||
// 'http://198.154.121.75/service/odata/' -> 'service/odata/' | ||
var parser; | ||
if (typeof document === 'object') { // browser | ||
parser = document.createElement('a'); | ||
parser.href = dataService.serviceName; | ||
} else { // node | ||
parser = url.parse(dataService.serviceName); | ||
} | ||
var prefix = parser.pathname; | ||
if (prefix[0] === '/') { | ||
prefix = prefix.substr(1); | ||
} // drop leading '/' (all but IE) | ||
if (prefix.substr(-1) !== '/') { | ||
prefix += '/'; | ||
} // ensure trailing '/' | ||
return prefix; | ||
}; | ||
// crude serializer. Doesn't recurse | ||
function toQueryString(obj) { | ||
var parts = []; | ||
for (var i in obj) { | ||
if (obj.hasOwnProperty(i)) { | ||
parts.push(encodeURIComponent(i) + "=" + encodeURIComponent(obj[i])); | ||
} | ||
} | ||
return parts.join("&"); | ||
} | ||
proto.executeQuery = function (mappingContext) { | ||
var deferred = Q.defer(); | ||
var url = this.getAbsoluteUrl(mappingContext.dataService, mappingContext.getUrl()); | ||
var deferred = breeze.Q.defer(); | ||
var url; | ||
if (this.relativeUrl === true) { | ||
url = mappingContext.getUrl(); | ||
} else if (core.isFunction(this.relativeUrl)) { | ||
url = this.relativeUrl(mappingContext.dataService, mappingContext.getUrl()); | ||
} else { | ||
url = this.getAbsoluteUrl(mappingContext.dataService, mappingContext.getUrl()); | ||
} | ||
// Add query params if .withParameters was used | ||
if (mappingContext.query.parameters) { | ||
var paramString = toQueryString(mappingContext.query.parameters); | ||
var sep = url.indexOf("?") < 0 ? "?" : "&"; | ||
url = url + sep + paramString; | ||
} | ||
OData.read({ | ||
@@ -74,3 +134,12 @@ requestUri: url, | ||
} | ||
return deferred.resolve({ results: data.results, inlineCount: inlineCount, httpResponse: response }); | ||
// Odata returns different result structure when it returns multiple entities (data.results) vs single entity (data directly). | ||
// @see http://www.odata.org/documentation/odata-version-2-0/json-format/#RepresentingCollectionsOfEntries | ||
// and http://www.odata.org/documentation/odata-version-2-0/json-format/#RepresentingEntries | ||
var results; | ||
if (data.results) { | ||
results = data.results; | ||
} else { | ||
results = data; | ||
} | ||
return deferred.resolve({ results: results, inlineCount: inlineCount, httpResponse: response }); | ||
}, | ||
@@ -87,7 +156,15 @@ function (error) { | ||
var deferred = Q.defer(); | ||
var deferred = breeze.Q.defer(); | ||
var serviceName = dataService.serviceName; | ||
//var url = dataService.qualifyUrl('$metadata'); | ||
var url = this.getAbsoluteUrl(dataService, '$metadata'); | ||
var url; | ||
if (this.relativeUrl === true) { | ||
url = dataService.qualifyUrl('$metadata'); | ||
} else if (core.isFunction(this.relativeUrl)) { | ||
url = this.relativeUrl(dataService, '$metadata'); | ||
} else { | ||
url = this.getAbsoluteUrl(dataService, '$metadata'); | ||
} | ||
// OData.read(url, | ||
@@ -137,8 +214,16 @@ OData.read({ | ||
var adapter = saveContext.adapter = this; | ||
var deferred = Q.defer(); | ||
//saveContext.routePrefix = adapter.getRoutePrefix(saveContext.dataService); | ||
//var url = saveContext.dataService.qualifyUrl("$batch"); | ||
saveContext.routePrefix = adapter.getAbsoluteUrl(saveContext.dataService, ''); | ||
var url = saveContext.routePrefix + '$batch'; | ||
var deferred = breeze.Q.defer(); | ||
var url; | ||
if (this.relativeUrl === true) { | ||
saveContext.routePrefix = adapter.getRoutePrefix(saveContext.dataService); | ||
url = saveContext.dataService.qualifyUrl("$batch"); | ||
} else if (core.isFunction(adapter.relativeUrl)) { | ||
saveContext.routePrefix = adapter.relativeUrl(saveContext.dataService, ''); | ||
url = saveContext.routePrefix + '$batch'; | ||
} else { | ||
saveContext.routePrefix = adapter.getAbsoluteUrl(saveContext.dataService, ''); | ||
url = saveContext.routePrefix + '$batch'; | ||
} | ||
var requestData = createChangeRequests(saveContext, saveBundle); | ||
@@ -167,2 +252,6 @@ var tempKeys = saveContext.tempKeys; | ||
var contentId = cr.headers["Content-ID"]; | ||
// Olingo sends different case of 'ID' for the header name. | ||
if (!contentId) { | ||
contentId = cr.headers["Content-Id"]; | ||
} | ||
@@ -401,29 +490,2 @@ var rawEntity = cr.data; | ||
/* | ||
// Deprecated in favor of getAbsoluteUrl | ||
// TODO: Remove from code base soon (15 June 2015) | ||
webApiODataCtor.prototype.getRoutePrefix = function (dataService) { | ||
// Get the routePrefix from a Web API OData service name. | ||
// The routePrefix is presumed to be the pathname within the dataService.serviceName | ||
// Examples of servicename -> routePrefix: | ||
// 'http://localhost:55802/odata/' -> 'odata/' | ||
// 'http://198.154.121.75/service/odata/' -> 'service/odata/' | ||
var parser; | ||
if (typeof document === 'object') { // browser | ||
parser = document.createElement('a'); | ||
parser.href = dataService.serviceName; | ||
} else { // node | ||
parser = url.parse(dataService.serviceName); | ||
} | ||
var prefix = parser.pathname; | ||
if (prefix[0] === '/') { | ||
prefix = prefix.substr(1); | ||
} // drop leading '/' (all but IE) | ||
if (prefix.substr(-1) !== '/') { | ||
prefix += '/'; | ||
} // ensure trailing '/' | ||
return prefix; | ||
}; | ||
*/ | ||
breeze.config.registerAdapter("dataService", webApiODataCtor); | ||
@@ -430,0 +492,0 @@ // OData 4 adapter |
@@ -30,3 +30,3 @@ (function (factory) { | ||
protoFn.initialize = function () { | ||
Backbone = core.requireLib("Backbone"); | ||
Backbone = core.requireLib("Backbone;backbone"); | ||
_ = core.requireLib("_;underscore"); | ||
@@ -33,0 +33,0 @@ bbSet = Backbone.Model.prototype.set; |
@@ -25,3 +25,3 @@ (function (factory) { | ||
protoFn.initialize = function () { | ||
ko = core.requireLib("ko", "The Knockout library"); | ||
ko = core.requireLib("ko;knockout", "The Knockout library"); | ||
ko.extenders.intercept = function (target, interceptorOptions) { | ||
@@ -28,0 +28,0 @@ var instance = interceptorOptions.instance; |
{ | ||
"name": "breeze-client", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"description": "Breeze Javascript client", | ||
@@ -5,0 +5,0 @@ "main": "breeze.debug", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2435288
51216
3