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/datastore.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 _fs = _interopRequireDefault(require("fs"));
|
|
14
10
|
var _geoserver = require("./util/geoserver.js");
|
|
@@ -18,15 +14,14 @@ var _about = _interopRequireDefault(require("./about.js"));
|
|
|
18
14
|
*
|
|
19
15
|
* @module DatastoreClient
|
|
20
16
|
*/
|
|
21
|
-
|
|
17
|
+
class DatastoreClient {
|
|
22
18
|
/**
|
|
23
19
|
* Creates a GeoServer REST DatastoreClient instance.
|
|
24
20
|
*
|
|
25
21
|
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
26
22
|
* @param {String} auth The Basic Authentication string
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
|
-
(0, _classCallCheck2["default"])(this, DatastoreClient);
|
|
24
|
+
constructor(url, auth) {
|
|
30
25
|
this.url = url;
|
|
31
26
|
this.auth = auth;
|
|
32
27
|
}
|
|
@@ -38,955 +33,534 @@ var DatastoreClient = exports["default"] = /*#__PURE__*/function () {
|
|
|
38
33
|
*
|
|
39
34
|
* @returns {Object} An object containing store details
|
|
40
35
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, {
|
|
96
|
-
key: "getWmsStores",
|
|
97
|
-
value: (function () {
|
|
98
|
-
var _getWmsStores = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(workspace) {
|
|
99
|
-
return _regenerator["default"].wrap(function (_context3) {
|
|
100
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
101
|
-
case 0:
|
|
102
|
-
return _context3.abrupt("return", this.getStores(workspace, 'wmsstores'));
|
|
103
|
-
case 1:
|
|
104
|
-
case "end":
|
|
105
|
-
return _context3.stop();
|
|
106
|
-
}
|
|
107
|
-
}, _callee3, this);
|
|
108
|
-
}));
|
|
109
|
-
function getWmsStores(_x3) {
|
|
110
|
-
return _getWmsStores.apply(this, arguments);
|
|
111
|
-
}
|
|
112
|
-
return getWmsStores;
|
|
113
|
-
}()
|
|
114
|
-
/**
|
|
115
|
-
* Get all WmtsStores in a workspace.
|
|
116
|
-
*
|
|
117
|
-
* @param {String} workspace The workspace to get WmtsStores for
|
|
118
|
-
*
|
|
119
|
-
* @returns {Object} An object containing store details
|
|
120
|
-
*/
|
|
121
|
-
)
|
|
122
|
-
}, {
|
|
123
|
-
key: "getWmtsStores",
|
|
124
|
-
value: (function () {
|
|
125
|
-
var _getWmtsStores = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(workspace) {
|
|
126
|
-
return _regenerator["default"].wrap(function (_context4) {
|
|
127
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
128
|
-
case 0:
|
|
129
|
-
return _context4.abrupt("return", this.getStores(workspace, 'wmtsstores'));
|
|
130
|
-
case 1:
|
|
131
|
-
case "end":
|
|
132
|
-
return _context4.stop();
|
|
133
|
-
}
|
|
134
|
-
}, _callee4, this);
|
|
135
|
-
}));
|
|
136
|
-
function getWmtsStores(_x4) {
|
|
137
|
-
return _getWmtsStores.apply(this, arguments);
|
|
138
|
-
}
|
|
139
|
-
return getWmtsStores;
|
|
140
|
-
}()
|
|
141
|
-
/**
|
|
142
|
-
* Get information about various store types in a workspace.
|
|
143
|
-
*
|
|
144
|
-
* @param {String} workspace The workspace name
|
|
145
|
-
* @param {String} storeType The type of store
|
|
146
|
-
*
|
|
147
|
-
* @throws Error if request fails
|
|
148
|
-
*
|
|
149
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
)
|
|
153
|
-
}, {
|
|
154
|
-
key: "getStores",
|
|
155
|
-
value: (function () {
|
|
156
|
-
var _getStores = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(workspace, storeType) {
|
|
157
|
-
var response, geoServerResponse;
|
|
158
|
-
return _regenerator["default"].wrap(function (_context5) {
|
|
159
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
160
|
-
case 0:
|
|
161
|
-
_context5.next = 1;
|
|
162
|
-
return (0, _nodeFetch["default"])(this.url + 'workspaces/' + workspace + '/' + storeType + '.json', {
|
|
163
|
-
credentials: 'include',
|
|
164
|
-
method: 'GET',
|
|
165
|
-
headers: {
|
|
166
|
-
Authorization: this.auth
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
case 1:
|
|
170
|
-
response = _context5.sent;
|
|
171
|
-
if (response.ok) {
|
|
172
|
-
_context5.next = 3;
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
_context5.next = 2;
|
|
176
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
177
|
-
case 2:
|
|
178
|
-
geoServerResponse = _context5.sent;
|
|
179
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
180
|
-
case 3:
|
|
181
|
-
return _context5.abrupt("return", response.json());
|
|
182
|
-
case 4:
|
|
183
|
-
case "end":
|
|
184
|
-
return _context5.stop();
|
|
185
|
-
}
|
|
186
|
-
}, _callee5, this);
|
|
187
|
-
}));
|
|
188
|
-
function getStores(_x5, _x6) {
|
|
189
|
-
return _getStores.apply(this, arguments);
|
|
190
|
-
}
|
|
191
|
-
return getStores;
|
|
192
|
-
}()
|
|
193
|
-
/**
|
|
194
|
-
* Get specific DataStore by name in a workspace.
|
|
195
|
-
*
|
|
196
|
-
* @param {String} workspace The workspace to search DataStore in
|
|
197
|
-
* @param {String} dataStore DataStore name
|
|
198
|
-
*
|
|
199
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
200
|
-
*/
|
|
201
|
-
)
|
|
202
|
-
}, {
|
|
203
|
-
key: "getDataStore",
|
|
204
|
-
value: (function () {
|
|
205
|
-
var _getDataStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(workspace, dataStore) {
|
|
206
|
-
return _regenerator["default"].wrap(function (_context6) {
|
|
207
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
208
|
-
case 0:
|
|
209
|
-
return _context6.abrupt("return", this.getStore(workspace, dataStore, 'datastores'));
|
|
210
|
-
case 1:
|
|
211
|
-
case "end":
|
|
212
|
-
return _context6.stop();
|
|
213
|
-
}
|
|
214
|
-
}, _callee6, this);
|
|
215
|
-
}));
|
|
216
|
-
function getDataStore(_x7, _x8) {
|
|
217
|
-
return _getDataStore.apply(this, arguments);
|
|
218
|
-
}
|
|
219
|
-
return getDataStore;
|
|
220
|
-
}()
|
|
221
|
-
/**
|
|
222
|
-
* Get specific CoverageStore by name in a workspace.
|
|
223
|
-
*
|
|
224
|
-
* @param {String} workspace The workspace to search CoverageStore in
|
|
225
|
-
* @param {String} covStore CoverageStore name
|
|
226
|
-
*
|
|
227
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
228
|
-
*/
|
|
229
|
-
)
|
|
230
|
-
}, {
|
|
231
|
-
key: "getCoverageStore",
|
|
232
|
-
value: (function () {
|
|
233
|
-
var _getCoverageStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(workspace, covStore) {
|
|
234
|
-
return _regenerator["default"].wrap(function (_context7) {
|
|
235
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
236
|
-
case 0:
|
|
237
|
-
return _context7.abrupt("return", this.getStore(workspace, covStore, 'coveragestores'));
|
|
238
|
-
case 1:
|
|
239
|
-
case "end":
|
|
240
|
-
return _context7.stop();
|
|
241
|
-
}
|
|
242
|
-
}, _callee7, this);
|
|
243
|
-
}));
|
|
244
|
-
function getCoverageStore(_x9, _x0) {
|
|
245
|
-
return _getCoverageStore.apply(this, arguments);
|
|
246
|
-
}
|
|
247
|
-
return getCoverageStore;
|
|
248
|
-
}()
|
|
249
|
-
/**
|
|
250
|
-
* Get specific WmsStore by name in a workspace.
|
|
251
|
-
*
|
|
252
|
-
* @param {String} workspace The workspace to search WmsStore in
|
|
253
|
-
* @param {String} wmsStore WmsStore name
|
|
254
|
-
*
|
|
255
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
256
|
-
*
|
|
257
|
-
*/
|
|
258
|
-
)
|
|
259
|
-
}, {
|
|
260
|
-
key: "getWmsStore",
|
|
261
|
-
value: (function () {
|
|
262
|
-
var _getWmsStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(workspace, wmsStore) {
|
|
263
|
-
return _regenerator["default"].wrap(function (_context8) {
|
|
264
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
265
|
-
case 0:
|
|
266
|
-
return _context8.abrupt("return", this.getStore(workspace, wmsStore, 'wmsstores'));
|
|
267
|
-
case 1:
|
|
268
|
-
case "end":
|
|
269
|
-
return _context8.stop();
|
|
270
|
-
}
|
|
271
|
-
}, _callee8, this);
|
|
272
|
-
}));
|
|
273
|
-
function getWmsStore(_x1, _x10) {
|
|
274
|
-
return _getWmsStore.apply(this, arguments);
|
|
275
|
-
}
|
|
276
|
-
return getWmsStore;
|
|
277
|
-
}()
|
|
278
|
-
/**
|
|
279
|
-
* Get specific WmtsStore by name in a workspace.
|
|
280
|
-
*
|
|
281
|
-
* @param {String} workspace The workspace to search WmtsStore in
|
|
282
|
-
* @param {String} wmtsStore WmtsStore name
|
|
283
|
-
*
|
|
284
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
285
|
-
*/
|
|
286
|
-
)
|
|
287
|
-
}, {
|
|
288
|
-
key: "getWmtsStore",
|
|
289
|
-
value: (function () {
|
|
290
|
-
var _getWmtsStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(workspace, wmtsStore) {
|
|
291
|
-
return _regenerator["default"].wrap(function (_context9) {
|
|
292
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
293
|
-
case 0:
|
|
294
|
-
return _context9.abrupt("return", this.getStore(workspace, wmtsStore, 'wmtsstores'));
|
|
295
|
-
case 1:
|
|
296
|
-
case "end":
|
|
297
|
-
return _context9.stop();
|
|
298
|
-
}
|
|
299
|
-
}, _callee9, this);
|
|
300
|
-
}));
|
|
301
|
-
function getWmtsStore(_x11, _x12) {
|
|
302
|
-
return _getWmtsStore.apply(this, arguments);
|
|
303
|
-
}
|
|
304
|
-
return getWmtsStore;
|
|
305
|
-
}()
|
|
306
|
-
/**
|
|
307
|
-
* Get GeoServer store by type
|
|
308
|
-
*
|
|
309
|
-
* @param {String} workspace The name of the workspace
|
|
310
|
-
* @param {String} storeName The name of the store
|
|
311
|
-
* @param {String} storeType The type of the store
|
|
312
|
-
*
|
|
313
|
-
* @throws Error if request fails
|
|
314
|
-
*
|
|
315
|
-
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
316
|
-
* @private
|
|
317
|
-
*/
|
|
318
|
-
)
|
|
319
|
-
}, {
|
|
320
|
-
key: "getStore",
|
|
321
|
-
value: (function () {
|
|
322
|
-
var _getStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(workspace, storeName, storeType) {
|
|
323
|
-
var url, response, grc, geoServerResponse;
|
|
324
|
-
return _regenerator["default"].wrap(function (_context0) {
|
|
325
|
-
while (1) switch (_context0.prev = _context0.next) {
|
|
326
|
-
case 0:
|
|
327
|
-
url = this.url + 'workspaces/' + workspace + '/' + storeType + '/' + storeName + '.json';
|
|
328
|
-
_context0.next = 1;
|
|
329
|
-
return (0, _nodeFetch["default"])(url, {
|
|
330
|
-
credentials: 'include',
|
|
331
|
-
method: 'GET',
|
|
332
|
-
headers: {
|
|
333
|
-
Authorization: this.auth
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
case 1:
|
|
337
|
-
response = _context0.sent;
|
|
338
|
-
if (response.ok) {
|
|
339
|
-
_context0.next = 5;
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
grc = new _about["default"](this.url, this.auth);
|
|
343
|
-
_context0.next = 2;
|
|
344
|
-
return grc.exists();
|
|
345
|
-
case 2:
|
|
346
|
-
if (!_context0.sent) {
|
|
347
|
-
_context0.next = 3;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
return _context0.abrupt("return");
|
|
351
|
-
case 3:
|
|
352
|
-
_context0.next = 4;
|
|
353
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
354
|
-
case 4:
|
|
355
|
-
geoServerResponse = _context0.sent;
|
|
356
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
357
|
-
case 5:
|
|
358
|
-
return _context0.abrupt("return", response.json());
|
|
359
|
-
case 6:
|
|
360
|
-
case "end":
|
|
361
|
-
return _context0.stop();
|
|
362
|
-
}
|
|
363
|
-
}, _callee0, this);
|
|
364
|
-
}));
|
|
365
|
-
function getStore(_x13, _x14, _x15) {
|
|
366
|
-
return _getStore.apply(this, arguments);
|
|
36
|
+
async getDataStores(workspace) {
|
|
37
|
+
return this.getStores(workspace, 'datastores');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get all CoverageStores in a workspace.
|
|
42
|
+
*
|
|
43
|
+
* @param {String} workspace The workspace to get CoverageStores for
|
|
44
|
+
*
|
|
45
|
+
* @returns {Object} An object containing store details
|
|
46
|
+
*/
|
|
47
|
+
async getCoverageStores(workspace) {
|
|
48
|
+
return this.getStores(workspace, 'coveragestores');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get all WmsStores in a workspace.
|
|
53
|
+
*
|
|
54
|
+
* @param {String} workspace The workspace to get WmsStores for
|
|
55
|
+
*
|
|
56
|
+
* @returns {Object} An object containing store details
|
|
57
|
+
*/
|
|
58
|
+
async getWmsStores(workspace) {
|
|
59
|
+
return this.getStores(workspace, 'wmsstores');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get all WmtsStores in a workspace.
|
|
64
|
+
*
|
|
65
|
+
* @param {String} workspace The workspace to get WmtsStores for
|
|
66
|
+
*
|
|
67
|
+
* @returns {Object} An object containing store details
|
|
68
|
+
*/
|
|
69
|
+
async getWmtsStores(workspace) {
|
|
70
|
+
return this.getStores(workspace, 'wmtsstores');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get information about various store types in a workspace.
|
|
75
|
+
*
|
|
76
|
+
* @param {String} workspace The workspace name
|
|
77
|
+
* @param {String} storeType The type of store
|
|
78
|
+
*
|
|
79
|
+
* @throws Error if request fails
|
|
80
|
+
*
|
|
81
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
async getStores(workspace, storeType) {
|
|
85
|
+
const response = await (0, _nodeFetch.default)(this.url + 'workspaces/' + workspace + '/' + storeType + '.json', {
|
|
86
|
+
credentials: 'include',
|
|
87
|
+
method: 'GET',
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: this.auth
|
|
367
90
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
91
|
+
});
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
94
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
95
|
+
}
|
|
96
|
+
return response.json();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get specific DataStore by name in a workspace.
|
|
101
|
+
*
|
|
102
|
+
* @param {String} workspace The workspace to search DataStore in
|
|
103
|
+
* @param {String} dataStore DataStore name
|
|
104
|
+
*
|
|
105
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
106
|
+
*/
|
|
107
|
+
async getDataStore(workspace, dataStore) {
|
|
108
|
+
return this.getStore(workspace, dataStore, 'datastores');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get specific CoverageStore by name in a workspace.
|
|
113
|
+
*
|
|
114
|
+
* @param {String} workspace The workspace to search CoverageStore in
|
|
115
|
+
* @param {String} covStore CoverageStore name
|
|
116
|
+
*
|
|
117
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
118
|
+
*/
|
|
119
|
+
async getCoverageStore(workspace, covStore) {
|
|
120
|
+
return this.getStore(workspace, covStore, 'coveragestores');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get specific WmsStore by name in a workspace.
|
|
125
|
+
*
|
|
126
|
+
* @param {String} workspace The workspace to search WmsStore in
|
|
127
|
+
* @param {String} wmsStore WmsStore name
|
|
128
|
+
*
|
|
129
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
async getWmsStore(workspace, wmsStore) {
|
|
133
|
+
return this.getStore(workspace, wmsStore, 'wmsstores');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get specific WmtsStore by name in a workspace.
|
|
138
|
+
*
|
|
139
|
+
* @param {String} workspace The workspace to search WmtsStore in
|
|
140
|
+
* @param {String} wmtsStore WmtsStore name
|
|
141
|
+
*
|
|
142
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
143
|
+
*/
|
|
144
|
+
async getWmtsStore(workspace, wmtsStore) {
|
|
145
|
+
return this.getStore(workspace, wmtsStore, 'wmtsstores');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get GeoServer store by type
|
|
150
|
+
*
|
|
151
|
+
* @param {String} workspace The name of the workspace
|
|
152
|
+
* @param {String} storeName The name of the store
|
|
153
|
+
* @param {String} storeType The type of the store
|
|
154
|
+
*
|
|
155
|
+
* @throws Error if request fails
|
|
156
|
+
*
|
|
157
|
+
* @returns {Object} An object containing store details or undefined if it cannot be found
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
async getStore(workspace, storeName, storeType) {
|
|
161
|
+
const url = this.url + 'workspaces/' + workspace + '/' + storeType + '/' + storeName + '.json';
|
|
162
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
163
|
+
credentials: 'include',
|
|
164
|
+
method: 'GET',
|
|
165
|
+
headers: {
|
|
166
|
+
Authorization: this.auth
|
|
406
167
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
* @param {String} layerTitle The published title of the new layer
|
|
418
|
-
* @param {Stream} readStream The stream of the GeoTIFF file
|
|
419
|
-
* @param {Number} fileSizeInBytes The number of bytes of the stream
|
|
420
|
-
*
|
|
421
|
-
* @throws Error if request fails
|
|
422
|
-
*
|
|
423
|
-
* @returns {String} The successful response text
|
|
424
|
-
*/
|
|
425
|
-
)
|
|
426
|
-
}, {
|
|
427
|
-
key: "createGeotiffFromStream",
|
|
428
|
-
value: (function () {
|
|
429
|
-
var _createGeotiffFromStream = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes) {
|
|
430
|
-
var lyrTitle, url, response, geoServerResponse;
|
|
431
|
-
return _regenerator["default"].wrap(function (_context10) {
|
|
432
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
433
|
-
case 0:
|
|
434
|
-
lyrTitle = layerTitle || layerName;
|
|
435
|
-
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.geotiff';
|
|
436
|
-
url += '?filename=' + lyrTitle + '&coverageName=' + layerName;
|
|
437
|
-
_context10.next = 1;
|
|
438
|
-
return (0, _nodeFetch["default"])(url, {
|
|
439
|
-
credentials: 'include',
|
|
440
|
-
method: 'PUT',
|
|
441
|
-
headers: {
|
|
442
|
-
Authorization: this.auth,
|
|
443
|
-
'Content-Type': 'image/tiff',
|
|
444
|
-
'Content-length': fileSizeInBytes
|
|
445
|
-
},
|
|
446
|
-
body: readStream
|
|
447
|
-
});
|
|
448
|
-
case 1:
|
|
449
|
-
response = _context10.sent;
|
|
450
|
-
if (response.ok) {
|
|
451
|
-
_context10.next = 3;
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
_context10.next = 2;
|
|
455
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
456
|
-
case 2:
|
|
457
|
-
geoServerResponse = _context10.sent;
|
|
458
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
459
|
-
case 3:
|
|
460
|
-
return _context10.abrupt("return", response.text());
|
|
461
|
-
case 4:
|
|
462
|
-
case "end":
|
|
463
|
-
return _context10.stop();
|
|
464
|
-
}
|
|
465
|
-
}, _callee10, this);
|
|
466
|
-
}));
|
|
467
|
-
function createGeotiffFromStream(_x21, _x22, _x23, _x24, _x25, _x26) {
|
|
468
|
-
return _createGeotiffFromStream.apply(this, arguments);
|
|
168
|
+
});
|
|
169
|
+
if (!response.ok) {
|
|
170
|
+
const grc = new _about.default(this.url, this.auth);
|
|
171
|
+
if (await grc.exists()) {
|
|
172
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
173
|
+
return;
|
|
174
|
+
} else {
|
|
175
|
+
// There was a general problem with GeoServer
|
|
176
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
177
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
469
178
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
179
|
+
}
|
|
180
|
+
return response.json();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Creates a GeoTIFF store from a file by path and publishes it as layer.
|
|
185
|
+
* The GeoTIFF file has to be placed on the server, where your GeoServer
|
|
186
|
+
* is running.
|
|
187
|
+
*
|
|
188
|
+
* @param {String} workspace The workspace to create GeoTIFF store in
|
|
189
|
+
* @param {String} coverageStore The name of the new GeoTIFF store
|
|
190
|
+
* @param {String} layerName The published name of the new layer
|
|
191
|
+
* @param {String} layerTitle The published title of the new layer
|
|
192
|
+
* @param {String} filePath The path to the GeoTIFF file on the server
|
|
193
|
+
*
|
|
194
|
+
* @throws Error if request fails
|
|
195
|
+
*
|
|
196
|
+
* @returns {String} The successful response text
|
|
197
|
+
*/
|
|
198
|
+
async createGeotiffFromFile(workspace, coverageStore, layerName, layerTitle, filePath) {
|
|
199
|
+
const stats = _fs.default.statSync(filePath);
|
|
200
|
+
const fileSizeInBytes = stats.size;
|
|
201
|
+
const readStream = _fs.default.createReadStream(filePath);
|
|
202
|
+
return this.createGeotiffFromStream(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Creates a GeoTIFF store from a file by stream and publishes it as layer.
|
|
207
|
+
* The GeoTIFF file is placed on the server, where your GeoServer
|
|
208
|
+
* is running.
|
|
209
|
+
*
|
|
210
|
+
* @param {String} workspace The workspace to create GeoTIFF store in
|
|
211
|
+
* @param {String} coverageStore The name of the new GeoTIFF store
|
|
212
|
+
* @param {String} layerName The published name of the new layer
|
|
213
|
+
* @param {String} layerTitle The published title of the new layer
|
|
214
|
+
* @param {Stream} readStream The stream of the GeoTIFF file
|
|
215
|
+
* @param {Number} fileSizeInBytes The number of bytes of the stream
|
|
216
|
+
*
|
|
217
|
+
* @throws Error if request fails
|
|
218
|
+
*
|
|
219
|
+
* @returns {String} The successful response text
|
|
220
|
+
*/
|
|
221
|
+
async createGeotiffFromStream(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes) {
|
|
222
|
+
const lyrTitle = layerTitle || layerName;
|
|
223
|
+
let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.geotiff';
|
|
224
|
+
url += '?filename=' + lyrTitle + '&coverageName=' + layerName;
|
|
225
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
226
|
+
credentials: 'include',
|
|
227
|
+
method: 'PUT',
|
|
228
|
+
headers: {
|
|
229
|
+
Authorization: this.auth,
|
|
230
|
+
'Content-Type': 'image/tiff',
|
|
231
|
+
'Content-length': fileSizeInBytes
|
|
232
|
+
},
|
|
233
|
+
body: readStream
|
|
234
|
+
});
|
|
235
|
+
if (!response.ok) {
|
|
236
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
237
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
238
|
+
}
|
|
239
|
+
// TODO: enforce JSON response or parse XML
|
|
240
|
+
return response.text();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Creates a PostGIS based data store.
|
|
245
|
+
*
|
|
246
|
+
* @param {String} workspace The WS to create the data store in
|
|
247
|
+
* @param {String} namespaceUri The namespace URI of the workspace
|
|
248
|
+
* @param {String} dataStore The data store name to be created
|
|
249
|
+
* @param {String} pgHost The PostGIS DB host
|
|
250
|
+
* @param {Number} pgPort The PostGIS DB port
|
|
251
|
+
* @param {String} pgUser The PostGIS DB user
|
|
252
|
+
* @param {String} pgPassword The PostGIS DB password
|
|
253
|
+
* @param {String} pgSchema The PostGIS DB schema
|
|
254
|
+
* @param {String} pgDb The PostGIS DB name
|
|
255
|
+
* @param {Boolean} [exposePk] expose primary key, defaults to false
|
|
256
|
+
*
|
|
257
|
+
* @throws Error if request fails
|
|
258
|
+
*/
|
|
259
|
+
async createPostgisStore(workspace, namespaceUri, dataStore, pgHost, pgPort, pgUser, pgPassword, pgSchema, pgDb, exposePk) {
|
|
260
|
+
const body = {
|
|
261
|
+
dataStore: {
|
|
262
|
+
name: dataStore,
|
|
263
|
+
type: 'PostGIS',
|
|
264
|
+
enabled: true,
|
|
265
|
+
workspace: {
|
|
266
|
+
name: workspace
|
|
267
|
+
},
|
|
268
|
+
connectionParameters: {
|
|
269
|
+
entry: [{
|
|
270
|
+
'@key': 'dbtype',
|
|
271
|
+
$: 'postgis'
|
|
272
|
+
}, {
|
|
273
|
+
'@key': 'schema',
|
|
274
|
+
$: pgSchema
|
|
275
|
+
}, {
|
|
276
|
+
'@key': 'database',
|
|
277
|
+
$: pgDb
|
|
278
|
+
}, {
|
|
279
|
+
'@key': 'host',
|
|
280
|
+
$: pgHost
|
|
281
|
+
}, {
|
|
282
|
+
'@key': 'port',
|
|
283
|
+
$: pgPort
|
|
284
|
+
}, {
|
|
285
|
+
'@key': 'passwd',
|
|
286
|
+
$: pgPassword
|
|
287
|
+
}, {
|
|
288
|
+
'@key': 'namespace',
|
|
289
|
+
$: namespaceUri
|
|
290
|
+
}, {
|
|
291
|
+
'@key': 'user',
|
|
292
|
+
$: pgUser
|
|
293
|
+
}, {
|
|
294
|
+
'@key': 'Expose primary keys',
|
|
295
|
+
$: exposePk || false
|
|
296
|
+
}]
|
|
297
|
+
}
|
|
567
298
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
299
|
+
};
|
|
300
|
+
const url = this.url + 'workspaces/' + workspace + '/datastores';
|
|
301
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
302
|
+
credentials: 'include',
|
|
303
|
+
method: 'POST',
|
|
304
|
+
headers: {
|
|
305
|
+
Authorization: this.auth,
|
|
306
|
+
'Content-Type': 'application/json'
|
|
307
|
+
},
|
|
308
|
+
body: JSON.stringify(body)
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// TODO: not tested yet
|
|
312
|
+
if (!response.ok) {
|
|
313
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
314
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Creates an ImageMosaic store from a zip archive with the 3 necessary files
|
|
320
|
+
* - datastore.properties
|
|
321
|
+
* - indexer.properties
|
|
322
|
+
* - timeregex.properties
|
|
323
|
+
*
|
|
324
|
+
* The zip archive has to be given as absolute path, so before it has to be
|
|
325
|
+
* placed on the server, where your GeoServer is running.
|
|
326
|
+
*
|
|
327
|
+
* @param {String} workspace The WS to create the data store in
|
|
328
|
+
* @param {String} dataStore The data store name
|
|
329
|
+
* @param {String} zipArchivePath Absolute path to zip archive with the 3 properties files
|
|
330
|
+
*
|
|
331
|
+
* @throws Error if request fails
|
|
332
|
+
*
|
|
333
|
+
* @returns {String} The response text
|
|
334
|
+
*/
|
|
335
|
+
async createImageMosaicStore(workspace, coverageStore, zipArchivePath) {
|
|
336
|
+
const readStream = _fs.default.createReadStream(zipArchivePath);
|
|
337
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.imagemosaic';
|
|
338
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
339
|
+
credentials: 'include',
|
|
340
|
+
method: 'PUT',
|
|
341
|
+
headers: {
|
|
342
|
+
Authorization: this.auth,
|
|
343
|
+
'Content-Type': 'application/zip'
|
|
344
|
+
},
|
|
345
|
+
body: readStream
|
|
346
|
+
});
|
|
347
|
+
if (!response.ok) {
|
|
348
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
349
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
350
|
+
}
|
|
351
|
+
return response.text();
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Creates a WMS based data store.
|
|
356
|
+
*
|
|
357
|
+
* @param {String} workspace The WS to create the data store in
|
|
358
|
+
* @param {String} dataStore The data store name
|
|
359
|
+
* @param {String} wmsCapabilitiesUrl Base WMS capabilities URL
|
|
360
|
+
*
|
|
361
|
+
* @throws Error if request fails
|
|
362
|
+
*/
|
|
363
|
+
async createWmsStore(workspace, dataStore, wmsCapabilitiesUrl) {
|
|
364
|
+
const body = {
|
|
365
|
+
wmsStore: {
|
|
366
|
+
name: dataStore,
|
|
367
|
+
type: 'WMS',
|
|
368
|
+
capabilitiesURL: wmsCapabilitiesUrl
|
|
629
369
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
)
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
headers: {
|
|
663
|
-
Authorization: this.auth,
|
|
664
|
-
'Content-Type': 'application/json'
|
|
665
|
-
},
|
|
666
|
-
body: JSON.stringify(body)
|
|
667
|
-
});
|
|
668
|
-
case 1:
|
|
669
|
-
response = _context13.sent;
|
|
670
|
-
if (response.ok) {
|
|
671
|
-
_context13.next = 3;
|
|
672
|
-
break;
|
|
673
|
-
}
|
|
674
|
-
_context13.next = 2;
|
|
675
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
676
|
-
case 2:
|
|
677
|
-
geoServerResponse = _context13.sent;
|
|
678
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
679
|
-
case 3:
|
|
680
|
-
case "end":
|
|
681
|
-
return _context13.stop();
|
|
682
|
-
}
|
|
683
|
-
}, _callee13, this);
|
|
684
|
-
}));
|
|
685
|
-
function createWmsStore(_x40, _x41, _x42) {
|
|
686
|
-
return _createWmsStore.apply(this, arguments);
|
|
370
|
+
};
|
|
371
|
+
const url = this.url + 'workspaces/' + workspace + '/wmsstores';
|
|
372
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
373
|
+
credentials: 'include',
|
|
374
|
+
method: 'POST',
|
|
375
|
+
headers: {
|
|
376
|
+
Authorization: this.auth,
|
|
377
|
+
'Content-Type': 'application/json'
|
|
378
|
+
},
|
|
379
|
+
body: JSON.stringify(body)
|
|
380
|
+
});
|
|
381
|
+
if (!response.ok) {
|
|
382
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
383
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Creates a WMTS based data store.
|
|
389
|
+
*
|
|
390
|
+
* @param {String} workspace The WS to create the data store in
|
|
391
|
+
* @param {String} dataStore The data store name
|
|
392
|
+
* @param {String} wmtsCapabilitiesUrl Base WMTS capabilities URL
|
|
393
|
+
*
|
|
394
|
+
* @throws Error if request fails
|
|
395
|
+
*/
|
|
396
|
+
async createWmtsStore(workspace, dataStore, wmtsCapabilitiesUrl) {
|
|
397
|
+
const body = {
|
|
398
|
+
wmtsStore: {
|
|
399
|
+
name: dataStore,
|
|
400
|
+
type: 'WMTS',
|
|
401
|
+
capabilitiesURL: wmtsCapabilitiesUrl
|
|
687
402
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
)
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
734
|
-
case 2:
|
|
735
|
-
geoServerResponse = _context14.sent;
|
|
736
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
737
|
-
case 3:
|
|
738
|
-
case "end":
|
|
739
|
-
return _context14.stop();
|
|
740
|
-
}
|
|
741
|
-
}, _callee14, this);
|
|
742
|
-
}));
|
|
743
|
-
function createWmtsStore(_x43, _x44, _x45) {
|
|
744
|
-
return _createWmtsStore.apply(this, arguments);
|
|
403
|
+
};
|
|
404
|
+
const url = this.url + 'workspaces/' + workspace + '/wmtsstores';
|
|
405
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
406
|
+
credentials: 'include',
|
|
407
|
+
method: 'POST',
|
|
408
|
+
headers: {
|
|
409
|
+
Authorization: this.auth,
|
|
410
|
+
'Content-Type': 'application/json'
|
|
411
|
+
},
|
|
412
|
+
body: JSON.stringify(body)
|
|
413
|
+
});
|
|
414
|
+
if (!response.ok) {
|
|
415
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
416
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Creates a WFS based data store.
|
|
422
|
+
*
|
|
423
|
+
* @param {String} workspace The WS to create the data store in
|
|
424
|
+
* @param {String} dataStore The data store name
|
|
425
|
+
* @param {String} wfsCapabilitiesUrl WFS capabilities URL
|
|
426
|
+
* @param {String} namespaceUrl URL of the GeoServer namespace
|
|
427
|
+
* @param {Boolean} [useHttpConnectionPooling=true] use HTTP connection pooling for WFS connection
|
|
428
|
+
*
|
|
429
|
+
* @throws Error if request fails
|
|
430
|
+
*/
|
|
431
|
+
async createWfsStore(workspace, dataStore, wfsCapabilitiesUrl, namespaceUrl, useHttpConnectionPooling) {
|
|
432
|
+
const body = {
|
|
433
|
+
dataStore: {
|
|
434
|
+
name: dataStore,
|
|
435
|
+
type: 'Web Feature Server (NG)',
|
|
436
|
+
connectionParameters: {
|
|
437
|
+
entry: [{
|
|
438
|
+
'@key': 'WFSDataStoreFactory:GET_CAPABILITIES_URL',
|
|
439
|
+
$: wfsCapabilitiesUrl
|
|
440
|
+
}, {
|
|
441
|
+
'@key': 'namespace',
|
|
442
|
+
$: namespaceUrl
|
|
443
|
+
}, {
|
|
444
|
+
'@key': 'WFSDataStoreFactory:USE_HTTP_CONNECTION_POOLING',
|
|
445
|
+
$: useHttpConnectionPooling !== false ? 'true' : 'false'
|
|
446
|
+
}]
|
|
447
|
+
}
|
|
745
448
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
'@key': 'WFSDataStoreFactory:USE_HTTP_CONNECTION_POOLING',
|
|
781
|
-
$: useHttpConnectionPooling !== false ? 'true' : 'false'
|
|
782
|
-
}]
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
url = this.url + 'workspaces/' + workspace + '/datastores';
|
|
787
|
-
_context15.next = 1;
|
|
788
|
-
return (0, _nodeFetch["default"])(url, {
|
|
789
|
-
credentials: 'include',
|
|
790
|
-
method: 'POST',
|
|
791
|
-
headers: {
|
|
792
|
-
Authorization: this.auth,
|
|
793
|
-
'Content-Type': 'application/json'
|
|
794
|
-
},
|
|
795
|
-
body: JSON.stringify(body)
|
|
796
|
-
});
|
|
797
|
-
case 1:
|
|
798
|
-
response = _context15.sent;
|
|
799
|
-
if (response.ok) {
|
|
800
|
-
_context15.next = 3;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
_context15.next = 2;
|
|
804
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
805
|
-
case 2:
|
|
806
|
-
geoServerResponse = _context15.sent;
|
|
807
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
808
|
-
case 3:
|
|
809
|
-
case "end":
|
|
810
|
-
return _context15.stop();
|
|
811
|
-
}
|
|
812
|
-
}, _callee15, this);
|
|
813
|
-
}));
|
|
814
|
-
function createWfsStore(_x46, _x47, _x48, _x49, _x50) {
|
|
815
|
-
return _createWfsStore.apply(this, arguments);
|
|
449
|
+
};
|
|
450
|
+
const url = this.url + 'workspaces/' + workspace + '/datastores';
|
|
451
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
452
|
+
credentials: 'include',
|
|
453
|
+
method: 'POST',
|
|
454
|
+
headers: {
|
|
455
|
+
Authorization: this.auth,
|
|
456
|
+
'Content-Type': 'application/json'
|
|
457
|
+
},
|
|
458
|
+
body: JSON.stringify(body)
|
|
459
|
+
});
|
|
460
|
+
if (!response.ok) {
|
|
461
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
462
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Deletes a data store.
|
|
468
|
+
*
|
|
469
|
+
* @param {String} workspace The workspace where the data store is in
|
|
470
|
+
* @param {String} coverageStore Name of data store to delete
|
|
471
|
+
* @param {String} recurse Flag to enable recursive deletion
|
|
472
|
+
*
|
|
473
|
+
* @throws Error if request fails
|
|
474
|
+
*/
|
|
475
|
+
async deleteDataStore(workspace, dataStore, recurse) {
|
|
476
|
+
let url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore;
|
|
477
|
+
url += '?recurse=' + recurse;
|
|
478
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
479
|
+
credentials: 'include',
|
|
480
|
+
method: 'DELETE',
|
|
481
|
+
headers: {
|
|
482
|
+
Authorization: this.auth
|
|
816
483
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
headers: {
|
|
844
|
-
Authorization: this.auth
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
case 1:
|
|
848
|
-
response = _context16.sent;
|
|
849
|
-
if (response.ok) {
|
|
850
|
-
_context16.next = 3;
|
|
851
|
-
break;
|
|
852
|
-
}
|
|
853
|
-
_context16.next = 2;
|
|
854
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
855
|
-
case 2:
|
|
856
|
-
geoServerResponse = _context16.sent;
|
|
857
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
858
|
-
case 3:
|
|
859
|
-
case "end":
|
|
860
|
-
return _context16.stop();
|
|
861
|
-
}
|
|
862
|
-
}, _callee16, this);
|
|
863
|
-
}));
|
|
864
|
-
function deleteDataStore(_x51, _x52, _x53) {
|
|
865
|
-
return _deleteDataStore.apply(this, arguments);
|
|
484
|
+
});
|
|
485
|
+
if (!response.ok) {
|
|
486
|
+
// TODO: could not find status codes in the docs or via testing
|
|
487
|
+
// https://docs.geoserver.org/latest/en/api/#1.0.0/datastores.yaml
|
|
488
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
489
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Deletes a CoverageStore.
|
|
495
|
+
*
|
|
496
|
+
* @param {String} workspace The workspace where the CoverageStore is in
|
|
497
|
+
* @param {String} coverageStore Name of CoverageStore to delete
|
|
498
|
+
* @param {String} recurse Flag to enable recursive deletion
|
|
499
|
+
*
|
|
500
|
+
* @throws Error if request fails
|
|
501
|
+
*/
|
|
502
|
+
async deleteCoverageStore(workspace, coverageStore, recurse) {
|
|
503
|
+
let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore;
|
|
504
|
+
url += '?recurse=' + recurse;
|
|
505
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
506
|
+
credentials: 'include',
|
|
507
|
+
method: 'DELETE',
|
|
508
|
+
headers: {
|
|
509
|
+
Authorization: this.auth
|
|
866
510
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
*/
|
|
878
|
-
)
|
|
879
|
-
}, {
|
|
880
|
-
key: "deleteCoverageStore",
|
|
881
|
-
value: (function () {
|
|
882
|
-
var _deleteCoverageStore = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee17(workspace, coverageStore, recurse) {
|
|
883
|
-
var url, response, geoServerResponse, _t;
|
|
884
|
-
return _regenerator["default"].wrap(function (_context17) {
|
|
885
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
886
|
-
case 0:
|
|
887
|
-
url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore;
|
|
888
|
-
url += '?recurse=' + recurse;
|
|
889
|
-
_context17.next = 1;
|
|
890
|
-
return (0, _nodeFetch["default"])(url, {
|
|
891
|
-
credentials: 'include',
|
|
892
|
-
method: 'DELETE',
|
|
893
|
-
headers: {
|
|
894
|
-
Authorization: this.auth
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
case 1:
|
|
898
|
-
response = _context17.sent;
|
|
899
|
-
if (response.ok) {
|
|
900
|
-
_context17.next = 5;
|
|
901
|
-
break;
|
|
902
|
-
}
|
|
903
|
-
_context17.next = 2;
|
|
904
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
905
|
-
case 2:
|
|
906
|
-
geoServerResponse = _context17.sent;
|
|
907
|
-
_t = response.status;
|
|
908
|
-
_context17.next = _t === 401 ? 3 : 4;
|
|
909
|
-
break;
|
|
910
|
-
case 3:
|
|
911
|
-
throw new _geoserver.GeoServerResponseError('Deletion failed. There might be dependant objects to ' + 'this store. Delete them first or call this with "recurse=false"', geoServerResponse);
|
|
912
|
-
case 4:
|
|
913
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
914
|
-
case 5:
|
|
915
|
-
case "end":
|
|
916
|
-
return _context17.stop();
|
|
917
|
-
}
|
|
918
|
-
}, _callee17, this);
|
|
919
|
-
}));
|
|
920
|
-
function deleteCoverageStore(_x54, _x55, _x56) {
|
|
921
|
-
return _deleteCoverageStore.apply(this, arguments);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// TODO: could not test it
|
|
514
|
+
if (!response.ok) {
|
|
515
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
516
|
+
switch (response.status) {
|
|
517
|
+
case 401:
|
|
518
|
+
throw new _geoserver.GeoServerResponseError('Deletion failed. There might be dependant objects to ' + 'this store. Delete them first or call this with "recurse=false"', geoServerResponse);
|
|
519
|
+
default:
|
|
520
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
922
521
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
'@key': 'database',
|
|
950
|
-
$: "file:".concat(gpkgPath)
|
|
951
|
-
}, {
|
|
952
|
-
'@key': 'dbtype',
|
|
953
|
-
$: 'geopkg'
|
|
954
|
-
}]
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
};
|
|
958
|
-
url = this.url + 'workspaces/' + workspace + '/datastores';
|
|
959
|
-
_context18.next = 1;
|
|
960
|
-
return (0, _nodeFetch["default"])(url, {
|
|
961
|
-
credentials: 'include',
|
|
962
|
-
method: 'POST',
|
|
963
|
-
headers: {
|
|
964
|
-
Authorization: this.auth,
|
|
965
|
-
'Content-Type': 'application/json'
|
|
966
|
-
},
|
|
967
|
-
body: JSON.stringify(body)
|
|
968
|
-
});
|
|
969
|
-
case 1:
|
|
970
|
-
response = _context18.sent;
|
|
971
|
-
if (response.ok) {
|
|
972
|
-
_context18.next = 3;
|
|
973
|
-
break;
|
|
974
|
-
}
|
|
975
|
-
_context18.next = 2;
|
|
976
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
977
|
-
case 2:
|
|
978
|
-
geoServerResponse = _context18.sent;
|
|
979
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
980
|
-
case 3:
|
|
981
|
-
case "end":
|
|
982
|
-
return _context18.stop();
|
|
983
|
-
}
|
|
984
|
-
}, _callee18, this);
|
|
985
|
-
}));
|
|
986
|
-
function createGpkgStore(_x57, _x58, _x59) {
|
|
987
|
-
return _createGpkgStore.apply(this, arguments);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Creates a GeoPackage store from a file placed in the geoserver_data dir.
|
|
527
|
+
*
|
|
528
|
+
* @param {String} workspace The WS to create the data store in
|
|
529
|
+
* @param {String} dataStore The data store name
|
|
530
|
+
* @param {String} gpkgPath Relative path to GeoPackage file within geoserver_data dir
|
|
531
|
+
*
|
|
532
|
+
* @throws Error if request fails
|
|
533
|
+
*/
|
|
534
|
+
async createGpkgStore(workspace, dataStore, gpkgPath) {
|
|
535
|
+
const body = {
|
|
536
|
+
dataStore: {
|
|
537
|
+
name: dataStore,
|
|
538
|
+
type: 'GeoPackage',
|
|
539
|
+
connectionParameters: {
|
|
540
|
+
entry: [{
|
|
541
|
+
'@key': 'database',
|
|
542
|
+
$: `file:${gpkgPath}`
|
|
543
|
+
}, {
|
|
544
|
+
'@key': 'dbtype',
|
|
545
|
+
$: 'geopkg'
|
|
546
|
+
}]
|
|
547
|
+
}
|
|
988
548
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
549
|
+
};
|
|
550
|
+
const url = this.url + 'workspaces/' + workspace + '/datastores';
|
|
551
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
552
|
+
credentials: 'include',
|
|
553
|
+
method: 'POST',
|
|
554
|
+
headers: {
|
|
555
|
+
Authorization: this.auth,
|
|
556
|
+
'Content-Type': 'application/json'
|
|
557
|
+
},
|
|
558
|
+
body: JSON.stringify(body)
|
|
559
|
+
});
|
|
560
|
+
if (!response.ok) {
|
|
561
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
562
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
exports.default = DatastoreClient;
|