igniteui-webcomponents-datasources 7.1.1-beta.1 → 7.1.1-beta.2

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.
Files changed (66) hide show
  1. package/fesm2022/igniteui-webcomponents-datasources.mjs +3611 -0
  2. package/igniteui-webcomponents-datasources.d.ts +754 -1
  3. package/package.json +13 -9
  4. package/bundles/igniteui-webcomponents-datasources.umd.js +0 -4725
  5. package/bundles/igniteui-webcomponents-datasources.umd.min.js +0 -7
  6. package/esm2015/igniteui-webcomponents-datasources.js +0 -1
  7. package/esm2015/lib/Entity.js +0 -65
  8. package/esm2015/lib/EntityProperty.js +0 -27
  9. package/esm2015/lib/EntitySet.js +0 -50
  10. package/esm2015/lib/ODataDataSourcePage.js +0 -67
  11. package/esm2015/lib/ODataSchemaProvider.js +0 -123
  12. package/esm2015/lib/ODataVirtualDataSource.js +0 -132
  13. package/esm2015/lib/ODataVirtualDataSourceDataProvider.js +0 -453
  14. package/esm2015/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -713
  15. package/esm2015/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -86
  16. package/esm2015/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -9
  17. package/esm2015/lib/RestVirtualDataSource.js +0 -272
  18. package/esm2015/lib/RestVirtualDataSourceDataProvider.js +0 -538
  19. package/esm2015/lib/RestVirtualDataSourceDataProviderWorker.js +0 -765
  20. package/esm2015/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -162
  21. package/esm2015/lib/RestVirtualDataSourcePage.js +0 -67
  22. package/esm2015/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -9
  23. package/esm2015/lib/Schema.js +0 -54
  24. package/esm2015/lib/util.js +0 -116
  25. package/esm2015/public_api.js +0 -18
  26. package/esm5/igniteui-webcomponents-datasources.js +0 -1
  27. package/esm5/lib/Entity.js +0 -79
  28. package/esm5/lib/EntityProperty.js +0 -41
  29. package/esm5/lib/EntitySet.js +0 -68
  30. package/esm5/lib/ODataDataSourcePage.js +0 -73
  31. package/esm5/lib/ODataSchemaProvider.js +0 -158
  32. package/esm5/lib/ODataVirtualDataSource.js +0 -169
  33. package/esm5/lib/ODataVirtualDataSourceDataProvider.js +0 -558
  34. package/esm5/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -920
  35. package/esm5/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -130
  36. package/esm5/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -11
  37. package/esm5/lib/RestVirtualDataSource.js +0 -357
  38. package/esm5/lib/RestVirtualDataSourceDataProvider.js +0 -687
  39. package/esm5/lib/RestVirtualDataSourceDataProviderWorker.js +0 -967
  40. package/esm5/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -250
  41. package/esm5/lib/RestVirtualDataSourcePage.js +0 -73
  42. package/esm5/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -11
  43. package/esm5/lib/Schema.js +0 -68
  44. package/esm5/lib/util.js +0 -160
  45. package/esm5/public_api.js +0 -18
  46. package/fesm2015/igniteui-webcomponents-datasources.js +0 -3638
  47. package/fesm5/igniteui-webcomponents-datasources.js +0 -4698
  48. package/lib/Entity.d.ts +0 -14
  49. package/lib/EntityProperty.d.ts +0 -12
  50. package/lib/EntitySet.d.ts +0 -15
  51. package/lib/ODataDataSourcePage.d.ts +0 -19
  52. package/lib/ODataSchemaProvider.d.ts +0 -12
  53. package/lib/ODataVirtualDataSource.d.ts +0 -28
  54. package/lib/ODataVirtualDataSourceDataProvider.d.ts +0 -120
  55. package/lib/ODataVirtualDataSourceDataProviderWorker.d.ts +0 -57
  56. package/lib/ODataVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -42
  57. package/lib/ODataVirtualDataSourceProviderTaskDataHolder.d.ts +0 -5
  58. package/lib/RestVirtualDataSource.d.ts +0 -86
  59. package/lib/RestVirtualDataSourceDataProvider.d.ts +0 -171
  60. package/lib/RestVirtualDataSourceDataProviderWorker.d.ts +0 -70
  61. package/lib/RestVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -93
  62. package/lib/RestVirtualDataSourcePage.d.ts +0 -19
  63. package/lib/RestVirtualDataSourceProviderTaskDataHolder.d.ts +0 -5
  64. package/lib/Schema.d.ts +0 -15
  65. package/lib/util.d.ts +0 -27
  66. package/public_api.d.ts +0 -18
