geoserver-node-client 1.2.3 → 1.3.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 CHANGED
@@ -4,35 +4,35 @@
4
4
  [![Website](https://img.shields.io/website?up_message=API-Docs&url=https%3A%2F%2Fmeggsimum.github.io%2Fgeoserver-node-client%2F)](https://meggsimum.github.io/geoserver-node-client)
5
5
  ![GitHub Release Date](https://img.shields.io/github/release-date/meggsimum/geoserver-node-client)
6
6
  ![GitHub last commit](https://img.shields.io/github/last-commit/meggsimum/geoserver-node-client)
7
- ![](https://github.com/meggsimum/geoserver-node-client/actions/workflows/ci-geoserver-node-client.yml/badge.svg)
7
+ ![CI Badge](https://github.com/meggsimum/geoserver-node-client/actions/workflows/ci-geoserver-node-client.yml/badge.svg)
8
8
 
9
9
  ![GeoSever Node Client Logo](/img/geoserver-node-client-logo_150px.png)
10
10
 
11
11
  Node.js / JavaScript Client for the [GeoServer REST API](https://docs.geoserver.org/stable/en/user/rest/).
12
12
 
13
- ### API-Docs ###
13
+ ## API-Docs
14
14
 
15
15
  Detailed [API-Docs](https://meggsimum.github.io/geoserver-node-client/) are automatically created with JSDoc.
16
16
 
17
- ### Meta information
17
+ ## Meta information
18
18
 
19
19
  Compatible with [GeoServer](https://geoserver.org)
20
20
 
21
- - v2.22.x
22
- - v2.21.x
23
- - v2.20.x (no more maintained and officially deprecated)
24
- - v2.19.x (no more maintained and officially deprecated)
25
- - v2.18.x (no more maintained and officially deprecated)
26
- - v2.17.x (no more maintained and officially deprecated)
21
+ - v2.22.x
22
+ - v2.21.x
23
+ - v2.20.x (no more maintained and officially deprecated)
24
+ - v2.19.x (no more maintained and officially deprecated)
25
+ - v2.18.x (no more maintained and officially deprecated)
26
+ - v2.17.x (no more maintained and officially deprecated)
27
27
 
28
-
29
- ### Usage
28
+ ## Usage
30
29
 
31
30
  ```shell
32
31
  npm i geoserver-node-client
33
32
  ```
34
33
 
35
34
  usage with require (ES5):
35
+
36
36
  ```js
37
37
  var grcImport = require('geoserver-node-client');
38
38
  var GeoServerRestClient = grcImport.GeoServerRestClient;
@@ -52,6 +52,7 @@ main();
52
52
  ```
53
53
 
54
54
  usage as ES module (ES6)
55
+
55
56
  ```js
56
57
  import {GeoServerRestClient} from 'geoserver-node-client';
57
58
 
@@ -68,7 +69,7 @@ async function main () {
68
69
  main();
69
70
  ```
70
71
 
71
- ### Setup
72
+ ## Setup
72
73
 
73
74
  Run as local checkout (mainly for development purposes)
74
75
 
@@ -82,7 +83,7 @@ npm install
82
83
  npm run demo
83
84
  ```
84
85
 
85
- ### Error Handling
86
+ ## Error Handling
86
87
 
87
88
  A request either succeeds or throws the custom `GeoServerResponseError`. It has the standard `message` property with a "human-readable" text. Additionally the error has the property `geoServerOutput` which contains the direct response from GeoServer. This output is not guaranteed to exist and can either be a simple text or a complete HTML document. The latter is difficult to read, but might still be helpful for debugging. This example shows how these error properties can be used. It also shows how to filter by error type:
88
89
 
@@ -105,7 +106,7 @@ A request either succeeds or throws the custom `GeoServerResponseError`. It has
105
106
  }
106
107
  ```
107
108
 
108
- ### Unit Tests
109
+ ## Unit Tests
109
110
 
110
111
  First start a test setup using this Docker compose file:
111
112
 
@@ -120,7 +121,7 @@ Then, in an other terminal, run:
120
121
  GEOSERVER_VERSION=2.20.4 npm run test
121
122
  ```
122
123
 
123
- ### Release
124
+ ## Release
124
125
 
125
126
  Setting a git tag and increasing the version in the `package.json` as well as releasing to npm is done via [release-it](https://github.com/release-it/release-it).
126
127
 
@@ -152,11 +153,11 @@ npm run release
152
153
  - makes a release commit and pushes it to GitHub
153
154
  - publishes the new version to npm
154
155
 
155
- ### Who do I talk to? ###
156
+ ## Who do I talk to?
156
157
 
157
- * meggsimum (Christian Mayer) - info __at## meggsimum ~~dot** de
158
+ - meggsimum (Christian Mayer) - info __at## meggsimum ~~dot** de
158
159
 
159
- ### Credits
160
+ ## Credits
160
161
 
161
162
  This project was initiated by [meggsimum](https://meggsimum.de) within the [mFund](https://www.bmvi.de/EN/Topics/Digital-Matters/mFund/mFund.html) research project [SAUBER](https://sauber-projekt.de/) and is further developed in the mFund research project [KLIPS](http://www.klips-projekt.de/):
162
163
  <p><img src="https://sauber-projekt.de/wp-content/uploads/2018/12/SAG_SAUBER_Logo_Dez3_transparent-1-e1543843688935.png" alt="SAUBER Logo" width="200"/></p>.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geoserver-node-client",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Node.js client for GeoServer REST API",
5
5
  "type": "commonjs",
6
6
  "main": "geoserver-rest-client.js",
@@ -461,18 +461,60 @@ var DatastoreClient = /*#__PURE__*/function () {
461
461
  key: "createGeotiffFromFile",
462
462
  value: function () {
463
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;
464
+ var stats, fileSizeInBytes, readStream;
465
465
  return _regenerator["default"].wrap(function _callee11$(_context11) {
466
466
  while (1) {
467
467
  switch (_context11.prev = _context11.next) {
468
468
  case 0:
469
- lyrTitle = layerTitle || layerName;
470
469
  stats = _fs["default"].statSync(filePath);
471
470
  fileSizeInBytes = stats.size;
472
471
  readStream = _fs["default"].createReadStream(filePath);
472
+ return _context11.abrupt("return", this.createGeotiffFromStream(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes));
473
+
474
+ case 4:
475
+ case "end":
476
+ return _context11.stop();
477
+ }
478
+ }
479
+ }, _callee11, this);
480
+ }));
481
+
482
+ function createGeotiffFromFile(_x18, _x19, _x20, _x21, _x22) {
483
+ return _createGeotiffFromFile.apply(this, arguments);
484
+ }
485
+
486
+ return createGeotiffFromFile;
487
+ }()
488
+ /**
489
+ * Creates a GeoTIFF store from a file by stream and publishes it as layer.
490
+ * The GeoTIFF file is placed on the server, where your GeoServer
491
+ * is running.
492
+ *
493
+ * @param {String} workspace The workspace to create GeoTIFF store in
494
+ * @param {String} coverageStore The name of the new GeoTIFF store
495
+ * @param {String} layerName The published name of the new layer
496
+ * @param {String} layerTitle The published title of the new layer
497
+ * @param {Stream} readStream The stream of the GeoTIFF file
498
+ * @param {Number} fileSizeInBytes The number of bytes of the stream
499
+ *
500
+ * @throws Error if request fails
501
+ *
502
+ * @returns {String} The successful response text
503
+ */
504
+
505
+ }, {
506
+ key: "createGeotiffFromStream",
507
+ value: function () {
508
+ var _createGeotiffFromStream = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes) {
509
+ var lyrTitle, url, response, geoServerResponse;
510
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
511
+ while (1) {
512
+ switch (_context12.prev = _context12.next) {
513
+ case 0:
514
+ lyrTitle = layerTitle || layerName;
473
515
  url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.geotiff';
474
516
  url += '?filename=' + lyrTitle + '&coverageName=' + layerName;
475
- _context11.next = 8;
517
+ _context12.next = 5;
476
518
  return (0, _nodeFetch["default"])(url, {
477
519
  credentials: 'include',
478
520
  method: 'PUT',
@@ -484,37 +526,37 @@ var DatastoreClient = /*#__PURE__*/function () {
484
526
  body: readStream
485
527
  });
486
528
 
487
- case 8:
488
- response = _context11.sent;
529
+ case 5:
530
+ response = _context12.sent;
489
531
 
490
532
  if (response.ok) {
491
- _context11.next = 14;
533
+ _context12.next = 11;
492
534
  break;
493
535
  }
494
536
 
495
- _context11.next = 12;
537
+ _context12.next = 9;
496
538
  return (0, _geoserver.getGeoServerResponseText)(response);
497
539
 
498
- case 12:
499
- geoServerResponse = _context11.sent;
540
+ case 9:
541
+ geoServerResponse = _context12.sent;
500
542
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
501
543
 
502
- case 14:
503
- return _context11.abrupt("return", response.text());
544
+ case 11:
545
+ return _context12.abrupt("return", response.text());
504
546
 
505
- case 15:
547
+ case 12:
506
548
  case "end":
507
- return _context11.stop();
549
+ return _context12.stop();
508
550
  }
509
551
  }
510
- }, _callee11, this);
552
+ }, _callee12, this);
511
553
  }));
512
554
 
513
- function createGeotiffFromFile(_x18, _x19, _x20, _x21, _x22) {
514
- return _createGeotiffFromFile.apply(this, arguments);
555
+ function createGeotiffFromStream(_x23, _x24, _x25, _x26, _x27, _x28) {
556
+ return _createGeotiffFromStream.apply(this, arguments);
515
557
  }
516
558
 
517
- return createGeotiffFromFile;
559
+ return createGeotiffFromStream;
518
560
  }()
519
561
  /**
520
562
  * Creates a PostGIS based data store.
@@ -536,11 +578,11 @@ var DatastoreClient = /*#__PURE__*/function () {
536
578
  }, {
537
579
  key: "createPostgisStore",
538
580
  value: function () {
539
- var _createPostgisStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(workspace, namespaceUri, dataStore, pgHost, pgPort, pgUser, pgPassword, pgSchema, pgDb, exposePk) {
581
+ var _createPostgisStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(workspace, namespaceUri, dataStore, pgHost, pgPort, pgUser, pgPassword, pgSchema, pgDb, exposePk) {
540
582
  var body, url, response, geoServerResponse;
541
- return _regenerator["default"].wrap(function _callee12$(_context12) {
583
+ return _regenerator["default"].wrap(function _callee13$(_context13) {
542
584
  while (1) {
543
- switch (_context12.prev = _context12.next) {
585
+ switch (_context13.prev = _context13.next) {
544
586
  case 0:
545
587
  body = {
546
588
  dataStore: {
@@ -583,7 +625,7 @@ var DatastoreClient = /*#__PURE__*/function () {
583
625
  }
584
626
  };
585
627
  url = this.url + 'workspaces/' + workspace + '/datastores';
586
- _context12.next = 4;
628
+ _context13.next = 4;
587
629
  return (0, _nodeFetch["default"])(url, {
588
630
  credentials: 'include',
589
631
  method: 'POST',
@@ -595,29 +637,29 @@ var DatastoreClient = /*#__PURE__*/function () {
595
637
  });
596
638
 
597
639
  case 4:
598
- response = _context12.sent;
640
+ response = _context13.sent;
599
641
 
600
642
  if (response.ok) {
601
- _context12.next = 10;
643
+ _context13.next = 10;
602
644
  break;
603
645
  }
604
646
 
605
- _context12.next = 8;
647
+ _context13.next = 8;
606
648
  return (0, _geoserver.getGeoServerResponseText)(response);
607
649
 
608
650
  case 8:
609
- geoServerResponse = _context12.sent;
651
+ geoServerResponse = _context13.sent;
610
652
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
611
653
 
612
654
  case 10:
613
655
  case "end":
614
- return _context12.stop();
656
+ return _context13.stop();
615
657
  }
616
658
  }
617
- }, _callee12, this);
659
+ }, _callee13, this);
618
660
  }));
619
661
 
620
- function createPostgisStore(_x23, _x24, _x25, _x26, _x27, _x28, _x29, _x30, _x31, _x32) {
662
+ function createPostgisStore(_x29, _x30, _x31, _x32, _x33, _x34, _x35, _x36, _x37, _x38) {
621
663
  return _createPostgisStore.apply(this, arguments);
622
664
  }
623
665
 
@@ -644,15 +686,15 @@ var DatastoreClient = /*#__PURE__*/function () {
644
686
  }, {
645
687
  key: "createImageMosaicStore",
646
688
  value: function () {
647
- var _createImageMosaicStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(workspace, coverageStore, zipArchivePath) {
689
+ var _createImageMosaicStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(workspace, coverageStore, zipArchivePath) {
648
690
  var readStream, url, response, geoServerResponse;
649
- return _regenerator["default"].wrap(function _callee13$(_context13) {
691
+ return _regenerator["default"].wrap(function _callee14$(_context14) {
650
692
  while (1) {
651
- switch (_context13.prev = _context13.next) {
693
+ switch (_context14.prev = _context14.next) {
652
694
  case 0:
653
695
  readStream = _fs["default"].createReadStream(zipArchivePath);
654
696
  url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/file.imagemosaic';
655
- _context13.next = 4;
697
+ _context14.next = 4;
656
698
  return (0, _nodeFetch["default"])(url, {
657
699
  credentials: 'include',
658
700
  method: 'PUT',
@@ -664,32 +706,32 @@ var DatastoreClient = /*#__PURE__*/function () {
664
706
  });
665
707
 
666
708
  case 4:
667
- response = _context13.sent;
709
+ response = _context14.sent;
668
710
 
669
711
  if (response.ok) {
670
- _context13.next = 10;
712
+ _context14.next = 10;
671
713
  break;
672
714
  }
673
715
 
674
- _context13.next = 8;
716
+ _context14.next = 8;
675
717
  return (0, _geoserver.getGeoServerResponseText)(response);
676
718
 
677
719
  case 8:
678
- geoServerResponse = _context13.sent;
720
+ geoServerResponse = _context14.sent;
679
721
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
680
722
 
681
723
  case 10:
682
- return _context13.abrupt("return", response.text());
724
+ return _context14.abrupt("return", response.text());
683
725
 
684
726
  case 11:
685
727
  case "end":
686
- return _context13.stop();
728
+ return _context14.stop();
687
729
  }
688
730
  }
689
- }, _callee13, this);
731
+ }, _callee14, this);
690
732
  }));
691
733
 
692
- function createImageMosaicStore(_x33, _x34, _x35) {
734
+ function createImageMosaicStore(_x39, _x40, _x41) {
693
735
  return _createImageMosaicStore.apply(this, arguments);
694
736
  }
695
737
 
@@ -708,11 +750,11 @@ var DatastoreClient = /*#__PURE__*/function () {
708
750
  * @throws Error if request fails
709
751
  */
710
752
  function () {
711
- var _createWmsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(workspace, dataStore, wmsCapabilitiesUrl) {
753
+ var _createWmsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(workspace, dataStore, wmsCapabilitiesUrl) {
712
754
  var body, url, response, geoServerResponse;
713
- return _regenerator["default"].wrap(function _callee14$(_context14) {
755
+ return _regenerator["default"].wrap(function _callee15$(_context15) {
714
756
  while (1) {
715
- switch (_context14.prev = _context14.next) {
757
+ switch (_context15.prev = _context15.next) {
716
758
  case 0:
717
759
  body = {
718
760
  wmsStore: {
@@ -722,7 +764,7 @@ var DatastoreClient = /*#__PURE__*/function () {
722
764
  }
723
765
  };
724
766
  url = this.url + 'workspaces/' + workspace + '/wmsstores';
725
- _context14.next = 4;
767
+ _context15.next = 4;
726
768
  return (0, _nodeFetch["default"])(url, {
727
769
  credentials: 'include',
728
770
  method: 'POST',
@@ -734,29 +776,29 @@ var DatastoreClient = /*#__PURE__*/function () {
734
776
  });
735
777
 
736
778
  case 4:
737
- response = _context14.sent;
779
+ response = _context15.sent;
738
780
 
739
781
  if (response.ok) {
740
- _context14.next = 10;
782
+ _context15.next = 10;
741
783
  break;
742
784
  }
743
785
 
744
- _context14.next = 8;
786
+ _context15.next = 8;
745
787
  return (0, _geoserver.getGeoServerResponseText)(response);
746
788
 
747
789
  case 8:
748
- geoServerResponse = _context14.sent;
790
+ geoServerResponse = _context15.sent;
749
791
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
750
792
 
751
793
  case 10:
752
794
  case "end":
753
- return _context14.stop();
795
+ return _context15.stop();
754
796
  }
755
797
  }
756
- }, _callee14, this);
798
+ }, _callee15, this);
757
799
  }));
758
800
 
759
- function createWmsStore(_x36, _x37, _x38) {
801
+ function createWmsStore(_x42, _x43, _x44) {
760
802
  return _createWmsStore.apply(this, arguments);
761
803
  }
762
804
 
@@ -775,11 +817,11 @@ var DatastoreClient = /*#__PURE__*/function () {
775
817
  }, {
776
818
  key: "createWmtsStore",
777
819
  value: function () {
778
- var _createWmtsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(workspace, dataStore, wmtsCapabilitiesUrl) {
820
+ var _createWmtsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(workspace, dataStore, wmtsCapabilitiesUrl) {
779
821
  var body, url, response, geoServerResponse;
780
- return _regenerator["default"].wrap(function _callee15$(_context15) {
822
+ return _regenerator["default"].wrap(function _callee16$(_context16) {
781
823
  while (1) {
782
- switch (_context15.prev = _context15.next) {
824
+ switch (_context16.prev = _context16.next) {
783
825
  case 0:
784
826
  body = {
785
827
  wmtsStore: {
@@ -789,7 +831,7 @@ var DatastoreClient = /*#__PURE__*/function () {
789
831
  }
790
832
  };
791
833
  url = this.url + 'workspaces/' + workspace + '/wmtsstores';
792
- _context15.next = 4;
834
+ _context16.next = 4;
793
835
  return (0, _nodeFetch["default"])(url, {
794
836
  credentials: 'include',
795
837
  method: 'POST',
@@ -801,29 +843,29 @@ var DatastoreClient = /*#__PURE__*/function () {
801
843
  });
802
844
 
803
845
  case 4:
804
- response = _context15.sent;
846
+ response = _context16.sent;
805
847
 
806
848
  if (response.ok) {
807
- _context15.next = 10;
849
+ _context16.next = 10;
808
850
  break;
809
851
  }
810
852
 
811
- _context15.next = 8;
853
+ _context16.next = 8;
812
854
  return (0, _geoserver.getGeoServerResponseText)(response);
813
855
 
814
856
  case 8:
815
- geoServerResponse = _context15.sent;
857
+ geoServerResponse = _context16.sent;
816
858
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
817
859
 
818
860
  case 10:
819
861
  case "end":
820
- return _context15.stop();
862
+ return _context16.stop();
821
863
  }
822
864
  }
823
- }, _callee15, this);
865
+ }, _callee16, this);
824
866
  }));
825
867
 
826
- function createWmtsStore(_x39, _x40, _x41) {
868
+ function createWmtsStore(_x45, _x46, _x47) {
827
869
  return _createWmtsStore.apply(this, arguments);
828
870
  }
829
871
 
@@ -844,11 +886,11 @@ var DatastoreClient = /*#__PURE__*/function () {
844
886
  }, {
845
887
  key: "createWfsStore",
846
888
  value: function () {
847
- var _createWfsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(workspace, dataStore, wfsCapabilitiesUrl, namespaceUrl, useHttpConnectionPooling) {
889
+ var _createWfsStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(workspace, dataStore, wfsCapabilitiesUrl, namespaceUrl, useHttpConnectionPooling) {
848
890
  var body, url, response, geoServerResponse;
849
- return _regenerator["default"].wrap(function _callee16$(_context16) {
891
+ return _regenerator["default"].wrap(function _callee17$(_context17) {
850
892
  while (1) {
851
- switch (_context16.prev = _context16.next) {
893
+ switch (_context17.prev = _context17.next) {
852
894
  case 0:
853
895
  body = {
854
896
  dataStore: {
@@ -869,7 +911,7 @@ var DatastoreClient = /*#__PURE__*/function () {
869
911
  }
870
912
  };
871
913
  url = this.url + 'workspaces/' + workspace + '/datastores';
872
- _context16.next = 4;
914
+ _context17.next = 4;
873
915
  return (0, _nodeFetch["default"])(url, {
874
916
  credentials: 'include',
875
917
  method: 'POST',
@@ -881,29 +923,29 @@ var DatastoreClient = /*#__PURE__*/function () {
881
923
  });
882
924
 
883
925
  case 4:
884
- response = _context16.sent;
926
+ response = _context17.sent;
885
927
 
886
928
  if (response.ok) {
887
- _context16.next = 10;
929
+ _context17.next = 10;
888
930
  break;
889
931
  }
890
932
 
891
- _context16.next = 8;
933
+ _context17.next = 8;
892
934
  return (0, _geoserver.getGeoServerResponseText)(response);
893
935
 
894
936
  case 8:
895
- geoServerResponse = _context16.sent;
937
+ geoServerResponse = _context17.sent;
896
938
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
897
939
 
898
940
  case 10:
899
941
  case "end":
900
- return _context16.stop();
942
+ return _context17.stop();
901
943
  }
902
944
  }
903
- }, _callee16, this);
945
+ }, _callee17, this);
904
946
  }));
905
947
 
906
- function createWfsStore(_x42, _x43, _x44, _x45, _x46) {
948
+ function createWfsStore(_x48, _x49, _x50, _x51, _x52) {
907
949
  return _createWfsStore.apply(this, arguments);
908
950
  }
909
951
 
@@ -922,15 +964,15 @@ var DatastoreClient = /*#__PURE__*/function () {
922
964
  }, {
923
965
  key: "deleteDataStore",
924
966
  value: function () {
925
- var _deleteDataStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(workspace, dataStore, recurse) {
967
+ var _deleteDataStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(workspace, dataStore, recurse) {
926
968
  var url, response, geoServerResponse;
927
- return _regenerator["default"].wrap(function _callee17$(_context17) {
969
+ return _regenerator["default"].wrap(function _callee18$(_context18) {
928
970
  while (1) {
929
- switch (_context17.prev = _context17.next) {
971
+ switch (_context18.prev = _context18.next) {
930
972
  case 0:
931
973
  url = this.url + 'workspaces/' + workspace + '/datastores/' + dataStore;
932
974
  url += '?recurse=' + recurse;
933
- _context17.next = 4;
975
+ _context18.next = 4;
934
976
  return (0, _nodeFetch["default"])(url, {
935
977
  credentials: 'include',
936
978
  method: 'DELETE',
@@ -940,29 +982,29 @@ var DatastoreClient = /*#__PURE__*/function () {
940
982
  });
941
983
 
942
984
  case 4:
943
- response = _context17.sent;
985
+ response = _context18.sent;
944
986
 
945
987
  if (response.ok) {
946
- _context17.next = 10;
988
+ _context18.next = 10;
947
989
  break;
948
990
  }
949
991
 
950
- _context17.next = 8;
992
+ _context18.next = 8;
951
993
  return (0, _geoserver.getGeoServerResponseText)(response);
952
994
 
953
995
  case 8:
954
- geoServerResponse = _context17.sent;
996
+ geoServerResponse = _context18.sent;
955
997
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
956
998
 
957
999
  case 10:
958
1000
  case "end":
959
- return _context17.stop();
1001
+ return _context18.stop();
960
1002
  }
961
1003
  }
962
- }, _callee17, this);
1004
+ }, _callee18, this);
963
1005
  }));
964
1006
 
965
- function deleteDataStore(_x47, _x48, _x49) {
1007
+ function deleteDataStore(_x53, _x54, _x55) {
966
1008
  return _deleteDataStore.apply(this, arguments);
967
1009
  }
968
1010
 
@@ -981,15 +1023,15 @@ var DatastoreClient = /*#__PURE__*/function () {
981
1023
  }, {
982
1024
  key: "deleteCoverageStore",
983
1025
  value: function () {
984
- var _deleteCoverageStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(workspace, coverageStore, recurse) {
1026
+ var _deleteCoverageStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(workspace, coverageStore, recurse) {
985
1027
  var url, response, geoServerResponse;
986
- return _regenerator["default"].wrap(function _callee18$(_context18) {
1028
+ return _regenerator["default"].wrap(function _callee19$(_context19) {
987
1029
  while (1) {
988
- switch (_context18.prev = _context18.next) {
1030
+ switch (_context19.prev = _context19.next) {
989
1031
  case 0:
990
1032
  url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore;
991
1033
  url += '?recurse=' + recurse;
992
- _context18.next = 4;
1034
+ _context19.next = 4;
993
1035
  return (0, _nodeFetch["default"])(url, {
994
1036
  credentials: 'include',
995
1037
  method: 'DELETE',
@@ -999,20 +1041,20 @@ var DatastoreClient = /*#__PURE__*/function () {
999
1041
  });
1000
1042
 
1001
1043
  case 4:
1002
- response = _context18.sent;
1044
+ response = _context19.sent;
1003
1045
 
1004
1046
  if (response.ok) {
1005
- _context18.next = 14;
1047
+ _context19.next = 14;
1006
1048
  break;
1007
1049
  }
1008
1050
 
1009
- _context18.next = 8;
1051
+ _context19.next = 8;
1010
1052
  return (0, _geoserver.getGeoServerResponseText)(response);
1011
1053
 
1012
1054
  case 8:
1013
- geoServerResponse = _context18.sent;
1014
- _context18.t0 = response.status;
1015
- _context18.next = _context18.t0 === 401 ? 12 : 13;
1055
+ geoServerResponse = _context19.sent;
1056
+ _context19.t0 = response.status;
1057
+ _context19.next = _context19.t0 === 401 ? 12 : 13;
1016
1058
  break;
1017
1059
 
1018
1060
  case 12:
@@ -1023,13 +1065,13 @@ var DatastoreClient = /*#__PURE__*/function () {
1023
1065
 
1024
1066
  case 14:
1025
1067
  case "end":
1026
- return _context18.stop();
1068
+ return _context19.stop();
1027
1069
  }
1028
1070
  }
1029
- }, _callee18, this);
1071
+ }, _callee19, this);
1030
1072
  }));
1031
1073
 
1032
- function deleteCoverageStore(_x50, _x51, _x52) {
1074
+ function deleteCoverageStore(_x56, _x57, _x58) {
1033
1075
  return _deleteCoverageStore.apply(this, arguments);
1034
1076
  }
1035
1077
 
@@ -1048,11 +1090,11 @@ var DatastoreClient = /*#__PURE__*/function () {
1048
1090
  }, {
1049
1091
  key: "createGpkgStore",
1050
1092
  value: function () {
1051
- var _createGpkgStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(workspace, dataStore, gpkgPath) {
1093
+ var _createGpkgStore = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee20(workspace, dataStore, gpkgPath) {
1052
1094
  var body, url, response, geoServerResponse;
1053
- return _regenerator["default"].wrap(function _callee19$(_context19) {
1095
+ return _regenerator["default"].wrap(function _callee20$(_context20) {
1054
1096
  while (1) {
1055
- switch (_context19.prev = _context19.next) {
1097
+ switch (_context20.prev = _context20.next) {
1056
1098
  case 0:
1057
1099
  body = {
1058
1100
  dataStore: {
@@ -1070,7 +1112,7 @@ var DatastoreClient = /*#__PURE__*/function () {
1070
1112
  }
1071
1113
  };
1072
1114
  url = this.url + 'workspaces/' + workspace + '/datastores';
1073
- _context19.next = 4;
1115
+ _context20.next = 4;
1074
1116
  return (0, _nodeFetch["default"])(url, {
1075
1117
  credentials: 'include',
1076
1118
  method: 'POST',
@@ -1082,29 +1124,29 @@ var DatastoreClient = /*#__PURE__*/function () {
1082
1124
  });
1083
1125
 
1084
1126
  case 4:
1085
- response = _context19.sent;
1127
+ response = _context20.sent;
1086
1128
 
1087
1129
  if (response.ok) {
1088
- _context19.next = 10;
1130
+ _context20.next = 10;
1089
1131
  break;
1090
1132
  }
1091
1133
 
1092
- _context19.next = 8;
1134
+ _context20.next = 8;
1093
1135
  return (0, _geoserver.getGeoServerResponseText)(response);
1094
1136
 
1095
1137
  case 8:
1096
- geoServerResponse = _context19.sent;
1138
+ geoServerResponse = _context20.sent;
1097
1139
  throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
1098
1140
 
1099
1141
  case 10:
1100
1142
  case "end":
1101
- return _context19.stop();
1143
+ return _context20.stop();
1102
1144
  }
1103
1145
  }
1104
- }, _callee19, this);
1146
+ }, _callee20, this);
1105
1147
  }));
1106
1148
 
1107
- function createGpkgStore(_x53, _x54, _x55) {
1149
+ function createGpkgStore(_x59, _x60, _x61) {
1108
1150
  return _createGpkgStore.apply(this, arguments);
1109
1151
  }
1110
1152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geoserver-node-client",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Node.js client for GeoServer REST API",
5
5
  "type": "module",
6
6
  "main": "geoserver-rest-client.js",
package/src/datastore.js CHANGED
@@ -191,11 +191,32 @@ export default class DatastoreClient {
191
191
  * @returns {String} The successful response text
192
192
  */
193
193
  async createGeotiffFromFile (workspace, coverageStore, layerName, layerTitle, filePath) {
194
- const lyrTitle = layerTitle || layerName;
195
194
  const stats = fs.statSync(filePath);
196
195
  const fileSizeInBytes = stats.size;
197
196
  const readStream = fs.createReadStream(filePath);
198
197
 
198
+ return this.createGeotiffFromStream(workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes);
199
+ }
200
+
201
+ /**
202
+ * Creates a GeoTIFF store from a file by stream and publishes it as layer.
203
+ * The GeoTIFF file is placed on the server, where your GeoServer
204
+ * is running.
205
+ *
206
+ * @param {String} workspace The workspace to create GeoTIFF store in
207
+ * @param {String} coverageStore The name of the new GeoTIFF store
208
+ * @param {String} layerName The published name of the new layer
209
+ * @param {String} layerTitle The published title of the new layer
210
+ * @param {Stream} readStream The stream of the GeoTIFF file
211
+ * @param {Number} fileSizeInBytes The number of bytes of the stream
212
+ *
213
+ * @throws Error if request fails
214
+ *
215
+ * @returns {String} The successful response text
216
+ */
217
+ async createGeotiffFromStream (workspace, coverageStore, layerName, layerTitle, readStream, fileSizeInBytes) {
218
+ const lyrTitle = layerTitle || layerName;
219
+
199
220
  let url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
200
221
  coverageStore + '/file.geotiff';
201
222
  url += '?filename=' + lyrTitle + '&coverageName=' + layerName;