From 35f720f94fa4feb10dd7f7488aed4b3090862149 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 11:56:25 +0200 Subject: [PATCH 1/7] Added extra parameters to delete projections --- src/projections/projectionsClient.js | 6 ++++-- src/projections/projectionsManager.js | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index 781694a..2808c74 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -102,8 +102,10 @@ ProjectionsClient.prototype.updateQuery = function(httpEndPoint, name, query, us return this.sendPut(httpEndPoint + '/projection/' + name + '/query?type=JS', query, userCredentials, HTTP_OK); }; -ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, userCredentials) { - return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteEmittedStreams=' + deleteEmittedStreams, userCredentials, HTTP_OK); +ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { + const stateStream = (deleteStateStream === undefined) ? false : deleteStateStream; + const checkpointStream = (deleteCheckpointStream === undefined) ? false : deleteCheckpointStream; + return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + stateStream + '&deleteCheckpointStream' + checkpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, userCredentials, HTTP_OK); }; ProjectionsClient.prototype.request = function(method, _url, data, userCredentials, expectedCode) { diff --git a/src/projections/projectionsManager.js b/src/projections/projectionsManager.js index f453d4b..0c2fcf0 100644 --- a/src/projections/projectionsManager.js +++ b/src/projections/projectionsManager.js @@ -190,13 +190,15 @@ ProjectionsManager.prototype.updateQuery = function(name, query, userCredentials /** * Updates the definition of a query. - * @param name The name of the projection. - * @param deleteEmittedStreams Whether to delete the streams that were emitted by this projection. - * @param userCredentials Credentials for a user with permission to delete a projection. + * @param name The name of the projection. + * @param deleteEmittedStreams Whether to delete the streams that were emitted by this projection. + * @param deleteStateStream Where to delete the state stream for this projection + * @param deleteCheckpointStream Where to delete the checkpoint stream for this projection + * @param userCredentials Credentials for a user with permission to delete a projection. * @returns {Promise} */ -ProjectionsManager.prototype.delete = function(name, deleteEmittedStreams, userCredentials) { - return this._client.delete(this._httpEndPoint, name, deleteEmittedStreams, userCredentials); +ProjectionsManager.prototype.delete = function(name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { + return this._client.delete(this._httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials); }; module.exports = ProjectionsManager; \ No newline at end of file From 88df807508915a209e0677593e9bc8cf79d90432 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 11:59:56 +0200 Subject: [PATCH 2/7] Update documentation for strict-event-emitter-types dependency --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c0b59a..4c8746b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Install using `npm install node-eventstore-client` ### Dependencies - Node.js >= 4.0 -- Modules: [long](https://www.npmjs.org/package/long), [protobufjs](https://www.npmjs.org/package/protobufjs), [uuid](https://www.npmjs.org/package/uuid) (installed via `npm install`) +- Modules: [long](https://www.npmjs.org/package/long), [protobufjs](https://www.npmjs.org/package/protobufjs), [uuid](https://www.npmjs.org/package/uuid), [strict-event-emitter-types](https://www.npmjs.com/package/strict-event-emitter-types) (installed via `npm install`) ### Install and run an Eventstore on localhost From 4d981596eb2f67a8ba72bfe51b785fd28f565d1d Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 15:35:20 +0200 Subject: [PATCH 3/7] Fix typings for delete (there is no deleteQuery) in projection manager --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index ff4940d..e9ec767 100644 --- a/index.d.ts +++ b/index.d.ts @@ -87,7 +87,7 @@ export class ProjectionsManager { getQuery(name: string, userCredentials: UserCredentials): Promise; getState(name: string, userCredentials: UserCredentials): Promise; updateQuery(name: string, query: string, userCredentials: UserCredentials): Promise; - deleteQuery(name: string, deleteEmittedStreams: boolean, userCredentials: UserCredentials): Promise; + delete(name: string, deleteEmittedStreams: boolean, deleteStateStream: boolean, deleteCheckpointStream: boolean, userCredentials: UserCredentials): Promise; } // Expose errors From 6663b42903aad237c78afe27d0b7029c51024caf Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 16:18:09 +0200 Subject: [PATCH 4/7] Fix sendDelete call to provide empty data so header is correct --- src/projections/projectionsClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index 2808c74..dfe51d0 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -105,7 +105,7 @@ ProjectionsClient.prototype.updateQuery = function(httpEndPoint, name, query, us ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { const stateStream = (deleteStateStream === undefined) ? false : deleteStateStream; const checkpointStream = (deleteCheckpointStream === undefined) ? false : deleteCheckpointStream; - return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + stateStream + '&deleteCheckpointStream' + checkpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, userCredentials, HTTP_OK); + return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + stateStream + '&deleteCheckpointStream' + checkpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); }; ProjectionsClient.prototype.request = function(method, _url, data, userCredentials, expectedCode) { From 8f6892300836e6946ff0c53597c4afd6d1072fcc Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 17:00:47 +0200 Subject: [PATCH 5/7] Remove undefine's check as the options will need to be provided anyways... --- src/projections/projectionsClient.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index dfe51d0..7af5169 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -103,8 +103,6 @@ ProjectionsClient.prototype.updateQuery = function(httpEndPoint, name, query, us }; ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { - const stateStream = (deleteStateStream === undefined) ? false : deleteStateStream; - const checkpointStream = (deleteCheckpointStream === undefined) ? false : deleteCheckpointStream; return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + stateStream + '&deleteCheckpointStream' + checkpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); }; From 2f4850680f397c5b6e8b5c8090956f24c29c72a9 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 17:01:30 +0200 Subject: [PATCH 6/7] Fix incorrect variables used after undefined removal --- src/projections/projectionsClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index 7af5169..aa7e4c3 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -103,7 +103,7 @@ ProjectionsClient.prototype.updateQuery = function(httpEndPoint, name, query, us }; ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { - return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + stateStream + '&deleteCheckpointStream' + checkpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); + return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + deleteStateStream + '&deleteCheckpointStream' + deleteCheckpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); }; ProjectionsClient.prototype.request = function(method, _url, data, userCredentials, expectedCode) { From 1449b43b8d696ed8b7ffa6eea29ed6056c834b20 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Fri, 17 May 2019 17:47:52 +0200 Subject: [PATCH 7/7] Fix missing = in delete uri --- src/projections/projectionsClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index aa7e4c3..d98083e 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -103,7 +103,7 @@ ProjectionsClient.prototype.updateQuery = function(httpEndPoint, name, query, us }; ProjectionsClient.prototype.delete = function(httpEndPoint, name, deleteEmittedStreams, deleteStateStream, deleteCheckpointStream, userCredentials) { - return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + deleteStateStream + '&deleteCheckpointStream' + deleteCheckpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); + return this.sendDelete(httpEndPoint + '/projection/' + name + '?deleteStateStream=' + deleteStateStream + '&deleteCheckpointStream=' + deleteCheckpointStream + '&deleteEmittedStreams=' + deleteEmittedStreams, '', userCredentials, HTTP_OK); }; ProjectionsClient.prototype.request = function(method, _url, data, userCredentials, expectedCode) {