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