From 7ccced45aa43f540f6124bfb591180947cc85712 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 13:57:11 +0200 Subject: [PATCH 1/4] Add reset endpoint --- index.d.ts | 1 + src/projections/projectionsClient.js | 4 ++++ src/projections/projectionsManager.js | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/index.d.ts b/index.d.ts index ff4940d..bed7feb 100644 --- a/index.d.ts +++ b/index.d.ts @@ -72,6 +72,7 @@ export class ProjectionsManager { enable(name: string, userCredentials: UserCredentials): Promise; disable(name: string, userCredentials: UserCredentials): Promise; abort(name: string, userCredentials: UserCredentials): Promise; + reset(name: string, userCredentials: UserCredentials): Promise; createOneTime(query: string, userCredentials: UserCredentials): Promise; createTransient(name: string, query: string, userCredentials: UserCredentials): Promise; createContinuous(name: string, query: string, trackEmittedStreams: boolean, userCredentials: UserCredentials): Promise; diff --git a/src/projections/projectionsClient.js b/src/projections/projectionsClient.js index 781694a..4657b88 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -31,6 +31,10 @@ ProjectionsClient.prototype.abort = function(httpEndPoint, name, userCredentials return this.sendPost(httpEndPoint + '/projection/' + name + '/command/abort', '', userCredentials, HTTP_OK); }; +ProjectionsClient.prototype.reset = function(httpEndPoint, name, userCredentials) { + return this.sendPost(httpEndPoint + '/projection/' + name + 'command/reset', userCredentials, HTTP_OK); +}; + ProjectionsClient.prototype.createOneTime = function(httpEndPoint, query, userCredentials) { return this.sendPost(httpEndPoint + '/projections/onetime?type=JS', query, userCredentials, HTTP_CREATED); }; diff --git a/src/projections/projectionsManager.js b/src/projections/projectionsManager.js index f453d4b..47a8925 100644 --- a/src/projections/projectionsManager.js +++ b/src/projections/projectionsManager.js @@ -45,6 +45,16 @@ ProjectionsManager.prototype.abort = function(name, userCredentials) { return this._client.abort(this._httpEndPoint, name, userCredentials); }; +/** + * Reset a projection. (This will re-emit events, streams that are written to from the projection will also be soft deleted) + * @param name The name of the projection. + * @param userCredentials Credentials for a user with permission to disable a projection. + * @returns {Promise} + */ +ProjectionsManager.prototype.reset = function(name, userCredentials) { + return this._client.abort(this._httpEndPoint, name, userCredentials); +}; + /** * Creates a one-time query. * @param query The JavaScript source code for the query. From bebd04a398f2181f93c1fac4ce107e17ac1fb8d2 Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 15:36:05 +0200 Subject: [PATCH 2/4] Fix client endpoint used --- src/projections/projectionsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projections/projectionsManager.js b/src/projections/projectionsManager.js index 47a8925..a3161e7 100644 --- a/src/projections/projectionsManager.js +++ b/src/projections/projectionsManager.js @@ -52,7 +52,7 @@ ProjectionsManager.prototype.abort = function(name, userCredentials) { * @returns {Promise} */ ProjectionsManager.prototype.reset = function(name, userCredentials) { - return this._client.abort(this._httpEndPoint, name, userCredentials); + return this._client.reset(this._httpEndPoint, name, userCredentials); }; /** From ad8d16d1128b129472b75e9b16b1242af45e115d Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 15:37:58 +0200 Subject: [PATCH 3/4] Fix documentation --- src/projections/projectionsManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projections/projectionsManager.js b/src/projections/projectionsManager.js index a3161e7..6f33ad6 100644 --- a/src/projections/projectionsManager.js +++ b/src/projections/projectionsManager.js @@ -48,7 +48,7 @@ ProjectionsManager.prototype.abort = function(name, userCredentials) { /** * Reset a projection. (This will re-emit events, streams that are written to from the projection will also be soft deleted) * @param name The name of the projection. - * @param userCredentials Credentials for a user with permission to disable a projection. + * @param userCredentials Credentials for a user with permission to reset a projection. * @returns {Promise} */ ProjectionsManager.prototype.reset = function(name, userCredentials) { From 8e54a22cd24b60c360cfd54d4951d9e4166faf7c Mon Sep 17 00:00:00 2001 From: Richard Shephard Date: Thu, 16 May 2019 16:52:11 +0200 Subject: [PATCH 4/4] Fix uri for reset --- 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 4657b88..6b569ee 100644 --- a/src/projections/projectionsClient.js +++ b/src/projections/projectionsClient.js @@ -32,7 +32,7 @@ ProjectionsClient.prototype.abort = function(httpEndPoint, name, userCredentials }; ProjectionsClient.prototype.reset = function(httpEndPoint, name, userCredentials) { - return this.sendPost(httpEndPoint + '/projection/' + name + 'command/reset', userCredentials, HTTP_OK); + return this.sendPost(httpEndPoint + '/projection/' + name + '/command/reset', '', userCredentials, HTTP_OK); }; ProjectionsClient.prototype.createOneTime = function(httpEndPoint, query, userCredentials) {