geoserver-node-client 1.2.4 → 1.4.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,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
12
  var _nodeFetch = _interopRequireDefault(require("node-fetch"));
19
-
20
13
  var _geoserver = require("./util/geoserver.js");
21
-
22
14
  /**
23
15
  * Client for GeoServer settings.
24
16
  *
@@ -36,6 +28,7 @@ var SettingsClient = /*#__PURE__*/function () {
36
28
  this.url = url;
37
29
  this.auth = auth;
38
30
  }
31
+
39
32
  /**
40
33
  * Get the complete GeoServer settings object.
41
34
  *
@@ -43,56 +36,44 @@ var SettingsClient = /*#__PURE__*/function () {
43
36
  *
44
37
  * @returns {Object} Settings object
45
38
  */
46
-
47
-
48
39
  (0, _createClass2["default"])(SettingsClient, [{
49
40
  key: "getSettings",
50
41
  value: function () {
51
42
  var _getSettings = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
52
43
  var response, geoServerResponse;
53
44
  return _regenerator["default"].wrap(function _callee$(_context) {
54
- while (1) {
55
- switch (_context.prev = _context.next) {
56
- case 0:
57
- _context.next = 2;
58
- return (0, _nodeFetch["default"])(this.url + 'settings.json', {
59
- credentials: 'include',
60
- method: 'GET',
61
- headers: {
62
- Authorization: this.auth
63
- }
64
- });
65
-
66
- case 2:
67
- response = _context.sent;
68
-
69
- if (response.ok) {
70
- _context.next = 8;
71
- break;
45
+ while (1) switch (_context.prev = _context.next) {
46
+ case 0:
47
+ _context.next = 2;
48
+ return (0, _nodeFetch["default"])(this.url + 'settings.json', {
49
+ credentials: 'include',
50
+ method: 'GET',
51
+ headers: {
52
+ Authorization: this.auth
72
53
  }
73
-
74
- _context.next = 6;
75
- return (0, _geoserver.getGeoServerResponseText)(response);
76
-
77
- case 6:
78
- geoServerResponse = _context.sent;
79
- throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
80
-
81
- case 8:
82
- return _context.abrupt("return", response.json());
83
-
84
- case 9:
85
- case "end":
86
- return _context.stop();
87
- }
54
+ });
55
+ case 2:
56
+ response = _context.sent;
57
+ if (response.ok) {
58
+ _context.next = 8;
59
+ break;
60
+ }
61
+ _context.next = 6;
62
+ return (0, _geoserver.getGeoServerResponseText)(response);
63
+ case 6:
64
+ geoServerResponse = _context.sent;
65
+ throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
66
+ case 8:
67
+ return _context.abrupt("return", response.json());
68
+ case 9:
69
+ case "end":
70
+ return _context.stop();
88
71
  }
89
72
  }, _callee, this);
90
73
  }));
91
-
92
74
  function getSettings() {
93
75
  return _getSettings.apply(this, arguments);
94
76
  }
95
-
96
77
  return getSettings;
97
78
  }()
98
79
  /**
@@ -100,54 +81,44 @@ var SettingsClient = /*#__PURE__*/function () {
100
81
  *
101
82
  * @param {Object} settings The adapted GeoServer settings object
102
83
  */
103
-
104
84
  }, {
105
85
  key: "updateSettings",
106
86
  value: function () {
107
87
  var _updateSettings = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(settings) {
108
88
  var response, geoServerResponse;
109
89
  return _regenerator["default"].wrap(function _callee2$(_context2) {
110
- while (1) {
111
- switch (_context2.prev = _context2.next) {
112
- case 0:
113
- _context2.next = 2;
114
- return (0, _nodeFetch["default"])(this.url + 'settings', {
115
- credentials: 'include',
116
- method: 'PUT',
117
- headers: {
118
- Authorization: this.auth,
119
- 'Content-Type': 'application/json'
120
- },
121
- body: JSON.stringify(settings)
122
- });
123
-
124
- case 2:
125
- response = _context2.sent;
126
-
127
- if (response.ok) {
128
- _context2.next = 8;
129
- break;
130
- }
131
-
132
- _context2.next = 6;
133
- return (0, _geoserver.getGeoServerResponseText)(response);
134
-
135
- case 6:
136
- geoServerResponse = _context2.sent;
137
- throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
138
-
139
- case 8:
140
- case "end":
141
- return _context2.stop();
142
- }
90
+ while (1) switch (_context2.prev = _context2.next) {
91
+ case 0:
92
+ _context2.next = 2;
93
+ return (0, _nodeFetch["default"])(this.url + 'settings', {
94
+ credentials: 'include',
95
+ method: 'PUT',
96
+ headers: {
97
+ Authorization: this.auth,
98
+ 'Content-Type': 'application/json'
99
+ },
100
+ body: JSON.stringify(settings)
101
+ });
102
+ case 2:
103
+ response = _context2.sent;
104
+ if (response.ok) {
105
+ _context2.next = 8;
106
+ break;
107
+ }
108
+ _context2.next = 6;
109
+ return (0, _geoserver.getGeoServerResponseText)(response);
110
+ case 6:
111
+ geoServerResponse = _context2.sent;
112
+ throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
113
+ case 8:
114
+ case "end":
115
+ return _context2.stop();
143
116
  }
144
117
  }, _callee2, this);
145
118
  }));
146
-
147
119
  function updateSettings(_x) {
148
120
  return _updateSettings.apply(this, arguments);
149
121
  }
150
-
151
122
  return updateSettings;
152
123
  }()
153
124
  /**
@@ -155,47 +126,37 @@ var SettingsClient = /*#__PURE__*/function () {
155
126
  *
156
127
  * @param {String} proxyBaseUrl The proxy base URL
157
128
  */
158
-
159
129
  }, {
160
130
  key: "updateProxyBaseUrl",
161
131
  value: function () {
162
132
  var _updateProxyBaseUrl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(proxyBaseUrl) {
163
133
  var settingsJson;
164
134
  return _regenerator["default"].wrap(function _callee3$(_context3) {
165
- while (1) {
166
- switch (_context3.prev = _context3.next) {
167
- case 0:
168
- _context3.next = 2;
169
- return this.getSettings();
170
-
171
- case 2:
172
- settingsJson = _context3.sent;
173
-
174
- if (!(!settingsJson.global && !settingsJson.global.settings)) {
175
- _context3.next = 5;
176
- break;
177
- }
178
-
179
- return _context3.abrupt("return", false);
180
-
181
- case 5:
182
- // add proxyBaseUrl to settings
183
- settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
184
- _context3.next = 8;
185
- return this.updateSettings(settingsJson);
186
-
187
- case 8:
188
- case "end":
189
- return _context3.stop();
190
- }
135
+ while (1) switch (_context3.prev = _context3.next) {
136
+ case 0:
137
+ _context3.next = 2;
138
+ return this.getSettings();
139
+ case 2:
140
+ settingsJson = _context3.sent;
141
+ if (!(!settingsJson.global && !settingsJson.global.settings)) {
142
+ _context3.next = 5;
143
+ break;
144
+ }
145
+ return _context3.abrupt("return", false);
146
+ case 5:
147
+ // add proxyBaseUrl to settings
148
+ settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
149
+ _context3.next = 8;
150
+ return this.updateSettings(settingsJson);
151
+ case 8:
152
+ case "end":
153
+ return _context3.stop();
191
154
  }
192
155
  }, _callee3, this);
193
156
  }));
194
-
195
157
  function updateProxyBaseUrl(_x2) {
196
158
  return _updateProxyBaseUrl.apply(this, arguments);
197
159
  }
198
-
199
160
  return updateProxyBaseUrl;
200
161
  }()
201
162
  /**
@@ -205,55 +166,44 @@ var SettingsClient = /*#__PURE__*/function () {
205
166
  *
206
167
  * @returns {Object} An object with contact information
207
168
  */
208
-
209
169
  }, {
210
170
  key: "getContactInformation",
211
171
  value: function () {
212
172
  var _getContactInformation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
213
173
  var response, geoServerResponse;
214
174
  return _regenerator["default"].wrap(function _callee4$(_context4) {
215
- while (1) {
216
- switch (_context4.prev = _context4.next) {
217
- case 0:
218
- _context4.next = 2;
219
- return (0, _nodeFetch["default"])(this.url + 'settings/contact', {
220
- credentials: 'include',
221
- method: 'GET',
222
- headers: {
223
- Authorization: this.auth
224
- }
225
- });
226
-
227
- case 2:
228
- response = _context4.sent;
229
-
230
- if (response.ok) {
231
- _context4.next = 8;
232
- break;
175
+ while (1) switch (_context4.prev = _context4.next) {
176
+ case 0:
177
+ _context4.next = 2;
178
+ return (0, _nodeFetch["default"])(this.url + 'settings/contact', {
179
+ credentials: 'include',
180
+ method: 'GET',
181
+ headers: {
182
+ Authorization: this.auth
233
183
  }
234
-
235
- _context4.next = 6;
236
- return (0, _geoserver.getGeoServerResponseText)(response);
237
-
238
- case 6:
239
- geoServerResponse = _context4.sent;
240
- throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
241
-
242
- case 8:
243
- return _context4.abrupt("return", response.json());
244
-
245
- case 9:
246
- case "end":
247
- return _context4.stop();
248
- }
184
+ });
185
+ case 2:
186
+ response = _context4.sent;
187
+ if (response.ok) {
188
+ _context4.next = 8;
189
+ break;
190
+ }
191
+ _context4.next = 6;
192
+ return (0, _geoserver.getGeoServerResponseText)(response);
193
+ case 6:
194
+ geoServerResponse = _context4.sent;
195
+ throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
196
+ case 8:
197
+ return _context4.abrupt("return", response.json());
198
+ case 9:
199
+ case "end":
200
+ return _context4.stop();
249
201
  }
250
202
  }, _callee4, this);
251
203
  }));
252
-
253
204
  function getContactInformation() {
254
205
  return _getContactInformation.apply(this, arguments);
255
206
  }
256
-
257
207
  return getContactInformation;
258
208
  }()
259
209
  /**
@@ -273,73 +223,62 @@ var SettingsClient = /*#__PURE__*/function () {
273
223
  *
274
224
  * @throws Error if request fails
275
225
  */
276
-
277
226
  }, {
278
227
  key: "updateContactInformation",
279
228
  value: function () {
280
229
  var _updateContactInformation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
281
230
  var contact, body, url, response, geoServerResponse;
282
231
  return _regenerator["default"].wrap(function _callee5$(_context5) {
283
- while (1) {
284
- switch (_context5.prev = _context5.next) {
285
- case 0:
286
- contact = {
287
- address: address,
288
- addressCity: city,
289
- addressCountry: country,
290
- addressPostalCode: postalCode,
291
- addressState: state,
292
- contactEmail: email,
293
- contactOrganization: organization,
294
- contactPerson: contactPerson,
295
- contactVoice: phoneNumber
296
- };
297
- body = {
298
- contact: contact
299
- };
300
- url = this.url + 'settings/contact';
301
- _context5.next = 5;
302
- return (0, _nodeFetch["default"])(url, {
303
- credentials: 'include',
304
- method: 'PUT',
305
- headers: {
306
- Authorization: this.auth,
307
- 'Content-Type': 'application/json'
308
- },
309
- body: JSON.stringify(body)
310
- });
311
-
312
- case 5:
313
- response = _context5.sent;
314
-
315
- if (response.ok) {
316
- _context5.next = 11;
317
- break;
318
- }
319
-
320
- _context5.next = 9;
321
- return (0, _geoserver.getGeoServerResponseText)(response);
322
-
323
- case 9:
324
- geoServerResponse = _context5.sent;
325
- throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
326
-
327
- case 11:
328
- case "end":
329
- return _context5.stop();
330
- }
232
+ while (1) switch (_context5.prev = _context5.next) {
233
+ case 0:
234
+ contact = {
235
+ address: address,
236
+ addressCity: city,
237
+ addressCountry: country,
238
+ addressPostalCode: postalCode,
239
+ addressState: state,
240
+ contactEmail: email,
241
+ contactOrganization: organization,
242
+ contactPerson: contactPerson,
243
+ contactVoice: phoneNumber
244
+ };
245
+ body = {
246
+ contact: contact
247
+ };
248
+ url = this.url + 'settings/contact';
249
+ _context5.next = 5;
250
+ return (0, _nodeFetch["default"])(url, {
251
+ credentials: 'include',
252
+ method: 'PUT',
253
+ headers: {
254
+ Authorization: this.auth,
255
+ 'Content-Type': 'application/json'
256
+ },
257
+ body: JSON.stringify(body)
258
+ });
259
+ case 5:
260
+ response = _context5.sent;
261
+ if (response.ok) {
262
+ _context5.next = 11;
263
+ break;
264
+ }
265
+ _context5.next = 9;
266
+ return (0, _geoserver.getGeoServerResponseText)(response);
267
+ case 9:
268
+ geoServerResponse = _context5.sent;
269
+ throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
270
+ case 11:
271
+ case "end":
272
+ return _context5.stop();
331
273
  }
332
274
  }, _callee5, this);
333
275
  }));
334
-
335
276
  function updateContactInformation(_x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10, _x11) {
336
277
  return _updateContactInformation.apply(this, arguments);
337
278
  }
338
-
339
279
  return updateContactInformation;
340
280
  }()
341
281
  }]);
342
282
  return SettingsClient;
343
283
  }();
344
-
345
284
  exports["default"] = SettingsClient;