geoserver-node-client 1.4.7 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geoserver-node-client",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "Node.js client for GeoServer REST API",
5
5
  "type": "module",
6
6
  "main": "geoserver-rest-client.js",
@@ -36,22 +36,23 @@
36
36
  "author": "C. Mayer, meggsimum (info_at*meggsimum?dot?de)",
37
37
  "license": "BSD-2-Clause",
38
38
  "dependencies": {
39
- "@babel/runtime": "^7.23.1",
39
+ "@babel/runtime": "^7.27.6",
40
40
  "node-fetch": "^3.3.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/cli": "^7.23.0",
44
- "@babel/core": "^7.23.0",
45
- "@babel/plugin-transform-runtime": "^7.22.15",
44
+ "@babel/core": "^7.27.4",
45
+ "@babel/plugin-transform-runtime": "^7.27.4",
46
46
  "@babel/preset-env": "^7.22.20",
47
+ "@eslint/compat": "^1.2.9",
47
48
  "chai": "^5.0.3",
48
- "eslint": "^8.51.0",
49
- "eslint-config-standard": "^17.1.0",
50
- "eslint-plugin-import": "^2.28.1",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-promise": "^6.1.1",
49
+ "eslint": "^9.29.0",
50
+ "eslint-config-prettier": "^10.1.5",
51
+ "eslint-plugin-prettier": "^5.5.1",
53
52
  "jsdoc": "^4.0.2",
54
- "mocha": "^11.0.1",
55
- "release-it": "^19.0.1"
53
+ "mocha": "^11.7.1",
54
+ "neostandard": "^0.12.1",
55
+ "prettier": "^3.6.1",
56
+ "release-it": "^19.0.3"
56
57
  }
57
58
  }
