geoserver-node-client 0.0.7 → 1.2.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/README.md +80 -9
- package/dist/geoserver-rest-client.js +92 -0
- package/dist/package.json +56 -0
- package/dist/src/about.js +145 -0
- package/dist/src/datastore.js +1117 -0
- package/dist/src/imagemosaic.js +297 -0
- package/dist/src/layer.js +1263 -0
- package/dist/src/namespace.js +315 -0
- package/dist/src/reset-reload.js +160 -0
- package/dist/src/security.js +297 -0
- package/dist/src/settings.js +345 -0
- package/dist/src/style.js +597 -0
- package/dist/src/util/geoserver.js +97 -0
- package/dist/src/workspace.js +321 -0
- package/geoserver-rest-client.js +18 -52
- package/package.json +24 -6
- package/src/about.js +59 -0
- package/src/datastore.js +196 -200
- package/src/imagemosaic.js +75 -98
- package/src/layer.js +469 -328
- package/src/namespace.js +84 -83
- package/src/reset-reload.js +70 -0
- package/src/security.js +61 -84
- package/src/settings.js +76 -91
- package/src/style.js +165 -171
- package/src/util/geoserver.js +41 -0
- package/src/workspace.js +89 -81
- package/.eslintrc.json +0 -20
- package/.github/workflows/ci-geoserver-node-client.yml +0 -54
- package/.github/workflows/ci-publish-docs.yml +0 -24
- package/.github/workflows/wait-for.sh +0 -145
- package/.vscode/settings.json +0 -3
- package/DOCS_HOME.md +0 -26
- package/demo/index.js +0 -188
- package/release-it.json +0 -8
- package/test/sample_data/iceland.gpkg +0 -0
- package/test/sample_data/world.geotiff +0 -0
- package/test/test.js +0 -502
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
19
|
+
|
|
20
|
+
var _geoserver = require("./util/geoserver.js");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Client for GeoServer security.
|
|
24
|
+
*
|
|
25
|
+
* @module SecurityClient
|
|
26
|
+
*/
|
|
27
|
+
var SecurityClient = /*#__PURE__*/function () {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a GeoServer REST SecurityClient instance.
|
|
30
|
+
*
|
|
31
|
+
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
32
|
+
* @param {String} auth The Basic Authentication string
|
|
33
|
+
*/
|
|
34
|
+
function SecurityClient(url, auth) {
|
|
35
|
+
(0, _classCallCheck2["default"])(this, SecurityClient);
|
|
36
|
+
this.url = url;
|
|
37
|
+
this.auth = auth;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns all users registered in GeoServer.
|
|
41
|
+
*
|
|
42
|
+
* @throws Error if request fails
|
|
43
|
+
*
|
|
44
|
+
* @returns {Object} An object with all users
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
(0, _createClass2["default"])(SecurityClient, [{
|
|
49
|
+
key: "getAllUsers",
|
|
50
|
+
value: function () {
|
|
51
|
+
var _getAllUsers = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
52
|
+
var response, geoServerResponse;
|
|
53
|
+
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 + 'security/usergroup/users.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;
|
|
72
|
+
}
|
|
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
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, _callee, this);
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
function getAllUsers() {
|
|
93
|
+
return _getAllUsers.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return getAllUsers;
|
|
97
|
+
}()
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new user.
|
|
100
|
+
*
|
|
101
|
+
* @param {String} username The name of the user to be created
|
|
102
|
+
* @param {String} password The password of the user to be created
|
|
103
|
+
*
|
|
104
|
+
* @throws Error if request fails
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
}, {
|
|
108
|
+
key: "createUser",
|
|
109
|
+
value: function () {
|
|
110
|
+
var _createUser = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(username, password) {
|
|
111
|
+
var body, response, geoServerResponse;
|
|
112
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
113
|
+
while (1) {
|
|
114
|
+
switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
body = {
|
|
117
|
+
user: {
|
|
118
|
+
userName: username,
|
|
119
|
+
password: password,
|
|
120
|
+
enabled: true
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
_context2.next = 3;
|
|
124
|
+
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/users.json', {
|
|
125
|
+
credentials: 'include',
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {
|
|
128
|
+
Authorization: this.auth,
|
|
129
|
+
'Content-Type': 'application/json'
|
|
130
|
+
},
|
|
131
|
+
body: JSON.stringify(body)
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
case 3:
|
|
135
|
+
response = _context2.sent;
|
|
136
|
+
|
|
137
|
+
if (response.ok) {
|
|
138
|
+
_context2.next = 13;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
_context2.next = 7;
|
|
143
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
144
|
+
|
|
145
|
+
case 7:
|
|
146
|
+
geoServerResponse = _context2.sent;
|
|
147
|
+
_context2.t0 = response.status;
|
|
148
|
+
_context2.next = _context2.t0 === 404 ? 11 : 12;
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
case 11:
|
|
152
|
+
throw new _geoserver.GeoServerResponseError("User ".concat(username, " might already exists."), geoServerResponse);
|
|
153
|
+
|
|
154
|
+
case 12:
|
|
155
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
156
|
+
|
|
157
|
+
case 13:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context2.stop();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}, _callee2, this);
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
function createUser(_x, _x2) {
|
|
166
|
+
return _createUser.apply(this, arguments);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return createUser;
|
|
170
|
+
}()
|
|
171
|
+
/**
|
|
172
|
+
* Updates an existing user. User name is only taken for identification and
|
|
173
|
+
* cannot be changed with this API call.
|
|
174
|
+
*
|
|
175
|
+
* @param {String} username The name of the user to be created
|
|
176
|
+
* @param {String} password The password of the user to be created
|
|
177
|
+
* @param {Boolean} enabled Enable / disable the user
|
|
178
|
+
*
|
|
179
|
+
* @throws Error if request fails
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
}, {
|
|
183
|
+
key: "updateUser",
|
|
184
|
+
value: function () {
|
|
185
|
+
var _updateUser = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(username, password, enabled) {
|
|
186
|
+
var body, response, geoServerResponse;
|
|
187
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
188
|
+
while (1) {
|
|
189
|
+
switch (_context3.prev = _context3.next) {
|
|
190
|
+
case 0:
|
|
191
|
+
body = {
|
|
192
|
+
user: {
|
|
193
|
+
password: password,
|
|
194
|
+
enabled: enabled
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
_context3.next = 3;
|
|
198
|
+
return (0, _nodeFetch["default"])(this.url + 'security/usergroup/user/' + username, {
|
|
199
|
+
credentials: 'include',
|
|
200
|
+
method: 'POST',
|
|
201
|
+
headers: {
|
|
202
|
+
Authorization: this.auth,
|
|
203
|
+
'Content-Type': 'application/json'
|
|
204
|
+
},
|
|
205
|
+
body: JSON.stringify(body)
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
case 3:
|
|
209
|
+
response = _context3.sent;
|
|
210
|
+
|
|
211
|
+
if (response.ok) {
|
|
212
|
+
_context3.next = 9;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
_context3.next = 7;
|
|
217
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
218
|
+
|
|
219
|
+
case 7:
|
|
220
|
+
geoServerResponse = _context3.sent;
|
|
221
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
222
|
+
|
|
223
|
+
case 9:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context3.stop();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}, _callee3, this);
|
|
229
|
+
}));
|
|
230
|
+
|
|
231
|
+
function updateUser(_x3, _x4, _x5) {
|
|
232
|
+
return _updateUser.apply(this, arguments);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return updateUser;
|
|
236
|
+
}()
|
|
237
|
+
/**
|
|
238
|
+
* Associates the given role to the user.
|
|
239
|
+
*
|
|
240
|
+
* @param {String} username The name of the user to add the role to
|
|
241
|
+
* @param {String} role The role to associate
|
|
242
|
+
*
|
|
243
|
+
* @throws Error if request fails
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
}, {
|
|
247
|
+
key: "associateUserRole",
|
|
248
|
+
value: function () {
|
|
249
|
+
var _associateUserRole = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(username, role) {
|
|
250
|
+
var response, geoServerResponse;
|
|
251
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
252
|
+
while (1) {
|
|
253
|
+
switch (_context4.prev = _context4.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
_context4.next = 2;
|
|
256
|
+
return (0, _nodeFetch["default"])("".concat(this.url, "security/roles/role/").concat(role, "/user/").concat(username), {
|
|
257
|
+
credentials: 'include',
|
|
258
|
+
method: 'POST',
|
|
259
|
+
headers: {
|
|
260
|
+
Authorization: this.auth
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
case 2:
|
|
265
|
+
response = _context4.sent;
|
|
266
|
+
|
|
267
|
+
if (response.ok) {
|
|
268
|
+
_context4.next = 8;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
_context4.next = 6;
|
|
273
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
274
|
+
|
|
275
|
+
case 6:
|
|
276
|
+
geoServerResponse = _context4.sent;
|
|
277
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
278
|
+
|
|
279
|
+
case 8:
|
|
280
|
+
case "end":
|
|
281
|
+
return _context4.stop();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, _callee4, this);
|
|
285
|
+
}));
|
|
286
|
+
|
|
287
|
+
function associateUserRole(_x6, _x7) {
|
|
288
|
+
return _associateUserRole.apply(this, arguments);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return associateUserRole;
|
|
292
|
+
}()
|
|
293
|
+
}]);
|
|
294
|
+
return SecurityClient;
|
|
295
|
+
}();
|
|
296
|
+
|
|
297
|
+
exports["default"] = SecurityClient;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
19
|
+
|
|
20
|
+
var _geoserver = require("./util/geoserver.js");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Client for GeoServer settings.
|
|
24
|
+
*
|
|
25
|
+
* @module SettingsClient
|
|
26
|
+
*/
|
|
27
|
+
var SettingsClient = /*#__PURE__*/function () {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a GeoServer REST SettingsClient instance.
|
|
30
|
+
*
|
|
31
|
+
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
32
|
+
* @param {String} auth The Basic Authentication string
|
|
33
|
+
*/
|
|
34
|
+
function SettingsClient(url, auth) {
|
|
35
|
+
(0, _classCallCheck2["default"])(this, SettingsClient);
|
|
36
|
+
this.url = url;
|
|
37
|
+
this.auth = auth;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the complete GeoServer settings object.
|
|
41
|
+
*
|
|
42
|
+
* @throws Error if request fails
|
|
43
|
+
*
|
|
44
|
+
* @returns {Object} Settings object
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
(0, _createClass2["default"])(SettingsClient, [{
|
|
49
|
+
key: "getSettings",
|
|
50
|
+
value: function () {
|
|
51
|
+
var _getSettings = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
52
|
+
var response, geoServerResponse;
|
|
53
|
+
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;
|
|
72
|
+
}
|
|
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
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, _callee, this);
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
function getSettings() {
|
|
93
|
+
return _getSettings.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return getSettings;
|
|
97
|
+
}()
|
|
98
|
+
/**
|
|
99
|
+
* Update the global GeoServer settings.
|
|
100
|
+
*
|
|
101
|
+
* @param {Object} settings The adapted GeoServer settings object
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
}, {
|
|
105
|
+
key: "updateSettings",
|
|
106
|
+
value: function () {
|
|
107
|
+
var _updateSettings = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(settings) {
|
|
108
|
+
var response, geoServerResponse;
|
|
109
|
+
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
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, _callee2, this);
|
|
145
|
+
}));
|
|
146
|
+
|
|
147
|
+
function updateSettings(_x) {
|
|
148
|
+
return _updateSettings.apply(this, arguments);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return updateSettings;
|
|
152
|
+
}()
|
|
153
|
+
/**
|
|
154
|
+
* Update the global proxyBaseUrl setting.
|
|
155
|
+
*
|
|
156
|
+
* @param {String} proxyBaseUrl The proxy base URL
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
}, {
|
|
160
|
+
key: "updateProxyBaseUrl",
|
|
161
|
+
value: function () {
|
|
162
|
+
var _updateProxyBaseUrl = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(proxyBaseUrl) {
|
|
163
|
+
var settingsJson;
|
|
164
|
+
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
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}, _callee3, this);
|
|
193
|
+
}));
|
|
194
|
+
|
|
195
|
+
function updateProxyBaseUrl(_x2) {
|
|
196
|
+
return _updateProxyBaseUrl.apply(this, arguments);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return updateProxyBaseUrl;
|
|
200
|
+
}()
|
|
201
|
+
/**
|
|
202
|
+
* Get the contact information of the GeoServer.
|
|
203
|
+
*
|
|
204
|
+
* @throws Error if request fails
|
|
205
|
+
*
|
|
206
|
+
* @returns {Object} An object with contact information
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
}, {
|
|
210
|
+
key: "getContactInformation",
|
|
211
|
+
value: function () {
|
|
212
|
+
var _getContactInformation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
213
|
+
var response, geoServerResponse;
|
|
214
|
+
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;
|
|
233
|
+
}
|
|
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
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, _callee4, this);
|
|
251
|
+
}));
|
|
252
|
+
|
|
253
|
+
function getContactInformation() {
|
|
254
|
+
return _getContactInformation.apply(this, arguments);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return getContactInformation;
|
|
258
|
+
}()
|
|
259
|
+
/**
|
|
260
|
+
* Update the contact information.
|
|
261
|
+
*
|
|
262
|
+
* Deleting is not supported.
|
|
263
|
+
*
|
|
264
|
+
* @param {String} [address] The contact's address
|
|
265
|
+
* @param {String} [city] The contact's city
|
|
266
|
+
* @param {String} [country] The contact's country
|
|
267
|
+
* @param {String} [postalCode] The contact's postCode
|
|
268
|
+
* @param {String} [state] The contact's state
|
|
269
|
+
* @param {String} [email] The contact's email
|
|
270
|
+
* @param {String} [organization] The contact's organization
|
|
271
|
+
* @param {String} [contactPerson] The contact person
|
|
272
|
+
* @param {String} [phoneNumber] The contact's phone number
|
|
273
|
+
*
|
|
274
|
+
* @throws Error if request fails
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
}, {
|
|
278
|
+
key: "updateContactInformation",
|
|
279
|
+
value: function () {
|
|
280
|
+
var _updateContactInformation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
|
|
281
|
+
var contact, body, url, response, geoServerResponse;
|
|
282
|
+
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
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, _callee5, this);
|
|
333
|
+
}));
|
|
334
|
+
|
|
335
|
+
function updateContactInformation(_x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10, _x11) {
|
|
336
|
+
return _updateContactInformation.apply(this, arguments);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return updateContactInformation;
|
|
340
|
+
}()
|
|
341
|
+
}]);
|
|
342
|
+
return SettingsClient;
|
|
343
|
+
}();
|
|
344
|
+
|
|
345
|
+
exports["default"] = SettingsClient;
|