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