arlas-web-core 18.1.0 → 19.3.0-dev0

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 (43) hide show
  1. package/.editorconfig +13 -0
  2. package/.gitlab-ci.yml +19 -0
  3. package/.travis.yml +27 -0
  4. package/CHANGELOG.md +446 -0
  5. package/CONTRIBUTING.md +48 -0
  6. package/{LICENSE → LICENSE.txt} +0 -0
  7. package/NOTICE.txt +10 -0
  8. package/README-NPM.md +78 -0
  9. package/README.md +2 -2
  10. package/arlas-web-core-19.3.0-dev0.tgz +0 -0
  11. package/build.sh +9 -0
  12. package/jsconfig.json +13 -0
  13. package/mkDocs.sh +18 -0
  14. package/package-release.json +25 -0
  15. package/package.json +13 -7
  16. package/release.sh +429 -0
  17. package/{index.js → src/index.ts} +7 -4
  18. package/{models/collaboration.js → src/models/collaboration.ts} +30 -6
  19. package/src/models/contributor.ts +161 -0
  20. package/src/models/projections.ts +58 -0
  21. package/{services/collaborativesearch.service.js → src/services/collaborativesearch.service.ts} +383 -176
  22. package/{services/config.service.js → src/services/config.service.ts} +15 -11
  23. package/src/utils/utils.ts +80 -0
  24. package/tsconfig-build.json +21 -0
  25. package/tsconfig.json +15 -0
  26. package/tslint.json +116 -0
  27. package/index.d.ts +0 -6
  28. package/index.js.map +0 -1
  29. package/models/collaboration.d.ts +0 -29
  30. package/models/collaboration.js.map +0 -1
  31. package/models/contributor.d.ts +0 -56
  32. package/models/contributor.js +0 -116
  33. package/models/contributor.js.map +0 -1
  34. package/models/projections.d.ts +0 -35
  35. package/models/projections.js +0 -38
  36. package/models/projections.js.map +0 -1
  37. package/services/collaborativesearch.service.d.ts +0 -313
  38. package/services/collaborativesearch.service.js.map +0 -1
  39. package/services/config.service.d.ts +0 -31
  40. package/services/config.service.js.map +0 -1
  41. package/utils/utils.d.ts +0 -18
  42. package/utils/utils.js +0 -63
  43. package/utils/utils.js.map +0 -1
