geoserver-node-client 0.0.7 → 1.2.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 +80 -9
- package/dist/geoserver-rest-client.js +92 -0
- package/dist/package.json +56 -0
- package/dist/src/about.js +145 -0
- package/dist/src/datastore.js +1117 -0
- package/dist/src/imagemosaic.js +297 -0
- package/dist/src/layer.js +1263 -0
- package/dist/src/namespace.js +315 -0
- package/dist/src/reset-reload.js +160 -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 +18 -52
- package/package.json +24 -6
- package/src/about.js +59 -0
- package/src/datastore.js +196 -200
- package/src/imagemosaic.js +75 -98
- package/src/layer.js +469 -328
- package/src/namespace.js +84 -83
- package/src/reset-reload.js +70 -0
- package/src/security.js +61 -84
- package/src/settings.js +76 -91
- package/src/style.js +165 -171
- 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/.vscode/settings.json +0 -3
- package/DOCS_HOME.md +0 -26
- 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 -502
package/src/settings.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 settings.
|
|
@@ -10,60 +11,54 @@ export default class SettingsClient {
|
|
|
10
11
|
* Creates a GeoServer REST SettingsClient 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
|
/**
|
|
23
22
|
* Get the complete GeoServer settings object.
|
|
24
23
|
*
|
|
25
|
-
* @
|
|
24
|
+
* @throws Error if request fails
|
|
25
|
+
*
|
|
26
|
+
* @returns {Object} Settings object
|
|
26
27
|
*/
|
|
27
28
|
async getSettings () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return await response.json();
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return false;
|
|
29
|
+
const response = await fetch(this.url + 'settings.json', {
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
method: 'GET',
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: this.auth
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
38
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
41
39
|
}
|
|
40
|
+
return response.json();
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* Update the global GeoServer settings.
|
|
46
45
|
*
|
|
47
|
-
* @param {
|
|
48
|
-
* @returns {Boolean} Flag indicating if request was successful
|
|
46
|
+
* @param {Object} settings The adapted GeoServer settings object
|
|
49
47
|
*/
|
|
50
48
|
async updateSettings (settings) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
body: JSON.stringify(settings)
|
|
62
|
-
});
|
|
49
|
+
const response = await fetch(this.url + 'settings', {
|
|
50
|
+
credentials: 'include',
|
|
51
|
+
method: 'PUT',
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: this.auth,
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify(settings)
|
|
57
|
+
});
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
61
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
|
|
@@ -71,42 +66,41 @@ export default class SettingsClient {
|
|
|
71
66
|
* Update the global proxyBaseUrl setting.
|
|
72
67
|
*
|
|
73
68
|
* @param {String} proxyBaseUrl The proxy base URL
|
|
74
|
-
* @returns {Boolean} Flag indicating if request was successful
|
|
75
69
|
*/
|
|
76
70
|
async updateProxyBaseUrl (proxyBaseUrl) {
|
|
77
71
|
const settingsJson = await this.getSettings();
|
|
78
72
|
|
|
73
|
+
// check if settings are correctly formatted
|
|
79
74
|
if (!settingsJson.global && !settingsJson.global.settings) {
|
|
80
|
-
// settings seem to be wrongly formated
|
|
81
75
|
return false;
|
|
82
76
|
}
|
|
83
77
|
|
|
84
78
|
// add proxyBaseUrl to settings
|
|
85
79
|
settingsJson.global.settings.proxyBaseUrl = proxyBaseUrl;
|
|
86
80
|
|
|
87
|
-
|
|
81
|
+
await this.updateSettings(settingsJson);
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
/**
|
|
91
85
|
* Get the contact information of the GeoServer.
|
|
92
86
|
*
|
|
93
|
-
* @
|
|
87
|
+
* @throws Error if request fails
|
|
88
|
+
*
|
|
89
|
+
* @returns {Object} An object with contact information
|
|
94
90
|
*/
|
|
95
91
|
async getContactInformation () {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return await response.json();
|
|
107
|
-
} catch (error) {
|
|
108
|
-
return false;
|
|
92
|
+
const response = await fetch(this.url + 'settings/contact', {
|
|
93
|
+
credentials: 'include',
|
|
94
|
+
method: 'GET',
|
|
95
|
+
headers: {
|
|
96
|
+
Authorization: this.auth
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
101
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
109
102
|
}
|
|
103
|
+
return response.json();
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
/**
|
|
@@ -124,47 +118,38 @@ export default class SettingsClient {
|
|
|
124
118
|
* @param {String} [contactPerson] The contact person
|
|
125
119
|
* @param {String} [phoneNumber] The contact's phone number
|
|
126
120
|
*
|
|
127
|
-
* @
|
|
121
|
+
* @throws Error if request fails
|
|
128
122
|
*/
|
|
129
123
|
async updateContactInformation (address, city, country, postalCode, state, email, organization, contactPerson, phoneNumber) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const body = {
|
|
144
|
-
contact: contact
|
|
145
|
-
};
|
|
124
|
+
const contact = {
|
|
125
|
+
address: address,
|
|
126
|
+
addressCity: city,
|
|
127
|
+
addressCountry: country,
|
|
128
|
+
addressPostalCode: postalCode,
|
|
129
|
+
addressState: state,
|
|
130
|
+
contactEmail: email,
|
|
131
|
+
contactOrganization: organization,
|
|
132
|
+
contactPerson: contactPerson,
|
|
133
|
+
contactVoice: phoneNumber
|
|
134
|
+
};
|
|
146
135
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
credentials: 'include',
|
|
151
|
-
method: 'PUT',
|
|
152
|
-
headers: {
|
|
153
|
-
Authorization: 'Basic ' + auth,
|
|
154
|
-
'Content-Type': 'application/json'
|
|
155
|
-
},
|
|
156
|
-
body: JSON.stringify(body)
|
|
157
|
-
});
|
|
136
|
+
const body = {
|
|
137
|
+
contact: contact
|
|
138
|
+
};
|
|
158
139
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
140
|
+
const url = this.url + 'settings/contact';
|
|
141
|
+
const response = await fetch(url, {
|
|
142
|
+
credentials: 'include',
|
|
143
|
+
method: 'PUT',
|
|
144
|
+
headers: {
|
|
145
|
+
Authorization: this.auth,
|
|
146
|
+
'Content-Type': 'application/json'
|
|
147
|
+
},
|
|
148
|
+
body: JSON.stringify(body)
|
|
149
|
+
});
|
|
150
|
+
if (!response.ok) {
|
|
151
|
+
const geoServerResponse = await getGeoServerResponseText(response);
|
|
152
|
+
throw new GeoServerResponseError(null, geoServerResponse);
|
|
168
153
|
}
|
|
169
154
|
}
|
|
170
155
|
}
|