@elastic/ems-client 7.14.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
5
 
6
+ ## [8.0.0] - 2021-10-20
7
+
8
+ ### Changed
9
+ - Default EMS version is 8.0
10
+ - Remove unused API descriptors
11
+
12
+ ## [7.16.0] - 2021-10-13
13
+
14
+ ### Changed
15
+ - Default EMS version is 7.16
16
+ - Update dependencies using `yarn upgrade`
17
+ - Better error handling for HTTP responses
18
+
19
+ ## [7.15.1] - 2021-09-01
20
+
21
+ ### Changed
22
+ - Unpinned `semver` dependency [#77](https://github.com/elastic/ems-client/pull/77)
23
+
24
+ ## [7.15.0] - 2021-08-12
25
+
26
+ ### Changed
27
+ - Default EMS version is 7.15
28
+ - Updated dependencies via `yarn upgrade`
29
+ - Fix linting issues
6
30
  ## [7.14.0] - 2021-06-15
7
31
  ### Added
8
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/ems-client",
3
- "version": "7.14.0",
3
+ "version": "8.0.0",
4
4
  "description": "JavaScript client library for the Elastic Maps Service",
5
5
  "main": "target/node/index.js",
6
6
  "browser": "target/web/index.js",
@@ -41,7 +41,7 @@
41
41
  "@types/topojson-specification": "^1.0.1",
42
42
  "lodash": "^4.17.15",
43
43
  "lru-cache": "^6.0.0",
44
- "semver": "7.3.2",
44
+ "semver": "^7.3.2",
45
45
  "topojson-client": "^3.1.0"
46
46
  },
