breeze-client 2.1.6 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/breeze-client.metadata.json +1 -1
- package/bundles/breeze-client.umd.js +88 -38
- package/bundles/breeze-client.umd.js.map +1 -1
- package/bundles/breeze-client.umd.min.js +1 -1
- package/bundles/breeze-client.umd.min.js.map +1 -1
- package/esm2015/src/abstract-data-service-adapter.js +68 -37
- package/esm2015/src/entity-query.js +23 -4
- package/esm5/src/abstract-data-service-adapter.js +68 -37
- package/esm5/src/entity-query.js +23 -4
- package/fesm2015/breeze-client.js +88 -38
- package/fesm2015/breeze-client.js.map +1 -1
- package/fesm5/breeze-client.js +88 -38
- package/fesm5/breeze-client.js.map +1 -1
- package/package.json +1 -1
- package/src/abstract-data-service-adapter.d.ts +20 -0
- package/src/entity-query.d.ts +17 -3
package/fesm5/breeze-client.js
CHANGED
|
@@ -5112,6 +5112,7 @@ var EntityQuery = /** @class */ (function () {
|
|
|
5112
5112
|
this.parameters = {};
|
|
5113
5113
|
this.inlineCountEnabled = false;
|
|
5114
5114
|
this.noTrackingEnabled = false;
|
|
5115
|
+
this.usePostEnabled = false;
|
|
5115
5116
|
// default is to get queryOptions and dataService from the entityManager.
|
|
5116
5117
|
// this.queryOptions = new QueryOptions();
|
|
5117
5118
|
// this.dataService = new DataService();
|
|
@@ -5385,7 +5386,7 @@ var EntityQuery = /** @class */ (function () {
|
|
|
5385
5386
|
return clone(this, "parameters", parameters);
|
|
5386
5387
|
};
|
|
5387
5388
|
/**
|
|
5388
|
-
Returns a query with the
|
|
5389
|
+
Returns a query with the `inlineCount` capability either enabled or disabled. With `inlineCount` enabled, an additional 'inlineCount' property
|
|
5389
5390
|
will be returned with the query results that will contain the number of entities that would have been returned by this
|
|
5390
5391
|
query with only the 'where'/'filter' clauses applied, i.e. without any 'skip'/'take' operators applied. For local queries this clause is ignored.
|
|
5391
5392
|
> let query = new EntityQuery("Customers")
|
|
@@ -5393,7 +5394,7 @@ var EntityQuery = /** @class */ (function () {
|
|
|
5393
5394
|
> .orderBy("CompanyName")
|
|
5394
5395
|
> .inlineCount(true);
|
|
5395
5396
|
|
|
5396
|
-
will return the first 20 customers as well as a count of
|
|
5397
|
+
will return the first 20 customers as well as a count of _all_ of the customers in the remote store.
|
|
5397
5398
|
@param enabled - (default = true) Whether or not inlineCount capability should be enabled. If this parameter is omitted, true is assumed.
|
|
5398
5399
|
**/
|
|
5399
5400
|
EntityQuery.prototype.inlineCount = function (enabled) {
|
|
@@ -5407,7 +5408,7 @@ var EntityQuery = /** @class */ (function () {
|
|
|
5407
5408
|
return clone(this, "usesNameOnServer", usesNameOnServer);
|
|
5408
5409
|
};
|
|
5409
5410
|
/**
|
|
5410
|
-
Returns a query with the
|
|
5411
|
+
Returns a query with the `noTracking` capability either enabled or disabled. With `noTracking` enabled, the results of this query
|
|
5411
5412
|
will not be coerced into entities but will instead look like raw javascript projections. i.e. simple javascript objects.
|
|
5412
5413
|
> let query = new EntityQuery("Customers")
|
|
5413
5414
|
> .take(20)
|
|
@@ -5421,6 +5422,22 @@ var EntityQuery = /** @class */ (function () {
|
|
|
5421
5422
|
return clone(this, "noTrackingEnabled", enabled);
|
|
5422
5423
|
};
|
|
5423
5424
|
/**
|
|
5425
|
+
Returns a query with the `usePost` capability either enabled or disabled. With `usePost` enabled, the query is sent
|
|
5426
|
+
as a POST request (instead of GET) and the query expression will be sent as JSON in the body of the post.
|
|
5427
|
+
Note that the server must be able to parse the body of the request; otherwise the query expression will be ignored.
|
|
5428
|
+
> let query = new EntityQuery("Customers")
|
|
5429
|
+
> .where("companyId", "eq", 1)
|
|
5430
|
+
> .usePost(true);
|
|
5431
|
+
results in a POST request to `{host}/{path}/Customers`
|
|
5432
|
+
with body `{"where": {"companyId":{"eq":1}}}`
|
|
5433
|
+
@param enabled - (default = true) Whether or not usePost should be enabled. If this parameter is omitted, true is assumed.
|
|
5434
|
+
**/
|
|
5435
|
+
EntityQuery.prototype.usePost = function (enabled) {
|
|
5436
|
+
assertParam(enabled, "enabled").isBoolean().isOptional().check();
|
|
5437
|
+
enabled = (enabled === undefined) ? true : !!enabled;
|
|
5438
|
+
return clone(this, "usePostEnabled", enabled);
|
|
5439
|
+
};
|
|
5440
|
+
/**
|
|
5424
5441
|
Returns a copy of this EntityQuery with the specified [[EntityManager]], [[DataService]],
|
|
5425
5442
|
[[JsonResultsAdapter]], [[MergeStrategy]] or [[FetchStrategy]] applied.
|
|
5426
5443
|
> // 'using' can be used to return a new query with a specified EntityManager.
|
|
@@ -5733,6 +5750,7 @@ function fromJSON(eq, json) {
|
|
|
5733
5750
|
},
|
|
5734
5751
|
"inlineCountEnabled,inlineCount": false,
|
|
5735
5752
|
"noTrackingEnabled,noTracking": false,
|
|
5753
|
+
"usePostEnabled,usePost": false,
|
|
5736
5754
|
queryOptions: function (v) {
|
|
5737
5755
|
return v ? QueryOptions.fromJSON(v) : undefined;
|
|
5738
5756
|
}
|
|
@@ -5757,6 +5775,7 @@ function clone(eq, propName, value) {
|
|
|
5757
5775
|
"expandClause",
|
|
5758
5776
|
"inlineCountEnabled",
|
|
5759
5777
|
"noTrackingEnabled",
|
|
5778
|
+
"usePostEnabled",
|
|
5760
5779
|
"usesNameOnServer",
|
|
5761
5780
|
"queryOptions",
|
|
5762
5781
|
"entityManager",
|
|
@@ -10080,52 +10099,83 @@ var AbstractDataServiceAdapter = /** @class */ (function () {
|
|
|
10080
10099
|
});
|
|
10081
10100
|
return promise;
|
|
10082
10101
|
};
|
|
10102
|
+
/** Execute the query in the mappingContext using the ajaxImpl. */
|
|
10083
10103
|
AbstractDataServiceAdapter.prototype.executeQuery = function (mappingContext) {
|
|
10084
10104
|
var _this = this;
|
|
10085
10105
|
mappingContext.adapter = this;
|
|
10106
|
+
var usePost = mappingContext.query.usePostEnabled;
|
|
10107
|
+
var params = usePost ? this._makeQueryPostParams(mappingContext) : this._makeQueryGetParams(mappingContext);
|
|
10086
10108
|
var promise = new Promise(function (resolve, reject) {
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
try {
|
|
10096
|
-
var rData = void 0;
|
|
10097
|
-
var results = data && (data.results || data.Results);
|
|
10098
|
-
if (results) {
|
|
10099
|
-
rData = { results: results, inlineCount: data.inlineCount || data.InlineCount,
|
|
10100
|
-
httpResponse: httpResponse, query: mappingContext.query };
|
|
10101
|
-
}
|
|
10102
|
-
else {
|
|
10103
|
-
rData = { results: data, httpResponse: httpResponse, query: mappingContext.query };
|
|
10104
|
-
}
|
|
10105
|
-
resolve(rData);
|
|
10109
|
+
params.success = function (httpResponse) {
|
|
10110
|
+
var data = httpResponse.data;
|
|
10111
|
+
try {
|
|
10112
|
+
var rData = void 0;
|
|
10113
|
+
var results = data && (data.results || data.Results);
|
|
10114
|
+
if (results) {
|
|
10115
|
+
rData = { results: results, inlineCount: data.inlineCount || data.InlineCount,
|
|
10116
|
+
httpResponse: httpResponse, query: mappingContext.query };
|
|
10106
10117
|
}
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
reject(e);
|
|
10110
|
-
}
|
|
10111
|
-
else {
|
|
10112
|
-
handleHttpError(reject, httpResponse);
|
|
10113
|
-
}
|
|
10118
|
+
else {
|
|
10119
|
+
rData = { results: data, httpResponse: httpResponse, query: mappingContext.query };
|
|
10114
10120
|
}
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10121
|
+
resolve(rData);
|
|
10122
|
+
}
|
|
10123
|
+
catch (e) {
|
|
10124
|
+
if (e instanceof Error) {
|
|
10125
|
+
reject(e);
|
|
10126
|
+
}
|
|
10127
|
+
else {
|
|
10128
|
+
handleHttpError(reject, httpResponse);
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
};
|
|
10132
|
+
params.error = function (httpResponse) {
|
|
10133
|
+
handleHttpError(reject, httpResponse);
|
|
10120
10134
|
};
|
|
10121
|
-
if (mappingContext.dataService.useJsonp) {
|
|
10122
|
-
params.dataType = 'jsonp';
|
|
10123
|
-
params.crossDomain = true;
|
|
10124
|
-
}
|
|
10125
10135
|
_this.ajaxImpl.ajax(params);
|
|
10126
10136
|
});
|
|
10127
10137
|
return promise;
|
|
10128
10138
|
};
|
|
10139
|
+
/** Set up ajax parameters for query GET. This puts the query into the request querystring in either JSON or OData-style syntax, depending upon the UriBuilder. */
|
|
10140
|
+
AbstractDataServiceAdapter.prototype._makeQueryGetParams = function (mappingContext) {
|
|
10141
|
+
var url = mappingContext.getUrl();
|
|
10142
|
+
var params = {
|
|
10143
|
+
type: "GET",
|
|
10144
|
+
url: url,
|
|
10145
|
+
params: mappingContext.query.parameters,
|
|
10146
|
+
dataType: 'json',
|
|
10147
|
+
crossDomain: false,
|
|
10148
|
+
};
|
|
10149
|
+
if (mappingContext.dataService.useJsonp) {
|
|
10150
|
+
params.dataType = 'jsonp';
|
|
10151
|
+
params.crossDomain = true;
|
|
10152
|
+
}
|
|
10153
|
+
return params;
|
|
10154
|
+
};
|
|
10155
|
+
/** Set up ajax parameters for query POST. This put the query into the request body as JSON. */
|
|
10156
|
+
AbstractDataServiceAdapter.prototype._makeQueryPostParams = function (mappingContext) {
|
|
10157
|
+
var entityQuery = mappingContext.query;
|
|
10158
|
+
var metadataStore = mappingContext.entityManager.metadataStore;
|
|
10159
|
+
var url = mappingContext.dataService.qualifyUrl(entityQuery.resourceName);
|
|
10160
|
+
var entityType = entityQuery._getFromEntityType(metadataStore, false);
|
|
10161
|
+
if (!entityType) {
|
|
10162
|
+
entityType = new EntityType(metadataStore);
|
|
10163
|
+
}
|
|
10164
|
+
var json = entityQuery.toJSONExt({ entityType: entityType, toNameOnServer: true });
|
|
10165
|
+
json.from = undefined;
|
|
10166
|
+
json.queryOptions = undefined;
|
|
10167
|
+
var params = {
|
|
10168
|
+
type: "POST",
|
|
10169
|
+
url: url,
|
|
10170
|
+
params: mappingContext.query.parameters,
|
|
10171
|
+
dataType: 'json',
|
|
10172
|
+
processData: false,
|
|
10173
|
+
contentType: "application/json; charset=UTF-8",
|
|
10174
|
+
data: JSON.stringify(json),
|
|
10175
|
+
crossDomain: false,
|
|
10176
|
+
};
|
|
10177
|
+
return params;
|
|
10178
|
+
};
|
|
10129
10179
|
AbstractDataServiceAdapter.prototype.saveChanges = function (saveContext, saveBundle) {
|
|
10130
10180
|
var _this = this;
|
|
10131
10181
|
var adapter = saveContext.adapter = this;
|