geoserver-node-client 1.6.1 → 2.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.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Client for GeoServer "Reset/Reload" to clear internal caches and reload
3
+ * configuration from disk endpoint.
4
+ *
5
+ * @module ResetReloadClient
6
+ */
7
+ export default class ResetReloadClient {
8
+ /**
9
+ * Creates a GeoServer REST ResetReloadClient instance.
10
+ *
11
+ * @param {String} url The URL of the GeoServer REST API endpoint
12
+ * @param {String} auth The Basic Authentication string
13
+ */
14
+ constructor(url: string, auth: string);
15
+ url: string;
16
+ auth: string;
17
+ /**
18
+ * Resets all store, raster, and schema caches. This operation is used to
19
+ * force GeoServer to drop all caches and store connections and reconnect to
20
+ * each of them the next time they are needed by a request.
21
+ * This is useful in case the stores themselves cache some information about
22
+ * the data structures they manage that may have changed in the meantime.
23
+ *
24
+ * @throws Error if request fails
25
+ */
26
+ reset(): Promise<void>;
27
+ /**
28
+ * Reloads the GeoServer catalog and configuration from disk. This operation
29
+ * is used in cases where an external tool has modified the on-disk
30
+ * configuration. This operation will also force GeoServer to drop any
31
+ * internal caches and reconnect to all data stores.
32
+ *
33
+ * @throws Error if request fails
34
+ */
35
+ reload(): Promise<void>;
36
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Client for GeoServer security.
3
+ *
4
+ * @module SecurityClient
5
+ */
6
+ export default class SecurityClient {
7
+ /**
8
+ * Creates a GeoServer REST SecurityClient instance.
9
+ *
10
+ * @param {String} url The URL of the GeoServer REST API endpoint
11
+ * @param {String} auth The Basic Authentication string
12
+ */
13
+ constructor(url: string, auth: string);
14
+ url: string;
15
+ auth: string;
16
+ /**
17
+ * Returns all users registered in GeoServer.
18
+ *
19
+ * @throws Error if request fails
20
+ *
21
+ * @returns {Object} An object with all users
22
+ */
23
+ getAllUsers(): Object;
24
+ /**
25
+ * Creates a new user.
26
+ *
27
+ * @param {String} username The name of the user to be created
28
+ * @param {String} password The password of the user to be created
29
+ *
30
+ * @throws Error if request fails
31
+ */
32
+ createUser(username: string, password: string): Promise<void>;
33
+ /**
34
+ * Updates an existing user. User name is only taken for identification and
35
+ * cannot be changed with this API call.
36
+ *
37
+ * @param {String} username The name of the user to be created
38
+ * @param {String} password The password of the user to be created
39
+ * @param {Boolean} enabled Enable / disable the user
40
+ *
41
+ * @throws Error if request fails
42
+ */
43
+ updateUser(username: string, password: string, enabled: boolean): Promise<void>;
44
+ /**
45
+ * Deletes an existing user.
46
+ *
47
+ * @param {String} username The name of the user to be deleted
48
+ *
49
+ * @throws Error if request fails
50
+ */
51
+ deleteUser(username: string): Promise<void>;
52
+ /**
53
+ * Returns all roles registered in GeoServer.
54
+ *
55
+ * @throws Error if request fails
56
+ *
57
+ * @returns {Object} An object with all roles like { "roles": ["ADMIN", "GROUP_ADMIN"] }
58
+ */
59
+ getAllRoles(): Object;
60
+ /**
61
+ * Creates a new role.
62
+ *
63
+ * @param {String} role The name of the role to be created
64
+ *
65
+ * @throws Error if request fails
66
+ */
67
+ createRole(role: string): Promise<void>;
68
+ /**
69
+ * Deletes an existing role.
70
+ *
71
+ * @param {String} role The name of the role to be deleted
72
+ *
73
+ * @throws Error if request fails
74
+ */
75
+ deleteRole(role: string): Promise<void>;
76
+ /**
77
+ * Associates the given role to the user.
78
+ *
79
+ * @param {String} username The name of the user to add the role to
80
+ * @param {String} role The role to associate
81
+ *
82
+ * @throws Error if request fails
83
+ */
84
+ associateUserRole(username: string, role: string): Promise<void>;
85
+ /**
86
+ * Returns all data access rules registered in GeoServer.
87
+ *
88
+ * @throws Error if request fails
89
+ *
90
+ * @returns {Object} An object with all data access rules like { "*.*.r": ["ADMIN", "GROUP_ADMIN"] }
91
+ */
92
+ getAllAccessRules(): Object;
93
+ /**
94
+ * Creates a new data access rule.
95
+ *
96
+ * @param {String} rule The rule in the form '<MY_WS>.<MY_LAYER>.r'
97
+ * @param {String[]} roles The roles to allow access to rule
98
+ *
99
+ * @throws Error if request fails
100
+ */
101
+ createDataAccessRule(rule: string, roles: string[]): Promise<void>;
102
+ /**
103
+ * Deletes an existing data access rule.
104
+ *
105
+ * @param {String} rule The rule to be deleted, like '<MY_WS>.<MY_LAYER>.r'
106
+ *
107
+ * @throws Error if request fails
108
+ */
109
+ deleteDataAccessRule(rule: string): Promise<void>;
110
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Client for GeoServer settings.
3
+ *
4
+ * @module SettingsClient
5
+ */
6
+ export default class SettingsClient {
7
+ /**
8
+ * Creates a GeoServer REST SettingsClient instance.
9
+ *
10
+ * @param {String} url The URL of the GeoServer REST API endpoint
11
+ * @param {String} auth The Basic Authentication string
12
+ */
13
+ constructor(url: string, auth: string);
14
+ url: string;
15
+ auth: string;
16
+ /**
17
+ * Get the complete GeoServer settings object.
18
+ *
19
+ * @throws Error if request fails
20
+ *
21
+ * @returns {Object} Settings object
22
+ */
23
+ getSettings(): Object;
24
+ /**
25
+ * Update the global GeoServer settings.
26
+ *
27
+ * @param {Object} settings The adapted GeoServer settings object
28
+ */
29
+ updateSettings(settings: Object): Promise<void>;
30
+ /**
31
+ * Update the global proxyBaseUrl setting.
32
+ *
33
+ * @param {String} proxyBaseUrl The proxy base URL
34
+ */
35
+ updateProxyBaseUrl(proxyBaseUrl: string): Promise<false | undefined>;
36
+ /**
37
+ * Get the contact information of the GeoServer.
38
+ *
39
+ * @throws Error if request fails
40
+ *
41
+ * @returns {Object} An object with contact information
42
+ */
43
+ getContactInformation(): Object;
44
+ /**
45
+ * Update the contact information.
46
+ *
47
+ * Deleting is not supported.
48
+ *
49
+ * @param {String} [address] The contact's address
50
+ * @param {String} [city] The contact's city
51
+ * @param {String} [country] The contact's country
52
+ * @param {String} [postalCode] The contact's postCode
53
+ * @param {String} [state] The contact's state
54
+ * @param {String} [email] The contact's email
55
+ * @param {String} [organization] The contact's organization
56
+ * @param {String} [contactPerson] The contact person
57
+ * @param {String} [phoneNumber] The contact's phone number
58
+ *
59
+ * @throws Error if request fails
60
+ */
61
+ updateContactInformation(address?: string, city?: string, country?: string, postalCode?: string, state?: string, email?: string, organization?: string, contactPerson?: string, phoneNumber?: string): Promise<void>;
62
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Client for GeoServer styles
3
+ *
4
+ * @module StyleClient
5
+ */
6
+ export default class StyleClient {
7
+ /**
8
+ * Creates a GeoServer REST StyleClient instance.
9
+ *
10
+ * @param {String} url The URL of the GeoServer REST API endpoint
11
+ * @param {String} auth The Basic Authentication string
12
+ */
13
+ constructor(url: string, auth: string);
14
+ url: string;
15
+ auth: string;
16
+ /**
17
+ * Returns all default styles.
18
+ *
19
+ * @throws Error if request fails
20
+ *
21
+ * @returns {Object} An object with the default styles
22
+ */
23
+ getDefaults(): Object;
24
+ /**
25
+ * Returns all styles in a workspace.
26
+ *
27
+ * @param {String} workspace Workspace name to get styles for
28
+ *
29
+ * @throws Error if request fails
30
+ *
31
+ * @returns {Object} An object with all styles
32
+ */
33
+ getInWorkspace(workspace: string): Object;
34
+ /**
35
+ * Returns all styles defined in workspaces.
36
+ *
37
+ * @throws Error if request fails
38
+ *
39
+ * @returns {Object[]} An array with all style objects
40
+ */
41
+ getAllWorkspaceStyles(): Object[];
42
+ /**
43
+ * Returns all styles as combined object (default ones and those in
44
+ * workspaces).
45
+ *
46
+ * @returns {Object[]} An array with all style objects
47
+ */
48
+ getAll(): Object[];
49
+ /**
50
+ * Publishes a new SLD style.
51
+ *
52
+ * @param {String} workspace The workspace to publish the style in
53
+ * @param {String} name Name of the style
54
+ * @param {String} sldBody SLD style (as XML text)
55
+ *
56
+ * @throws Error if request fails
57
+ */
58
+ publish(workspace: string, name: string, sldBody: string): Promise<void>;
59
+ /**
60
+ * Deletes a style.
61
+ *
62
+ * @param {String} workspace The name of the workspace, can be undefined if style is not assigned to a workspace
63
+ * @param {String} name The name of the style to delete
64
+ * @param {Boolean} [recurse=false] If references to the specified style in existing layers should be deleted
65
+ * @param {Boolean} [purge=false] Whether the underlying file containing the style should be deleted on disk
66
+ */
67
+ delete(workspace: string, name: string, recurse?: boolean, purge?: boolean): Promise<void>;
68
+ /**
69
+ * Assigns a style to a layer.
70
+ *
71
+ * @param {String} workspaceOfLayer The name of the layer's workspace, can be undefined
72
+ * @param {String} layerName The name of the layer to query
73
+ * @param {String} workspaceOfStyle The workspace of the style, can be undefined
74
+ * @param {String} styleName The name of the style
75
+ * @param {Boolean} [isDefaultStyle=true] If the style should be the default style of the layer
76
+ *
77
+ * @throws Error if request fails
78
+ */
79
+ assignStyleToLayer(workspaceOfLayer: string, layerName: string, workspaceOfStyle: string, styleName: string, isDefaultStyle?: boolean): Promise<void>;
80
+ /**
81
+ * Get information about a style.
82
+ *
83
+ * @param {String} workspace The name of the workspace, can be undefined
84
+ * @param {String} styleName The name of the style
85
+ *
86
+ * @throws Error if request fails
87
+ *
88
+ * @returns {Object} An object about the style or undefined if it cannot be found
89
+ */
90
+ getStyleInformation(workspace: string, styleName: string): Object;
91
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility functions and classes
3
+ */
4
+ /**
5
+ * Return the GeoServer response text if available.
6
+ *
7
+ * @param {Response} response The response of the GeoServer
8
+ *
9
+ * @returns {String} The response text if available
10
+ */
11
+ export function getGeoServerResponseText(response: Response): string;
12
+ /**
13
+ * Generic GeoServer error
14
+ */
15
+ export class GeoServerResponseError extends Error {
16
+ /**
17
+ * @param {String} [message=GeoServer Response Error] The error message
18
+ * @param {String} [geoServerOutput] The error output from GeoServer (useful for debugging)
19
+ */
20
+ constructor(message?: string, geoServerOutput?: string);
21
+ geoServerOutput: string | undefined;
22
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Client for GeoServer workspaces
3
+ *
4
+ * @module WorkspaceClient
5
+ */
6
+ export default class WorkspaceClient {
7
+ /**
8
+ * Creates a GeoServer REST WorkspaceClient instance.
9
+ *
10
+ * WARNING: For most cases the 'NameSpaceClient' seems to fit better.
11
+ *
12
+ * @param {String} url The URL of the GeoServer REST API endpoint
13
+ * @param {String} auth The Basic Authentication string
14
+ */
15
+ constructor(url: string, auth: string);
16
+ url: string;
17
+ auth: string;
18
+ /**
19
+ * Returns all workspaces.
20
+ *
21
+ * @throws Error if request fails
22
+ *
23
+ * @returns {Object} An Object describing the workspaces
24
+ */
25
+ getAll(): Object;
26
+ /**
27
+ * Returns a workspace.
28
+ *
29
+ * @param {String} name Name of the workspace
30
+ *
31
+ * @throws Error if request fails
32
+ *
33
+ * @returns {Object} An object describing the workspaces
34
+ */
35
+ get(name: string): Object;
36
+ /**
37
+ * Creates a new workspace.
38
+ *
39
+ * @param {String} name Name of the new workspace
40
+ *
41
+ * @throws Error if request fails
42
+ *
43
+ * @returns {String} The name of the created workspace
44
+ */
45
+ create(name: string): string;
46
+ /**
47
+ * Deletes a workspace.
48
+ *
49
+ * @param {String} name Name of the workspace to delete
50
+ * @param {Boolean} recurse Flag to enable recursive deletion
51
+ *
52
+ * @throws Error if request fails
53
+ */
54
+ delete(name: string, recurse: boolean): Promise<void>;
55
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "geoserver-node-client",
3
- "version": "1.6.1",
3
+ "version": "2.0.0",
4
4
  "description": "Node.js client for GeoServer REST API",
5
5
  "type": "module",
6
6
  "main": "geoserver-rest-client.js",
7
+ "types": "./dist/types/geoserver-rest-client.d.ts",
7
8
  "scripts": {
8
9
  "demo": "node demo/index.js",
9
10
  "docs": "./node_modules/.bin/jsdoc geoserver-rest-client.js src/*.js DOCS_HOME.md && cp img/*.png out/",
@@ -14,14 +15,18 @@
14
15
  "test:reset-gs": "node test/reset-gs.js",
15
16
  "release": "release-it",
16
17
  "release:dry": "release-it --dry-run",
17
- "build": "npm run build:clean && npm run build:babel && npm run build:fixup",
18
+ "build": "npm run build:clean && npm run build:babel && npm run build:types && npm run build:fixup",
18
19
  "build:clean": "rm -rf dist",
19
20
  "build:babel": "babel geoserver-rest-client.js -d dist && babel src -d dist/src",
21
+ "build:types": "tsc -p tsconfig.json",
20
22
  "build:fixup": "node scripts/create-custom-package-json.js"
21
23
  },
22
24
  "exports": {
23
- "import": "./geoserver-rest-client.js",
24
- "require": "./dist/geoserver-rest-client.js"
25
+ ".": {
26
+ "types": "./dist/types/geoserver-rest-client.d.ts",
27
+ "import": "./geoserver-rest-client.js",
28
+ "require": "./dist/geoserver-rest-client.js"
29
+ }
25
30
  },
26
31
  "files": [
27
32
  "geoserver-rest-client.js",
@@ -36,15 +41,16 @@
36
41
  "author": "C. Mayer, meggsimum (info_at*meggsimum?dot?de)",
37
42
  "license": "BSD-2-Clause",
38
43
  "dependencies": {
39
- "@babel/runtime": "^7.27.6",
44
+ "@babel/runtime": "^8.0.0",
40
45
  "node-fetch": "^3.3.2"
41
46
  },
42
47
  "devDependencies": {
43
- "@babel/cli": "^7.23.0",
44
- "@babel/core": "^7.27.4",
45
- "@babel/plugin-transform-runtime": "^7.27.4",
46
- "@babel/preset-env": "^7.22.20",
48
+ "@babel/cli": "^8.0.0",
49
+ "@babel/core": "^8.0.0",
50
+ "@babel/plugin-transform-runtime": "^8.0.0",
51
+ "@babel/preset-env": "^8.0.0",
47
52
  "@eslint/compat": "^2.0.0",
53
+ "@types/node": "^26.0.0",
48
54
  "chai": "^6.0.1",
49
55
  "eslint": "^9.29.0",
50
56
  "eslint-config-prettier": "^10.1.5",
@@ -53,6 +59,7 @@
53
59
  "mocha": "^11.7.1",
54
60
  "neostandard": "^0.13.0",
55
61
  "prettier": "^3.6.1",
56
- "release-it": "^19.0.3"
62
+ "release-it": "^20.0.0",
63
+ "typescript": "^6.0.3"
57
64
  }
58
65
  }
package/src/datastore.js CHANGED
@@ -214,7 +214,7 @@ export default class DatastoreClient {
214
214
  * @param {String} coverageStore The name of the new GeoTIFF store
215
215
  * @param {String} layerName The published name of the new layer
216
216
  * @param {String} layerTitle The published title of the new layer
217
- * @param {Stream} readStream The stream of the GeoTIFF file
217
+ * @param {fs.ReadStream} readStream The stream of the GeoTIFF file
218
218
  * @param {Number} fileSizeInBytes The number of bytes of the stream
219
219
  *
220
220
  * @throws Error if request fails
package/src/layer.js CHANGED
@@ -254,11 +254,11 @@ export default class LayerClient {
254
254
  * Publishes a FeatureType in the default data store of the workspace.
255
255
  *
256
256
  * @param {String} workspace Workspace to publish FeatureType in
257
- * @param {String} [nativeName] Native name of FeatureType
258
- * @param {String} name Published name of FeatureType
259
- * @param {String} [title] Published title of FeatureType
257
+ * @param {String} nativeName Native name of FeatureType
258
+ * @param {String} [name] Published name of FeatureType, defaults to `nativeName`
259
+ * @param {String} [title] Published title of FeatureType, defaults to `name` or `nativeName`
260
260
  * @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
261
- * @param {String} enabled Flag to enable FeatureType by default
261
+ * @param {Boolean} [enabled=true] Flag to enable FeatureType by default
262
262
  * @param {String} [abstract] The abstract of the layer
263
263
  *
264
264
  * @throws Error if request fails
@@ -274,11 +274,11 @@ export default class LayerClient {
274
274
  ) {
275
275
  const body = {
276
276
  featureType: {
277
- name: name,
278
- nativeName: nativeName || name,
279
- title: title || name,
277
+ nativeName: nativeName,
278
+ name: name || nativeName,
279
+ title: title || name || nativeName,
280
280
  srs: srs || 'EPSG:4326',
281
- enabled: enabled,
281
+ enabled: typeof enabled === 'boolean' ? enabled : true,
282
282
  abstract: abstract || ''
283
283
  }
284
284
  };
@@ -304,11 +304,11 @@ export default class LayerClient {
304
304
  *
305
305
  * @param {String} workspace Workspace to publish FeatureType in
306
306
  * @param {String} dataStore The datastore where the FeatureType's data is in
307
- * @param {String} [nativeName] Native name of FeatureType
308
- * @param {String} name Published name of FeatureType
309
- * @param {String} [title] Published title of FeatureType
307
+ * @param {String} nativeName Native name of FeatureType
308
+ * @param {String} [name] Published name of FeatureType, defaults to `nativeName`
309
+ * @param {String} [title] Published title of FeatureType, defaults to `name` or `nativeName`
310
310
  * @param {String} [srs="EPSG:4326"] The SRS of the FeatureType
311
- * @param {String} enabled Flag to enable FeatureType by default
311
+ * @param {Boolean} [enabled=true] Flag to enable FeatureType by default
312
312
  * @param {String} [abstract] The abstract of the layer
313
313
  * @param {String} [nativeBoundingBox] The native BoundingBox of the FeatureType (has to be set if no data is in store at creation time)
314
314
  *
@@ -335,11 +335,11 @@ export default class LayerClient {
335
335
 
336
336
  const body = {
337
337
  featureType: {
338
- name: name || nativeName,
339
338
  nativeName: nativeName,
340
- title: title || name,
339
+ name: name || nativeName,
340
+ title: title || name || nativeName,
341
341
  srs: srs || 'EPSG:4326',
342
- enabled: enabled,
342
+ enabled: typeof enabled === 'boolean' ? enabled : true,
343
343
  abstract: abstract || '',
344
344
  nativeBoundingBox: nativeBoundingBox
345
345
  }
@@ -449,10 +449,10 @@ export default class LayerClient {
449
449
  * @param {String} workspace Workspace to publish WMS layer in
450
450
  * @param {String} dataStore The datastore where the WMS is connected
451
451
  * @param {String} nativeName Native name of WMS layer
452
- * @param {String} [name] Published name of WMS layer
453
- * @param {String} [title] Published title of WMS layer
452
+ * @param {String} [name] Published name of WMS layer, defaults to `nativeName`
453
+ * @param {String} [title] Published title of WMS layer, defaults to `name` or `nativeName`
454
454
  * @param {String} [srs="EPSG:4326"] The SRS of the WMS layer
455
- * @param {String} enabled Flag to enable WMS layer by default
455
+ * @param {Boolean} [enabled=true] Flag to enable WMS layer by default
456
456
  * @param {String} [abstract] The abstract of the layer
457
457
  *
458
458
  * @throws Error if request fails
@@ -460,11 +460,11 @@ export default class LayerClient {
460
460
  async publishWmsLayer(workspace, dataStore, nativeName, name, title, srs, enabled, abstract) {
461
461
  const body = {
462
462
  wmsLayer: {
463
- name: name || nativeName,
464
463
  nativeName: nativeName,
464
+ name: name || nativeName,
465
465
  title: title || name || nativeName,
466
466
  srs: srs || 'EPSG:4326',
467
- enabled: enabled,
467
+ enabled: typeof enabled === 'boolean' ? enabled : true,
468
468
  abstract: abstract || ''
469
469
  }
470
470
  };
@@ -494,10 +494,10 @@ export default class LayerClient {
494
494
  * @param {String} workspace Workspace to publish layer in
495
495
  * @param {String} coverageStore The coveragestore where the layer's data is in
496
496
  * @param {String} nativeName Native name of raster
497
- * @param {String} name Published name of layer
498
- * @param {String} [title] Published title of layer
497
+ * @param {String} [name] Published name of layer, defaults to `nativeName`
498
+ * @param {String} [title] Published title of layer, defaults to `name` or `nativeName`
499
499
  * @param {String} [srs="EPSG:4326"] The SRS of the layer
500
- * @param {String} enabled Flag to enable layer by default
500
+ * @param {Boolean} [enabled=true] Flag to enable layer by default
501
501
  * @param {String} [abstract] The abstract of the layer
502
502
  *
503
503
  * @throws Error if request fails
@@ -505,9 +505,9 @@ export default class LayerClient {
505
505
  async publishDbRaster(workspace, coverageStore, nativeName, name, title, srs, enabled, abstract) {
506
506
  const body = {
507
507
  coverage: {
508
- name: name || nativeName,
509
508
  nativeName: nativeName,
510
- title: title || name,
509
+ name: name || nativeName,
510
+ title: title || name || nativeName,
511
511
  srs: srs,
512
512
  enabled: enabled,
513
513
  abstract: abstract || ''