@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.
@@ -1,125 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/helpers/classCallCheck", "@babel/runtime/helpers/createClass", "@babel/runtime/helpers/defineProperty", "./origin", "./utils"], factory);
4
- } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/helpers/classCallCheck"), require("@babel/runtime/helpers/createClass"), require("@babel/runtime/helpers/defineProperty"), require("./origin"), require("./utils"));
6
- } else {
7
- var mod = {
8
- exports: {}
9
- };
10
- factory(mod.exports, global.classCallCheck, global.createClass, global.defineProperty, global.origin, global.utils);
11
- global.ems_service = mod.exports;
12
- }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _classCallCheck2, _createClass2, _defineProperty2, _origin, _utils) {
14
- "use strict";
15
-
16
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
-
18
- Object.defineProperty(_exports, "__esModule", {
19
- value: true
20
- });
21
- _exports.AbstractEmsService = void 0;
22
- _classCallCheck2 = _interopRequireDefault(_classCallCheck2);
23
- _createClass2 = _interopRequireDefault(_createClass2);
24
- _defineProperty2 = _interopRequireDefault(_defineProperty2);
25
-
26
- /*
27
- * Licensed to Elasticsearch B.V. under one or more contributor
28
- * license agreements. See the NOTICE file distributed with
29
- * this work for additional information regarding copyright
30
- * ownership. Elasticsearch B.V. licenses this file to you under
31
- * the Apache License, Version 2.0 (the "License"); you may
32
- * not use this file except in compliance with the License.
33
- * You may obtain a copy of the License at
34
- *
35
- * http://www.apache.org/licenses/LICENSE-2.0
36
- *
37
- * Unless required by applicable law or agreed to in writing,
38
- * software distributed under the License is distributed on an
39
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
- * KIND, either express or implied. See the License for the
41
- * specific language governing permissions and limitations
42
- * under the License.
43
- */
44
- var AbstractEmsService = /*#__PURE__*/function () {
45
- function AbstractEmsService(config, emsClient, proxyPath) {
46
- var _this = this;
47
-
48
- (0, _classCallCheck2["default"])(this, AbstractEmsService);
49
- (0, _defineProperty2["default"])(this, "_emsClient", void 0);
50
- (0, _defineProperty2["default"])(this, "_config", void 0);
51
- (0, _defineProperty2["default"])(this, "_proxyPath", void 0);
52
- (0, _defineProperty2["default"])(this, "_getAbsoluteUrl", function (url) {
53
- if (/^https?:\/\//.test(url)) {
54
- return url;
55
- } else {
56
- return (0, _utils.toAbsoluteUrl)(_this.getApiUrl(), url);
57
- }
58
- });
59
- this._config = config;
60
- this._emsClient = emsClient;
61
- this._proxyPath = proxyPath;
62
- }
63
-
64
- (0, _createClass2["default"])(AbstractEmsService, [{
65
- key: "getAttributions",
66
- value: function getAttributions() {
67
- var _this2 = this;
68
-
69
- return this._config.attribution.map(function (attribution) {
70
- var url = _this2._emsClient.getValueInLanguage(attribution.url);
71
-
72
- var label = _this2._emsClient.getValueInLanguage(attribution.label);
73
-
74
- return {
75
- url: url,
76
- label: label
77
- };
78
- });
79
- }
80
- }, {
81
- key: "getHTMLAttribution",
82
- value: function getHTMLAttribution() {
83
- var _this3 = this;
84
-
85
- var attributions = this._config.attribution.map(function (attribution) {
86
- var url = _this3._emsClient.getValueInLanguage(attribution.url);
87
-
88
- var label = _this3._emsClient.getValueInLanguage(attribution.label);
89
-
90
- var html = url ? "<a rel=\"noreferrer noopener\" href=\"".concat(url, "\">").concat(label, "</a>") : label;
91
- return _this3._emsClient.sanitizeHtml(html);
92
- });
93
-
94
- return attributions.join(' | '); //!!!this is the current convention used in Kibana
95
- }
96
- }, {
97
- key: "getMarkdownAttribution",
98
- value: function getMarkdownAttribution() {
99
- var _this4 = this;
100
-
101
- var attributions = this._config.attribution.map(function (attribution) {
102
- var url = _this4._emsClient.getValueInLanguage(attribution.url);
103
-
104
- var label = _this4._emsClient.getValueInLanguage(attribution.label);
105
-
106
- return "[".concat(label, "](").concat(url, ")");
107
- });
108
-
109
- return attributions.join('|');
110
- }
111
- }, {
112
- key: "getOrigin",
113
- value: function getOrigin() {
114
- return _origin.ORIGIN.EMS;
115
- }
116
- /**
117
- * Checks if url is absolute. If not, prepend the basePath.
118
- */
119
-
120
- }]);
121
- return AbstractEmsService;
122
- }();
123
-
124
- _exports.AbstractEmsService = AbstractEmsService;
125
- });
@@ -1,158 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof define === "function" && define.amd) {
3
- define(["exports", "@babel/runtime/helpers/classCallCheck", "@babel/runtime/helpers/createClass", "@babel/runtime/helpers/assertThisInitialized", "@babel/runtime/helpers/possibleConstructorReturn", "@babel/runtime/helpers/getPrototypeOf", "@babel/runtime/helpers/inherits", "@babel/runtime/helpers/defineProperty", "url", "./ems_service"], factory);
4
- } else if (typeof exports !== "undefined") {
5
- factory(exports, require("@babel/runtime/helpers/classCallCheck"), require("@babel/runtime/helpers/createClass"), require("@babel/runtime/helpers/assertThisInitialized"), require("@babel/runtime/helpers/possibleConstructorReturn"), require("@babel/runtime/helpers/getPrototypeOf"), require("@babel/runtime/helpers/inherits"), require("@babel/runtime/helpers/defineProperty"), require("url"), require("./ems_service"));
6
- } else {
7
- var mod = {
8
- exports: {}
9
- };
10
- factory(mod.exports, global.classCallCheck, global.createClass, global.assertThisInitialized, global.possibleConstructorReturn, global.getPrototypeOf, global.inherits, global.defineProperty, global.url, global.ems_service);
11
- global.file_layer = mod.exports;
12
- }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _classCallCheck2, _createClass2, _assertThisInitialized2, _possibleConstructorReturn2, _getPrototypeOf2, _inherits2, _defineProperty2, _url, _ems_service) {
14
- "use strict";
15
-
16
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
17
-
18
- Object.defineProperty(_exports, "__esModule", {
19
- value: true
20
- });
21
- _exports.FileLayer = void 0;
22
- _classCallCheck2 = _interopRequireDefault(_classCallCheck2);
23
- _createClass2 = _interopRequireDefault(_createClass2);
24
- _assertThisInitialized2 = _interopRequireDefault(_assertThisInitialized2);
25
- _possibleConstructorReturn2 = _interopRequireDefault(_possibleConstructorReturn2);
26
- _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf2);
27
- _inherits2 = _interopRequireDefault(_inherits2);
28
- _defineProperty2 = _interopRequireDefault(_defineProperty2);
29
- _url = _interopRequireDefault(_url);
30
-
31
- 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; }
32
-
33
- 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) { (0, _defineProperty2["default"])(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; }
34
-
35
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
36
-
37
- 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; } }
38
-
39
- var FileLayer = /*#__PURE__*/function (_AbstractEmsService) {
40
- (0, _inherits2["default"])(FileLayer, _AbstractEmsService);
41
-
42
- var _super = _createSuper(FileLayer);
43
-
44
- function FileLayer(config, emsClient, proxyPath) {
45
- var _this;
46
-
47
- (0, _classCallCheck2["default"])(this, FileLayer);
48
- _this = _super.call(this, config, emsClient, proxyPath);
49
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_config", void 0);
50
- _this._config = config;
51
- return _this;
52
- }
53
-
54
- (0, _createClass2["default"])(FileLayer, [{
55
- key: "getFields",
56
- value: function getFields() {
57
- return this._config.fields;
58
- }
59
- }, {
60
- key: "getFieldsInLanguage",
61
- value: function getFieldsInLanguage() {
62
- var _this2 = this;
63
-
64
- return this.getFields().map(function (field) {
65
- return {
66
- type: field.type,
67
- name: field.id,
68
- description: _this2._emsClient.getValueInLanguage(field.label)
69
- };
70
- });
71
- }
72
- }, {
73
- key: "getDisplayName",
74
- value: function getDisplayName() {
75
- var layerName = this._emsClient.getValueInLanguage(this._config.layer_name);
76
-
77
- return layerName ? layerName : '';
78
- }
79
- }, {
80
- key: "getId",
81
- value: function getId() {
82
- return this._config.layer_id;
83
- }
84
- }, {
85
- key: "hasId",
86
- value: function hasId(id) {
87
- var matchesLegacyId = this._config.legacy_ids.indexOf(id) >= 0;
88
- return this._config.layer_id === id || matchesLegacyId;
89
- }
90
- }, {
91
- key: "getEMSHotLink",
92
- value: function getEMSHotLink() {
93
- var landingPageString = this._emsClient.getLandingPageUrl();
94
-
95
- var urlObject = _url["default"].parse(landingPageString, true);
96
-
97
- urlObject.hash = "file/".concat(this.getId());
98
- urlObject.query = _objectSpread({}, urlObject.query, {
99
- locale: this._emsClient.getLocale()
100
- });
101
- return _url["default"].format(urlObject);
102
- }
103
- }, {
104
- key: "getDefaultFormatType",
105
- value: function getDefaultFormatType() {
106
- var format = this._getDefaultFormat();
107
-
108
- return format.type;
109
- }
110
- }, {
111
- key: "getDefaultFormatMeta",
112
- value: function getDefaultFormatMeta() {
113
- var format = this._getDefaultFormat();
114
-
115
- if ('meta' in format) {
116
- return format.meta;
117
- } else {
118
- return;
119
- }
120
- }
121
- }, {
122
- key: "getDefaultFormatUrl",
123
- value: function getDefaultFormatUrl() {
124
- var format = this._getDefaultFormat();
125
-
126
- var url = this._proxyPath + this._getAbsoluteUrl(format.url);
127
-
128
- return this._emsClient.extendUrlWithParams(url);
129
- }
130
- }, {
131
- key: "getCreatedAt",
132
- value: function getCreatedAt() {
133
- return this._config.created_at;
134
- }
135
- }, {
136
- key: "getApiUrl",
137
- value: function getApiUrl() {
138
- return this._emsClient.getFileApiUrl();
139
- }
140
- }, {
141
- key: "_getDefaultFormat",
142
- value: function _getDefaultFormat() {
143
- var defaultFormat = this._config.formats.find(function (format) {
144
- return format.legacy_default;
145
- });
146
-
147
- if (defaultFormat) {
148
- return defaultFormat;
149
- }
150
-
151
- return this._config.formats[0];
152
- }
153
- }]);
154
- return FileLayer;
155
- }(_ems_service.AbstractEmsService);
156
-
157
- _exports.FileLayer = FileLayer;
158
- });
@@ -1,43 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof define === "function" && define.amd) {
3
- define(["exports", "./ems_client", "./origin", "./file_layer", "./tms_service"], factory);
4
- } else if (typeof exports !== "undefined") {
5
- factory(exports, require("./ems_client"), require("./origin"), require("./file_layer"), require("./tms_service"));
6
- } else {
7
- var mod = {
8
- exports: {}
9
- };
10
- factory(mod.exports, global.ems_client, global.origin, global.file_layer, global.tms_service);
11
- global.index = mod.exports;
12
- }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _ems_client, _origin, _file_layer, _tms_service) {
14
- "use strict";
15
-
16
- Object.defineProperty(_exports, "__esModule", {
17
- value: true
18
- });
19
- Object.defineProperty(_exports, "EMSClient", {
20
- enumerable: true,
21
- get: function get() {
22
- return _ems_client.EMSClient;
23
- }
24
- });
25
- Object.defineProperty(_exports, "ORIGIN", {
26
- enumerable: true,
27
- get: function get() {
28
- return _origin.ORIGIN;
29
- }
30
- });
31
- Object.defineProperty(_exports, "FileLayer", {
32
- enumerable: true,
33
- get: function get() {
34
- return _file_layer.FileLayer;
35
- }
36
- });
37
- Object.defineProperty(_exports, "TMSService", {
38
- enumerable: true,
39
- get: function get() {
40
- return _tms_service.TMSService;
41
- }
42
- });
43
- });
@@ -1,44 +0,0 @@
1
- (function (global, factory) {
2
- if (typeof define === "function" && define.amd) {
3
- define(["exports"], factory);
4
- } else if (typeof exports !== "undefined") {
5
- factory(exports);
6
- } else {
7
- var mod = {
8
- exports: {}
9
- };
10
- factory(mod.exports);
11
- global.origin = mod.exports;
12
- }
13
- })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
14
- "use strict";
15
-
16
- Object.defineProperty(_exports, "__esModule", {
17
- value: true
18
- });
19
- _exports.ORIGIN = void 0;
20
-
21
- /*
22
- * Licensed to Elasticsearch B.V. under one or more contributor
23
- * license agreements. See the NOTICE file distributed with
24
- * this work for additional information regarding copyright
25
- * ownership. Elasticsearch B.V. licenses this file to you under
26
- * the Apache License, Version 2.0 (the "License"); you may
27
- * not use this file except in compliance with the License.
28
- * You may obtain a copy of the License at
29
- *
30
- * http://www.apache.org/licenses/LICENSE-2.0
31
- *
32
- * Unless required by applicable law or agreed to in writing,
33
- * software distributed under the License is distributed on an
34
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
35
- * KIND, either express or implied. See the License for the
36
- * specific language governing permissions and limitations
37
- * under the License.
38
- */
39
- var ORIGIN = {
40
- EMS: 'elastic_maps_service',
41
- KIBANA_YML: 'self_hosted'
42
- };
43
- _exports.ORIGIN = ORIGIN;
44
- });