47
47
  "devDependencies": {
package/src/ems_client.ts CHANGED
@@ -9,13 +9,14 @@ import _ from 'lodash';
9
9
  import { TMSService } from './tms_service';
10
10
  import { EMSFormatType, FileLayer } from './file_layer';
11
11
  import { FeatureCollection } from 'geojson';
12
+ import { Response } from 'node-fetch';
12
13
  import semver from 'semver';
13
14
  import { format as formatUrl, parse as parseUrl, UrlObject } from 'url';
14
15
  import { toAbsoluteUrl } from './utils';
15
16
  import { ParsedUrlQueryInput } from 'querystring';
16
17
  import LRUCache from 'lru-cache';
17
18
 
18
- const DEFAULT_EMS_VERSION = '7.14';
19
+ const DEFAULT_EMS_VERSION = '8.0';
19
20
 
20
21
  type URLMeaningfulParts = {
21
22
  auth?: string | null;
@@ -278,16 +279,17 @@ export class EMSClient {
278
279
  async getManifest<T>(endpointUrl: string): Promise<T> {
279
280
  try {
280
281
  const url = extendUrl(endpointUrl, { query: this._queryParams });
281
- const result = await this._fetchWithTimeout(url);
282
- return result ? await result.json() : null;
283
- } catch (e) {
284
- if (!e) {
285
- e = new Error('Unknown error');
282
+ const response = await this._fetchWithTimeout(url);
283
+ if (!response.ok) {
284
+ throw new Error(response.statusText);
286
285
  }
287
- if (!(e instanceof Error)) {
288
- e = new Error(e.data || `status ${e.statusText || e.status}`);
286
+ return response ? await response.json() : null;
287
+ } catch (e) {
288
+ if (e instanceof Error) {
289
+ throw e;
290
+ } else {
291
+ throw new Error('Unknown error');
289
292
  }
290
- throw new Error(`Unable to retrieve data from ${endpointUrl}: ${e.message}`);
291
293
  }
292
294
  }
293
295
 
@@ -390,14 +392,14 @@ export class EMSClient {
390
392
  }
391
393
  }
392
394
 
393
- private _fetchWithTimeout(url: string): Promise<Body> {
394
- return new Promise<Body>((resolve, reject) => {
395
+ private _fetchWithTimeout(url: string): Promise<Response> {
396
+ return new Promise<Response>((resolve, reject) => {
395
397
  const timer = setTimeout(
396
398
  () => reject(new Error(`Request to ${url} timed out`)),
397
399
  this.EMS_LOAD_TIMEOUT
398
400
  );
399
401
  this._fetchFunction(url).then(
400
- (response: Body) => {
402
+ (response: Response) => {
401
403
  clearTimeout(timer);
402
404
  resolve(response);
403
405
  },
@@ -416,77 +418,67 @@ export class EMSClient {
416
418
 
417
419
  private _invalidateSettings(): void {
418
420
  this._cache.reset();
419
- this._getMainCatalog = _.once(
420
- async (): Promise<EmsCatalogManifest> => {
421
- // Preserve manifestServiceUrl parameter for backwards compatibility with EMS v7.2
422
- if (this._manifestServiceUrl) {
423
- console.warn(`The "manifestServiceUrl" parameter is deprecated in v7.6.0.
421
+ this._getMainCatalog = _.once(async (): Promise<EmsCatalogManifest> => {
422
+ // Preserve manifestServiceUrl parameter for backwards compatibility with EMS v7.2
423
+ if (this._manifestServiceUrl) {
424
+ console.warn(`The "manifestServiceUrl" parameter is deprecated in v7.6.0.
424
425
  Consider using "tileApiUrl" and "fileApiUrl" instead.`);
425
- return await this._getManifestWithParams(this._manifestServiceUrl);
426
- } else {
427
- const services = [];
428
- if (this._tileApiUrl) {
429
- services.push({
430
- type: 'tms',
431
- manifest: toAbsoluteUrl(this._tileApiUrl, `${this._emsVersion}/manifest`),
432
- });
433
- }
434
- if (this._fileApiUrl) {
435
- services.push({
436
- type: 'file',
437
- manifest: toAbsoluteUrl(this._fileApiUrl, `${this._emsVersion}/manifest`),
438
- });
439
- }
440
- return { services: services };
426
+ return await this._getManifestWithParams(this._manifestServiceUrl);
427
+ } else {
428
+ const services = [];
429
+ if (this._tileApiUrl) {
430
+ services.push({
431
+ type: 'tms',
432
+ manifest: toAbsoluteUrl(this._tileApiUrl, `${this._emsVersion}/manifest`),
433
+ });
434
+ }
435
+ if (this._fileApiUrl) {
436
+ services.push({
437
+ type: 'file',
438
+ manifest: toAbsoluteUrl(this._fileApiUrl, `${this._emsVersion}/manifest`),
439
+ });
441
440
  }
441
+ return { services: services };
442
442
  }
443
- );
443
+ });
444
444
 
445
- this._getDefaultTMSCatalog = _.once(
446
- async (): Promise<EmsTmsCatalog> => {
447
- const catalogue = await this._getMainCatalog();
448
- const firstService = catalogue.services.find(
449
- (service: EmsCatalogService) => service.type === 'tms'
450
- );
451
- if (!firstService) {
452
- return { services: [] };
453
- }
454
- const url = this._proxyPath + firstService.manifest;
455
- return await this.getManifest(url);
445
+ this._getDefaultTMSCatalog = _.once(async (): Promise<EmsTmsCatalog> => {
446
+ const catalogue = await this._getMainCatalog();
447
+ const firstService = catalogue.services.find(
448
+ (service: EmsCatalogService) => service.type === 'tms'
449
+ );
450
+ if (!firstService) {
451
+ return { services: [] };
456
452
  }
457
- );
453
+ const url = this._proxyPath + firstService.manifest;
454
+ return await this.getManifest(url);
455
+ });
458
456
 
459
- this._getDefaultFileCatalog = _.once(
460
- async (): Promise<EmsFileCatalog> => {
461
- const catalogue = await this._getMainCatalog();
462
- const firstService = catalogue.services.find(
463
- (service: EmsCatalogService) => service.type === 'file'
464
- );
465
- if (!firstService) {
466
- return { layers: [] };
467
- }
468
- const url = this._proxyPath + firstService.manifest;
469
- return await this.getManifest(url);
457
+ this._getDefaultFileCatalog = _.once(async (): Promise<EmsFileCatalog> => {
458
+ const catalogue = await this._getMainCatalog();
459
+ const firstService = catalogue.services.find(
460
+ (service: EmsCatalogService) => service.type === 'file'
461
+ );
462
+ if (!firstService) {
463
+ return { layers: [] };
470
464
  }
471
- );
465
+ const url = this._proxyPath + firstService.manifest;
466
+ return await this.getManifest(url);
467
+ });
472
468
 
473
469
  //Cache the actual instances of TMSService as these in turn cache sub-manifests for the style-files
474
- this._loadTMSServices = _.once(
475
- async (): Promise<TMSService[]> => {
476
- const tmsManifest = await this._getDefaultTMSCatalog();
477
- return tmsManifest.services.map(
478
- (serviceConfig: TMSServiceConfig) => new TMSService(serviceConfig, this, this._proxyPath)
479
- );
480
- }
481
- );
470
+ this._loadTMSServices = _.once(async (): Promise<TMSService[]> => {
471
+ const tmsManifest = await this._getDefaultTMSCatalog();
472
+ return tmsManifest.services.map(
473
+ (serviceConfig: TMSServiceConfig) => new TMSService(serviceConfig, this, this._proxyPath)
474
+ );
475
+ });
482
476
 
483
- this._loadFileLayers = _.once(
484
- async (): Promise<FileLayer[]> => {
485
- const fileManifest = await this._getDefaultFileCatalog();
486
- return fileManifest.layers.map(
487
- (layerConfig: FileLayerConfig) => new FileLayer(layerConfig, this, this._proxyPath)
488
- );
489
- }
490
- );
477
+ this._loadFileLayers = _.once(async (): Promise<FileLayer[]> => {
478
+ const fileManifest = await this._getDefaultFileCatalog();
479
+ return fileManifest.layers.map(
480
+ (layerConfig: FileLayerConfig) => new FileLayer(layerConfig, this, this._proxyPath)
481
+ );
482
+ });
491
483
  }
492
484
  }
package/src/file_layer.ts CHANGED
@@ -41,12 +41,11 @@ export class FileLayer extends AbstractEmsService {
41
41
 
42
42
  const format = this.getDefaultFormatType();
43
43
  const fetchUrl = this.getDefaultFormatUrl();
44
- // let fetchedJson;
45
44
  let geojson;
46
45
  const fetchedJson = await this._emsClient.getManifest(fetchUrl);
47
46
  if (fetchedJson) {
48
47
  if (format === 'geojson') {
49
- geojson = (fetchedJson as unknown) as FeatureCollection;
48
+ geojson = fetchedJson as unknown as FeatureCollection;
50
49
  } else if (format === 'topojson') {
51
50
  const meta = this.getDefaultFormatMeta();
52
51
  const featureCollectionPath = meta?.feature_collection_path ?? 'data';
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * 2.0.
6
6
  */
7
7
 
8
- export { EMSClient } from './ems_client';
8
+ export { EMSClient, FileLayerField } from './ems_client';
9
9
  export { ORIGIN } from './origin';
10
10
  export { FileLayer } from './file_layer';
11
11
  export { TMSService } from './tms_service';
@@ -68,68 +68,60 @@ type EmsRasterStyle = {
68
68
  export class TMSService extends AbstractEmsService {
69
69
  protected readonly _config: TMSServiceConfig;
70
70
 
71
- private _getRasterStyleJson = _.once(
72
- async (): Promise<EmsRasterStyle | undefined> => {
73
- const rasterUrl = this._getStyleUrlForLocale('raster');
74
- if (rasterUrl) {
75
- const url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
76
- return this._emsClient.getManifest<EmsRasterStyle>(
77
- this._emsClient.extendUrlWithParams(url)
78
- );
79
- } else {
80
- return;
81
- }
71
+ private _getRasterStyleJson = _.once(async (): Promise<EmsRasterStyle | undefined> => {
72
+ const rasterUrl = this._getStyleUrlForLocale('raster');
73
+ if (rasterUrl) {
74
+ const url = this._proxyPath + this._getAbsoluteUrl(rasterUrl);
75
+ return this._emsClient.getManifest<EmsRasterStyle>(this._emsClient.extendUrlWithParams(url));
76
+ } else {
77
+ return;
82
78
  }
83
- );
79
+ });
84
80
 
85
- private _getVectorStyleJsonRaw = _.once(
86
- async (): Promise<EmsVectorStyle | undefined> => {
87
- const vectorUrl = this._getStyleUrlForLocale('vector');
88
- if (vectorUrl) {
89
- const url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
90
- const vectorJson = await this._emsClient.getManifest<EmsVectorStyle>(
91
- this._emsClient.extendUrlWithParams(url)
92
- );
93
- return { ...vectorJson };
94
- } else {
95
- return;
96
- }
81
+ private _getVectorStyleJsonRaw = _.once(async (): Promise<EmsVectorStyle | undefined> => {
82
+ const vectorUrl = this._getStyleUrlForLocale('vector');
83
+ if (vectorUrl) {
84
+ const url = this._proxyPath + this._getAbsoluteUrl(vectorUrl);
85
+ const vectorJson = await this._emsClient.getManifest<EmsVectorStyle>(
86
+ this._emsClient.extendUrlWithParams(url)
87
+ );
88
+ return { ...vectorJson };
89
+ } else {
90
+ return;
97
91
  }
98
- );
92
+ });
99
93
 
100
- private _getVectorStyleJsonInlined = _.once(
101
- async (): Promise<EmsVectorStyle | undefined> => {
102
- const vectorJson = await this._getVectorStyleJsonRaw();
103
- if (vectorJson) {
104
- const inlinedSources: EmsVectorSources = {};
105
- const { sources } = vectorJson;
106
- for (const sourceName of Object.getOwnPropertyNames(sources)) {
107
- const { url } = sources[sourceName];
108
- const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
109
- const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
110
- const sourceJson = await this._emsClient.getManifest<EmsVectorSource>(extendedUrl);
94
+ private _getVectorStyleJsonInlined = _.once(async (): Promise<EmsVectorStyle | undefined> => {
95
+ const vectorJson = await this._getVectorStyleJsonRaw();
96
+ if (vectorJson) {
97
+ const inlinedSources: EmsVectorSources = {};
98
+ const { sources } = vectorJson;
99
+ for (const sourceName of Object.getOwnPropertyNames(sources)) {
100
+ const { url } = sources[sourceName];
101
+ const sourceUrl = this._proxyPath + this._getAbsoluteUrl(url);
102
+ const extendedUrl = this._emsClient.extendUrlWithParams(sourceUrl);
103
+ const sourceJson = await this._emsClient.getManifest<EmsVectorSource>(extendedUrl);
111
104
 
112
- const extendedTileUrls = sourceJson.tiles.map((tileUrl: string) => {
113
- const url = this._proxyPath + this._getAbsoluteUrl(tileUrl);
114
- return this._emsClient.extendUrlWithParams(url);
115
- });
116
- inlinedSources[sourceName] = {
117
- ...sourceJson,
118
- type: 'vector',
119
- tiles: extendedTileUrls,
120
- };
121
- }
122
- return {
123
- ...vectorJson,
124
- sources: inlinedSources,
125
- sprite: await this._getSpriteSheetRootPath(),
126
- glyphs: await this._getUrlTemplateForGlyphs(),
105
+ const extendedTileUrls = sourceJson.tiles.map((tileUrl: string) => {
106
+ const url = this._proxyPath + this._getAbsoluteUrl(tileUrl);
107
+ return this._emsClient.extendUrlWithParams(url);
108
+ });
109
+ inlinedSources[sourceName] = {
110
+ ...sourceJson,
111
+ type: 'vector',
112
+ tiles: extendedTileUrls,
127
113
  };
128
- } else {
129
- return;
130
114
  }
115
+ return {
116
+ ...vectorJson,
117
+ sources: inlinedSources,
118
+ sprite: await this._getSpriteSheetRootPath(),
119
+ glyphs: await this._getUrlTemplateForGlyphs(),
120
+ };
121
+ } else {
122
+ return;
131
123
  }
132
- );
124
+ });
133
125
 
134
126
  constructor(config: TMSServiceConfig, emsClient: EMSClient, proxyPath: string) {
135
127
  super(config, emsClient, proxyPath);
package/target/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { EMSClient } from './ems_client';
1
+ export { EMSClient, FileLayerField } from './ems_client';
2
2
  export { ORIGIN } from './origin';
3
3
  export { FileLayer } from './file_layer';
4
4
  export { TMSService } from './tms_service';
@@ -23,7 +23,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
23
 
24
24
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
25
 
26
- const DEFAULT_EMS_VERSION = '7.14';
26
+ const DEFAULT_EMS_VERSION = '8.0';
27
27
 
28
28
  /**
29
29
  * plugins cannot have upstream dependencies on core/*-kibana.
@@ -176,18 +176,19 @@ class EMSClient {
176
176
  const url = extendUrl(endpointUrl, {
177
177
  query: this._queryParams
178
178
  });
179
- const result = await this._fetchWithTimeout(url);
180
- return result ? await result.json() : null;
181
- } catch (e) {
182
- if (!e) {
183
- e = new Error('Unknown error');
184
- }
179
+ const response = await this._fetchWithTimeout(url);
185
180
 
186
- if (!(e instanceof Error)) {
187
- e = new Error(e.data || `status ${e.statusText || e.status}`);
181
+ if (!response.ok) {
182
+ throw new Error(response.statusText);
188
183
  }
189
184
 
190
- throw new Error(`Unable to retrieve data from ${endpointUrl}: ${e.message}`);
185
+ return response ? await response.json() : null;
186
+ } catch (e) {
187
+ if (e instanceof Error) {
188
+ throw e;
189
+ } else {
190
+ throw new Error('Unknown error');
191
+ }
191
192
  }
192
193
  }
193
194
  /**
@@ -11,9 +11,9 @@ var _ems_service = require("./ems_service");
11
11
 
12
12
  var topojson = _interopRequireWildcard(require("topojson-client"));
13
13
 
14
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
 
16
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
@@ -44,8 +44,7 @@ class FileLayer extends _ems_service.AbstractEmsService {
44
44
  }
45
45
 
46
46
  const format = this.getDefaultFormatType();
47
- const fetchUrl = this.getDefaultFormatUrl(); // let fetchedJson;
48
-
47
+ const fetchUrl = this.getDefaultFormatUrl();
49
48
  let geojson;
50
49
  const fetchedJson = await this._emsClient.getManifest(fetchUrl);
51
50
 
@@ -54,7 +53,7 @@ class FileLayer extends _ems_service.AbstractEmsService {
54
53
  geojson = fetchedJson;
55
54
  } else if (format === 'topojson') {
56
55
  const meta = this.getDefaultFormatMeta();
57
- const featureCollectionPath = meta?.feature_collection_path ?? 'data'; // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
56
+ const featureCollectionPath = (meta === null || meta === void 0 ? void 0 : meta.feature_collection_path) ?? 'data'; // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
58
57
 
59
58
  geojson = topojson.feature(fetchedJson, featureCollectionPath);
60
59
  } else {
@@ -9,16 +9,22 @@ Object.defineProperty(exports, "EMSClient", {
9
9
  return _ems_client.EMSClient;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "ORIGIN", {
12
+ Object.defineProperty(exports, "FileLayer", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _origin.ORIGIN;
15
+ return _file_layer.FileLayer;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "FileLayer", {
18
+ Object.defineProperty(exports, "FileLayerField", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _file_layer.FileLayer;
21
+ return _ems_client.FileLayerField;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "ORIGIN", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _origin.ORIGIN;
22
28
  }
23
29
  });
24
30
  Object.defineProperty(exports, "TMSService", {
@@ -23,7 +23,7 @@ import semver from 'semver';
23
23
  import { format as formatUrl, parse as parseUrl } from 'url';
24
24
  import { toAbsoluteUrl } from './utils';
25
25
  import LRUCache from 'lru-cache';
26
- var DEFAULT_EMS_VERSION = '7.14';
26
+ var DEFAULT_EMS_VERSION = '8.0';
27
27
 
28
28
  /**
29
29
  * plugins cannot have upstream dependencies on core/*-kibana.
@@ -187,7 +187,7 @@ export var EMSClient = /*#__PURE__*/function () {
187
187
  key: "getManifest",
188
188
  value: function () {
189
189
  var _getManifest = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(endpointUrl) {
190
- var url, result;
190
+ var url, response;
191
191
  return regeneratorRuntime.wrap(function _callee$(_context) {
192
192
  while (1) {
193
193
  switch (_context.prev = _context.next) {
@@ -200,47 +200,55 @@ export var EMSClient = /*#__PURE__*/function () {
200
200
  return this._fetchWithTimeout(url);
201
201
 
202
202
  case 4:
203
- result = _context.sent;
203
+ response = _context.sent;
204
204
 
205
- if (!result) {
206
- _context.next = 11;
205
+ if (response.ok) {
206
+ _context.next = 7;
207
207
  break;
208
208
  }
209
209
 
210
- _context.next = 8;
211
- return result.json();
210
+ throw new Error(response.statusText);
212
211
 
213
- case 8:
212
+ case 7:
213
+ if (!response) {
214
+ _context.next = 13;
215
+ break;
216
+ }
217
+
218
+ _context.next = 10;
219
+ return response.json();
220
+
221
+ case 10:
214
222
  _context.t0 = _context.sent;
215
- _context.next = 12;
223
+ _context.next = 14;
216
224
  break;
217
225
 
218
- case 11:
226
+ case 13:
219
227
  _context.t0 = null;
220
228
 
221
- case 12:
229
+ case 14:
222
230
  return _context.abrupt("return", _context.t0);
223
231
 
224
- case 15:
225
- _context.prev = 15;
232
+ case 17:
233
+ _context.prev = 17;
226
234
  _context.t1 = _context["catch"](0);
227
235
 
228
- if (!_context.t1) {
229
- _context.t1 = new Error('Unknown error');
230
- }
231
-
232
236
  if (!(_context.t1 instanceof Error)) {
233
- _context.t1 = new Error(_context.t1.data || "status ".concat(_context.t1.statusText || _context.t1.status));
237
+ _context.next = 23;
238
+ break;
234
239
  }
235
240
 
236
- throw new Error("Unable to retrieve data from ".concat(endpointUrl, ": ").concat(_context.t1.message));
241
+ throw _context.t1;
242
+
243
+ case 23:
244
+ throw new Error('Unknown error');
237
245
 
238
- case 20:
246
+ case 24:
239
247
  case "end":
240
248
  return _context.stop();
241
249
  }
242
250
  }
243
- }, _callee, this, [[0, 15]]);
251
+ }, _callee, this, [[0, 17]]);
244
252
  }));
245
253
 
246
254
  function getManifest(_x) {
@@ -1,6 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
6
 
@@ -20,11 +20,11 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
20
20
 
21
21
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22
22
 
23
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
24
24
 
25
25
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
26
26
 
27
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
27
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
28
28
 
29
29
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
30
30
 
@@ -85,8 +85,7 @@ export var FileLayer = /*#__PURE__*/function (_AbstractEmsService) {
85
85
 
86
86
  case 3:
87
87
  format = this.getDefaultFormatType();
88
- fetchUrl = this.getDefaultFormatUrl(); // let fetchedJson;
89
-
88
+ fetchUrl = this.getDefaultFormatUrl();
90
89
  _context.next = 7;
91
90
  return this._emsClient.getManifest(fetchUrl);
92
91
 
@@ -4,7 +4,7 @@
4
4
  * 2.0; you may not use this file except in compliance with the Elastic License
5
5
  * 2.0.
6
6
  */
7
- export { EMSClient } from './ems_client';
7
+ export { EMSClient, FileLayerField } from './ems_client';
8
8
  export { ORIGIN } from './origin';
9
9
  export { FileLayer } from './file_layer';
10
10
  export { TMSService } from './tms_service';