@elastic/ems-client 8.7.0 → 8.8.1

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.
@@ -1,10 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
3
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
4
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
5
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
1
  /*
9
2
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
3
  * or more contributor license agreements. Licensed under the Elastic License
@@ -12,51 +5,44 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
12
5
  * 2.0.
13
6
  */
14
7
 
8
+ import { EMSClient, BaseEmsServiceConfig } from './ems_client';
15
9
  import { toAbsoluteUrl } from './utils';
16
- export var AbstractEmsService = /*#__PURE__*/function () {
17
- function AbstractEmsService(config, emsClient, proxyPath) {
18
- var _this = this;
19
- _classCallCheck(this, AbstractEmsService);
20
- _defineProperty(this, "_emsClient", void 0);
21
- _defineProperty(this, "_config", void 0);
22
- _defineProperty(this, "_proxyPath", void 0);
23
- /**
24
- * Checks if url is absolute. If not, prepend the basePath.
25
- */
26
- _defineProperty(this, "_getAbsoluteUrl", function (url) {
27
- if (/^https?:\/\//.test(url)) {
28
- return url;
29
- } else {
30
- return toAbsoluteUrl(_this.getApiUrl(), url);
31
- }
32
- });
10
+ export class AbstractEmsService {
11
+ _emsClient;
12
+ _config;
13
+ _proxyPath;
14
+ constructor(config, emsClient, proxyPath) {
33
15
  this._config = config;
34
16
  this._emsClient = emsClient;
35
17
  this._proxyPath = proxyPath;
36
18
  }
37
- return _createClass(AbstractEmsService, [{
38
- key: "getAttributions",
39
- value: function getAttributions() {
40
- var _this2 = this;
41
- return this._config.attribution.map(function (attribution) {
42
- var url = _this2._emsClient.getValueInLanguage(attribution.url);
43
- var label = _this2._emsClient.getValueInLanguage(attribution.label);
44
- return {
45
- url: url,
46
- label: label
47
- };
48
- });
49
- }
50
- }, {
51
- key: "getMarkdownAttribution",
52
- value: function getMarkdownAttribution() {
53
- var _this3 = this;
54
- var attributions = this._config.attribution.map(function (attribution) {
55
- var url = _this3._emsClient.getValueInLanguage(attribution.url);
56
- var label = _this3._emsClient.getValueInLanguage(attribution.label);
57
- return "[".concat(label, "](").concat(url, ")");
58
- });
59
- return attributions.join('|');
19
+ getAttributions() {
20
+ return this._config.attribution.map(attribution => {
21
+ const url = this._emsClient.getValueInLanguage(attribution.url);
22
+ const label = this._emsClient.getValueInLanguage(attribution.label);
23
+ return {
24
+ url: url,
25
+ label: label
26
+ };
27
+ });
28
+ }
29
+ getMarkdownAttribution() {
30
+ const attributions = this._config.attribution.map(attribution => {
31
+ const url = this._emsClient.getValueInLanguage(attribution.url);
32
+ const label = this._emsClient.getValueInLanguage(attribution.label);
33
+ return `[${label}](${url})`;
34
+ });
35
+ return attributions.join('|');
36
+ }
37
+
38
+ /**
39
+ * Checks if url is absolute. If not, prepend the basePath.
40
+ */
41
+ _getAbsoluteUrl = url => {
42
+ if (/^https?:\/\//.test(url)) {
43
+ return url;
44
+ } else {
45
+ return toAbsoluteUrl(this.getApiUrl(), url);
60
46
  }
61
- }]);
62
- }();
47
+ };
48
+ }
@@ -1,23 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
5
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
6
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
7
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
8
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
13
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
14
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
15
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
16
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
17
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
18
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
1
  /*
22
2
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
3
  * or more contributor license agreements. Licensed under the Elastic License
@@ -26,204 +6,132 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
26
6
  */
27
7
 
28
8
  import url from 'url';
9
+ import { EMSClient, EmsFileLayerFormatGeoJson, EmsFileLayerFormatTopoJson, FileLayerConfig, FileLayerField } from './ems_client';
29
10
  import { AbstractEmsService } from './ems_service';
30
11
  import * as topojson from 'topojson-client';
31
- export var EMSFormatType = /*#__PURE__*/function (EMSFormatType) {
12
+ export let EMSFormatType = /*#__PURE__*/function (EMSFormatType) {
32
13
  EMSFormatType["geojson"] = "geojson";
33
14
  EMSFormatType["topojson"] = "topojson";
34
15
  return EMSFormatType;
35
16
  }({});
36
- export var FileLayer = /*#__PURE__*/function (_AbstractEmsService) {
37
- function FileLayer(config, emsClient, proxyPath) {
38
- var _this;
39
- _classCallCheck(this, FileLayer);
40
- _this = _callSuper(this, FileLayer, [config, emsClient, proxyPath]);
41
- _defineProperty(_this, "_config", void 0);
42
- _this._config = config;
43
- return _this;
44
- }
45
- _inherits(FileLayer, _AbstractEmsService);
46
- return _createClass(FileLayer, [{
47
- key: "getGeoJson",
48
- value: function () {
49
- var _getGeoJson = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
50
- var cachedGeoJson, format, fetchUrl, geojson, fetchedJson, _meta$feature_collect, meta, featureCollectionPath;
51
- return _regenerator().w(function (_context) {
52
- while (1) switch (_context.n) {
53
- case 0:
54
- cachedGeoJson = this._emsClient.getCachedGeoJson(this.getId());
55
- if (!cachedGeoJson) {
56
- _context.n = 1;
57
- break;
58
- }
59
- return _context.a(2, cachedGeoJson);
60
- case 1:
61
- format = this.getDefaultFormatType();
62
- fetchUrl = this.getDefaultFormatUrl();
63
- _context.n = 2;
64
- return this._emsClient.getManifest(fetchUrl);
65
- case 2:
66
- fetchedJson = _context.v;
67
- if (!fetchedJson) {
68
- _context.n = 6;
69
- break;
70
- }
71
- if (!(format === 'geojson')) {
72
- _context.n = 3;
73
- break;
74
- }
75
- geojson = fetchedJson;
76
- _context.n = 5;
77
- break;
78
- case 3:
79
- if (!(format === 'topojson')) {
80
- _context.n = 4;
81
- break;
82
- }
83
- meta = this.getDefaultFormatMeta();
84
- featureCollectionPath = (_meta$feature_collect = meta === null || meta === void 0 ? void 0 : meta.feature_collection_path) !== null && _meta$feature_collect !== void 0 ? _meta$feature_collect : 'data'; // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
85
- geojson = topojson.feature(fetchedJson, featureCollectionPath);
86
- _context.n = 5;
87
- break;
88
- case 4:
89
- return _context.a(2);
90
- case 5:
91
- this._emsClient.cacheGeoJson(this.getId(), geojson);
92
- return _context.a(2, geojson);
93
- case 6:
94
- return _context.a(2);
95
- }
96
- }, _callee, this);
97
- }));
98
- function getGeoJson() {
99
- return _getGeoJson.apply(this, arguments);
100
- }
101
- return getGeoJson;
102
- }()
103
- }, {
104
- key: "getFields",
105
- value: function getFields() {
106
- return this._config.fields;
107
- }
108
- }, {
109
- key: "getFieldsInLanguage",
110
- value: function getFieldsInLanguage() {
111
- var _this2 = this;
112
- return this.getFields().map(function (field) {
113
- return {
114
- type: field.type,
115
- name: field.id,
116
- description: _this2._emsClient.getValueInLanguage(field.label)
117
- };
118
- });
119
- }
120
- }, {
121
- key: "getDisplayName",
122
- value: function getDisplayName() {
123
- var layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
124
- return layerName ? layerName : '';
125
- }
126
- }, {
127
- key: "getId",
128
- value: function getId() {
129
- return this._config.layer_id;
130
- }
131
- }, {
132
- key: "hasId",
133
- value: function hasId(id) {
134
- var matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
135
- return this._config.layer_id === id || matchesLegacyId;
136
- }
137
- }, {
138
- key: "getEMSHotLink",
139
- value: function getEMSHotLink() {
140
- var landingPageString = this._emsClient.getLandingPageUrl();
141
- var urlObject = url.parse(landingPageString, true);
142
- urlObject.hash = "file/".concat(this.getId());
143
- urlObject.query = _objectSpread(_objectSpread({}, urlObject.query), {}, {
144
- locale: this._emsClient.getLocale()
145
- });
146
- return url.format(urlObject);
147
- }
148
- }, {
149
- key: "getDefaultFormatType",
150
- value: function getDefaultFormatType() {
151
- var format = this._getDefaultFormat();
152
- return format.type;
153
- }
154
- }, {
155
- key: "getFormatOfType",
156
- value: function getFormatOfType(type) {
157
- var format = this._getFormatOfType(type);
158
- return format.type;
159
- }
160
- }, {
161
- key: "getDefaultFormatMeta",
162
- value: function getDefaultFormatMeta() {
163
- var format = this._getDefaultFormat();
164
- return this._getFormatMeta(format);
165
- }
166
- }, {
167
- key: "getFormatOfTypeMeta",
168
- value: function getFormatOfTypeMeta(type) {
169
- var format = this._getFormatOfType(type);
170
- return this._getFormatMeta(format);
171
- }
172
- }, {
173
- key: "getDefaultFormatUrl",
174
- value: function getDefaultFormatUrl() {
175
- var format = this._getDefaultFormat();
176
- return this._getFormatUrl(format);
177
- }
178
- }, {
179
- key: "getFormatOfTypeUrl",
180
- value: function getFormatOfTypeUrl(type) {
181
- var format = this._getFormatOfType(type);
182
- return this._getFormatUrl(format);
183
- }
184
- }, {
185
- key: "getCreatedAt",
186
- value: function getCreatedAt() {
187
- return this._config.created_at;
188
- }
189
- }, {
190
- key: "getApiUrl",
191
- value: function getApiUrl() {
192
- return this._emsClient.getFileApiUrl();
193
- }
194
- }, {
195
- key: "_getFormatUrl",
196
- value: function _getFormatUrl(format) {
197
- var url = this._proxyPath + this._getAbsoluteUrl(format.url);
198
- return this._emsClient.extendUrlWithParams(url);
199
- }
200
- }, {
201
- key: "_getFormatMeta",
202
- value: function _getFormatMeta(format) {
203
- if ('meta' in format) {
204
- return format.meta;
17
+ export class FileLayer extends AbstractEmsService {
18
+ _config;
19
+ constructor(config, emsClient, proxyPath) {
20
+ super(config, emsClient, proxyPath);
21
+ this._config = config;
22
+ }
23
+ async getGeoJson() {
24
+ const cachedGeoJson = this._emsClient.getCachedGeoJson(this.getId());
25
+ if (cachedGeoJson) {
26
+ return cachedGeoJson;
27
+ }
28
+ const format = this.getDefaultFormatType();
29
+ const fetchUrl = this.getDefaultFormatUrl();
30
+ let geojson;
31
+ const fetchedJson = await this._emsClient.getManifest(fetchUrl);
32
+ if (fetchedJson) {
33
+ if (format === 'geojson') {
34
+ geojson = fetchedJson;
35
+ } else if (format === 'topojson') {
36
+ const meta = this.getDefaultFormatMeta();
37
+ const featureCollectionPath = meta?.feature_collection_path ?? 'data';
38
+ // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52156
39
+ geojson = topojson.feature(fetchedJson, featureCollectionPath);
205
40
  } else {
206
41
  return;
207
42
  }
43
+ this._emsClient.cacheGeoJson(this.getId(), geojson);
44
+ return geojson;
208
45
  }
209
- }, {
210
- key: "_getDefaultFormat",
211
- value: function _getDefaultFormat() {
212
- var defaultFormat = this._config.formats.find(function (format) {
213
- return format.legacy_default;
214
- });
215
- if (defaultFormat) {
216
- return defaultFormat;
217
- }
218
- return this._config.formats[0];
219
- }
220
- }, {
221
- key: "_getFormatOfType",
222
- value: function _getFormatOfType(type) {
223
- var requestedFormat = this._config.formats.find(function (format) {
224
- return format.type === type;
225
- });
226
- return requestedFormat || this._getDefaultFormat();
46
+ return;
47
+ }
48
+ getFields() {
49
+ return this._config.fields;
50
+ }
51
+ getFieldsInLanguage() {
52
+ return this.getFields().map(field => {
53
+ return {
54
+ type: field.type,
55
+ name: field.id,
56
+ description: this._emsClient.getValueInLanguage(field.label)
57
+ };
58
+ });
59
+ }
60
+ getDisplayName() {
61
+ const layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
62
+ return layerName ? layerName : '';
63
+ }
64
+ getId() {
65
+ return this._config.layer_id;
66
+ }
67
+ hasId(id) {
68
+ const matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
69
+ return this._config.layer_id === id || matchesLegacyId;
70
+ }
71
+ getEMSHotLink() {
72
+ const landingPageString = this._emsClient.getLandingPageUrl();
73
+ const urlObject = url.parse(landingPageString, true);
74
+ urlObject.hash = `file/${this.getId()}`;
75
+ urlObject.query = {
76
+ ...urlObject.query,
77
+ locale: this._emsClient.getLocale()
78
+ };
79
+ return url.format(urlObject);
80
+ }
81
+ getDefaultFormatType() {
82
+ const format = this._getDefaultFormat();
83
+ return format.type;
84
+ }
85
+ getFormatOfType(type) {
86
+ const format = this._getFormatOfType(type);
87
+ return format.type;
88
+ }
89
+ getDefaultFormatMeta() {
90
+ const format = this._getDefaultFormat();
91
+ return this._getFormatMeta(format);
92
+ }
93
+ getFormatOfTypeMeta(type) {
94
+ const format = this._getFormatOfType(type);
95
+ return this._getFormatMeta(format);
96
+ }
97
+ getDefaultFormatUrl() {
98
+ const format = this._getDefaultFormat();
99
+ return this._getFormatUrl(format);
100
+ }
101
+ getFormatOfTypeUrl(type) {
102
+ const format = this._getFormatOfType(type);
103
+ return this._getFormatUrl(format);
104
+ }
105
+ getCreatedAt() {
106
+ return this._config.created_at;
107
+ }
108
+ getApiUrl() {
109
+ return this._emsClient.getFileApiUrl();
110
+ }
111
+ _getFormatUrl(format) {
112
+ const url = this._proxyPath + this._getAbsoluteUrl(format.url);
113
+ return this._emsClient.extendUrlWithParams(url);
114
+ }
115
+ _getFormatMeta(format) {
116
+ if ('meta' in format) {
117
+ return format.meta;
118
+ } else {
119
+ return;
227
120
  }
228
- }]);
229
- }(AbstractEmsService);
121
+ }
122
+ _getDefaultFormat() {
123
+ const defaultFormat = this._config.formats.find(format => {
124
+ return format.legacy_default;
125
+ });
126
+ if (defaultFormat) {
127
+ return defaultFormat;
128
+ }
129
+ return this._config.formats[0];
130
+ }
131
+ _getFormatOfType(type) {
132
+ const requestedFormat = this._config.formats.find(format => {
133
+ return format.type === type;
134
+ });
135
+ return requestedFormat || this._getDefaultFormat();
136
+ }
137
+ }