@@ -1,49 +1,101 @@
1
- import { Subject, from } from 'rxjs';
1
+ /*
2
+ * Licensed to Gisaïa under one or more contributor
3
+ * license agreements. See the NOTICE.txt file distributed with
4
+ * this work for additional information regarding copyright
5
+ * ownership. Gisaïa licenses this file to you under
6
+ * the Apache License, Version 2.0 (the "License"); you may
7
+ * not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import {
20
+ Aggregation, AggregationResponse, AggregationsRequest,
21
+ CollectionReferenceDescription, Count, ExploreApi, Expression,
22
+ FeatureCollection, Filter, Hits, Search, Metric, Page, Form, ComputationRequest, ComputationResponse
23
+ } from 'arlas-api';
24
+ import { Observable, Subject, from, zip } from 'rxjs';
2
25
  import { map } from 'rxjs/operators';
3
- import { fromEntries } from '../utils/utils';
4
- import { OperationEnum } from '../models/collaboration';
5
- import { projType } from '../models/projections';
26
+ import { fromEntries, CollectionCount } from '../utils/utils';
27
+ import { Collaboration, CollaborationEvent, OperationEnum } from '../models/collaboration';
28
+ import { Contributor } from '../models/contributor';
29
+ import { GeohashAggregation, TiledSearch, projType, GeoTileAggregation } from '../models/projections';
30
+ import { ConfigService } from './config.service';
31
+
6
32
  export class CollaborativesearchService {
7
- constructor() {
8
- /**
9
- * Bus of CollaborationEvent.
10
- */
11
- this.collaborationBus = new Subject();
12
- /**
13
- * Bus of CollaborationEvent.
14
- */
15
- this.contribFilterBus = new Subject();
16
- /**
17
- * Registry of Collaborations, Map of contributor identifier,Collaboration.
18
- */
19
- this.collaborations = new Map();
20
- /**
21
- * Registry of Contributor, Map of contributor identifier,Contributor.
22
- */
23
- this.registry = new Map();
24
- /**
25
- * ARLAS SERVER max age cache used by the collaborativesearchService.
26
- */
27
- this.max_age = 60;
28
- /**
29
- * Bus number of ongoing subscribe to the collaborativesearchService
30
- */
31
- this.ongoingSubscribe = new Subject();
32
- /**
33
- * Bus number of ongoing subscribe to the collaborativesearchService
34
- */
35
- this.totalSubscribe = 0;
36
- /**
37
- * Bus of Error.
38
- */
39
- this.collaborationErrorBus = new Subject();
40
- /**
41
- * Configuration object of fetch call. By default all credentials are included.
42
- */
43
- this.fetchOptions = {
33
+ /**
34
+ * Bus of CollaborationEvent.
35
+ */
36
+ public collaborationBus: Subject<CollaborationEvent> = new Subject<CollaborationEvent>();
37
+
38
+ /**
39
+ * Bus of CollaborationEvent.
40
+ */
41
+ public contribFilterBus: Subject<Contributor> = new Subject<Contributor>();
42
+ /**
43
+ * Registry of Collaborations, Map of contributor identifier,Collaboration.
44
+ */
45
+ public collaborations = new Map<string, Collaboration>();
46
+ /**
47
+ * Registry of Contributor, Map of contributor identifier,Contributor.
48
+ */
49
+ public registry = new Map<string, Contributor>();
50
+ /**
51
+ * ARLAS SERVER collection used by default by the contributors.
52
+ */
53
+ public defaultCollection: string;
54
+
55
+ /** ARLAS SERVER collections that declared in the contributos */
56
+
57
+ public collections: Set<string> = new Set();
58
+ /**
59
+ * ARLAS SERVER max age cache used by the collaborativesearchService.
60
+ */
61
+ public max_age = 60;
62
+ /**
63
+ * Number of entity return by the collaborativesearchService at any time
64
+ */
65
+ public countAll: Observable<CollectionCount[]>;
66
+ /**
67
+ * Bus number of ongoing subscribe to the collaborativesearchService
68
+ */
69
+ public ongoingSubscribe: Subject<number> = new Subject<number>();
70
+ /**
71
+ * Bus number of ongoing subscribe to the collaborativesearchService
72
+ */
73
+ public totalSubscribe = 0;
74
+ /**
75
+ * Bus of Error.
76
+ */
77
+ public collaborationErrorBus: Subject<Error> = new Subject<Error>();
78
+ /**
79
+ * ARLAS SERVER Explore Api used by the collaborativesearchService.
80
+ */
81
+ private exploreApi: ExploreApi;
82
+ /**
83
+ * Configuration Service used by the collaborativesearchService.
84
+ */
85
+ private configService: ConfigService;
86
+ /**
87
+ * Configuration object of fetch call. By default all credentials are included.
88
+ */
89
+ private fetchOptions: {
90
+ credentials: string,
91
+ signal?: any,
92
+ responseType?: string,
93
+ referrerPolicy?: string
94
+ } = {
44
95
  credentials: 'include',
45
96
  referrerPolicy: 'origin'
46
97
  };
98
+ constructor() {
47
99
  /**
48
100
  * Subscribe ongoingSubscribe bus to know how many subscribe are on going.
49
101
  */
@@ -58,8 +110,7 @@ export class CollaborativesearchService {
58
110
  if (collaborationEvent.operation === OperationEnum.remove) {
59
111
  if (collaborationEvent.all) {
60
112
  this.collaborations.clear();
61
- }
62
- else {
113
+ } else {
63
114
  this.collaborations.delete(collaborationEvent.id);
64
115
  }
65
116
  }
@@ -69,59 +120,75 @@ export class CollaborativesearchService {
69
120
  * Return options used to fetch call.
70
121
  * @returns Object.
71
122
  */
72
- getFetchOptions() {
123
+ public getFetchOptions() {
73
124
  return this.fetchOptions;
74
125
  }
75
126
  /**
76
127
  * Set the fetch options.
77
128
  * @param fetchOptions : Object.
78
129
  */
79
- setFetchOptions(fetchOptions) {
130
+ public setFetchOptions(fetchOptions: any) {
80
131
  this.fetchOptions = fetchOptions;
81
132
  }
82
133
  /**
83
134
  * Return the ARLAS Explore API.
84
135
  * @returns ExploreApi.
85
136
  */
86
- getExploreApi() {
137
+ public getExploreApi() {
87
138
  return this.exploreApi;
88
139
  }
89
140
  /**
90
141
  * Set the ARLAS Explore API.
91
142
  * @param api : ExploreApi.
92
143
  */
93
- setExploreApi(exploreApi) {
144
+ public setExploreApi(exploreApi: ExploreApi) {
94
145
  this.exploreApi = exploreApi;
95
146
  }
96
147
  /**
97
148
  * Return the Configuraion Service.
98
149
  * @returns ConfigService.
99
150
  */
100
- getConfigService() {
151
+ public getConfigService() {
101
152
  return this.configService;
102
153
  }
103
154
  /**
104
155
  * Set the Configuraion Service.
105
156
  * @param configService ConfigService.
106
157
  */
107
- setConfigService(configService) {
158
+ public setConfigService(configService: ConfigService) {
108
159
  this.configService = configService;
109
160
  }
110
161
  /**
111
162
  * Register contributor with its identifier in the map contributor registry.
112
163
  */
113
- register(identifier, contributor) {
164
+ public register(identifier: string, contributor: Contributor): void {
114
165
  this.registry.set(identifier, contributor);
166
+ this.registerCollections(contributor);
115
167
  }
168
+
169
+ /**
170
+ * Register collections of the given contributor in a collections registry.
171
+ */
172
+ public registerCollections(contributor: Contributor) {
173
+ if (contributor.collections) {
174
+ contributor.collections.forEach(cf => {
175
+ this.collections.add(cf.collectionName);
176
+ });
177
+ }
178
+ if (contributor.collection) {
179
+ this.collections.add(contributor.collection);
180
+ }
181
+ }
182
+
116
183
  /**
117
184
  * Add Filter setted by a contributor in the registry of collaboration, notify the collaborationBus of a changement.
118
185
  * @param contributorId Sting identifier of contributor.
119
186
  * @param collaboration Collaboration added by the contributor.
120
187
  */
121
- setFilter(contributorId, collaboration) {
188
+ public setFilter(contributorId: string, collaboration: Collaboration) {
122
189
  collaboration.enabled = true;
123
190
  this.collaborations.set(contributorId, collaboration);
124
- const collaborationEvent = {
191
+ const collaborationEvent: CollaborationEvent = {
125
192
  id: contributorId,
126
193
  operation: OperationEnum.add,
127
194
  all: false
@@ -133,9 +200,9 @@ export class CollaborativesearchService {
133
200
  * @param contributorId Sting identifier of contributor.
134
201
  * @param collaboration Collaboration added by the contributor.
135
202
  */
136
- removeFilter(contributorId) {
203
+ public removeFilter(contributorId: string) {
137
204
  this.collaborations.delete(contributorId);
138
- const collaborationEvent = {
205
+ const collaborationEvent: CollaborationEvent = {
139
206
  id: contributorId,
140
207
  operation: OperationEnum.remove,
141
208
  all: false
@@ -145,33 +212,34 @@ export class CollaborativesearchService {
145
212
  /**
146
213
  * Remove all the collaborations filters, notify the collaborationBus of a all removing changement.
147
214
  */
148
- removeAll() {
215
+ public removeAll() {
149
216
  this.collaborations.clear();
150
- const collaborationEvent = {
217
+ const collaborationEvent: CollaborationEvent = {
151
218
  id: 'all',
152
219
  operation: OperationEnum.remove,
153
220
  all: true
154
221
  };
155
222
  this.collaborationBus.next(collaborationEvent);
156
223
  }
157
- dataModelBuilder(filter) {
224
+
225
+ public dataModelBuilder(filter: string): Object {
158
226
  const dataModel = JSON.parse(filter);
159
227
  /** transform "filters" object to Map */
160
228
  Object.keys(dataModel).forEach(key => {
161
229
  const collab = dataModel['' + key];
162
230
  if (!!collab && !!collab.filters) {
163
231
  collab.filters = new Map(Object.entries(collab.filters));
164
- }
165
- else if (!!collab && !collab.filters && !!collab.filter) {
232
+ } else if (!!collab && !collab.filters && !!collab.filter) {
166
233
  /** retrocompatibility code to transform an pre-18 collaboration structure to 18 one */
167
- collab.filters = new Map();
234
+ collab.filters = new Map<string, Filter[]>();
168
235
  collab.filters.set(this.defaultCollection, [Object.assign({}, collab.filter)]);
169
236
  delete collab.filter;
170
237
  }
171
238
  });
172
239
  return dataModel;
173
240
  }
174
- urlBuilder() {
241
+
242
+ public urlBuilder(): string {
175
243
  const dataModel = {};
176
244
  Array.from(this.collaborations.keys()).forEach(identifier => {
177
245
  dataModel[identifier] = Object.assign({}, this.collaborations.get(identifier));
@@ -180,43 +248,43 @@ export class CollaborativesearchService {
180
248
  dataModel[identifier].filters = {};
181
249
  dataModel[identifier].filters[this.defaultCollection] = [Object.assign({}, dataModel[identifier].filter)];
182
250
  delete dataModel[identifier].filter;
183
- }
184
- else if (!!dataModel[identifier].filters) {
251
+ } else if (!!dataModel[identifier].filters) {
185
252
  dataModel[identifier].filters = fromEntries(dataModel[identifier].filters);
186
253
  }
187
254
  });
188
255
  const url = 'filter=' + JSON.stringify(dataModel);
189
256
  return url;
190
257
  }
258
+
191
259
  /**
192
260
  * Initialize all the contributor in the state of dataModel.
193
261
  * @param dataModel
194
262
  */
195
- setCollaborations(dataModel) {
263
+ public setCollaborations(dataModel: Object) {
196
264
  this.collaborations.clear();
197
265
  Array.from(this.registry.keys()).forEach(identifier => {
198
266
  if (dataModel[identifier] !== undefined) {
199
- const collaboration = dataModel[identifier];
267
+ const collaboration: Collaboration = dataModel[identifier];
200
268
  this.collaborations.set(identifier, collaboration);
201
269
  }
202
270
  });
203
- const collaborationEvent = {
271
+ const collaborationEvent: CollaborationEvent = {
204
272
  id: 'url',
205
273
  operation: OperationEnum.add,
206
274
  all: true
207
275
  };
208
276
  this.collaborationBus.next(collaborationEvent);
209
277
  }
278
+
210
279
  /**
211
280
  * Retrieve the collaboration from a contributor identifier.
212
281
  * @param contributorId Identifier of a contributor.
213
282
  * @returns Collaboration.
214
283
  */
215
- getCollaboration(contributorId) {
284
+ public getCollaboration(contributorId: string): Collaboration {
216
285
  if (this.collaborations.get(contributorId)) {
217
286
  return this.collaborations.get(contributorId);
218
- }
219
- else {
287
+ } else {
220
288
  return null;
221
289
  }
222
290
  }
@@ -230,7 +298,11 @@ export class CollaborativesearchService {
230
298
  * @param max_age Duration of browser cache.
231
299
  * @returns ARLAS Server observable.
232
300
  */
233
- resolveButNotHits(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
301
+ public resolveButNotHits(projection:
302
+ [projType.search, Search]
303
+ | [projType.count, Count], collaborations: Map<string, Collaboration>, collection,
304
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
305
+ ): Observable<Hits> {
234
306
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
235
307
  }
236
308
  /**
@@ -242,9 +314,14 @@ export class CollaborativesearchService {
242
314
  * @param max_age Duration of browser cache.
243
315
  * @returns ARLAS Server observable.
244
316
  */
245
- resolveHits(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
317
+ public resolveHits(projection:
318
+ [projType.search, Search]
319
+ | [projType.count, Count], collaborations: Map<string, Collaboration>, collection,
320
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
321
+ ): Observable<Hits> {
246
322
  return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
247
323
  }
324
+
248
325
  /**
249
326
  * Resolve an ARLAS Server Search or Count request for an array of filter.
250
327
  * @param projection Type of projection of ARLAS Server request :Search or Count .
@@ -253,9 +330,14 @@ export class CollaborativesearchService {
253
330
  * @param max_age Duration of browser cache.
254
331
  * @returns ARLAS Server observable.
255
332
  */
256
- resolveComputeHits(projection, filters, collection, isFlat, max_age = this.max_age) {
333
+ public resolveComputeHits(projection:
334
+ [projType.search, Search]
335
+ | [projType.count, Count],
336
+ filters: Array<Filter>, collection, isFlat?: boolean, max_age = this.max_age
337
+ ): Observable<Hits> {
257
338
  return this.computeResolve(projection, filters, collection, isFlat, max_age);
258
339
  }
340
+
259
341
  /**
260
342
  * Resolve an ARLAS Server Geosearch or Geoaggregate request with all the collaborations enabled in the collaboration registry
261
343
  except for the contributor given in second optionnal parameter.
@@ -266,13 +348,34 @@ export class CollaborativesearchService {
266
348
  * @param max_age Duration of browser cache.
267
349
  * @returns ARLAS Server observable.
268
350
  */
269
- resolveButNotFeatureCollection(projection, collaborations, collection, isFlat = true, contributorId, filter, max_age = this.max_age) {
351
+ public resolveButNotFeatureCollection(projection:
352
+ [projType.geosearch, Search]
353
+ | [projType.tiledgeosearch, TiledSearch]
354
+ | [projType.geohashgeoaggregate, GeohashAggregation]
355
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
356
+ | [projType.geoaggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection, isFlat = true,
357
+ contributorId?: string, filter?: Filter, max_age = this.max_age
358
+ ): Observable<FeatureCollection> {
270
359
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
271
360
  }
272
- resolveButNotShapefile(projection, collaborations, collection, isFlat = true, contributorId, filter, max_age = this.max_age) {
361
+
362
+ public resolveButNotShapefile(projection:
363
+ [projType.shapeaggregate, Array<Aggregation>]
364
+ | [projType.shapesearch, Search], collaborations: Map<string, Collaboration>, collection, isFlat = true,
365
+ contributorId?: string, filter?: Filter, max_age = this.max_age
366
+ ): Observable<ArrayBuffer> {
273
367
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
274
368
  }
275
- resolveButNotFeatureCollectionWithAbort(projection, collaborations, collection, isFlat = true, abortableSignal, contributorId, filter, max_age = this.max_age) {
369
+
370
+ public resolveButNotFeatureCollectionWithAbort(projection:
371
+ [projType.geosearch, Search]
372
+ | [projType.tiledgeosearch, TiledSearch]
373
+ | [projType.geohashgeoaggregate, GeohashAggregation]
374
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
375
+ | [projType.geoaggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>,
376
+ collection, isFlat = true, abortableSignal,
377
+ contributorId?: string, filter?: Filter, max_age = this.max_age,
378
+ ): Observable<FeatureCollection> {
276
379
  const fetchOptions = Object.assign({}, this.fetchOptions);
277
380
  fetchOptions.signal = abortableSignal;
278
381
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age, fetchOptions);
@@ -287,7 +390,14 @@ export class CollaborativesearchService {
287
390
  * @param max_age Duration of browser cache.
288
391
  * @returns ARLAS Server observable.
289
392
  */
290
- resolveFeatureCollection(projection, isFlat = true, collaborations, collection, contributorId, filter, max_age = this.max_age) {
393
+ public resolveFeatureCollection(projection:
394
+ [projType.geosearch, Search]
395
+ | [projType.tiledgeosearch, TiledSearch]
396
+ | [projType.geohashgeoaggregate, GeohashAggregation]
397
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
398
+ | [projType.geoaggregate, Array<Aggregation>], isFlat = true, collaborations: Map<string, Collaboration>, collection,
399
+ contributorId?: string, filter?: Filter, max_age = this.max_age
400
+ ): Observable<FeatureCollection> {
291
401
  return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
292
402
  }
293
403
  /**
@@ -300,7 +410,10 @@ export class CollaborativesearchService {
300
410
  * @param max_age Duration of browser cache.
301
411
  * @returns ARLAS Server observable.
302
412
  */
303
- resolveButNotAggregation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
413
+ public resolveButNotAggregation(projection:
414
+ [projType.aggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection,
415
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
416
+ ): Observable<AggregationResponse> {
304
417
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
305
418
  }
306
419
  /**
@@ -312,7 +425,10 @@ export class CollaborativesearchService {
312
425
  * @param max_age Duration of browser cache.
313
426
  * @returns ARLAS Server observable.
314
427
  */
315
- resolveAggregation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
428
+ public resolveAggregation(projection:
429
+ [projType.aggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection,
430
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
431
+ ): Observable<AggregationResponse> {
316
432
  return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
317
433
  }
318
434
  /**
@@ -326,78 +442,96 @@ export class CollaborativesearchService {
326
442
  * @param max_age Duration of browser cache.
327
443
  * @returns ARLAS Server observable.
328
444
  */
329
- resolveButNotComputation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
445
+ public resolveButNotComputation(projection:
446
+ [projType.compute, ComputationRequest], collaborations: Map<string, Collaboration>, collection,
447
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
448
+ ): Observable<ComputationResponse> {
330
449
  return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
331
450
  }
332
451
  /**
333
452
  * Enable a contributor collaboration from its identifier.
334
453
  */
335
- enable(contributorId) {
454
+ public enable(contributorId: string) {
336
455
  this.setEnable(true, contributorId);
337
456
  }
338
457
  /**
339
458
  * Disable a contributor collaboration from its identifier.
340
459
  */
341
- disable(contributorId) {
460
+ public disable(contributorId: string) {
342
461
  this.setEnable(false, contributorId);
343
462
  }
344
463
  /**
345
464
  * Retrieve all the contributor identifiers.
346
465
  * @returns List of contributor idenfiers.
347
466
  */
348
- getAllContributors() {
467
+ public getAllContributors(): Array<string> {
349
468
  return Array.from(this.collaborations.keys());
350
469
  }
351
470
  /**
352
471
  * Retrieve the contributor identifiers for which the collaboration is enabled.
353
472
  * @returns List of contributor idenfiers.
354
473
  */
355
- getEnableContributors() {
474
+ public getEnableContributors(): Array<string> {
356
475
  return Array.from(this.collaborations.keys()).filter(x => this.collaborations.get(x).enabled);
357
476
  }
358
477
  /**
359
478
  * Retrieve the contributor identifiers for which the collaboration is disabled.
360
479
  * @returns List of contributor idenfiers.
361
480
  */
362
- getDisableContributors() {
481
+ public getDisableContributors(): Array<string> {
363
482
  return Array.from(this.collaborations.keys()).filter(x => !this.collaborations.get(x).enabled);
364
483
  }
365
484
  /**
366
485
  * Retrieve enabled parameter of collaboration from a contributor identifier.
367
486
  * @returns Contributor collaboration enabled properties.
368
487
  */
369
- isEnable(contributorId) {
488
+ public isEnable(contributorId: string): boolean {
370
489
  return this.collaborations.get(contributorId).enabled;
371
490
  }
372
491
  /**
373
492
  * Update countAll property.
374
493
  */
375
- setCountAll(collaborations) {
376
- const result = this.resolveButNot([projType.count, {}], collaborations, this.defaultCollection);
377
- this.countAll = result.pipe(map(c => c.totalnb));
494
+ public setCountAll(collaborations: Map<string, Collaboration>) {
495
+ this.countAll = zip(...Array.from(this.collections).map(c => {
496
+ return this.resolveButNot([projType.count, {}], collaborations, c);
497
+ })).pipe(map(l => {
498
+ return l.map(count => ({count: count.totalnb, collection: count.collection}));
499
+ }));
378
500
  }
501
+
379
502
  /**
380
503
  * Build query parameters from aggregation and filters
381
504
  * @return Url encoded string
382
505
  */
383
- getUrl(projection, filters, max_age = this.max_age) {
506
+ public getUrl(
507
+ projection: [
508
+ projType.geoaggregate | projType.geosearch | projType.aggregate | projType.shapeaggregate | projType.shapesearch |
509
+ projType.count | projType.geohashgeoaggregate | projType.geotilegeoaggregate | projType.search | projType.tiledgeosearch,
510
+ Array<Aggregation>
511
+ ],
512
+ filters: Array<Filter>, max_age = this.max_age): string {
513
+
384
514
  const finalFilter = this.getFinalFilter(filters);
385
- let aggregationRequest;
386
- let aggregationsForGet;
515
+ let aggregationRequest: AggregationsRequest;
516
+ let aggregationsForGet: string[];
517
+
387
518
  const fForGet = this.buildFilterFieldGetParam('f', finalFilter);
388
519
  const qForGet = this.buildFilterFieldGetParam('q', finalFilter);
520
+
389
521
  const queryParameters = new URLSearchParams();
390
- aggregationRequest = {
522
+ aggregationRequest = <AggregationsRequest>{
391
523
  filter: finalFilter,
392
524
  aggregations: projection[1]
393
525
  };
394
526
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
527
+
395
528
  if (aggregationsForGet
396
529
  && (projection[0] === projType.geoaggregate
397
530
  || projection[0] === projType.aggregate
398
531
  || projection[0] === projType.geohashgeoaggregate
399
532
  || projection[0] === projType.geotilegeoaggregate
400
- || projection[0] === projType.shapeaggregate)) {
533
+ || projection[0] === projType.shapeaggregate)
534
+ ) {
401
535
  aggregationsForGet.filter(element => element !== undefined).forEach(function (element) {
402
536
  queryParameters.append('agg', element);
403
537
  });
@@ -416,20 +550,22 @@ export class CollaborativesearchService {
416
550
  }
417
551
  if (finalFilter.dateformat !== undefined) {
418
552
  queryParameters.set('dateformat', finalFilter.dateformat.toString());
553
+
419
554
  }
420
555
  return queryParameters.toString();
421
556
  }
422
- getFinalFilter(filters) {
423
- const finalFilter = {};
424
- const f = new Array();
425
- const q = new Array();
426
- const p = new Array();
427
- const gi = new Array();
557
+
558
+ public getFinalFilter(filters: Array<Filter>): Filter {
559
+ const finalFilter: Filter = {};
560
+ const f: Array<Array<Expression>> = new Array<Array<Expression>>();
561
+ const q: Array<Array<string>> = new Array<Array<string>>();
562
+ const p: Array<Array<string>> = new Array<Array<string>>();
563
+ const gi: Array<Array<string>> = new Array<Array<string>>();
564
+
428
565
  const dateformats = new Set(filters.map(filter => filter.dateformat));
429
566
  if (dateformats.size > 1) {
430
- this.collaborationErrorBus.next(new Error('Dateformats must be equals for each filters'));
431
- }
432
- else if (dateformats.size === 1) {
567
+ this.collaborationErrorBus.next((<Error>new Error('Dateformats must be equals for each filters')));
568
+ } else if (dateformats.size === 1) {
433
569
  finalFilter.dateformat = dateformats[0];
434
570
  }
435
571
  filters.forEach(filter => {
@@ -448,6 +584,7 @@ export class CollaborativesearchService {
448
584
  }
449
585
  });
450
586
  }
587
+
451
588
  }
452
589
  });
453
590
  if (f.length > 0) {
@@ -458,36 +595,43 @@ export class CollaborativesearchService {
458
595
  }
459
596
  return finalFilter;
460
597
  }
598
+
461
599
  /**
462
600
  * Describe the structure and the content of the given collection.
463
601
  * @param collection collection name
464
602
  * @param pretty Whether pretty print or not
465
603
  * @param max_age Duration of browser cache.s
466
604
  */
467
- describe(collection, pretty, max_age = this.max_age) {
468
- const result = from(this.exploreApi.describe(collection, pretty, max_age, this.fetchOptions));
605
+ public describe(collection: string, pretty?: boolean, max_age = this.max_age): Observable<CollectionReferenceDescription> {
606
+ const result = <Observable<CollectionReferenceDescription>>from(
607
+ this.exploreApi.describe(collection, pretty, max_age, this.fetchOptions)
608
+ );
469
609
  return result;
470
610
  }
611
+
471
612
  /**
472
613
  * Lists the collections configured in ARLAS.
473
614
  * @param pretty Whether pretty print or not
474
615
  */
475
- list(pretty = false) {
476
- const result = from(this.exploreApi.list(pretty, this.max_age, this.fetchOptions));
616
+ public list(pretty = false): Observable<Array<CollectionReferenceDescription>> {
617
+ const result = <Observable<Array<CollectionReferenceDescription>>>from(
618
+ this.exploreApi.list(pretty, this.max_age, this.fetchOptions)
619
+ );
477
620
  return result;
478
621
  }
622
+
479
623
  /**
480
624
  * Set enabled value of a collaboration from a contributor identifier.
481
625
  * @param enabled Enabled collaboration value.
482
626
  * @param contributorId Contributor identifier.
483
627
  */
484
- setEnable(enabled, contributorId) {
628
+ private setEnable(enabled: boolean, contributorId: string) {
485
629
  const collaboration = this.collaborations.get(contributorId);
486
630
  if (collaboration) {
487
631
  collaboration.enabled = enabled;
488
632
  }
489
633
  this.collaborations.set(contributorId, collaboration);
490
- const collaborationEvent = {
634
+ const collaborationEvent: CollaborationEvent = {
491
635
  id: contributorId,
492
636
  operation: OperationEnum.add,
493
637
  all: true
@@ -502,9 +646,19 @@ export class CollaborativesearchService {
502
646
  * @param isFlat Boolean option to flat output geojson properties.
503
647
  * @returns ARLAS Server observable.
504
648
  */
505
- resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
649
+ private resolve(projection: [projType.aggregate, Array<Aggregation>]
650
+ | [projType.search, Search]
651
+ | [projType.geoaggregate, Array<Aggregation>]
652
+ | [projType.geohashgeoaggregate, GeohashAggregation]
653
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
654
+ | [projType.geosearch, Search]
655
+ | [projType.tiledgeosearch, TiledSearch]
656
+ | [projType.count, Count]
657
+ | [projType.compute, ComputationRequest], collaborations: Map<string, Collaboration>, collection,
658
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age, fetchOptions = this.fetchOptions
659
+ ): Observable<any> {
506
660
  try {
507
- const filters = new Array();
661
+ const filters: Array<Filter> = new Array<Filter>();
508
662
  if (contributorId) {
509
663
  const collaboration = collaborations.get(contributorId);
510
664
  if (collaboration !== undefined) {
@@ -522,9 +676,8 @@ export class CollaborativesearchService {
522
676
  filters.push(filter);
523
677
  }
524
678
  return this.computeResolve(projection, filters, collection, isFlat, max_age, fetchOptions);
525
- }
526
- catch (ex) {
527
- this.collaborationErrorBus.next(ex);
679
+ } catch (ex) {
680
+ this.collaborationErrorBus.next((<Error>ex));
528
681
  }
529
682
  }
530
683
  /**
@@ -537,9 +690,21 @@ export class CollaborativesearchService {
537
690
  * @param max_age Duration of browser cache.
538
691
  * @returns ARLAS Server observable.
539
692
  */
540
- resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
693
+ private resolveButNot(projection: [projType.aggregate, Array<Aggregation>]
694
+ | [projType.search, Search]
695
+ | [projType.geoaggregate, Array<Aggregation>]
696
+ | [projType.geohashgeoaggregate, GeohashAggregation]
697
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
698
+ | [projType.geosearch, Search]
699
+ | [projType.tiledgeosearch, TiledSearch]
700
+ | [projType.count, Count]
701
+ | [projType.compute, ComputationRequest]
702
+ | [projType.shapeaggregate, Array<Aggregation>]
703
+ | [projType.shapesearch, Search], collaborations: Map<string, Collaboration>, collection,
704
+ contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age, fetchOptions = this.fetchOptions
705
+ ): Observable<any> {
541
706
  try {
542
- const filters = new Array();
707
+ const filters: Array<Filter> = new Array<Filter>();
543
708
  if (contributorId) {
544
709
  collaborations.forEach((collab, c) => {
545
710
  if (c !== contributorId && collab.enabled) {
@@ -549,13 +714,11 @@ export class CollaborativesearchService {
549
714
  filters.push(collabFilters[0]);
550
715
  }
551
716
  }
552
- }
553
- else {
717
+ } else {
554
718
  return;
555
719
  }
556
720
  });
557
- }
558
- else {
721
+ } else {
559
722
  collaborations.forEach((collab, c) => {
560
723
  if (collab.enabled) {
561
724
  if (collab.filters && collab.filters.get(collection)) {
@@ -571,11 +734,11 @@ export class CollaborativesearchService {
571
734
  filters.push(filter);
572
735
  }
573
736
  return this.computeResolve(projection, filters, collection, isFlat, max_age, fetchOptions);
574
- }
575
- catch (ex) {
576
- this.collaborationErrorBus.next(ex);
737
+ } catch (ex) {
738
+ this.collaborationErrorBus.next((<Error>ex));
577
739
  }
578
740
  }
741
+
579
742
  /**
580
743
  * Build an ARLAS Server request from an Array of Filter
581
744
  * @param projection Type of projection of ARLAS Server request.
@@ -583,18 +746,30 @@ export class CollaborativesearchService {
583
746
  * @param isFlat Boolean option to flat output geojson properties.
584
747
  * @returns ARLAS Server observable.
585
748
  */
586
- computeResolve(projection, filters, collection, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
749
+ private computeResolve(projection: [projType.aggregate, Array<Aggregation>]
750
+ | [projType.search, Search]
751
+ | [projType.geoaggregate, Array<Aggregation>]
752
+ | [projType.geohashgeoaggregate, GeohashAggregation]
753
+ | [projType.geotilegeoaggregate, GeoTileAggregation]
754
+ | [projType.geosearch, Search]
755
+ | [projType.tiledgeosearch, TiledSearch]
756
+ | [projType.count, Count]
757
+ | [projType.compute, ComputationRequest]
758
+ | [projType.shapeaggregate, Array<Aggregation>]
759
+ | [projType.shapesearch, Search], filters: Array<Filter>, collection, isFlat?: boolean, max_age = this.max_age,
760
+ fetchOptions = this.fetchOptions
761
+ ): Observable<any> {
587
762
  const finalFilter = this.getFinalFilter(filters);
588
763
  const dateformat = finalFilter.dateformat;
589
- let aggregationRequest;
590
- let aggregationsForGet;
591
- let includes = [];
592
- let excludes = [];
593
- let returned_geometries;
764
+ let aggregationRequest: AggregationsRequest;
765
+ let aggregationsForGet: string[];
766
+ let includes: string[] = [];
767
+ let excludes: string[] = [];
768
+ let returned_geometries: string;
594
769
  let result;
595
770
  const fForGet = this.buildFilterFieldGetParam('f', finalFilter);
596
771
  const qForGet = this.buildFilterFieldGetParam('q', finalFilter);
597
- let search;
772
+ let search: Search;
598
773
  let pretty = false;
599
774
  let flat = false;
600
775
  let pageAfter;
@@ -604,7 +779,7 @@ export class CollaborativesearchService {
604
779
  let pageSort;
605
780
  if (projection[0] === projType.search.valueOf() || projection[0] === projType.geosearch.valueOf() ||
606
781
  projection[0] === projType.tiledgeosearch.valueOf() || projection[0] === projType.shapesearch.valueOf()) {
607
- search = projection[0] === projType.tiledgeosearch.valueOf() ? projection[1].search : projection[1];
782
+ search = projection[0] === projType.tiledgeosearch.valueOf() ? (<TiledSearch>projection[1]).search : (<Search>projection[1]);
608
783
  includes = [];
609
784
  excludes = [];
610
785
  if (search.projection !== undefined) {
@@ -616,13 +791,12 @@ export class CollaborativesearchService {
616
791
  }
617
792
  }
618
793
  returned_geometries = search.returned_geometries;
619
- const form = search.form;
620
- const page = search.page;
794
+ const form: Form = search.form;
795
+ const page: Page = search.page;
621
796
  if (form !== undefined) {
622
797
  if (form.flat !== undefined) {
623
798
  flat = form.flat;
624
- }
625
- else {
799
+ } else {
626
800
  if (isFlat !== undefined && isFlat !== null) {
627
801
  flat = isFlat;
628
802
  }
@@ -630,8 +804,7 @@ export class CollaborativesearchService {
630
804
  if (form.pretty !== undefined) {
631
805
  pretty = form.pretty;
632
806
  }
633
- }
634
- else {
807
+ } else {
635
808
  if (isFlat !== undefined && isFlat !== null) {
636
809
  flat = isFlat;
637
810
  }
@@ -656,86 +829,123 @@ export class CollaborativesearchService {
656
829
  }
657
830
  switch (projection[0]) {
658
831
  case projType.aggregate.valueOf():
659
- aggregationRequest = {
832
+ aggregationRequest = <AggregationsRequest>{
660
833
  filter: finalFilter,
661
834
  aggregations: projection[1]
662
835
  };
663
836
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
664
- result = from(this.exploreApi.aggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
837
+ result = <Observable<AggregationResponse>>from(
838
+ this.exploreApi.aggregate(collection, aggregationsForGet,
839
+ fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
840
+ );
665
841
  break;
666
842
  case projType.geoaggregate.valueOf():
667
- aggregationRequest = {
843
+ aggregationRequest = <AggregationsRequest>{
668
844
  filter: finalFilter,
669
845
  aggregations: projection[1]
670
846
  };
671
847
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
672
- result = from(this.exploreApi.geoaggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
848
+ result = <Observable<FeatureCollection>>from(
849
+ this.exploreApi.geoaggregate(collection, aggregationsForGet,
850
+ fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
851
+ );
673
852
  break;
674
853
  case projType.shapeaggregate.valueOf():
675
- aggregationRequest = {
854
+ aggregationRequest = <AggregationsRequest>{
676
855
  filter: finalFilter,
677
856
  aggregations: projection[1]
678
857
  };
679
858
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
680
859
  fetchOptions.responseType = 'arraybuffer';
681
- result = from(this.exploreApi.shapeaggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer())));
860
+ result = <Observable<ArrayBuffer>>from(
861
+ this.exploreApi.shapeaggregate(collection, aggregationsForGet,
862
+ fForGet, qForGet, dateformat, false, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer()))
863
+ );
682
864
  break;
683
865
  case projType.shapesearch.valueOf():
684
866
  fetchOptions.responseType = 'arraybuffer';
685
- result = from(this.exploreApi.shapesearch(collection, fForGet, qForGet, dateformat, false, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer())));
867
+ result = <Observable<ArrayBuffer>>from(
868
+ this.exploreApi.shapesearch(collection, fForGet, qForGet
869
+ , dateformat, false, includes, excludes, returned_geometries, pageSize,
870
+ pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer()))
871
+ );
686
872
  break;
687
873
  case projType.geohashgeoaggregate.valueOf():
688
- const aggregationsGeohash = projection[1].aggregations;
689
- const geohash = projection[1].geohash;
690
- aggregationRequest = {
874
+ const aggregationsGeohash: Array<Aggregation> = (<GeohashAggregation>projection[1]).aggregations;
875
+ const geohash = (<GeohashAggregation>projection[1]).geohash;
876
+ aggregationRequest = <AggregationsRequest>{
691
877
  filter: finalFilter,
692
878
  aggregations: aggregationsGeohash
693
879
  };
694
880
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
695
- result = from(this.exploreApi.geohashgeoaggregate(collection, geohash, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
881
+ result = <Observable<FeatureCollection>>from(
882
+ this.exploreApi.geohashgeoaggregate(collection, geohash, aggregationsForGet,
883
+ fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
884
+ );
696
885
  break;
697
886
  case projType.geotilegeoaggregate.valueOf():
698
- const aggregationsGeoTile = projection[1].aggregations;
699
- aggregationRequest = {
887
+ const aggregationsGeoTile: Array<Aggregation> = (<GeoTileAggregation>projection[1]).aggregations;
888
+ aggregationRequest = <AggregationsRequest>{
700
889
  filter: finalFilter,
701
890
  aggregations: aggregationsGeoTile
702
891
  };
703
892
  aggregationsForGet = this.buildAggGetParam(aggregationRequest);
704
- const xGeotile = projection[1].x;
705
- const yGeotile = projection[1].y;
706
- const zGeotile = projection[1].z;
707
- result = from(this.exploreApi.geotilegeoaggregate(collection, zGeotile, xGeotile, yGeotile, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
893
+ const xGeotile = (<GeoTileAggregation>projection[1]).x;
894
+ const yGeotile = (<GeoTileAggregation>projection[1]).y;
895
+ const zGeotile = (<GeoTileAggregation>projection[1]).z;
896
+ result = <Observable<FeatureCollection>>from(
897
+ this.exploreApi.geotilegeoaggregate(collection, zGeotile, xGeotile, yGeotile, aggregationsForGet,
898
+ fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
899
+ );
708
900
  break;
709
901
  case projType.count.valueOf():
710
- result = from(this.exploreApi.count(collection, fForGet, qForGet, dateformat, false, max_age, fetchOptions));
902
+ result = <Observable<Hits>>from(
903
+ this.exploreApi.count(collection, fForGet, qForGet, dateformat, false, max_age, fetchOptions));
711
904
  break;
712
905
  case projType.search.valueOf():
713
- result = from(this.exploreApi.search(collection, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
906
+ result = <Observable<Hits>>from(
907
+ this.exploreApi.search(collection, fForGet, qForGet
908
+ , dateformat, false, flat, includes, excludes, returned_geometries, pageSize,
909
+ pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
910
+ );
714
911
  break;
715
912
  case projType.geosearch.valueOf():
716
- result = from(this.exploreApi.geosearch(collection, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
913
+ result = <Observable<FeatureCollection>>from(
914
+ this.exploreApi.geosearch(collection, fForGet, qForGet
915
+ , dateformat, false, flat, includes, excludes, returned_geometries, pageSize,
916
+ pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
917
+ );
717
918
  break;
718
919
  case projType.tiledgeosearch.valueOf():
719
- const x = projection[1].x;
720
- const y = projection[1].y;
721
- const z = projection[1].z;
722
- result = from(this.exploreApi.tiledgeosearch(collection, x, y, z, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
920
+ const x = (<TiledSearch>projection[1]).x;
921
+ const y = (<TiledSearch>projection[1]).y;
922
+ const z = (<TiledSearch>projection[1]).z;
923
+ result = <Observable<FeatureCollection>>from(
924
+ this.exploreApi.tiledgeosearch(collection, x, y, z
925
+ , fForGet, qForGet
926
+ , dateformat, false, flat, includes, excludes, returned_geometries,
927
+ pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
928
+ );
723
929
  break;
724
930
  case projType.compute.valueOf():
725
- const field = projection[1].field;
726
- const metric = projection[1].metric;
727
- result = from(this.exploreApi.compute(collection, field, metric.toString().toLowerCase(), fForGet, qForGet, dateformat, false, max_age, fetchOptions));
931
+ const field = (<ComputationRequest>projection[1]).field;
932
+ const metric = (<ComputationRequest>projection[1]).metric;
933
+ result = <Observable<ComputationResponse>>from(
934
+ this.exploreApi.compute(collection, field, metric.toString().toLowerCase(), fForGet,
935
+ qForGet, dateformat, false, max_age, fetchOptions)
936
+ );
728
937
  break;
729
938
  }
730
939
  return result;
731
940
  }
941
+
732
942
  /**
733
943
  * Build an AggregationsRequest String[] for get mode request
734
944
  * @param aggregationRequest AggregationsRequest arlas object use in post request.
735
945
  * @returns aggregations as string[].
736
946
  */
737
- buildAggGetParam(aggregationRequest) {
738
- const aggregations = [];
947
+ private buildAggGetParam(aggregationRequest: AggregationsRequest): string[] {
948
+ const aggregations: string[] = [];
739
949
  aggregationRequest.aggregations.forEach(agg => {
740
950
  let aggregation = agg.type + ':' + agg.field;
741
951
  if (agg.interval !== undefined) {
@@ -750,7 +960,7 @@ export class CollaborativesearchService {
750
960
  aggregation += ':format-' + agg.format;
751
961
  }
752
962
  if (agg.metrics) {
753
- agg.metrics.filter((m) => (m.collect_field && m.collect_fct)).forEach(m => {
963
+ agg.metrics.filter((m: Metric) => (m.collect_field && m.collect_fct)).forEach(m => {
754
964
  aggregation += ':collect_field-' + m.collect_field + ':collect_fct-' + m.collect_fct;
755
965
  });
756
966
  }
@@ -770,8 +980,7 @@ export class CollaborativesearchService {
770
980
  aggregation += ':raw_geometries-' + agg.raw_geometries.map(rg => {
771
981
  if (rg.sort) {
772
982
  return rg.geometry + '(' + rg.sort + ')';
773
- }
774
- else {
983
+ } else {
775
984
  return rg.geometry;
776
985
  }
777
986
  }).join(';');
@@ -792,15 +1001,16 @@ export class CollaborativesearchService {
792
1001
  });
793
1002
  return aggregations;
794
1003
  }
1004
+
795
1005
  /**
796
1006
  * Build an filter String[] or string for get mode request
797
1007
  * @param field
798
1008
  * @param filter
799
1009
  * @returns aggregations as string[].
800
1010
  */
801
- buildFilterFieldGetParam(field, filter) {
1011
+ private buildFilterFieldGetParam(field: string, filter: Filter): any {
802
1012
  if (field === 'f') {
803
- const f = [];
1013
+ const f: string[] = [];
804
1014
  if (filter.f !== undefined) {
805
1015
  filter.f.forEach(e => {
806
1016
  let union = '';
@@ -811,9 +1021,8 @@ export class CollaborativesearchService {
811
1021
  });
812
1022
  }
813
1023
  return f;
814
- }
815
- else {
816
- const f = [];
1024
+ } else {
1025
+ const f: string[] = [];
817
1026
  if (filter[field] !== undefined) {
818
1027
  filter[field].forEach(e => {
819
1028
  let union = '';
@@ -823,11 +1032,9 @@ export class CollaborativesearchService {
823
1032
  f.push(union.substring(0, union.length - 1));
824
1033
  });
825
1034
  return f;
826
- }
827
- else {
1035
+ } else {
828
1036
  return undefined;
829
1037
  }
830
1038
  }
831
1039
  }
832
1040
  }
833
- //# sourceMappingURL=collaborativesearch.service.js.map