geoserver-node-client 0.0.5 → 1.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/LICENSE +25 -0
- package/README.md +81 -9
- package/dist/geoserver-rest-client.js +87 -0
- package/dist/package.json +55 -0
- package/dist/src/about.js +145 -0
- package/dist/src/datastore.js +1050 -0
- package/dist/src/imagemosaic.js +297 -0
- package/dist/src/layer.js +1040 -0
- package/dist/src/namespace.js +315 -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 +15 -52
- package/package.json +28 -10
- package/src/about.js +59 -0
- package/src/datastore.js +161 -200
- package/src/imagemosaic.js +74 -97
- package/src/layer.js +376 -332
- package/src/namespace.js +84 -83
- package/src/security.js +61 -84
- package/src/settings.js +76 -91
- package/src/style.js +200 -147
- 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/DOCS_HOME.md +0 -24
- 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 -491
|
@@ -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;
|