package/src/about.js CHANGED
@@ -13,7 +13,7 @@ export default class AboutClient {
13
13
  * @param {String} url The URL of the GeoServer REST API endpoint
14
14
  * @param {String} auth The Basic Authentication string
15
15
  */
16
- constructor (url, auth) {
16
+ constructor(url, auth) {
17
17
  this.url = url;
18
18
  this.auth = auth;
19
19
  }
@@ -25,7 +25,7 @@ export default class AboutClient {
25
25
  *
26
26
  * @returns {Object} The version of GeoServer
27
27
  */
28
- async getVersion () {
28
+ async getVersion() {
29
29
  const url = this.url + 'about/version.json';
30
30
  const response = await fetch(url, {
31
31
  credentials: 'include',
@@ -47,12 +47,12 @@ export default class AboutClient {
47
47
  *
48
48
  * @returns {Boolean} If the connection exists
49
49
  */
50
- async exists () {
50
+ async exists() {
51
51
  let versionInfo;
52
52
  try {
53
53
  versionInfo = await this.getVersion();
54
- return !!versionInfo
55
- } catch (error) {
54
+ return !!versionInfo;
55
+ } catch {
56
56
  return false;
57
57
  }
58
58
  }
package/src/datastore.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fetch from 'node-fetch';
2
2
  import fs from 'fs';
3
3
  import { getGeoServerResponseText, GeoServerResponseError } from './util/geoserver.js';
4
- import AboutClient from './about.js'
4
+ import AboutClient from './about.js';
5
5
 
6
6
  /**
7
7
  * Client for GeoServer data stores
@@ -15,7 +15,7 @@ export default class DatastoreClient {
15
15
  * @param {String} url The URL of the GeoServer REST API endpoint
16
16
  * @param {String} auth The Basic Authentication string
17
17
  */
18
- constructor (url, auth) {
18
+ constructor(url, auth) {
19
19
  this.url = url;
20
20
  this.auth = auth;
21
21
  }
@@ -27,7 +27,7 @@ export default class DatastoreClient {
27
27
  *
28
28
  * @returns {Object} An object containing store details
29
29
  */
30
- async getDataStores (workspace) {
30
+ async getDataStores(workspace) {
31
31
  return this.getStores(workspace, 'datastores');
32
32
  }
33
33
 
@@ -38,7 +38,7 @@ export default class DatastoreClient {
38
38
  *
39
39
  * @returns {Object} An object containing store details
40
40
  */
41
- async getCoverageStores (workspace) {
41
+ async getCoverageStores(workspace) {
42
42
  return this.getStores(workspace, 'coveragestores');
43
43
  }
44
44
 
@@ -49,7 +49,7 @@ export default class DatastoreClient {
49
49
  *
50
50
  * @returns {Object} An object containing store details
51
51
  */
52
- async getWmsStores (workspace) {
52
+ async getWmsStores(workspace) {
53
53
  return this.getStores(workspace, 'wmsstores');
54
54
  }
55
55
 
@@ -60,7 +60,7 @@ export default class DatastoreClient {
60
60
  *
61
61
  * @returns {Object} An object containing store details
62
62
  */
63
- async getWmtsStores (workspace) {
63
+ async getWmtsStores(workspace) {
64
64
  return this.getStores(workspace, 'wmtsstores');
65
65
  }
66
66
 
@@ -75,7 +75,7 @@ export default class DatastoreClient {
75
75
  * @returns {Object} An object containing store details or undefined if it cannot be found
76
76
  * @private
77
77
  */
78
- async getStores (workspace, storeType) {
78
+ async getStores(workspace, storeType) {
79
79
  const response = await fetch(this.url + 'workspaces/' + workspace + '/' + storeType + '.json', {
80
80
  credentials: 'include',
81
81
  method: 'GET',
@@ -98,7 +98,7 @@ export default class DatastoreClient {
98
98
  *
99
99
  * @returns {Object} An object containing store details or undefined if it cannot be found
100
100
  */
101
- async getDataStore (workspace, dataStore) {
101
+ async getDataStore(workspace, dataStore) {
102
102
  return this.getStore(workspace, dataStore, 'datastores');
103
103
  }
104
104
 
@@ -110,7 +110,7 @@ export default class DatastoreClient {
110
110
  *
111
111
  * @returns {Object} An object containing store details or undefined if it cannot be found
112
112
  */
113
- async getCoverageStore (workspace, covStore) {
113
+ async getCoverageStore(workspace, covStore) {
114
114
  return this.getStore(workspace, covStore, 'coveragestores');
115
115
  }
116
116
 
@@ -123,7 +123,7 @@ export default class DatastoreClient {
123
123
  * @returns {Object} An object containing store details or undefined if it cannot be found
124
124
  *
125
125
  */
126
- async getWmsStore (workspace, wmsStore) {
126
+ async getWmsStore(workspace, wmsStore) {
127
127
  return this.getStore(workspace, wmsStore, 'wmsstores');
128
128
  }
129
129
 
@@ -135,7 +135,7 @@ export default class DatastoreClient {
135
135
  *
136
136
  * @returns {Object} An object containing store details or undefined if it cannot be found
137
137
  */
138
- async getWmtsStore (workspace, wmtsStore) {
138
+ async getWmtsStore(workspace, wmtsStore) {
139
139
  return this.getStore(workspace, wmtsStore, 'wmtsstores');
140
140
  }
141
141
 
@@ -151,7 +151,7 @@ export default class DatastoreClient {
151
151
  * @returns {Object} An object containing store details or undefined if it cannot be found
152
152
  * @private
153
153
  */
154
- async getStore (workspace, storeName, storeType) {
154
+ async getStore(workspace, storeName, storeType) {
155
155
  const url = this.url + 'workspaces/' + workspace + '/' + storeType + '/' + storeName + '.json';
156
156
  const response = await fetch(url, {
157
157
  credentials: 'include',
@@ -190,12 +190,19 @@ export default class DatastoreClient {
190
190
  *
191
191
  * @returns {String} The successful response text
192
192
  */
193
- async createGeotiffFromFile (workspace, coverageStore, layerName, layerTitle, filePath) {
193
+ async createGeotiffFromFile(workspace, coverageStore, layerName, layerTitle, filePath) {
194
194
  const stats = fs.statSync(filePath);
195
195
  const fileSizeInBytes = stats.size;
196
196
  const readStream = fs.createReadStream(filePath);
197
197
 
198
- return this.createGeotiffFromStream(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes);
198
+ return this.createGeotiffFromStream(
199
+ workspace,
200
+ coverageStore,
201
+ layerName,
202
+ layerTitle,
203
+ readStream,
204
+ fileSizeInBytes
205
+ );
199
206
  }
200
207
 
201
208
  /**
@@ -214,11 +221,18 @@ export default class DatastoreClient {
214
221
  *
215
222
  * @returns {String} The successful response text
216
223
  */
217
- async createGeotiffFromStream (workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes) {
224
+ async createGeotiffFromStream(
225
+ workspace,
226
+ coverageStore,
227
+ layerName,
228
+ layerTitle,
229
+ readStream,
230
+ fileSizeInBytes
231
+ ) {
218
232
  const lyrTitle = layerTitle || layerName;
219
233
 
220
- let url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
221
- coverageStore + '/file.geotiff';
234
+ let url =
235
+ this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.geotiff';
222
236
  url += '?filename=' + lyrTitle + '&coverageName=' + layerName;
223
237
  const response = await fetch(url, {
224
238
  credentials: 'include',
@@ -255,7 +269,18 @@ export default class DatastoreClient {
255
269
  *
256
270
  * @throws Error if request fails
257
271
  */
258
- async createPostgisStore (workspace, namespaceUri, dataStore, pgHost, pgPort, pgUser, pgPassword, pgSchema, pgDb, exposePk) {
272
+ async createPostgisStore(
273
+ workspace,
274
+ namespaceUri,
275
+ dataStore,
276
+ pgHost,
277
+ pgPort,
278
+ pgUser,
279
+ pgPassword,
280
+ pgSchema,
281
+ pgDb,
282
+ exposePk
283
+ ) {
259
284
  const body = {
260
285
  dataStore: {
261
286
  name: dataStore,
@@ -342,10 +367,16 @@ export default class DatastoreClient {
342
367
  *
343
368
  * @returns {String} The response text
344
369
  */
345
- async createImageMosaicStore (workspace, coverageStore, zipArchivePath) {
370
+ async createImageMosaicStore(workspace, coverageStore, zipArchivePath) {
346
371
  const readStream = fs.createReadStream(zipArchivePath);
347
372
 
348
- const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.imagemosaic';
373
+ const url =
374
+ this.url +
375
+ 'workspaces/' +
376
+ workspace +
377
+ '/coveragestores/' +
378
+ coverageStore +
379
+ '/file.imagemosaic';
349
380
  const response = await fetch(url, {
350
381
  credentials: 'include',
351
382
  method: 'PUT',
@@ -362,7 +393,7 @@ export default class DatastoreClient {
362
393
  }
363
394
 
364
395
  return response.text();
365
- };
396
+ }
366
397
 
367
398
  /**
368
399
  * Creates a WMS based data store.
@@ -373,7 +404,7 @@ export default class DatastoreClient {
373
404
  *
374
405
  * @throws Error if request fails
375
406
  */
376
- async createWmsStore (workspace, dataStore, wmsCapabilitiesUrl) {
407
+ async createWmsStore(workspace, dataStore, wmsCapabilitiesUrl) {
377
408
  const body = {
378
409
  wmsStore: {
379
410
  name: dataStore,
@@ -408,7 +439,7 @@ export default class DatastoreClient {
408
439
  *
409
440
  * @throws Error if request fails
410
441
  */
411
- async createWmtsStore (workspace, dataStore, wmtsCapabilitiesUrl) {
442
+ async createWmtsStore(workspace, dataStore, wmtsCapabilitiesUrl) {
412
443
  const body = {
413
444
  wmtsStore: {
414
445
  name: dataStore,
@@ -445,7 +476,13 @@ export default class DatastoreClient {
445
476
  *
446
477
  * @throws Error if request fails
447
478
  */
448
- async createWfsStore (workspace, dataStore, wfsCapabilitiesUrl, namespaceUrl, useHttpConnectionPooling) {
479
+ async createWfsStore(
480
+ workspace,
481
+ dataStore,
482
+ wfsCapabilitiesUrl,
483
+ namespaceUrl,
484
+ useHttpConnectionPooling
485
+ ) {
449
486
  const body = {
450
487
  dataStore: {
451
488
  name: dataStore,
@@ -495,7 +532,7 @@ export default class DatastoreClient {
495
532
  *
496
533
  * @throws Error if request fails
497
534
  */
498
- async deleteDataStore (workspace, dataStore, recurse) {
535
+ async deleteDataStore(workspace, dataStore, recurse) {
499
536
  let url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore;
500
537
  url += '?recurse=' + recurse;
501
538
 
@@ -524,7 +561,7 @@ export default class DatastoreClient {
524
561
  *
525
562
  * @throws Error if request fails
526
563
  */
527
- async deleteCoverageStore (workspace, coverageStore, recurse) {
564
+ async deleteCoverageStore(workspace, coverageStore, recurse) {
528
565
  let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore;
529
566
  url += '?recurse=' + recurse;
530
567
 
@@ -541,8 +578,11 @@ export default class DatastoreClient {
541
578
  const geoServerResponse = await getGeoServerResponseText(response);
542
579
  switch (response.status) {
543
580
  case 401:
544
- throw new GeoServerResponseError('Deletion failed. There might be dependant objects to ' +
545
- 'this store. Delete them first or call this with "recurse=false"', geoServerResponse);
581
+ throw new GeoServerResponseError(
582
+ 'Deletion failed. There might be dependant objects to ' +
583
+ 'this store. Delete them first or call this with "recurse=false"',
584
+ geoServerResponse
585
+ );
546
586
  default:
547
587
  throw new GeoServerResponseError(null, geoServerResponse);
548
588
  }
@@ -558,7 +598,7 @@ export default class DatastoreClient {
558
598
  *
559
599
  * @throws Error if request fails
560
600
  */
561
- async createGpkgStore (workspace, dataStore, gpkgPath) {
601
+ async createGpkgStore(workspace, dataStore, gpkgPath) {
562
602
  const body = {
563
603
  dataStore: {
564
604
  name: dataStore,
@@ -13,7 +13,7 @@ export default class ImageMosaicClient {
13
13
  * @param {String} url The URL of the GeoServer REST API endpoint
14
14
  * @param {String} auth The Basic Authentication string
15
15
  */
16
- constructor (url, auth) {
16
+ constructor(url, auth) {
17
17
  this.url = url;
18
18
  this.auth = auth;
19
19
  }
@@ -29,9 +29,16 @@ export default class ImageMosaicClient {
29
29
  *
30
30
  * @returns {Object} An object with the granules
31
31
  */
32
- async getGranules (workspace, coverageStore, coverage) {
33
- const url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
34
- coverageStore + '/coverages/' + coverage + '/index/granules.json';
32
+ async getGranules(workspace, coverageStore, coverage) {
33
+ const url =
34
+ this.url +
35
+ 'workspaces/' +
36
+ workspace +
37
+ '/coveragestores/' +
38
+ coverageStore +
39
+ '/coverages/' +
40
+ coverage +
41
+ '/index/granules.json';
35
42
  const response = await fetch(url, {
36
43
  credentials: 'include',
37
44
  method: 'GET',
@@ -60,8 +67,14 @@ export default class ImageMosaicClient {
60
67
  *
61
68
  * @returns {Object} An object with the granules
62
69
  */
63
- async harvestGranules (workspace, coverageStore, filePath) {
64
- const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
70
+ async harvestGranules(workspace, coverageStore, filePath) {
71
+ const url =
72
+ this.url +
73
+ 'workspaces/' +
74
+ workspace +
75
+ '/coveragestores/' +
76
+ coverageStore +
77
+ '/external.imagemosaic';
65
78
 
66
79
  const response = await fetch(url, {
67
80
  credentials: 'include',
@@ -90,8 +103,14 @@ export default class ImageMosaicClient {
90
103
  *
91
104
  * @throws Error if request fails
92
105
  */
93
- async addGranuleByServerFile (workspace, coverageStore, filePath) {
94
- const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
106
+ async addGranuleByServerFile(workspace, coverageStore, filePath) {
107
+ const url =
108
+ this.url +
109
+ 'workspaces/' +
110
+ workspace +
111
+ '/coveragestores/' +
112
+ coverageStore +
113
+ '/external.imagemosaic';
95
114
 
96
115
  const response = await fetch(url, {
97
116
  credentials: 'include',
@@ -119,9 +138,17 @@ export default class ImageMosaicClient {
119
138
  *
120
139
  * @throws Error if request fails
121
140
  */
122
- async deleteSingleGranule (workspace, coverageStore, coverage, covFileLocation) {
123
- let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + coverage + '/index/granules.xml';
124
- url += '?filter=location=\'' + covFileLocation + '\'';
141
+ async deleteSingleGranule(workspace, coverageStore, coverage, covFileLocation) {
142
+ let url =
143
+ this.url +
144
+ 'workspaces/' +
145
+ workspace +
146
+ '/coveragestores/' +
147
+ coverageStore +
148
+ '/coverages/' +
149
+ coverage +
150
+ '/index/granules.xml';
151
+ url += "?filter=location='" + covFileLocation + "'";
125
152
 
126
153
  const response = await fetch(url, {
127
154
  credentials: 'include',