geoserver-node-client 1.2.4 → 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/dist/package.json +1 -1
- package/dist/src/datastore.js +150 -108
- package/package.json +1 -1
- package/src/datastore.js +22 -1
package/dist/package.json
CHANGED
package/dist/src/datastore.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
488
|
-
response =
|
|
529
|
+
case 5:
|
|
530
|
+
response = _context12.sent;
|
|
489
531
|
|
|
490
532
|
if (response.ok) {
|
|
491
|
-
|
|
533
|
+
_context12.next = 11;
|
|
492
534
|
break;
|
|
493
535
|
}
|
|
494
536
|
|
|
495
|
-
|
|
537
|
+
_context12.next = 9;
|
|
496
538
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
497
539
|
|
|
498
|
-
case
|
|
499
|
-
geoServerResponse =
|
|
540
|
+
case 9:
|
|
541
|
+
geoServerResponse = _context12.sent;
|
|
500
542
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
501
543
|
|
|
502
|
-
case
|
|
503
|
-
return
|
|
544
|
+
case 11:
|
|
545
|
+
return _context12.abrupt("return", response.text());
|
|
504
546
|
|
|
505
|
-
case
|
|
547
|
+
case 12:
|
|
506
548
|
case "end":
|
|
507
|
-
return
|
|
549
|
+
return _context12.stop();
|
|
508
550
|
}
|
|
509
551
|
}
|
|
510
|
-
},
|
|
552
|
+
}, _callee12, this);
|
|
511
553
|
}));
|
|
512
554
|
|
|
513
|
-
function
|
|
514
|
-
return
|
|
555
|
+
function createGeotiffFromStream(_x23, _x24, _x25, _x26, _x27, _x28) {
|
|
556
|
+
return _createGeotiffFromStream.apply(this, arguments);
|
|
515
557
|
}
|
|
516
558
|
|
|
517
|
-
return
|
|
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
|
|
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
|
|
583
|
+
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
542
584
|
while (1) {
|
|
543
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
640
|
+
response = _context13.sent;
|
|
599
641
|
|
|
600
642
|
if (response.ok) {
|
|
601
|
-
|
|
643
|
+
_context13.next = 10;
|
|
602
644
|
break;
|
|
603
645
|
}
|
|
604
646
|
|
|
605
|
-
|
|
647
|
+
_context13.next = 8;
|
|
606
648
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
607
649
|
|
|
608
650
|
case 8:
|
|
609
|
-
geoServerResponse =
|
|
651
|
+
geoServerResponse = _context13.sent;
|
|
610
652
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
611
653
|
|
|
612
654
|
case 10:
|
|
613
655
|
case "end":
|
|
614
|
-
return
|
|
656
|
+
return _context13.stop();
|
|
615
657
|
}
|
|
616
658
|
}
|
|
617
|
-
},
|
|
659
|
+
}, _callee13, this);
|
|
618
660
|
}));
|
|
619
661
|
|
|
620
|
-
function createPostgisStore(
|
|
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
|
|
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
|
|
691
|
+
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
|
650
692
|
while (1) {
|
|
651
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
709
|
+
response = _context14.sent;
|
|
668
710
|
|
|
669
711
|
if (response.ok) {
|
|
670
|
-
|
|
712
|
+
_context14.next = 10;
|
|
671
713
|
break;
|
|
672
714
|
}
|
|
673
715
|
|
|
674
|
-
|
|
716
|
+
_context14.next = 8;
|
|
675
717
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
676
718
|
|
|
677
719
|
case 8:
|
|
678
|
-
geoServerResponse =
|
|
720
|
+
geoServerResponse = _context14.sent;
|
|
679
721
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
680
722
|
|
|
681
723
|
case 10:
|
|
682
|
-
return
|
|
724
|
+
return _context14.abrupt("return", response.text());
|
|
683
725
|
|
|
684
726
|
case 11:
|
|
685
727
|
case "end":
|
|
686
|
-
return
|
|
728
|
+
return _context14.stop();
|
|
687
729
|
}
|
|
688
730
|
}
|
|
689
|
-
},
|
|
731
|
+
}, _callee14, this);
|
|
690
732
|
}));
|
|
691
733
|
|
|
692
|
-
function createImageMosaicStore(
|
|
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
|
|
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
|
|
755
|
+
return _regenerator["default"].wrap(function _callee15$(_context15) {
|
|
714
756
|
while (1) {
|
|
715
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
779
|
+
response = _context15.sent;
|
|
738
780
|
|
|
739
781
|
if (response.ok) {
|
|
740
|
-
|
|
782
|
+
_context15.next = 10;
|
|
741
783
|
break;
|
|
742
784
|
}
|
|
743
785
|
|
|
744
|
-
|
|
786
|
+
_context15.next = 8;
|
|
745
787
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
746
788
|
|
|
747
789
|
case 8:
|
|
748
|
-
geoServerResponse =
|
|
790
|
+
geoServerResponse = _context15.sent;
|
|
749
791
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
750
792
|
|
|
751
793
|
case 10:
|
|
752
794
|
case "end":
|
|
753
|
-
return
|
|
795
|
+
return _context15.stop();
|
|
754
796
|
}
|
|
755
797
|
}
|
|
756
|
-
},
|
|
798
|
+
}, _callee15, this);
|
|
757
799
|
}));
|
|
758
800
|
|
|
759
|
-
function createWmsStore(
|
|
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
|
|
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
|
|
822
|
+
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
|
781
823
|
while (1) {
|
|
782
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
846
|
+
response = _context16.sent;
|
|
805
847
|
|
|
806
848
|
if (response.ok) {
|
|
807
|
-
|
|
849
|
+
_context16.next = 10;
|
|
808
850
|
break;
|
|
809
851
|
}
|
|
810
852
|
|
|
811
|
-
|
|
853
|
+
_context16.next = 8;
|
|
812
854
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
813
855
|
|
|
814
856
|
case 8:
|
|
815
|
-
geoServerResponse =
|
|
857
|
+
geoServerResponse = _context16.sent;
|
|
816
858
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
817
859
|
|
|
818
860
|
case 10:
|
|
819
861
|
case "end":
|
|
820
|
-
return
|
|
862
|
+
return _context16.stop();
|
|
821
863
|
}
|
|
822
864
|
}
|
|
823
|
-
},
|
|
865
|
+
}, _callee16, this);
|
|
824
866
|
}));
|
|
825
867
|
|
|
826
|
-
function createWmtsStore(
|
|
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
|
|
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
|
|
891
|
+
return _regenerator["default"].wrap(function _callee17$(_context17) {
|
|
850
892
|
while (1) {
|
|
851
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
926
|
+
response = _context17.sent;
|
|
885
927
|
|
|
886
928
|
if (response.ok) {
|
|
887
|
-
|
|
929
|
+
_context17.next = 10;
|
|
888
930
|
break;
|
|
889
931
|
}
|
|
890
932
|
|
|
891
|
-
|
|
933
|
+
_context17.next = 8;
|
|
892
934
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
893
935
|
|
|
894
936
|
case 8:
|
|
895
|
-
geoServerResponse =
|
|
937
|
+
geoServerResponse = _context17.sent;
|
|
896
938
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
897
939
|
|
|
898
940
|
case 10:
|
|
899
941
|
case "end":
|
|
900
|
-
return
|
|
942
|
+
return _context17.stop();
|
|
901
943
|
}
|
|
902
944
|
}
|
|
903
|
-
},
|
|
945
|
+
}, _callee17, this);
|
|
904
946
|
}));
|
|
905
947
|
|
|
906
|
-
function createWfsStore(
|
|
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
|
|
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
|
|
969
|
+
return _regenerator["default"].wrap(function _callee18$(_context18) {
|
|
928
970
|
while (1) {
|
|
929
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
985
|
+
response = _context18.sent;
|
|
944
986
|
|
|
945
987
|
if (response.ok) {
|
|
946
|
-
|
|
988
|
+
_context18.next = 10;
|
|
947
989
|
break;
|
|
948
990
|
}
|
|
949
991
|
|
|
950
|
-
|
|
992
|
+
_context18.next = 8;
|
|
951
993
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
952
994
|
|
|
953
995
|
case 8:
|
|
954
|
-
geoServerResponse =
|
|
996
|
+
geoServerResponse = _context18.sent;
|
|
955
997
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
956
998
|
|
|
957
999
|
case 10:
|
|
958
1000
|
case "end":
|
|
959
|
-
return
|
|
1001
|
+
return _context18.stop();
|
|
960
1002
|
}
|
|
961
1003
|
}
|
|
962
|
-
},
|
|
1004
|
+
}, _callee18, this);
|
|
963
1005
|
}));
|
|
964
1006
|
|
|
965
|
-
function deleteDataStore(
|
|
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
|
|
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
|
|
1028
|
+
return _regenerator["default"].wrap(function _callee19$(_context19) {
|
|
987
1029
|
while (1) {
|
|
988
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
1044
|
+
response = _context19.sent;
|
|
1003
1045
|
|
|
1004
1046
|
if (response.ok) {
|
|
1005
|
-
|
|
1047
|
+
_context19.next = 14;
|
|
1006
1048
|
break;
|
|
1007
1049
|
}
|
|
1008
1050
|
|
|
1009
|
-
|
|
1051
|
+
_context19.next = 8;
|
|
1010
1052
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1011
1053
|
|
|
1012
1054
|
case 8:
|
|
1013
|
-
geoServerResponse =
|
|
1014
|
-
|
|
1015
|
-
|
|
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
|
|
1068
|
+
return _context19.stop();
|
|
1027
1069
|
}
|
|
1028
1070
|
}
|
|
1029
|
-
},
|
|
1071
|
+
}, _callee19, this);
|
|
1030
1072
|
}));
|
|
1031
1073
|
|
|
1032
|
-
function deleteCoverageStore(
|
|
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
|
|
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
|
|
1095
|
+
return _regenerator["default"].wrap(function _callee20$(_context20) {
|
|
1054
1096
|
while (1) {
|
|
1055
|
-
switch (
|
|
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
|
-
|
|
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 =
|
|
1127
|
+
response = _context20.sent;
|
|
1086
1128
|
|
|
1087
1129
|
if (response.ok) {
|
|
1088
|
-
|
|
1130
|
+
_context20.next = 10;
|
|
1089
1131
|
break;
|
|
1090
1132
|
}
|
|
1091
1133
|
|
|
1092
|
-
|
|
1134
|
+
_context20.next = 8;
|
|
1093
1135
|
return (0, _geoserver.getGeoServerResponseText)(response);
|
|
1094
1136
|
|
|
1095
1137
|
case 8:
|
|
1096
|
-
geoServerResponse =
|
|
1138
|
+
geoServerResponse = _context20.sent;
|
|
1097
1139
|
throw new _geoserver.GeoServerResponseError(null, geoServerResponse);
|
|
1098
1140
|
|
|
1099
1141
|
case 10:
|
|
1100
1142
|
case "end":
|
|
1101
|
-
return
|
|
1143
|
+
return _context20.stop();
|
|
1102
1144
|
}
|
|
1103
1145
|
}
|
|
1104
|
-
},
|
|
1146
|
+
}, _callee20, this);
|
|
1105
1147
|
}));
|
|
1106
1148
|
|
|
1107
|
-
function createGpkgStore(
|
|
1149
|
+
function createGpkgStore(_x59, _x60, _x61) {
|
|
1108
1150
|
return _createGpkgStore.apply(this, arguments);
|
|
1109
1151
|
}
|
|
1110
1152
|
|
package/package.json
CHANGED
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;
|