geoserver-node-client 1.3.0 → 1.4.1
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 +5 -2
- package/dist/geoserver-rest-client.js +4 -25
- package/dist/package.json +15 -16
- package/dist/src/about.js +42 -70
- package/dist/src/datastore.js +450 -633
- package/dist/src/imagemosaic.js +112 -164
- package/dist/src/layer.js +591 -797
- package/dist/src/layergroup.js +275 -0
- package/dist/src/namespace.js +126 -186
- package/dist/src/reset-reload.js +49 -78
- package/dist/src/security.js +117 -169
- package/dist/src/settings.js +137 -198
- package/dist/src/style.js +260 -376
- package/dist/src/util/geoserver.js +12 -36
- package/dist/src/workspace.js +133 -190
- package/geoserver-rest-client.js +3 -0
- package/package.json +15 -16
- package/src/layergroup.js +176 -0
- package/src/workspace.js +4 -3
package/dist/src/style.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
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 _workspace = _interopRequireDefault(require("./workspace.js"));
|
|
21
|
-
|
|
22
14
|
var _geoserver = require("./util/geoserver.js");
|
|
23
|
-
|
|
24
15
|
var _about = _interopRequireDefault(require("./about.js"));
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
* Client for GeoServer styles
|
|
28
18
|
*
|
|
@@ -40,6 +30,7 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
40
30
|
this.url = url;
|
|
41
31
|
this.auth = auth;
|
|
42
32
|
}
|
|
33
|
+
|
|
43
34
|
/**
|
|
44
35
|
* Returns all default styles.
|
|
45
36
|
*
|
|
@@ -47,56 +38,44 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
47
38
|
*
|
|
48
39
|
* @returns {Object} An object with the default styles
|
|
49
40
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
41
|
(0, _createClass2["default"])(StyleClient, [{
|
|
53
42
|
key: "getDefaults",
|
|
54
43
|
value: function () {
|
|
55
44
|
var _getDefaults = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
56
45
|
var response, geoServerResponse;
|
|
57
46
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
58
|
-
while (1) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Authorization: this.auth
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
case 2:
|
|
71
|
-
response = _context.sent;
|
|
72
|
-
|
|
73
|
-
if (response.ok) {
|
|
74
|
-
_context.next = 8;
|
|
75
|
-
break;
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
_context.next = 2;
|
|
50
|
+
return (0, _nodeFetch["default"])(this.url + 'styles.json', {
|
|
51
|
+
credentials: 'include',
|
|
52
|
+
method: 'GET',
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: this.auth
|
|
76
55
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
56
|
+
});
|
|
57
|
+
case 2:
|
|
58
|
+
response = _context.sent;
|
|
59
|
+
if (response.ok) {
|
|
60
|
+
_context.next = 8;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
_context.next = 6;
|
|
64
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
65
|
+
case 6:
|
|
66
|
+
geoServerResponse = _context.sent;
|
|
67
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
68
|
+
case 8:
|
|
69
|
+
return _context.abrupt("return", response.json());
|
|
70
|
+
case 9:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context.stop();
|
|
92
73
|
}
|
|
93
74
|
}, _callee, this);
|
|
94
75
|
}));
|
|
95
|
-
|
|
96
76
|
function getDefaults() {
|
|
97
77
|
return _getDefaults.apply(this, arguments);
|
|
98
78
|
}
|
|
99
|
-
|
|
100
79
|
return getDefaults;
|
|
101
80
|
}()
|
|
102
81
|
/**
|
|
@@ -108,55 +87,44 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
108
87
|
*
|
|
109
88
|
* @returns {Object} An object with all styles
|
|
110
89
|
*/
|
|
111
|
-
|
|
112
90
|
}, {
|
|
113
91
|
key: "getInWorkspace",
|
|
114
92
|
value: function () {
|
|
115
93
|
var _getInWorkspace = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(workspace) {
|
|
116
94
|
var response, geoServerResponse;
|
|
117
95
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
118
|
-
while (1) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
Authorization: this.auth
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
case 2:
|
|
131
|
-
response = _context2.sent;
|
|
132
|
-
|
|
133
|
-
if (response.ok) {
|
|
134
|
-
_context2.next = 8;
|
|
135
|
-
break;
|
|
96
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
97
|
+
case 0:
|
|
98
|
+
_context2.next = 2;
|
|
99
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/styles.json', {
|
|
100
|
+
credentials: 'include',
|
|
101
|
+
method: 'GET',
|
|
102
|
+
headers: {
|
|
103
|
+
Authorization: this.auth
|
|
136
104
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
105
|
+
});
|
|
106
|
+
case 2:
|
|
107
|
+
response = _context2.sent;
|
|
108
|
+
if (response.ok) {
|
|
109
|
+
_context2.next = 8;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
_context2.next = 6;
|
|
113
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
114
|
+
case 6:
|
|
115
|
+
geoServerResponse = _context2.sent;
|
|
116
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
117
|
+
case 8:
|
|
118
|
+
return _context2.abrupt("return", response.json());
|
|
119
|
+
case 9:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context2.stop();
|
|
152
122
|
}
|
|
153
123
|
}, _callee2, this);
|
|
154
124
|
}));
|
|
155
|
-
|
|
156
125
|
function getInWorkspace(_x) {
|
|
157
126
|
return _getInWorkspace.apply(this, arguments);
|
|
158
127
|
}
|
|
159
|
-
|
|
160
128
|
return getInWorkspace;
|
|
161
129
|
}()
|
|
162
130
|
/**
|
|
@@ -166,74 +134,57 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
166
134
|
*
|
|
167
135
|
* @returns {Object[]} An array with all style objects
|
|
168
136
|
*/
|
|
169
|
-
|
|
170
137
|
}, {
|
|
171
138
|
key: "getAllWorkspaceStyles",
|
|
172
139
|
value: function () {
|
|
173
140
|
var _getAllWorkspaceStyles = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
174
141
|
var allStyles, ws, allWs, i, _ws, wsStyles;
|
|
175
|
-
|
|
176
142
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
177
|
-
while (1) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (!(!allWs || !allWs.workspaces || !allWs.workspaces.workspace || !Array.isArray(allWs.workspaces.workspace))) {
|
|
189
|
-
_context3.next = 7;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
throw new _geoserver.GeoServerResponseError('Response of available workspaces is malformed');
|
|
194
|
-
|
|
195
|
-
case 7:
|
|
196
|
-
i = 0;
|
|
197
|
-
|
|
198
|
-
case 8:
|
|
199
|
-
if (!(i < allWs.workspaces.workspace.length)) {
|
|
200
|
-
_context3.next = 17;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
_ws = allWs.workspaces.workspace[i];
|
|
205
|
-
_context3.next = 12;
|
|
206
|
-
return this.getInWorkspace(_ws.name);
|
|
207
|
-
|
|
208
|
-
case 12:
|
|
209
|
-
wsStyles = _context3.sent;
|
|
210
|
-
|
|
211
|
-
if (wsStyles.styles.style) {
|
|
212
|
-
wsStyles.styles.style.forEach(function (wsStyle) {
|
|
213
|
-
allStyles.push(wsStyle);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
case 14:
|
|
218
|
-
i++;
|
|
219
|
-
_context3.next = 8;
|
|
143
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
allStyles = [];
|
|
146
|
+
ws = new _workspace["default"](this.url, this.auth);
|
|
147
|
+
_context3.next = 4;
|
|
148
|
+
return ws.getAll();
|
|
149
|
+
case 4:
|
|
150
|
+
allWs = _context3.sent;
|
|
151
|
+
if (!(!allWs || !allWs.workspaces || !allWs.workspaces.workspace || !Array.isArray(allWs.workspaces.workspace))) {
|
|
152
|
+
_context3.next = 7;
|
|
220
153
|
break;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
154
|
+
}
|
|
155
|
+
throw new _geoserver.GeoServerResponseError('Response of available workspaces is malformed');
|
|
156
|
+
case 7:
|
|
157
|
+
i = 0;
|
|
158
|
+
case 8:
|
|
159
|
+
if (!(i < allWs.workspaces.workspace.length)) {
|
|
160
|
+
_context3.next = 17;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
_ws = allWs.workspaces.workspace[i];
|
|
164
|
+
_context3.next = 12;
|
|
165
|
+
return this.getInWorkspace(_ws.name);
|
|
166
|
+
case 12:
|
|
167
|
+
wsStyles = _context3.sent;
|
|
168
|
+
if (wsStyles.styles.style) {
|
|
169
|
+
wsStyles.styles.style.forEach(function (wsStyle) {
|
|
170
|
+
allStyles.push(wsStyle);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
case 14:
|
|
174
|
+
i++;
|
|
175
|
+
_context3.next = 8;
|
|
176
|
+
break;
|
|
177
|
+
case 17:
|
|
178
|
+
return _context3.abrupt("return", allStyles);
|
|
179
|
+
case 18:
|
|
180
|
+
case "end":
|
|
181
|
+
return _context3.stop();
|
|
229
182
|
}
|
|
230
183
|
}, _callee3, this);
|
|
231
184
|
}));
|
|
232
|
-
|
|
233
185
|
function getAllWorkspaceStyles() {
|
|
234
186
|
return _getAllWorkspaceStyles.apply(this, arguments);
|
|
235
187
|
}
|
|
236
|
-
|
|
237
188
|
return getAllWorkspaceStyles;
|
|
238
189
|
}()
|
|
239
190
|
/**
|
|
@@ -242,50 +193,39 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
242
193
|
*
|
|
243
194
|
* @returns {Object[]} An array with all style objects
|
|
244
195
|
*/
|
|
245
|
-
|
|
246
196
|
}, {
|
|
247
197
|
key: "getAll",
|
|
248
198
|
value: function () {
|
|
249
199
|
var _getAll = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
250
200
|
var defaultStyles, wsStyles, allStyles;
|
|
251
201
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
252
|
-
while (1) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
case 8:
|
|
274
|
-
allStyles = defaultStyles.styles.style.concat(wsStyles);
|
|
275
|
-
return _context4.abrupt("return", allStyles);
|
|
276
|
-
|
|
277
|
-
case 10:
|
|
278
|
-
case "end":
|
|
279
|
-
return _context4.stop();
|
|
280
|
-
}
|
|
202
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
203
|
+
case 0:
|
|
204
|
+
_context4.next = 2;
|
|
205
|
+
return this.getDefaults();
|
|
206
|
+
case 2:
|
|
207
|
+
defaultStyles = _context4.sent;
|
|
208
|
+
_context4.next = 5;
|
|
209
|
+
return this.getAllWorkspaceStyles();
|
|
210
|
+
case 5:
|
|
211
|
+
wsStyles = _context4.sent;
|
|
212
|
+
if (!(!defaultStyles || !defaultStyles.styles || !defaultStyles.styles.style || !Array.isArray(defaultStyles.styles.style))) {
|
|
213
|
+
_context4.next = 8;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
throw new _geoserver.GeoServerResponseError('Response of default styles malformed');
|
|
217
|
+
case 8:
|
|
218
|
+
allStyles = defaultStyles.styles.style.concat(wsStyles);
|
|
219
|
+
return _context4.abrupt("return", allStyles);
|
|
220
|
+
case 10:
|
|
221
|
+
case "end":
|
|
222
|
+
return _context4.stop();
|
|
281
223
|
}
|
|
282
224
|
}, _callee4, this);
|
|
283
225
|
}));
|
|
284
|
-
|
|
285
226
|
function getAll() {
|
|
286
227
|
return _getAll.apply(this, arguments);
|
|
287
228
|
}
|
|
288
|
-
|
|
289
229
|
return getAll;
|
|
290
230
|
}()
|
|
291
231
|
/**
|
|
@@ -297,54 +237,44 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
297
237
|
*
|
|
298
238
|
* @throws Error if request fails
|
|
299
239
|
*/
|
|
300
|
-
|
|
301
240
|
}, {
|
|
302
241
|
key: "publish",
|
|
303
242
|
value: function () {
|
|
304
243
|
var _publish = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(workspace, name, sldBody) {
|
|
305
244
|
var response, geoServerResponse;
|
|
306
245
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
307
|
-
while (1) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
geoServerResponse = _context5.sent;
|
|
334
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
335
|
-
|
|
336
|
-
case 8:
|
|
337
|
-
case "end":
|
|
338
|
-
return _context5.stop();
|
|
339
|
-
}
|
|
246
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
247
|
+
case 0:
|
|
248
|
+
_context5.next = 2;
|
|
249
|
+
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/styles?name=' + name, {
|
|
250
|
+
credentials: 'include',
|
|
251
|
+
method: 'POST',
|
|
252
|
+
headers: {
|
|
253
|
+
Authorization: this.auth,
|
|
254
|
+
'Content-Type': 'application/vnd.ogc.sld+xml'
|
|
255
|
+
},
|
|
256
|
+
body: sldBody
|
|
257
|
+
});
|
|
258
|
+
case 2:
|
|
259
|
+
response = _context5.sent;
|
|
260
|
+
if (response.ok) {
|
|
261
|
+
_context5.next = 8;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
_context5.next = 6;
|
|
265
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
266
|
+
case 6:
|
|
267
|
+
geoServerResponse = _context5.sent;
|
|
268
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
269
|
+
case 8:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context5.stop();
|
|
340
272
|
}
|
|
341
273
|
}, _callee5, this);
|
|
342
274
|
}));
|
|
343
|
-
|
|
344
275
|
function publish(_x2, _x3, _x4) {
|
|
345
276
|
return _publish.apply(this, arguments);
|
|
346
277
|
}
|
|
347
|
-
|
|
348
278
|
return publish;
|
|
349
279
|
}()
|
|
350
280
|
/**
|
|
@@ -355,79 +285,63 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
355
285
|
* @param {Boolean} [recurse=false] If references to the specified style in existing layers should be deleted
|
|
356
286
|
* @param {Boolean} [purge=false] Whether the underlying file containing the style should be deleted on disk
|
|
357
287
|
*/
|
|
358
|
-
|
|
359
288
|
}, {
|
|
360
289
|
key: "delete",
|
|
361
290
|
value: function () {
|
|
362
291
|
var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(workspace, name, recurse, purge) {
|
|
363
292
|
var paramPurge, paramRecurse, endpoint, response, geoServerResponse;
|
|
364
293
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
365
|
-
while (1) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
294
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
295
|
+
case 0:
|
|
296
|
+
paramPurge = false;
|
|
297
|
+
paramRecurse = false;
|
|
298
|
+
if (purge === true) {
|
|
299
|
+
paramPurge = true;
|
|
300
|
+
}
|
|
301
|
+
if (recurse === true) {
|
|
302
|
+
paramRecurse = true;
|
|
303
|
+
}
|
|
304
|
+
if (workspace) {
|
|
305
|
+
// delete style inside workspace
|
|
306
|
+
endpoint = this.url + 'workspaces/' + workspace + '/styles/' + name + '?' + 'purge=' + paramPurge + '&' + 'recurse=' + paramRecurse;
|
|
307
|
+
} else {
|
|
308
|
+
// delete style without workspace
|
|
309
|
+
endpoint = this.url + 'styles/' + name + '?' + 'purge=' + paramPurge + '&' + 'recurse=' + paramRecurse;
|
|
310
|
+
}
|
|
311
|
+
_context6.next = 7;
|
|
312
|
+
return (0, _nodeFetch["default"])(endpoint, {
|
|
313
|
+
credentials: 'include',
|
|
314
|
+
method: 'DELETE',
|
|
315
|
+
headers: {
|
|
316
|
+
Authorization: this.auth
|
|
385
317
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
headers: {
|
|
392
|
-
Authorization: this.auth
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
case 7:
|
|
397
|
-
response = _context6.sent;
|
|
398
|
-
|
|
399
|
-
if (response.ok) {
|
|
400
|
-
_context6.next = 17;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
_context6.next = 11;
|
|
405
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
406
|
-
|
|
407
|
-
case 11:
|
|
408
|
-
geoServerResponse = _context6.sent;
|
|
409
|
-
_context6.t0 = response.status;
|
|
410
|
-
_context6.next = _context6.t0 === 403 ? 15 : 16;
|
|
318
|
+
});
|
|
319
|
+
case 7:
|
|
320
|
+
response = _context6.sent;
|
|
321
|
+
if (response.ok) {
|
|
322
|
+
_context6.next = 17;
|
|
411
323
|
break;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
324
|
+
}
|
|
325
|
+
_context6.next = 11;
|
|
326
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
327
|
+
case 11:
|
|
328
|
+
geoServerResponse = _context6.sent;
|
|
329
|
+
_context6.t0 = response.status;
|
|
330
|
+
_context6.next = _context6.t0 === 403 ? 15 : 16;
|
|
331
|
+
break;
|
|
332
|
+
case 15:
|
|
333
|
+
throw new _geoserver.GeoServerResponseError('Deletion failed. There might be dependant layers to this style. Delete them first or call this with "recurse=false"', geoServerResponse);
|
|
334
|
+
case 16:
|
|
335
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
336
|
+
case 17:
|
|
337
|
+
case "end":
|
|
338
|
+
return _context6.stop();
|
|
423
339
|
}
|
|
424
340
|
}, _callee6, this);
|
|
425
341
|
}));
|
|
426
|
-
|
|
427
342
|
function _delete(_x5, _x6, _x7, _x8) {
|
|
428
343
|
return _delete2.apply(this, arguments);
|
|
429
344
|
}
|
|
430
|
-
|
|
431
345
|
return _delete;
|
|
432
346
|
}()
|
|
433
347
|
/**
|
|
@@ -441,73 +355,59 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
441
355
|
*
|
|
442
356
|
* @throws Error if request fails
|
|
443
357
|
*/
|
|
444
|
-
|
|
445
358
|
}, {
|
|
446
359
|
key: "assignStyleToLayer",
|
|
447
360
|
value: function () {
|
|
448
361
|
var _assignStyleToLayer = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(workspaceOfLayer, layerName, workspaceOfStyle, styleName, isDefaultStyle) {
|
|
449
362
|
var qualifiedName, styleBody, url, response, geoServerResponse;
|
|
450
363
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
451
|
-
while (1) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
_context7.next = 11;
|
|
493
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
494
|
-
|
|
495
|
-
case 11:
|
|
496
|
-
geoServerResponse = _context7.sent;
|
|
497
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
498
|
-
|
|
499
|
-
case 13:
|
|
500
|
-
case "end":
|
|
501
|
-
return _context7.stop();
|
|
502
|
-
}
|
|
364
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
365
|
+
case 0:
|
|
366
|
+
if (workspaceOfLayer) {
|
|
367
|
+
qualifiedName = "".concat(workspaceOfLayer, ":").concat(layerName);
|
|
368
|
+
} else {
|
|
369
|
+
qualifiedName = layerName;
|
|
370
|
+
}
|
|
371
|
+
_context7.next = 3;
|
|
372
|
+
return this.getStyleInformation(workspaceOfStyle, styleName);
|
|
373
|
+
case 3:
|
|
374
|
+
styleBody = _context7.sent;
|
|
375
|
+
// we set the style as defaultStyle, unless user explicitly provides 'false'
|
|
376
|
+
if (isDefaultStyle !== false) {
|
|
377
|
+
url = this.url + 'layers/' + qualifiedName + '/styles?default=true';
|
|
378
|
+
} else {
|
|
379
|
+
url = this.url + 'layers/' + qualifiedName + '/styles';
|
|
380
|
+
}
|
|
381
|
+
_context7.next = 7;
|
|
382
|
+
return (0, _nodeFetch["default"])(url, {
|
|
383
|
+
credentials: 'include',
|
|
384
|
+
method: 'POST',
|
|
385
|
+
headers: {
|
|
386
|
+
Authorization: this.auth,
|
|
387
|
+
'Content-Type': 'application/json'
|
|
388
|
+
},
|
|
389
|
+
body: JSON.stringify(styleBody)
|
|
390
|
+
});
|
|
391
|
+
case 7:
|
|
392
|
+
response = _context7.sent;
|
|
393
|
+
if (response.ok) {
|
|
394
|
+
_context7.next = 13;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
_context7.next = 11;
|
|
398
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
399
|
+
case 11:
|
|
400
|
+
geoServerResponse = _context7.sent;
|
|
401
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
402
|
+
case 13:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context7.stop();
|
|
503
405
|
}
|
|
504
406
|
}, _callee7, this);
|
|
505
407
|
}));
|
|
506
|
-
|
|
507
408
|
function assignStyleToLayer(_x9, _x10, _x11, _x12, _x13) {
|
|
508
409
|
return _assignStyleToLayer.apply(this, arguments);
|
|
509
410
|
}
|
|
510
|
-
|
|
511
411
|
return assignStyleToLayer;
|
|
512
412
|
}()
|
|
513
413
|
/**
|
|
@@ -520,78 +420,62 @@ var StyleClient = /*#__PURE__*/function () {
|
|
|
520
420
|
*
|
|
521
421
|
* @returns {Object} An object about the style or undefined if it cannot be found
|
|
522
422
|
*/
|
|
523
|
-
|
|
524
423
|
}, {
|
|
525
424
|
key: "getStyleInformation",
|
|
526
425
|
value: function () {
|
|
527
426
|
var _getStyleInformation = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(workspace, styleName) {
|
|
528
427
|
var url, response, grc, geoServerResponse;
|
|
529
428
|
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
530
|
-
while (1) {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
headers: {
|
|
544
|
-
Authorization: this.auth
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
case 3:
|
|
549
|
-
response = _context8.sent;
|
|
550
|
-
|
|
551
|
-
if (response.ok) {
|
|
552
|
-
_context8.next = 16;
|
|
553
|
-
break;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
grc = new _about["default"](this.url, this.auth);
|
|
557
|
-
_context8.next = 8;
|
|
558
|
-
return grc.exists();
|
|
559
|
-
|
|
560
|
-
case 8:
|
|
561
|
-
if (!_context8.sent) {
|
|
562
|
-
_context8.next = 12;
|
|
563
|
-
break;
|
|
429
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
if (workspace) {
|
|
432
|
+
url = this.url + 'workspaces/' + workspace + '/styles/' + styleName + '.json';
|
|
433
|
+
} else {
|
|
434
|
+
url = this.url + 'styles/' + styleName + '.json';
|
|
435
|
+
}
|
|
436
|
+
_context8.next = 3;
|
|
437
|
+
return (0, _nodeFetch["default"])(url, {
|
|
438
|
+
credentials: 'include',
|
|
439
|
+
method: 'GET',
|
|
440
|
+
headers: {
|
|
441
|
+
Authorization: this.auth
|
|
564
442
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
_context8.next =
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
443
|
+
});
|
|
444
|
+
case 3:
|
|
445
|
+
response = _context8.sent;
|
|
446
|
+
if (response.ok) {
|
|
447
|
+
_context8.next = 16;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
grc = new _about["default"](this.url, this.auth);
|
|
451
|
+
_context8.next = 8;
|
|
452
|
+
return grc.exists();
|
|
453
|
+
case 8:
|
|
454
|
+
if (!_context8.sent) {
|
|
455
|
+
_context8.next = 12;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
return _context8.abrupt("return");
|
|
459
|
+
case 12:
|
|
460
|
+
_context8.next = 14;
|
|
461
|
+
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
462
|
+
case 14:
|
|
463
|
+
geoServerResponse = _context8.sent;
|
|
464
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
465
|
+
case 16:
|
|
466
|
+
return _context8.abrupt("return", response.json());
|
|
467
|
+
case 17:
|
|
468
|
+
case "end":
|
|
469
|
+
return _context8.stop();
|
|
583
470
|
}
|
|
584
471
|
}, _callee8, this);
|
|
585
472
|
}));
|
|
586
|
-
|
|
587
473
|
function getStyleInformation(_x14, _x15) {
|
|
588
474
|
return _getStyleInformation.apply(this, arguments);
|
|
589
475
|
}
|
|
590
|
-
|
|
591
476
|
return getStyleInformation;
|
|
592
477
|
}()
|
|
593
478
|
}]);
|
|
594
479
|
return StyleClient;
|
|
595
480
|
}();
|
|
596
|
-
|
|
597
481
|
exports["default"] = StyleClient;
|