@@ -1,967 +0,0 @@
1
- import { __extends, __generator, __values } from "tslib";
2
- import { AsyncVirtualDataSourceProviderWorker } from "igniteui-webcomponents-core";
3
- import { SortDescriptionCollection } from "igniteui-webcomponents-core";
4
- import { RestVirtualDataSourceProviderTaskDataHolder } from "./RestVirtualDataSourceProviderTaskDataHolder";
5
- import { AsyncDataSourcePageTaskHolder } from "igniteui-webcomponents-core";
6
- import { AsyncVirtualDataTask } from "igniteui-webcomponents-core";
7
- import { RestVirtualDataSourcePage } from "./RestVirtualDataSourcePage";
8
- import { DefaultSectionInformation } from "igniteui-webcomponents-core";
9
- import { Convert } from "igniteui-webcomponents-core";
10
- import { ODataDataSourceFilterExpressionVisitor } from "igniteui-webcomponents-core";
11
- import { ListSortDirection } from "igniteui-webcomponents-core";
12
- import { stringIsNullOrEmpty } from "igniteui-webcomponents-core";
13
- import { DataSourceSummaryOperand } from "igniteui-webcomponents-core";
14
- import { DataSourceSummaryScope } from "igniteui-webcomponents-core";
15
- import { DefaultSummaryResult } from "igniteui-webcomponents-core";
16
- import { LocalDataSource } from "igniteui-webcomponents-core";
17
- import { DefaultDataSourceSchema } from "igniteui-webcomponents-core";
18
- export var RestVirtualDataSourceDataProviderWorker = /** @class */ /*@__PURE__*/ (function (_super) {
19
- __extends(RestVirtualDataSourceDataProviderWorker, _super);
20
- function RestVirtualDataSourceDataProviderWorker(settings) {
21
- var e_1, _a;
22
- var _this = _super.call(this, settings) || this;
23
- _this._baseUri = null;
24
- _this._entitySet = null;
25
- _this._sortDescriptions = null;
26
- _this._groupDescriptions = null;
27
- _this._filterExpressions = null;
28
- _this._summaryDescriptions = null;
29
- _this._desiredPropeties = null;
30
- _this._schemaIncludedProperties = null;
31
- _this._enableJsonp = true;
32
- _this._isAggregationSupported = false;
33
- _this._provideFullCount = null;
34
- _this._provideOrderByParameter = null;
35
- _this._provideFilterParameter = null;
36
- _this._provideAggregationParameter = null;
37
- _this._provideAggregatedCount = null;
38
- _this._providePagingParameter = null;
39
- _this._provideDesiredPropertiesParameter = null;
40
- _this._provideUri = null;
41
- _this._performFetch = null;
42
- _this._fixedFullCount = -1;
43
- _this._groupInformation = null;
44
- _this._summaryInformation = null;
45
- _this._filterString = null;
46
- _this._selectedString = null;
47
- _this.doWork = _this.doWork.bind(_this);
48
- _this._baseUri = settings.baseUri;
49
- _this._entitySet = settings.entitySet;
50
- _this._sortDescriptions = settings.sortDescriptions;
51
- _this._groupDescriptions = settings.groupDescriptions;
52
- if (_this._groupDescriptions != null && _this._groupDescriptions.size() > 0) {
53
- _this._sortDescriptions = new SortDescriptionCollection();
54
- try {
55
- for (var _b = __values(_this.iter(settings.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
56
- var sd = _c.value;
57
- _this._sortDescriptions.add(sd);
58
- }
59
- }
60
- catch (e_1_1) {
61
- e_1 = { error: e_1_1 };
62
- }
63
- finally {
64
- try {
65
- if (_c && !_c.done && (_a = _b.return))
66
- _a.call(_b);
67
- }
68
- finally {
69
- if (e_1)
70
- throw e_1.error;
71
- }
72
- }
73
- for (var i = 0; i < _this._groupDescriptions.size(); i++) {
74
- _this._sortDescriptions.insert(i, _this._groupDescriptions.get(i));
75
- }
76
- }
77
- _this._filterExpressions = settings.filterExpressions;
78
- _this._desiredPropeties = settings.propertiesRequested;
79
- if (settings.schemaIncludedProperties != null) {
80
- _this._schemaIncludedProperties = new Set();
81
- for (var i = 0; i < settings.schemaIncludedProperties.length; i++) {
82
- _this._schemaIncludedProperties.add(settings.schemaIncludedProperties[i]);
83
- }
84
- }
85
- _this._summaryDescriptions = settings.summaryDescriptions;
86
- _this._fixedFullCount = settings.fixedFullCount;
87
- _this._summaryScope = settings.summaryScope;
88
- _this._enableJsonp = settings.enableJsonp;
89
- _this._provideFullCount = settings.provideFullCount;
90
- _this._performFetch = settings.performFetch;
91
- _this._provideAggregationParameter = settings.provideAggregationParameter;
92
- _this._provideFilterParameter = settings.provideFilterParameter;
93
- _this._provideOrderByParameter = settings.provideOrderByParameter;
94
- _this._provideUri = settings.provideUri;
95
- _this._providePagingParameter = settings.providePagingParameter;
96
- _this._provideDesiredPropertiesParameter = settings.provideDesiredPropertiesParameter;
97
- _this._provideItems = settings.provideItems;
98
- _this._provideAggregatedCount = settings.provideAggregatedCount;
99
- if (!_this._provideItems) {
100
- _this._provideItems = function (res) {
101
- return res ? res.items : null;
102
- };
103
- }
104
- if (!_this._provideFullCount) {
105
- _this._provideFullCount = function (p) {
106
- if (p.fullCount) {
107
- return p.fullCount;
108
- }
109
- else {
110
- return _this._fixedFullCount >= 0 ? _this._fixedFullCount : 0;
111
- }
112
- };
113
- }
114
- if (!_this._provideOrderByParameter) {
115
- _this._provideOrderByParameter = function (args, orderByString, orderBy) {
116
- args.push({ name: "orderBy", value: encodeURIComponent(orderByString) });
117
- };
118
- }
119
- if (!_this._providePagingParameter) {
120
- _this._providePagingParameter = function (args, skip, take) {
121
- args.push({ name: "skip", value: skip });
122
- args.push({ name: "take", value: take });
123
- };
124
- }
125
- if (!_this._provideAggregationParameter) {
126
- _this._provideAggregationParameter = function (args, fetchCountOnly, groupByString, groupBy, summaryString, summary) {
127
- args.push({ name: "groupBy", value: groupByString });
128
- args.push({ name: "aggregate", value: "count" });
129
- };
130
- }
131
- if (!_this._provideUri) {
132
- _this._provideUri = function (baseUri, entitySet, args) {
133
- var requestUri = baseUri;
134
- requestUri += "/" + entitySet;
135
- if (args.length > 0) {
136
- requestUri += "?";
137
- }
138
- var argsString = "";
139
- for (var i = 0; i < args.length; i++) {
140
- if (i > 0) {
141
- argsString += "&";
142
- }
143
- argsString += args[i].name + "=" + args[i].value;
144
- }
145
- return requestUri + argsString;
146
- };
147
- }
148
- _this._isAggregationSupported = settings.isAggregationSupported;
149
- window.setTimeout(_this.doWork, 100);
150
- return _this;
151
- }
152
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "sortDescriptions", {
153
- get: function () {
154
- return this._sortDescriptions;
155
- },
156
- enumerable: false,
157
- configurable: true
158
- });
159
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "filterExpressions", {
160
- get: function () {
161
- return this._filterExpressions;
162
- },
163
- enumerable: false,
164
- configurable: true
165
- });
166
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "desiredProperties", {
167
- get: function () {
168
- return this._desiredPropeties;
169
- },
170
- enumerable: false,
171
- configurable: true
172
- });
173
- RestVirtualDataSourceDataProviderWorker.prototype.initialize = function () {
174
- _super.prototype.initialize.call(this);
175
- };
176
- RestVirtualDataSourceDataProviderWorker.prototype.getTaskDataHolder = function () {
177
- var holder = new RestVirtualDataSourceProviderTaskDataHolder();
178
- return holder;
179
- };
180
- RestVirtualDataSourceDataProviderWorker.prototype.getCompletedTaskData = function (holder, completed) {
181
- _super.prototype.getCompletedTaskData.call(this, holder, completed);
182
- };
183
- RestVirtualDataSourceDataProviderWorker.prototype.removeCompletedTaskData = function (holder, completed) {
184
- _super.prototype.removeCompletedTaskData.call(this, holder, completed);
185
- };
186
- RestVirtualDataSourceDataProviderWorker.prototype.getTasksData = function (holder) {
187
- _super.prototype.getTasksData.call(this, holder);
188
- };
189
- RestVirtualDataSourceDataProviderWorker.prototype.iter = function (coll) {
190
- var i;
191
- return __generator(this, function (_a) {
192
- switch (_a.label) {
193
- case 0:
194
- i = 0;
195
- _a.label = 1;
196
- case 1:
197
- if (!(i < coll.size()))
198
- return [3 /*break*/, 4];
199
- return [4 /*yield*/, coll.get(i)];
200
- case 2:
201
- _a.sent();
202
- _a.label = 3;
203
- case 3:
204
- i++;
205
- return [3 /*break*/, 1];
206
- case 4: return [2 /*return*/];
207
- }
208
- });
209
- };
210
- RestVirtualDataSourceDataProviderWorker.prototype.iterFilter = function (coll) {
211
- var i;
212
- return __generator(this, function (_a) {
213
- switch (_a.label) {
214
- case 0:
215
- i = 0;
216
- _a.label = 1;
217
- case 1:
218
- if (!(i < coll.size()))
219
- return [3 /*break*/, 4];
220
- return [4 /*yield*/, coll.get(i)];
221
- case 2:
222
- _a.sent();
223
- _a.label = 3;
224
- case 3:
225
- i++;
226
- return [3 /*break*/, 1];
227
- case 4: return [2 /*return*/];
228
- }
229
- });
230
- };
231
- RestVirtualDataSourceDataProviderWorker.prototype.iterSummaries = function (summaries) {
232
- var i;
233
- return __generator(this, function (_a) {
234
- switch (_a.label) {
235
- case 0:
236
- i = 0;
237
- _a.label = 1;
238
- case 1:
239
- if (!(i < summaries.size()))
240
- return [3 /*break*/, 4];
241
- return [4 /*yield*/, summaries.get(i)];
242
- case 2:
243
- _a.sent();
244
- _a.label = 3;
245
- case 3:
246
- i++;
247
- return [3 /*break*/, 1];
248
- case 4: return [2 /*return*/];
249
- }
250
- });
251
- };
252
- RestVirtualDataSourceDataProviderWorker.prototype.processCompletedTask = function (completedTask, currentDelay, pageIndex, taskDataHolder) {
253
- var _this = this;
254
- var h = taskDataHolder;
255
- var schema = null;
256
- var result = null;
257
- var schemaFetchCount = -1;
258
- var task = completedTask.task;
259
- try {
260
- if (task.hasErrors) {
261
- this.retryIndex(pageIndex, currentDelay);
262
- return;
263
- }
264
- if (pageIndex == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
265
- result = task.result;
266
- schemaFetchCount = (this._provideFullCount(result));
267
- }
268
- else {
269
- result = task.result;
270
- }
271
- }
272
- catch (e) {
273
- this.retryIndex(pageIndex, currentDelay);
274
- return;
275
- }
276
- if (schemaFetchCount >= 0) {
277
- this.actualCount = schemaFetchCount;
278
- }
279
- else {
280
- this.actualCount = (this._provideFullCount(result));
281
- }
282
- schema = this.actualSchema;
283
- if (schema == null) {
284
- var requests_1 = 0;
285
- this.resolveSchema(function (s) {
286
- // resolveSchema success callback
287
- _this.actualSchema = s;
288
- if (_this._isAggregationSupported && (_this._groupDescriptions.size() !== 0 || _this._summaryDescriptions.size() !== 0)) {
289
- if (_this._groupDescriptions.size() > 0) {
290
- requests_1++;
291
- _this.resolveGroupInformation(function (g) {
292
- // group info success
293
- requests_1--;
294
- if (requests_1 === 0) {
295
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
296
- }
297
- }, function () {
298
- // group info failure
299
- _this.retryIndex(pageIndex, currentDelay);
300
- return;
301
- });
302
- }
303
- if (_this._summaryDescriptions.size() > 0) {
304
- requests_1++;
305
- _this.resolveSummaryInformation(function (g) {
306
- // summary info success
307
- requests_1--;
308
- if (requests_1 === 0) {
309
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
310
- }
311
- }, function () {
312
- // summary info failure
313
- _this.retryIndex(pageIndex, currentDelay);
314
- return;
315
- });
316
- }
317
- }
318
- else {
319
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
320
- }
321
- }, function () {
322
- // resolveSchema failure callback
323
- _this.retryIndex(pageIndex, currentDelay);
324
- return;
325
- });
326
- return;
327
- }
328
- this.finishProcessingCompletedTask(task, pageIndex, schema, result);
329
- };
330
- RestVirtualDataSourceDataProviderWorker.prototype.finishProcessingCompletedTask = function (task, pageIndex, schema, result) {
331
- var _this = this;
332
- var executionContext;
333
- var pageLoaded;
334
- var groupInformation;
335
- var summaryInformation;
336
- this.actualSchema = schema;
337
- executionContext = this.executionContext;
338
- groupInformation = this._groupInformation;
339
- summaryInformation = this._summaryInformation;
340
- pageLoaded = this.pageLoaded;
341
- var page = null;
342
- if (result != null) {
343
- page = new RestVirtualDataSourcePage(result, schema, groupInformation, summaryInformation, pageIndex);
344
- if (!this.isLastPage(pageIndex) && page.count() > 0 && !this.populatedActualPageSize) {
345
- this.populatedActualPageSize = true;
346
- this.actualPageSize = page.count();
347
- }
348
- }
349
- else {
350
- page = new RestVirtualDataSourcePage(null, schema, groupInformation, summaryInformation, pageIndex);
351
- }
352
- if (this.pageLoaded != null) {
353
- if (this.executionContext != null) {
354
- if (executionContext == null || pageLoaded == null) {
355
- this.shutdown();
356
- return;
357
- }
358
- executionContext.execute(function () { return pageLoaded(page, _this.actualCount, _this.actualPageSize); });
359
- }
360
- else {
361
- if (pageLoaded == null) {
362
- this.shutdown();
363
- return;
364
- }
365
- pageLoaded(page, this.actualCount, this.actualPageSize);
366
- }
367
- }
368
- };
369
- RestVirtualDataSourceDataProviderWorker.prototype.resolveGroupInformation = function (finishAction, failureAction) {
370
- var e_2, _a;
371
- var _this = this;
372
- if (this._groupInformation != null) {
373
- finishAction(this._groupInformation);
374
- return;
375
- }
376
- var orderBy = "";
377
- var groupBy = "";
378
- var filter = null;
379
- var summary = "";
380
- if (this._groupDescriptions == null || this._groupDescriptions.size() == 0) {
381
- finishAction(null);
382
- return;
383
- }
384
- if (this._provideAggregationParameter == null) {
385
- finishAction(null);
386
- return;
387
- }
388
- filter = this._filterString;
389
- this.updateFilterString();
390
- if (this._groupDescriptions != null) {
391
- var first1 = true;
392
- try {
393
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
394
- var group = _c.value;
395
- if (first1) {
396
- first1 = false;
397
- }
398
- else {
399
- orderBy += ", ";
400
- groupBy += ", ";
401
- }
402
- groupBy += group.propertyName;
403
- if (group.direction === ListSortDirection.Descending) {
404
- orderBy += group.propertyName + " desc";
405
- }
406
- else {
407
- orderBy += group.propertyName + " asc";
408
- }
409
- }
410
- }
411
- catch (e_2_1) {
412
- e_2 = { error: e_2_1 };
413
- }
414
- finally {
415
- try {
416
- if (_c && !_c.done && (_a = _b.return))
417
- _a.call(_b);
418
- }
419
- finally {
420
- if (e_2)
421
- throw e_2.error;
422
- }
423
- }
424
- }
425
- if (this._summaryScope === DataSourceSummaryScope.Both || this._summaryScope === DataSourceSummaryScope.Groups) {
426
- var summaryParameters = this.getSummaryQueryParameters(true);
427
- if (!stringIsNullOrEmpty(summaryParameters)) {
428
- summary = ", " + summaryParameters;
429
- }
430
- }
431
- var args = [];
432
- if (this._provideOrderByParameter) {
433
- this._provideOrderByParameter(args, orderBy, this._groupDescriptions);
434
- }
435
- if (this._provideFilterParameter && filter != null) {
436
- this._provideFilterParameter(args, filter, this._filterExpressions);
437
- }
438
- if (this._provideAggregationParameter) {
439
- this._provideAggregationParameter(args, true, groupBy, this._groupDescriptions, summary, this._summaryDescriptions);
440
- }
441
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
442
- try {
443
- var groupInformation_1 = [];
444
- var success_1 = function (data, response) { return _this.groupSuccess(data, response, finishAction, failureAction, groupInformation_1); };
445
- var failure_1 = function (err) { return _this.groupError(err, finishAction, failureAction, groupInformation_1); };
446
- var run_ = null;
447
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
448
- var request = {
449
- requestUri: uri,
450
- enableJsonpCallback: this._enableJsonp,
451
- method: 'GET',
452
- headers: headers,
453
- data: null
454
- };
455
- run_ = function () {
456
- _this.fetchUri(request, success_1, failure_1);
457
- };
458
- run_();
459
- }
460
- catch (e) {
461
- failureAction();
462
- }
463
- };
464
- RestVirtualDataSourceDataProviderWorker.prototype.fetchUri = function (request, success, failure) {
465
- if (this._performFetch) {
466
- this._performFetch(request, success, failure);
467
- }
468
- else {
469
- fetch(request.requestUri, {
470
- method: request.method,
471
- headers: request.headers,
472
- }).then(function (res) {
473
- res.json().then(function (j) {
474
- success(j, res);
475
- });
476
- }).catch(function (e) {
477
- failure(e);
478
- });
479
- }
480
- };
481
- RestVirtualDataSourceDataProviderWorker.prototype.groupError = function (err, finishAction, failureAction, groupInformation) {
482
- this._groupInformation = null;
483
- };
484
- RestVirtualDataSourceDataProviderWorker.prototype.groupSuccess = function (data, response, finishAction, failureAction, groupInformation) {
485
- var e_3, _a;
486
- var groupNames = [];
487
- try {
488
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
489
- var group = _c.value;
490
- groupNames.push(group.propertyName);
491
- }
492
- }
493
- catch (e_3_1) {
494
- e_3 = { error: e_3_1 };
495
- }
496
- finally {
497
- try {
498
- if (_c && !_c.done && (_a = _b.return))
499
- _a.call(_b);
500
- }
501
- finally {
502
- if (e_3)
503
- throw e_3.error;
504
- }
505
- }
506
- var groupNamesArray = groupNames;
507
- var items = this._provideItems(data);
508
- if (items && items.length > 0) {
509
- var currentIndex = 0;
510
- for (var i = 0; i < items.length; i++) {
511
- this.addGroup(groupInformation, groupNames, groupNames, currentIndex, items[i]);
512
- }
513
- }
514
- this._groupInformation = groupInformation;
515
- finishAction(this._groupInformation);
516
- };
517
- RestVirtualDataSourceDataProviderWorker.prototype.addGroup = function (groupInformation, groupNames, groupNamesArray, currentIndex, group) {
518
- var e_4, _a;
519
- var groupValues = [];
520
- try {
521
- for (var groupNames_1 = __values(groupNames), groupNames_1_1 = groupNames_1.next(); !groupNames_1_1.done; groupNames_1_1 = groupNames_1.next()) {
522
- var name_1 = groupNames_1_1.value;
523
- if (group[name_1]) {
524
- groupValues.push(group[name_1]);
525
- }
526
- }
527
- }
528
- catch (e_4_1) {
529
- e_4 = { error: e_4_1 };
530
- }
531
- finally {
532
- try {
533
- if (groupNames_1_1 && !groupNames_1_1.done && (_a = groupNames_1.return))
534
- _a.call(groupNames_1);
535
- }
536
- finally {
537
- if (e_4)
538
- throw e_4.error;
539
- }
540
- }
541
- var groupCount = 0;
542
- //todo: make this customizable
543
- if (this._provideAggregatedCount) {
544
- var ct = this._provideAggregatedCount(group);
545
- }
546
- else {
547
- if (group["aggregatedCount"]) {
548
- groupCount = Convert.toInt321(group["aggregatedCount"]);
549
- }
550
- }
551
- var summaryResults = null;
552
- if (this._summaryScope == DataSourceSummaryScope.Both || this._summaryScope == DataSourceSummaryScope.Groups) {
553
- summaryResults = this.createSummaryResults(group);
554
- }
555
- var groupInfo = new DefaultSectionInformation(currentIndex, currentIndex + (groupCount - 1), groupNamesArray, groupValues, summaryResults);
556
- groupInformation.push(groupInfo);
557
- };
558
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSummaryInformation = function (finishAction, failureAction) {
559
- var _this = this;
560
- if (this._summaryInformation != null) {
561
- finishAction(this._summaryInformation);
562
- return;
563
- }
564
- var filter = null;
565
- var summary = null;
566
- if (this._summaryDescriptions == null ||
567
- this._summaryDescriptions.size() == 0 ||
568
- this._summaryScope == DataSourceSummaryScope.Groups ||
569
- this._summaryScope == DataSourceSummaryScope.None) {
570
- finishAction(null);
571
- return;
572
- }
573
- filter = this._filterString;
574
- this.updateFilterString();
575
- summary = this.getSummaryQueryParameters(false);
576
- var args = [];
577
- // if (this._provideOrderByParameter) {
578
- // args.push({ name: "orderBy", value: this._provideOrderByParameter(orderBy, this._sortDescriptions) });
579
- // }
580
- if (this._provideFilterParameter && filter != null) {
581
- this._provideFilterParameter(args, filter, this._filterExpressions);
582
- }
583
- if (this._provideAggregationParameter) {
584
- this._provideAggregationParameter(args, true, null, null, summary, this._summaryDescriptions);
585
- }
586
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
587
- // let commandText = this._entitySet + "?$apply=";
588
- // if (!stringIsNullOrEmpty(filter)) {
589
- // commandText += "filter(" + filter + ")/";
590
- // }
591
- // commandText += "aggregate(" + summary + ")";
592
- try {
593
- var summaryInformation_1 = [];
594
- var success_2 = function (data, response) { return _this.summarySuccess(data, response, finishAction, failureAction, summaryInformation_1); };
595
- var failure_2 = function (err) { return _this.summaryError(err, finishAction, failureAction, summaryInformation_1); };
596
- var run_ = null;
597
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
598
- var request = {
599
- requestUri: uri,
600
- enableJsonpCallback: this._enableJsonp,
601
- method: 'GET',
602
- headers: headers,
603
- data: null
604
- };
605
- run_ = function () {
606
- _this.fetchUri(request, success_2, failure_2);
607
- };
608
- run_();
609
- }
610
- catch (e) {
611
- failureAction();
612
- }
613
- };
614
- RestVirtualDataSourceDataProviderWorker.prototype.summarySuccess = function (data, response, finishAction, failureAction, summaryInformation) {
615
- if (data && data.value && data.value.length > 0) {
616
- summaryInformation = this.createSummaryResults(data.value[0]);
617
- }
618
- this._summaryInformation = summaryInformation;
619
- finishAction(this._summaryInformation);
620
- };
621
- RestVirtualDataSourceDataProviderWorker.prototype.summaryError = function (err, finishAction, failureAction, summaryInformation) {
622
- this._summaryInformation = null;
623
- };
624
- RestVirtualDataSourceDataProviderWorker.prototype.getSummaryQueryParameters = function (ignoreCount) {
625
- var e_5, _a;
626
- var result = "";
627
- if (this._summaryDescriptions != null) {
628
- var first = true;
629
- var countExists = false;
630
- try {
631
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
632
- var summary = _c.value;
633
- if (summary.operand == DataSourceSummaryOperand.Count && (ignoreCount || countExists)) {
634
- continue;
635
- }
636
- if (!first) {
637
- result += ", ";
638
- }
639
- switch (summary.operand) {
640
- case DataSourceSummaryOperand.Average:
641
- result += summary.propertyName + " with average as " + summary.propertyName + "Average";
642
- break;
643
- case DataSourceSummaryOperand.Min:
644
- result += summary.propertyName + " with min as " + summary.propertyName + "Min";
645
- break;
646
- case DataSourceSummaryOperand.Max:
647
- result += summary.propertyName + " with max as " + summary.propertyName + "Max";
648
- break;
649
- case DataSourceSummaryOperand.Sum:
650
- result += summary.propertyName + " with sum as " + summary.propertyName + "Sum";
651
- break;
652
- case DataSourceSummaryOperand.Count:
653
- result += "$count as $__count";
654
- countExists = true;
655
- break;
656
- }
657
- first = false;
658
- }
659
- }
660
- catch (e_5_1) {
661
- e_5 = { error: e_5_1 };
662
- }
663
- finally {
664
- try {
665
- if (_c && !_c.done && (_a = _b.return))
666
- _a.call(_b);
667
- }
668
- finally {
669
- if (e_5)
670
- throw e_5.error;
671
- }
672
- }
673
- }
674
- return result;
675
- };
676
- RestVirtualDataSourceDataProviderWorker.prototype.createSummaryResults = function (data) {
677
- var e_6, _a;
678
- var summaryResults = [];
679
- try {
680
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
681
- var summary = _c.value;
682
- var summaryName = summary.propertyName;
683
- switch (summary.operand) {
684
- case DataSourceSummaryOperand.Average:
685
- summaryName += "Average";
686
- break;
687
- case DataSourceSummaryOperand.Min:
688
- summaryName += "Min";
689
- break;
690
- case DataSourceSummaryOperand.Max:
691
- summaryName += "Max";
692
- break;
693
- case DataSourceSummaryOperand.Sum:
694
- summaryName += "Sum";
695
- break;
696
- case DataSourceSummaryOperand.Count:
697
- summaryName = "$__count";
698
- break;
699
- }
700
- var summaryValue = null;
701
- if (data && data[summaryName]) {
702
- summaryValue = data[summaryName];
703
- }
704
- var summaryResult = new DefaultSummaryResult(summary.propertyName, summary.operand, summaryValue);
705
- summaryResults.push(summaryResult);
706
- }
707
- }
708
- catch (e_6_1) {
709
- e_6 = { error: e_6_1 };
710
- }
711
- finally {
712
- try {
713
- if (_c && !_c.done && (_a = _b.return))
714
- _a.call(_b);
715
- }
716
- finally {
717
- if (e_6)
718
- throw e_6.error;
719
- }
720
- }
721
- return summaryResults;
722
- };
723
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSchemaFromItems = function (items) {
724
- var lds = new LocalDataSource();
725
- lds.dataSource = items;
726
- lds.flushAutoRefresh();
727
- return lds.actualSchema;
728
- };
729
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSchema = function (finishAction, failureAction) {
730
- var _this = this;
731
- if (!this._provideItems || !this._providePagingParameter) {
732
- failureAction("required providers for items and paging are not specified");
733
- return;
734
- }
735
- var success_ = function (res) {
736
- var items = _this._provideItems(res);
737
- if (items && items.length > 0) {
738
- var schema = _this.resolveSchemaFromItems(items);
739
- if (_this._schemaIncludedProperties != null) {
740
- var propertyNames = [];
741
- var propertyTypes = [];
742
- for (var i = 0; i < schema.propertyNames.length; i++) {
743
- if (!_this._schemaIncludedProperties.has(schema.propertyNames[i])) {
744
- continue;
745
- }
746
- propertyNames.push(schema.propertyNames[i]);
747
- propertyTypes.push(schema.propertyTypes[i]);
748
- }
749
- schema = new DefaultDataSourceSchema(propertyNames, propertyTypes, schema.primaryKey, schema.propertyDataIntents, schema.subSchemas);
750
- }
751
- finishAction(schema);
752
- }
753
- else {
754
- failureAction("could not find items to resolve schema");
755
- }
756
- };
757
- var failure_ = function (e) { return failureAction(e); };
758
- var args = [];
759
- if (this._providePagingParameter) {
760
- this._providePagingParameter(args, 0, this.actualPageSize);
761
- }
762
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
763
- try {
764
- var run_ = null;
765
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
766
- var request = {
767
- requestUri: uri,
768
- enableJsonpCallback: this._enableJsonp,
769
- method: 'GET',
770
- headers: headers,
771
- data: null
772
- };
773
- run_ = function () {
774
- _this.fetchUri(request, success_, failure_);
775
- };
776
- run_();
777
- }
778
- catch (e) {
779
- failureAction(e);
780
- }
781
- };
782
- RestVirtualDataSourceDataProviderWorker.prototype.makeTaskForRequest = function (request, retryDelay) {
783
- var e_7, _a;
784
- var args = [];
785
- // if (this._provideAggregationParameter) {
786
- // args.push({ name: "apply", value: this._provideAggregationParameter(true, groupBy, this._groupDescriptions, summary, this._summaryDescriptions) });
787
- // }
788
- var actualPageSize = 0;
789
- var sortDescriptions = null;
790
- actualPageSize = this.actualPageSize;
791
- sortDescriptions = this.sortDescriptions;
792
- //let requestUrl: string = this._baseUri;
793
- //requestUrl += "/" + this._entitySet;
794
- var queryStarted = false;
795
- this.updateFilterString();
796
- if (this._filterString != null) {
797
- if (this._provideFilterParameter) {
798
- this._provideFilterParameter(args, this._filterString, this._filterExpressions);
799
- }
800
- }
801
- if (this.sortDescriptions != null) {
802
- var sortString = null;
803
- try {
804
- for (var _b = __values(this.iter(this.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
805
- var sort = _c.value;
806
- if (sortString == null) {
807
- sortString = "";
808
- }
809
- else {
810
- sortString += ", ";
811
- }
812
- if (sort.direction == ListSortDirection.Descending) {
813
- sortString += sort.propertyName + " desc";
814
- }
815
- else {
816
- sortString += sort.propertyName;
817
- }
818
- }
819
- }
820
- catch (e_7_1) {
821
- e_7 = { error: e_7_1 };
822
- }
823
- finally {
824
- try {
825
- if (_c && !_c.done && (_a = _b.return))
826
- _a.call(_b);
827
- }
828
- finally {
829
- if (e_7)
830
- throw e_7.error;
831
- }
832
- }
833
- if (sortString != null) {
834
- if (this._provideOrderByParameter) {
835
- this._provideOrderByParameter(args, sortString, this._sortDescriptions);
836
- }
837
- }
838
- }
839
- if (this.desiredProperties != null && this.desiredProperties.length > 0) {
840
- var selectString = "";
841
- var first = true;
842
- var $t = this.desiredProperties;
843
- for (var i = 0; i < $t.length; i++) {
844
- var select = $t[i];
845
- if (first) {
846
- first = false;
847
- }
848
- else {
849
- selectString += ", ";
850
- }
851
- selectString += select;
852
- }
853
- if (this._provideDesiredPropertiesParameter) {
854
- this._provideDesiredPropertiesParameter(args, selectString, this._desiredPropeties);
855
- }
856
- }
857
- if (this._providePagingParameter) {
858
- if (request.index == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
859
- this._providePagingParameter(args, 0, actualPageSize);
860
- }
861
- else {
862
- this._providePagingParameter(args, request.index * actualPageSize, actualPageSize);
863
- }
864
- }
865
- var task = new AsyncVirtualDataTask();
866
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
867
- if (request.index == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
868
- this.executeRequest(uri, queryStarted, 0, actualPageSize, task);
869
- }
870
- else {
871
- this.executeRequest(uri, queryStarted, request.index * actualPageSize, actualPageSize, task);
872
- }
873
- request.taskHolder = new AsyncDataSourcePageTaskHolder();
874
- request.taskHolder.task = task;
875
- this.tasks.add(request);
876
- };
877
- RestVirtualDataSourceDataProviderWorker.prototype.updateFilterString = function () {
878
- var e_8, _a;
879
- if (this.filterExpressions != null && this.filterExpressions.size() > 0 && this._filterString == null) {
880
- var sb = "";
881
- var first = true;
882
- try {
883
- for (var _b = __values(this.iterFilter(this.filterExpressions)), _c = _b.next(); !_c.done; _c = _b.next()) {
884
- var expr = _c.value;
885
- if (first) {
886
- first = false;
887
- }
888
- else {
889
- sb += " AND ";
890
- }
891
- var visitor = new ODataDataSourceFilterExpressionVisitor(0);
892
- visitor.visit(expr);
893
- var txt = visitor.toString();
894
- if (this.filterExpressions.size() > 1) {
895
- txt = "(" + txt + ")";
896
- }
897
- sb += (txt);
898
- }
899
- }
900
- catch (e_8_1) {
901
- e_8 = { error: e_8_1 };
902
- }
903
- finally {
904
- try {
905
- if (_c && !_c.done && (_a = _b.return))
906
- _a.call(_b);
907
- }
908
- finally {
909
- if (e_8)
910
- throw e_8.error;
911
- }
912
- }
913
- this._filterString = sb;
914
- }
915
- };
916
- RestVirtualDataSourceDataProviderWorker.prototype.executeRequest = function (requestUrl, queryStarted, skip, top, task) {
917
- var _this = this;
918
- // if (!queryStarted) {
919
- // queryStarted = true;
920
- // requestUrl += "?";
921
- // } else {
922
- // requestUrl += "&";
923
- // }
924
- // requestUrl += "$skip=" + skip + "&$top=" + top + "&$count=true";
925
- var requestUrl_ = requestUrl;
926
- var self_ = this;
927
- var success_ = function (data, response) { return _this.success(task, data, response); };
928
- var failure_ = function (err) { return _this.error(task, err); };
929
- var run_ = null;
930
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
931
- var request = {
932
- requestUri: requestUrl_,
933
- enableJsonpCallback: this._enableJsonp,
934
- method: 'GET',
935
- headers: headers,
936
- data: null
937
- };
938
- run_ = function () {
939
- _this.fetchUri(request, success_, failure_);
940
- };
941
- task.run = run_;
942
- };
943
- RestVirtualDataSourceDataProviderWorker.prototype.success = function (t, data, response) {
944
- t.result = data;
945
- t.isCompleted = true;
946
- };
947
- RestVirtualDataSourceDataProviderWorker.prototype.error = function (t, result) {
948
- t.isCompleted = true;
949
- t.hasErrors = true;
950
- };
951
- RestVirtualDataSourceDataProviderWorker.prototype.createBatchRequest = function (changes) {
952
- //TODO: updates
953
- };
954
- RestVirtualDataSourceDataProviderWorker.prototype.getRequestUriWithKey = function (key) {
955
- var result = "";
956
- var keys = Object.keys(key);
957
- for (var i = 0; i < keys.length; i++) {
958
- if (i > 0) {
959
- result += ",";
960
- }
961
- result += "".concat(keys[i], "=").concat(key[keys[i]]);
962
- }
963
- return "".concat(this._entitySet, "(").concat(result, ")");
964
- };
965
- RestVirtualDataSourceDataProviderWorker.schemaRequestIndex = -1;
966
- return RestVirtualDataSourceDataProviderWorker;
967
- }(AsyncVirtualDataSourceProviderWorker));