geoserver-node-client 1.6.0 → 1.6.2
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 +1 -1
- package/dist/geoserver-rest-client.js +38 -39
- package/dist/package.json +8 -8
- package/dist/src/about.js +35 -86
- package/dist/src/datastore.js +524 -950
- package/dist/src/imagemosaic.js +103 -211
- package/dist/src/layer.js +718 -1287
- package/dist/src/layergroup.js +128 -226
- package/dist/src/namespace.js +110 -222
- package/dist/src/reset-reload.js +41 -96
- package/dist/src/security.js +279 -567
- package/dist/src/settings.js +127 -255
- package/dist/src/style.js +228 -448
- package/dist/src/util/geoserver.js +17 -44
- package/dist/src/workspace.js +116 -229
- package/package.json +8 -8
package/dist/src/settings.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
7
|
+
exports.default = void 0;
|
|
12
8
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
13
9
|
var _geoserver = require("./util/geoserver.js");
|
|
14
10
|
/**
|
|
@@ -16,15 +12,14 @@ var _geoserver = require("./util/geoserver.js");
|
|
|
16
12
|
*
|
|
17
13
|
* @module SettingsClient
|
|
18
14
|
*/
|
|
19
|
-
|
|
15
|
+
class SettingsClient {
|
|
20
16
|
/**
|
|
21
17
|
* Creates a GeoServer REST SettingsClient instance.
|
|
22
18
|
*
|
|
23
19
|
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
24
20
|
* @param {String} auth The Basic Authentication string
|
|
25
21
|
*/
|
|
26
|
-
|
|
27
|
-
(0, _classCallCheck2["default"])(this, SettingsClient);
|
|
22
|
+
constructor(url, auth) {
|
|
28
23
|
this.url = url;
|
|
29
24
|
this.auth = auth;
|
|
30
25
|
}
|
|
@@ -36,251 +31,128 @@ var SettingsClient = exports["default"] = /*#__PURE__*/function () {
|
|
|
36
31
|
*
|
|
37
32
|
* @returns {Object} Settings object
|
|
38
33
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
while (1) switch (_context.prev = _context.next) {
|
|
46
|
-
case 0:
|
|
47
|
-
_context.next = 1;
|
|
48
|
-
return (0, _nodeFetch["default"])(this.url + 'settings.json', {
|
|
49
|
-
credentials: 'include',
|
|
50
|
-
method: 'GET',
|
|
51
|
-
headers: {
|
|
52
|
-
Authorization: this.auth
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
case 1:
|
|
56
|
-
response = _context.sent;
|
|
57
|
-
if (response.ok) {
|
|
58
|
-
_context.next = 3;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
_context.next = 2;
|
|
62
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
63
|
-
case 2:
|
|
64
|
-
geoServerResponse = _context.sent;
|
|
65
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
66
|
-
case 3:
|
|
67
|
-
return _context.abrupt("return", response.json());
|
|
68
|
-
case 4:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
|
-
}
|
|
72
|
-
}, _callee, this);
|
|
73
|
-
}));
|
|
74
|
-
function getSettings() {
|
|
75
|
-
return _getSettings.apply(this, arguments);
|
|
34
|
+
async getSettings() {
|
|
35
|
+
const response = await (0, _nodeFetch.default)(this.url + 'settings.json', {
|
|
36
|
+
credentials: 'include',
|
|
37
|
+
method: 'GET',
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: this.auth
|
|
76
40
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
138
|
-
case 0:
|
|
139
|
-
_context3.next = 1;
|
|
140
|
-
return this.getSettings();
|
|
141
|
-
case 1:
|
|
142
|
-
settingsJson = _context3.sent;
|
|
143
|
-
if (!(!settingsJson.global && !settingsJson.global.settings)) {
|
|
144
|
-
_context3.next = 2;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
return _context3.abrupt("return", false);
|
|
148
|
-
case 2:
|
|
149
|
-
// add proxyBaseUrl to settings
|
|
150
|
-
settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
|
|
151
|
-
_context3.next = 3;
|
|
152
|
-
return this.updateSettings(settingsJson);
|
|
153
|
-
case 3:
|
|
154
|
-
case "end":
|
|
155
|
-
return _context3.stop();
|
|
156
|
-
}
|
|
157
|
-
}, _callee3, this);
|
|
158
|
-
}));
|
|
159
|
-
function updateProxyBaseUrl(_x2) {
|
|
160
|
-
return _updateProxyBaseUrl.apply(this, arguments);
|
|
161
|
-
}
|
|
162
|
-
return updateProxyBaseUrl;
|
|
163
|
-
}()
|
|
164
|
-
/**
|
|
165
|
-
* Get the contact information of the GeoServer.
|
|
166
|
-
*
|
|
167
|
-
* @throws Error if request fails
|
|
168
|
-
*
|
|
169
|
-
* @returns {Object} An object with contact information
|
|
170
|
-
*/
|
|
171
|
-
)
|
|
172
|
-
}, {
|
|
173
|
-
key: "getContactInformation",
|
|
174
|
-
value: (function () {
|
|
175
|
-
var _getContactInformation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
176
|
-
var response, geoServerResponse;
|
|
177
|
-
return _regenerator["default"].wrap(function (_context4) {
|
|
178
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
179
|
-
case 0:
|
|
180
|
-
_context4.next = 1;
|
|
181
|
-
return (0, _nodeFetch["default"])(this.url + 'settings/contact', {
|
|
182
|
-
credentials: 'include',
|
|
183
|
-
method: 'GET',
|
|
184
|
-
headers: {
|
|
185
|
-
Authorization: this.auth
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
case 1:
|
|
189
|
-
response = _context4.sent;
|
|
190
|
-
if (response.ok) {
|
|
191
|
-
_context4.next = 3;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
_context4.next = 2;
|
|
195
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
196
|
-
case 2:
|
|
197
|
-
geoServerResponse = _context4.sent;
|
|
198
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
199
|
-
case 3:
|
|
200
|
-
return _context4.abrupt("return", response.json());
|
|
201
|
-
case 4:
|
|
202
|
-
case "end":
|
|
203
|
-
return _context4.stop();
|
|
204
|
-
}
|
|
205
|
-
}, _callee4, this);
|
|
206
|
-
}));
|
|
207
|
-
function getContactInformation() {
|
|
208
|
-
return _getContactInformation.apply(this, arguments);
|
|
209
|
-
}
|
|
210
|
-
return getContactInformation;
|
|
211
|
-
}()
|
|
212
|
-
/**
|
|
213
|
-
* Update the contact information.
|
|
214
|
-
*
|
|
215
|
-
* Deleting is not supported.
|
|
216
|
-
*
|
|
217
|
-
* @param {String} [address] The contact's address
|
|
218
|
-
* @param {String} [city] The contact's city
|
|
219
|
-
* @param {String} [country] The contact's country
|
|
220
|
-
* @param {String} [postalCode] The contact's postCode
|
|
221
|
-
* @param {String} [state] The contact's state
|
|
222
|
-
* @param {String} [email] The contact's email
|
|
223
|
-
* @param {String} [organization] The contact's organization
|
|
224
|
-
* @param {String} [contactPerson] The contact person
|
|
225
|
-
* @param {String} [phoneNumber] The contact's phone number
|
|
226
|
-
*
|
|
227
|
-
* @throws Error if request fails
|
|
228
|
-
*/
|
|
229
|
-
)
|
|
230
|
-
}, {
|
|
231
|
-
key: "updateContactInformation",
|
|
232
|
-
value: (function () {
|
|
233
|
-
var _updateContactInformation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
|
|
234
|
-
var contact, body, url, response, geoServerResponse;
|
|
235
|
-
return _regenerator["default"].wrap(function (_context5) {
|
|
236
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
237
|
-
case 0:
|
|
238
|
-
contact = {
|
|
239
|
-
address: address,
|
|
240
|
-
addressCity: city,
|
|
241
|
-
addressCountry: country,
|
|
242
|
-
addressPostalCode: postalCode,
|
|
243
|
-
addressState: state,
|
|
244
|
-
contactEmail: email,
|
|
245
|
-
contactOrganization: organization,
|
|
246
|
-
contactPerson: contactPerson,
|
|
247
|
-
contactVoice: phoneNumber
|
|
248
|
-
};
|
|
249
|
-
body = {
|
|
250
|
-
contact: contact
|
|
251
|
-
};
|
|
252
|
-
url = this.url + 'settings/contact';
|
|
253
|
-
_context5.next = 1;
|
|
254
|
-
return (0, _nodeFetch["default"])(url, {
|
|
255
|
-
credentials: 'include',
|
|
256
|
-
method: 'PUT',
|
|
257
|
-
headers: {
|
|
258
|
-
Authorization: this.auth,
|
|
259
|
-
'Content-Type': 'application/json'
|
|
260
|
-
},
|
|
261
|
-
body: JSON.stringify(body)
|
|
262
|
-
});
|
|
263
|
-
case 1:
|
|
264
|
-
response = _context5.sent;
|
|
265
|
-
if (response.ok) {
|
|
266
|
-
_context5.next = 3;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
_context5.next = 2;
|
|
270
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
271
|
-
case 2:
|
|
272
|
-
geoServerResponse = _context5.sent;
|
|
273
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
274
|
-
case 3:
|
|
275
|
-
case "end":
|
|
276
|
-
return _context5.stop();
|
|
277
|
-
}
|
|
278
|
-
}, _callee5, this);
|
|
279
|
-
}));
|
|
280
|
-
function updateContactInformation(_x3, _x4, _x5, _x6, _x7, _x8, _x9, _x0, _x1) {
|
|
281
|
-
return _updateContactInformation.apply(this, arguments);
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
44
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
45
|
+
}
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Update the global GeoServer settings.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} settings The adapted GeoServer settings object
|
|
53
|
+
*/
|
|
54
|
+
async updateSettings(settings) {
|
|
55
|
+
const response = await (0, _nodeFetch.default)(this.url + 'settings', {
|
|
56
|
+
credentials: 'include',
|
|
57
|
+
method: 'PUT',
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: this.auth,
|
|
60
|
+
'Content-Type': 'application/json'
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify(settings)
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
66
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Update the global proxyBaseUrl setting.
|
|
72
|
+
*
|
|
73
|
+
* @param {String} proxyBaseUrl The proxy base URL
|
|
74
|
+
*/
|
|
75
|
+
async updateProxyBaseUrl(proxyBaseUrl) {
|
|
76
|
+
const settingsJson = await this.getSettings();
|
|
77
|
+
|
|
78
|
+
// check if settings are correctly formatted
|
|
79
|
+
if (!settingsJson.global && !settingsJson.global.settings) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// add proxyBaseUrl to settings
|
|
84
|
+
settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
|
|
85
|
+
await this.updateSettings(settingsJson);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the contact information of the GeoServer.
|
|
90
|
+
*
|
|
91
|
+
* @throws Error if request fails
|
|
92
|
+
*
|
|
93
|
+
* @returns {Object} An object with contact information
|
|
94
|
+
*/
|
|
95
|
+
async getContactInformation() {
|
|
96
|
+
const response = await (0, _nodeFetch.default)(this.url + 'settings/contact', {
|
|
97
|
+
credentials: 'include',
|
|
98
|
+
method: 'GET',
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: this.auth
|
|
282
101
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
105
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
106
|
+
}
|
|
107
|
+
return response.json();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Update the contact information.
|
|
112
|
+
*
|
|
113
|
+
* Deleting is not supported.
|
|
114
|
+
*
|
|
115
|
+
* @param {String} [address] The contact's address
|
|
116
|
+
* @param {String} [city] The contact's city
|
|
117
|
+
* @param {String} [country] The contact's country
|
|
118
|
+
* @param {String} [postalCode] The contact's postCode
|
|
119
|
+
* @param {String} [state] The contact's state
|
|
120
|
+
* @param {String} [email] The contact's email
|
|
121
|
+
* @param {String} [organization] The contact's organization
|
|
122
|
+
* @param {String} [contactPerson] The contact person
|
|
123
|
+
* @param {String} [phoneNumber] The contact's phone number
|
|
124
|
+
*
|
|
125
|
+
* @throws Error if request fails
|
|
126
|
+
*/
|
|
127
|
+
async updateContactInformation(address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
|
|
128
|
+
const contact = {
|
|
129
|
+
address: address,
|
|
130
|
+
addressCity: city,
|
|
131
|
+
addressCountry: country,
|
|
132
|
+
addressPostalCode: postalCode,
|
|
133
|
+
addressState: state,
|
|
134
|
+
contactEmail: email,
|
|
135
|
+
contactOrganization: organization,
|
|
136
|
+
contactPerson: contactPerson,
|
|
137
|
+
contactVoice: phoneNumber
|
|
138
|
+
};
|
|
139
|
+
const body = {
|
|
140
|
+
contact: contact
|
|
141
|
+
};
|
|
142
|
+
const url = this.url + 'settings/contact';
|
|
143
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
144
|
+
credentials: 'include',
|
|
145
|
+
method: 'PUT',
|
|
146
|
+
headers: {
|
|
147
|
+
Authorization: this.auth,
|
|
148
|
+
'Content-Type': 'application/json'
|
|
149
|
+
},
|
|
150
|
+
body: JSON.stringify(body)
|
|
151
|
+
});
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
154
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.default = SettingsClient;
|