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/layergroup.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
7
|
+
exports.default = void 0;
|
|
13
8
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
14
9
|
var _geoserver = require("./util/geoserver.js");
|
|
15
10
|
var _about = _interopRequireDefault(require("./about.js"));
|
|
16
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
17
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
11
|
/**
|
|
22
12
|
* Client for GeoServer layergroups
|
|
23
13
|
*
|
|
24
14
|
* @module LayerGroupClient
|
|
25
15
|
*/
|
|
26
|
-
|
|
16
|
+
class LayerGroupClient {
|
|
27
17
|
/**
|
|
28
18
|
* Creates a GeoServer REST LayerGroupClient instance.
|
|
29
19
|
*
|
|
30
20
|
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
31
21
|
* @param {String} auth The Basic Authentication string
|
|
32
22
|
*/
|
|
33
|
-
|
|
34
|
-
(0, _classCallCheck2["default"])(this, LayerGroupClient);
|
|
23
|
+
constructor(url, auth) {
|
|
35
24
|
this.url = url;
|
|
36
25
|
this.auth = auth;
|
|
37
26
|
}
|
|
@@ -58,217 +47,130 @@ var LayerGroupClient = exports["default"] = /*#__PURE__*/function () {
|
|
|
58
47
|
*
|
|
59
48
|
* @returns {string} A string with layer group location or undefined if not found
|
|
60
49
|
*/
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
body = {
|
|
101
|
-
layerGroup: _objectSpread({
|
|
102
|
-
name: layerGroupName,
|
|
103
|
-
workspace: {
|
|
104
|
-
name: workspace
|
|
105
|
-
},
|
|
106
|
-
publishables: {
|
|
107
|
-
published: publishedLayers
|
|
108
|
-
},
|
|
109
|
-
styles: {
|
|
110
|
-
style: styles
|
|
111
|
-
}
|
|
112
|
-
}, options)
|
|
113
|
-
};
|
|
114
|
-
_context.next = 1;
|
|
115
|
-
return (0, _nodeFetch["default"])("".concat(this.url, "/workspaces/").concat(workspace, "/layergroups"), {
|
|
116
|
-
credentials: 'include',
|
|
117
|
-
method: 'POST',
|
|
118
|
-
headers: {
|
|
119
|
-
Authorization: this.auth,
|
|
120
|
-
'Content-Type': 'application/json'
|
|
121
|
-
},
|
|
122
|
-
body: JSON.stringify(body)
|
|
123
|
-
});
|
|
124
|
-
case 1:
|
|
125
|
-
response = _context.sent;
|
|
126
|
-
if (response.ok) {
|
|
127
|
-
_context.next = 5;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
grc = new _about["default"](this.url, this.auth);
|
|
131
|
-
_context.next = 2;
|
|
132
|
-
return grc.exists();
|
|
133
|
-
case 2:
|
|
134
|
-
if (!_context.sent) {
|
|
135
|
-
_context.next = 3;
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
return _context.abrupt("return");
|
|
139
|
-
case 3:
|
|
140
|
-
_context.next = 4;
|
|
141
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
142
|
-
case 4:
|
|
143
|
-
geoServerResponse = _context.sent;
|
|
144
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
145
|
-
case 5:
|
|
146
|
-
// get resource location from response header
|
|
147
|
-
location = response.headers.get('location'); // return resource location
|
|
148
|
-
return _context.abrupt("return", location);
|
|
149
|
-
case 6:
|
|
150
|
-
case "end":
|
|
151
|
-
return _context.stop();
|
|
152
|
-
}
|
|
153
|
-
}, _callee, this);
|
|
154
|
-
}));
|
|
155
|
-
function create(_x, _x2, _x3, _x4) {
|
|
156
|
-
return _create.apply(this, arguments);
|
|
50
|
+
async create(workspace, layerGroupName, layers, layerGroupOptions) {
|
|
51
|
+
const options = {
|
|
52
|
+
mode: 'SINGLE',
|
|
53
|
+
layerGroupTitle: '',
|
|
54
|
+
abstractTxt: '',
|
|
55
|
+
bounds: {
|
|
56
|
+
minx: -180,
|
|
57
|
+
maxx: -90,
|
|
58
|
+
miny: 180,
|
|
59
|
+
maxy: 90,
|
|
60
|
+
crs: 'EPSG:4326'
|
|
61
|
+
},
|
|
62
|
+
...layerGroupOptions
|
|
63
|
+
};
|
|
64
|
+
const publishedLayers = [];
|
|
65
|
+
const styles = [];
|
|
66
|
+
for (const l of layers) {
|
|
67
|
+
publishedLayers.push({
|
|
68
|
+
'@type': 'layer',
|
|
69
|
+
name: `${workspace}:${l}`,
|
|
70
|
+
href: `${this.url}/workspaces/${workspace}/layers/${l}.json`
|
|
71
|
+
});
|
|
72
|
+
// use default style by define empty string
|
|
73
|
+
styles.push('');
|
|
74
|
+
}
|
|
75
|
+
const body = {
|
|
76
|
+
layerGroup: {
|
|
77
|
+
name: layerGroupName,
|
|
78
|
+
workspace: {
|
|
79
|
+
name: workspace
|
|
80
|
+
},
|
|
81
|
+
publishables: {
|
|
82
|
+
published: publishedLayers
|
|
83
|
+
},
|
|
84
|
+
styles: {
|
|
85
|
+
style: styles
|
|
86
|
+
},
|
|
87
|
+
...options
|
|
157
88
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return _regenerator["default"].wrap(function (_context2) {
|
|
178
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
179
|
-
case 0:
|
|
180
|
-
_context2.next = 1;
|
|
181
|
-
return (0, _nodeFetch["default"])("".concat(this.url, "/workspaces/").concat(workspace, "/layergroups/").concat(layerGroupName, ".json"), {
|
|
182
|
-
credentials: 'include',
|
|
183
|
-
method: 'GET',
|
|
184
|
-
headers: {
|
|
185
|
-
Authorization: this.auth
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
case 1:
|
|
189
|
-
response = _context2.sent;
|
|
190
|
-
if (response.ok) {
|
|
191
|
-
_context2.next = 5;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
grc = new _about["default"](this.url, this.auth);
|
|
195
|
-
_context2.next = 2;
|
|
196
|
-
return grc.exists();
|
|
197
|
-
case 2:
|
|
198
|
-
if (!_context2.sent) {
|
|
199
|
-
_context2.next = 3;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
return _context2.abrupt("return");
|
|
203
|
-
case 3:
|
|
204
|
-
_context2.next = 4;
|
|
205
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
206
|
-
case 4:
|
|
207
|
-
geoServerResponse = _context2.sent;
|
|
208
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
209
|
-
case 5:
|
|
210
|
-
return _context2.abrupt("return", response.json());
|
|
211
|
-
case 6:
|
|
212
|
-
case "end":
|
|
213
|
-
return _context2.stop();
|
|
214
|
-
}
|
|
215
|
-
}, _callee2, this);
|
|
216
|
-
}));
|
|
217
|
-
function get(_x5, _x6) {
|
|
218
|
-
return _get.apply(this, arguments);
|
|
89
|
+
};
|
|
90
|
+
const response = await (0, _nodeFetch.default)(`${this.url}/workspaces/${workspace}/layergroups`, {
|
|
91
|
+
credentials: 'include',
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
Authorization: this.auth,
|
|
95
|
+
'Content-Type': 'application/json'
|
|
96
|
+
},
|
|
97
|
+
body: JSON.stringify(body)
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const grc = new _about.default(this.url, this.auth);
|
|
101
|
+
if (await grc.exists()) {
|
|
102
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
103
|
+
return;
|
|
104
|
+
} else {
|
|
105
|
+
// There was a general problem with GeoServer
|
|
106
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
107
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
219
108
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
headers: {
|
|
246
|
-
Authorization: this.auth,
|
|
247
|
-
'Content-Type': 'application/json'
|
|
248
|
-
},
|
|
249
|
-
body: JSON.stringify(layerGroupDefinition)
|
|
250
|
-
});
|
|
251
|
-
case 1:
|
|
252
|
-
response = _context3.sent;
|
|
253
|
-
if (response.ok) {
|
|
254
|
-
_context3.next = 3;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
_context3.next = 2;
|
|
258
|
-
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
259
|
-
case 2:
|
|
260
|
-
geoServerResponse = _context3.sent;
|
|
261
|
-
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
262
|
-
case 3:
|
|
263
|
-
case "end":
|
|
264
|
-
return _context3.stop();
|
|
265
|
-
}
|
|
266
|
-
}, _callee3, this);
|
|
267
|
-
}));
|
|
268
|
-
function update(_x7, _x8, _x9) {
|
|
269
|
-
return _update.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
// get resource location from response header
|
|
111
|
+
const location = response.headers.get('location');
|
|
112
|
+
|
|
113
|
+
// return resource location
|
|
114
|
+
return location;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns a GeoServer layergroup by the given workspace and layergroup name,
|
|
119
|
+
* e.g. "myWs:myLayergroup".
|
|
120
|
+
*
|
|
121
|
+
* @param {String} workspace The name of the workspace
|
|
122
|
+
* @param {String} layerGroupName The name of the layer group to query
|
|
123
|
+
*
|
|
124
|
+
* @throws Error if request fails
|
|
125
|
+
*
|
|
126
|
+
* @returns {Object} An object with layer group information or undefined if it cannot be found
|
|
127
|
+
*/
|
|
128
|
+
async get(workspace, layerGroupName) {
|
|
129
|
+
const response = await (0, _nodeFetch.default)(`${this.url}/workspaces/${workspace}/layergroups/${layerGroupName}.json`, {
|
|
130
|
+
credentials: 'include',
|
|
131
|
+
method: 'GET',
|
|
132
|
+
headers: {
|
|
133
|
+
Authorization: this.auth
|
|
270
134
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
135
|
+
});
|
|
136
|
+
if (!response.ok) {
|
|
137
|
+
const grc = new _about.default(this.url, this.auth);
|
|
138
|
+
if (await grc.exists()) {
|
|
139
|
+
// GeoServer exists, but requested item does not exist, we return empty
|
|
140
|
+
return;
|
|
141
|
+
} else {
|
|
142
|
+
// There was a general problem with GeoServer
|
|
143
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
144
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return response.json();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Updates an existing GeoServer layergroup
|
|
152
|
+
*
|
|
153
|
+
* @param {String} workspace The name of the workspace
|
|
154
|
+
* @param {String} layerName The name of the layergroup to update
|
|
155
|
+
* @param {Object} layerGroupDefinition The updated definiton of the layergroup
|
|
156
|
+
*
|
|
157
|
+
* @throws Error if request fails
|
|
158
|
+
*/
|
|
159
|
+
async update(workspace, layerGroupName, layerGroupDefinition) {
|
|
160
|
+
const url = `${this.url}/workspaces/${workspace}/layergroups/${layerGroupName}.json`;
|
|
161
|
+
const response = await (0, _nodeFetch.default)(url, {
|
|
162
|
+
credentials: 'include',
|
|
163
|
+
method: 'PUT',
|
|
164
|
+
headers: {
|
|
165
|
+
Authorization: this.auth,
|
|
166
|
+
'Content-Type': 'application/json'
|
|
167
|
+
},
|
|
168
|
+
body: JSON.stringify(layerGroupDefinition)
|
|
169
|
+
});
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
const geoServerResponse = await (0, _geoserver.getGeoServerResponseText)(response);
|
|
172
|
+
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.default = LayerGroupClient;
|