geoserver-node-client 0.0.5 → 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/LICENSE +25 -0
- package/README.md +81 -9
- 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 +28 -10
- 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 +200 -147
- 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/DOCS_HOME.md +0 -24
- 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 -491
package/src/imagemosaic.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fetch from 'node-fetch';
|
|
2
|
+
import { getGeoServerResponseText, GeoServerResponseError } from './util/geoserver.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Client for GeoServer image mosaics
|
|
@@ -10,13 +11,11 @@ export default class ImageMosaicClient {
|
|
|
10
11
|
* Creates a GeoServer REST ImageMosaicClient instance.
|
|
11
12
|
*
|
|
12
13
|
* @param {String} url The URL of the GeoServer REST API endpoint
|
|
13
|
-
* @param {String}
|
|
14
|
-
* @param {String} password The password for the GeoServer REST API
|
|
14
|
+
* @param {String} auth The Basic Authentication string
|
|
15
15
|
*/
|
|
16
|
-
constructor (url,
|
|
17
|
-
this.url = url
|
|
18
|
-
this.
|
|
19
|
-
this.password = password;
|
|
16
|
+
constructor (url, auth) {
|
|
17
|
+
this.url = url;
|
|
18
|
+
this.auth = auth;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -26,32 +25,28 @@ export default class ImageMosaicClient {
|
|
|
26
25
|
* @param {String} coverageStore CoverageStore of image mosaic
|
|
27
26
|
* @param {*} coverage Name of image mosaic
|
|
28
27
|
*
|
|
29
|
-
* @
|
|
28
|
+
* @throws Error if request fails
|
|
29
|
+
*
|
|
30
|
+
* @returns {Object} An object with the granules
|
|
30
31
|
*/
|
|
31
32
|
async getGranules (workspace, coverageStore, coverage) {
|
|
32
|
-
|
|
33
|
-
const auth =
|
|
34
|
-
Buffer.from(this.user + ':' + this.password).toString('base64');
|
|
35
|
-
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
|
|
33
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' +
|
|
36
34
|
coverageStore + '/coverages/' + coverage + '/index/granules.json';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (response.status === 200) {
|
|
47
|
-
return await response.json();
|
|
48
|
-
} else {
|
|
49
|
-
console.warn(await response.text());
|
|
50
|
-
return false;
|
|
35
|
+
const response = await fetch(url, {
|
|
36
|
+
credentials: 'include',
|
|
37
|
+
method: 'GET',
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: this.auth,
|
|
40
|
+
'Content-type': 'text/plain'
|
|
51
41
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
46
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
54
47
|
}
|
|
48
|
+
|
|
49
|
+
return response.json();
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
/**
|
|
@@ -61,33 +56,29 @@ export default class ImageMosaicClient {
|
|
|
61
56
|
* @param {String} coverageStore CoverageStore of image mosaic
|
|
62
57
|
* @param {String} filePath Server path of folder to harvest
|
|
63
58
|
*
|
|
64
|
-
* @
|
|
59
|
+
* @throws Error if request fails
|
|
60
|
+
*
|
|
61
|
+
* @returns {Object} An object with the granules
|
|
65
62
|
*/
|
|
66
63
|
async harvestGranules (workspace, coverageStore, filePath) {
|
|
67
|
-
|
|
68
|
-
const auth =
|
|
69
|
-
Buffer.from(this.user + ':' + this.password).toString('base64');
|
|
70
|
-
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
|
|
64
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
|
|
71
65
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
66
|
+
const response = await fetch(url, {
|
|
67
|
+
credentials: 'include',
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
Authorization: this.auth,
|
|
71
|
+
'Content-Type': 'text/plain'
|
|
72
|
+
},
|
|
73
|
+
body: filePath
|
|
74
|
+
});
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
console.warn(await response.text());
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
} catch (error) {
|
|
89
|
-
return false;
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
78
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
90
79
|
}
|
|
80
|
+
|
|
81
|
+
return response.json();
|
|
91
82
|
}
|
|
92
83
|
|
|
93
84
|
/**
|
|
@@ -97,69 +88,55 @@ export default class ImageMosaicClient {
|
|
|
97
88
|
* @param {String} coverageStore CoverageStore of image mosaic
|
|
98
89
|
* @param {String} filePath Server file path of new granule
|
|
99
90
|
*
|
|
100
|
-
* @
|
|
91
|
+
* @throws Error if request fails
|
|
101
92
|
*/
|
|
102
93
|
async addGranuleByServerFile (workspace, coverageStore, filePath) {
|
|
103
|
-
|
|
104
|
-
const auth =
|
|
105
|
-
Buffer.from(this.user + ':' + this.password).toString('base64');
|
|
106
|
-
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
|
|
94
|
+
const url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/external.imagemosaic';
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
96
|
+
const response = await fetch(url, {
|
|
97
|
+
credentials: 'include',
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: this.auth,
|
|
101
|
+
'Content-type': 'text/plain'
|
|
102
|
+
},
|
|
103
|
+
body: filePath
|
|
104
|
+
});
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
console.warn(await response.text());
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
} catch (error) {
|
|
125
|
-
return false;
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
108
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
126
109
|
}
|
|
127
110
|
}
|
|
128
111
|
|
|
129
112
|
/**
|
|
130
113
|
* Deletes a single granule of an image mosaic.
|
|
131
114
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {
|
|
135
|
-
* @param {
|
|
115
|
+
* @param {String} workspace Workspace of image mosaic
|
|
116
|
+
* @param {String} coverageStore CoverageStore of image mosaic
|
|
117
|
+
* @param {String} coverage Name of image mosaic
|
|
118
|
+
* @param {String} covFileLocation Location of coverage file
|
|
136
119
|
*
|
|
137
|
-
* @
|
|
120
|
+
* @throws Error if request fails
|
|
138
121
|
*/
|
|
139
122
|
async deleteSingleGranule (workspace, coverageStore, coverage, covFileLocation) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
Buffer.from(this.user + ':' + this.password).toString('base64');
|
|
143
|
-
let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + coverage + '/index/granules.xml';
|
|
144
|
-
url += '?filter=location=\'' + covFileLocation + '\'';
|
|
123
|
+
let url = this.url + 'workspaces/' + workspace + '/coveragestores/' + coverageStore + '/coverages/' + coverage + '/index/granules.xml';
|
|
124
|
+
url += '?filter=location=\'' + covFileLocation + '\'';
|
|
145
125
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (response.status === 200) {
|
|
156
|
-
return true;
|
|
157
|
-
} else {
|
|
158
|
-
console.warn(await response.text());
|
|
159
|
-
return false;
|
|
126
|
+
const response = await fetch(url, {
|
|
127
|
+
credentials: 'include',
|
|
128
|
+
method: 'DELETE',
|
|
129
|
+
headers: {
|
|
130
|
+
Authorization: this.auth,
|
|
131
|
+
'Content-type': 'text/plain'
|
|
160
132
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
137
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
163
138
|
}
|
|
139
|
+
|
|
140
|
+
return true;
|
|
164
141
|
}
|
|
165
142
|
}
|