├── .babelrc
├── .editorconfig
├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── index.d.ts
├── index.js
├── lib
├── AggRoot.js
├── EventFactory.js
├── httpClient
│ ├── admin
│ │ ├── sendScavengeCommand.js
│ │ └── sendShutdownCommand.js
│ ├── checkStreamExists.js
│ ├── deleteStream.js
│ ├── getAllStreamEvents.js
│ ├── getEvents.js
│ ├── getEventsByType.js
│ ├── index.js
│ ├── persistentSubscriptions
│ │ ├── assert.js
│ │ ├── getAllSubscriptionsInfo.js
│ │ ├── getEvents.js
│ │ ├── getStreamSubscriptionsInfo.js
│ │ ├── getSubscriptionInfo.js
│ │ └── remove.js
│ ├── ping.js
│ ├── projections
│ │ ├── assert.js
│ │ ├── config.js
│ │ ├── disableAll.js
│ │ ├── enableAll.js
│ │ ├── getAllProjectionsInfo.js
│ │ ├── getInfo.js
│ │ ├── getResult.js
│ │ ├── getState.js
│ │ ├── remove.js
│ │ ├── reset.js
│ │ ├── start.js
│ │ └── stop.js
│ ├── readEvents.js
│ ├── utilities
│ │ └── mapEvents.js
│ ├── writeEvent.js
│ └── writeEvents.js
├── index.js
├── tcpClient
│ ├── checkStreamExists.js
│ ├── connectionManager.js
│ ├── deleteStream.js
│ ├── eventEnumerator.js
│ ├── getAllStreamEvents.js
│ ├── getEvents.js
│ ├── getEventsByType.js
│ ├── index.js
│ ├── readEvents.js
│ ├── subscribeToStream.js
│ ├── subscribeToStreamFrom.js
│ ├── utilities
│ │ └── mapEvents.js
│ ├── writeEvent.js
│ └── writeEvents.js
└── utilities
│ ├── chunkArray.js
│ ├── createHttpClient.js
│ ├── flattenArray.js
│ └── generateEventId.js
├── package.json
├── tests
├── _globalHooks.js
├── http.checkStreamExists.js
├── http.config.js
├── http.deleteStream.js
├── http.getAllStreamEvents.js
├── http.getEvents.js
├── http.persistentSubscriptions.js
├── http.ping.js
├── http.projections.js
├── http.readEvents.js
├── http.sendScavengeCommand.js
├── http.writeEvent.js
├── http.writeEvents.js
├── support
│ ├── cluster
│ │ ├── docker-compose-insecure.yml
│ │ ├── docker-compose-secure.yml
│ │ └── vars.env
│ ├── getHttpConfig.js
│ ├── getTcpConfig.js
│ ├── getTcpConfigCustomConnectionName.js
│ ├── getTcpConfigDNSDiscoveryCluster.js
│ ├── getTcpConfigGossipCluster.js
│ ├── single
│ │ ├── docker-compose-insecure.yml
│ │ └── docker-compose-secure.yml
│ ├── testPartitionedProjection.js
│ └── testProjection.js
├── tcp.checkStreamExists.js
├── tcp.cluster.js
├── tcp.config.js
├── tcp.connection.js
├── tcp.deleteStream.js
├── tcp.eventEnumerator.js
├── tcp.getAllStreamEvents.js
├── tcp.getEvents.js
├── tcp.readEvents.js
├── tcp.stressTests.js
├── tcp.subscribeToStream.js
├── tcp.subscribeToStreamFrom.js
├── tcp.writeEvent.js
├── tcp.writeEvents.js
└── utilities
│ └── sleep.js
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env"],
3 | "plugins": ["@babel/plugin-transform-runtime", "add-module-exports"]
4 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_size = 4
5 | indent_style = tab
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # tgz
6 | *.tgz
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 |
13 | # Directory for instrumented libs generated by jscoverage/JSCover
14 | lib-cov
15 |
16 | # Coverage directory used by tools like istanbul
17 | coverage
18 |
19 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
20 | .grunt
21 |
22 | # node-waf configuration
23 | .lock-wscript
24 |
25 | # Compiled binary addons (http://nodejs.org/api/addons.html)
26 | build/Release
27 |
28 | # Dependency directory
29 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
30 | node_modules
31 |
32 | #nyc output
33 | .nyc_output
34 |
35 | # Distribution
36 | **/dist/*
37 |
38 | # Tests
39 | **/certs/*
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | **/.*
2 | **/*.tgz
3 | **/*.lock
4 | node_modules/
5 | tests/
6 | coverage/
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # 4.0.1 (2021-09-28)
2 |
3 | ## TCP
4 |
5 | - Fix - handle closed connection when `closed` event never emitted
6 |
7 | #### Dependencies
8 |
9 | - Update packages
10 |
11 | # 4.0.0 (2021-05-22)
12 |
13 | #### Features
14 |
15 | - Added support for `v20` and `v21`
16 | - Added support for secured EventStoreDB clusters and single instances
17 |
18 | #### Breaking Changes
19 |
20 | - Removed deprecated legacy instance creation: `geteventstore.tcp(config)`, `geteventstore.http(config)` and `geteventstore.eventFactory`
21 |
22 | ## TCP
23 |
24 | ##### Features
25 |
26 | - Added `connectionNameGenerator` function to config that allows custom TCP connection names
27 |
28 | ## Tests
29 |
30 | - Tests now solely uses docker
31 | - Added `test:secure` and `test:insecure` scripts
32 | - `test` will now run all tests with secured and insecure EventStoreDB's
33 |
34 | # 3.3.0 (2021-02-22)
35 |
36 | ## TCP
37 |
38 | #### Changes
39 |
40 | - Destroy connection on connection close
41 | - Subscription connection pools now tracked uniquely
42 | - `close` connection pool will now drain pool first
43 |
44 | #### Fixes
45 |
46 | - `subscribeToStream` - `close` will now release and close subscription connection pool
47 | - `subscribeToStreamFrom` - added `close` function that will release and close subscription connection pool
48 |
49 | #### Dependencies
50 |
51 | - Update packages
52 |
53 | # 3.2.5 (2021-01-29)
54 |
55 | #### Dependencies
56 |
57 | - Update packages
58 |
59 | # 3.2.4 (2020-11-04)
60 |
61 | #### Fix
62 |
63 | - projections - `assert`, `trackEmittedStreams` setter. Thanks [@maniolias](https://github.com/maniolias)
64 |
65 | # 3.2.3 (2020-10-20)
66 |
67 | - projections - `config` query added. Thanks [@maniolias](https://github.com/maniolias)
68 | - projections - `getInfo`, `includeConfig` in result set added. Thanks [@maniolias](https://github.com/maniolias)
69 | - projections - `assert`, `trackEmittedStreams` added. Thanks [@maniolias](https://github.com/maniolias)
70 |
71 | # 3.2.2 (2020-10-05)
72 |
73 | #### Fix
74 |
75 | - persistentSubscriptions.assert - `resolveLinkTos` not applying due to typo. Thanks [@maniolias](https://github.com/maniolias)
76 | - persistentSubscriptions.getEvents - 401 due to missing auth headers. Thanks [@maniolias](https://github.com/maniolias)
77 |
78 | #### Dependencies
79 |
80 | - Update packages
81 |
82 | # 3.2.1 (2020-02-27)
83 |
84 | #### Dependencies
85 |
86 | - Update packages
87 |
88 | # 3.2.0 (2019-10-07)
89 |
90 | #### Breaking Changes
91 |
92 | - subscriptions - onEventAppeared aligned with `node-eventstore-client`, previously: `onEventAppeared(ev)` now: `onEventAppeared(subscription, ev)`. Thanks [@adebisi-fa](https://github.com/adebisi-fa)
93 |
94 | #### Features
95 |
96 | - projections - `result` query added. Thanks [@set4812](https://github.com/set4812)
97 |
98 | # 3.1.3 (2019-09-09)
99 |
100 | #### Fix
101 |
102 | - Typings - Metadata and eventId is optional. Thanks [@spontoreau](https://github.com/spontoreau)
103 |
104 | #### Dependencies
105 |
106 | - Update packages
107 |
108 | # 3.1.2 (2019-07-29)
109 |
110 | #### Misc
111 |
112 | - Typings - Inherit base TCP config from 'node-eventstore-client'. Thanks [@adebisi-fa](https://github.com/adebisi-fa)
113 |
114 | #### Dependencies
115 |
116 | - Update packages
117 |
118 | # 3.1.1 (2019-02-14)
119 |
120 | #### Fix
121 |
122 | - TCPReadResult typescript definition
123 |
124 | # 3.1.0 (2019-02-07)
125 |
126 | #### Features
127 |
128 | - Add readEventsForward and readEventsBackward returning read metadata + events
129 |
130 | #### Misc
131 |
132 | - Rename "length" parameter to "count"
133 |
134 | # 3.0.3 (2019-02-06)
135 |
136 | #### TCP Client
137 |
138 | - Fix - mapping of non-json events
139 |
140 | # 3.0.2 (2019-01-02)
141 |
142 | #### Fix
143 |
144 | - Expected version on writes defaulting to -2 when 0 provided. Thanks [@amaghfur](https://github.com/amaghfur)
145 |
146 | #### Dependencies
147 |
148 | - Update packages
149 |
150 | #### Misc
151 |
152 | - Change folder structure
153 |
154 | # 3.0.1 (2018-09-17)
155 |
156 | #### Misc
157 |
158 | - Fix - General Typescript definition issues
159 |
160 | # 3.0.0 (2018-09-13)
161 |
162 | #### Features
163 |
164 | - Typescript definitions added
165 | - Package exports now exposed as classes
166 |
167 | ##### Previous Usage (Deprecated)
168 | ```javascript
169 | const eventstore = require('geteventstore-promise');
170 | const httpClient = eventstore.http(...config);
171 | const tcpClient = eventstore.tcp(...config);
172 | const newEvent = eventstore.eventFactory.NewEvent(...args);
173 | ```
174 |
175 | ##### New Usage
176 | ```javascript
177 | const EventStore = require('geteventstore-promise');
178 | const httpClient = new EventStore.HTTPClient(...config);
179 | const tcpClient = new EventStore.TCPClient(...config);
180 | const newEvent = new EventStore.EventFactory().newEvent(...args);
181 | ```
182 |
183 | #### Dependencies
184 |
185 | - Remove - bluebird
186 | - Remove - lodash
187 | - Replace - request-promise with axios
188 |
189 | #### Breaking Changes
190 |
191 | ##### General
192 |
193 | - Promises - '.finally()' will not be available anymore due to the removal of bluebird
194 |
195 | ##### HTTP Client
196 |
197 | - Errors returned from HTTP calls might differ slightly from removed request-promise package vs the new axios implementation
198 |
199 | # 2.0.2 (2018-09-11)
200 |
201 | #### TCP Client
202 |
203 | - Feature - Add support for connecting to a cluster using gossip seeds or dns discovery (https://github.com/RemoteMetering/geteventstore-promise#config-example)
204 |
205 | #### Misc
206 |
207 | - Update dependencies
208 |
209 | # 2.0.1 (2018-06-04)
210 |
211 | #### TCP Client
212 |
213 | - Fix - edge case when eventNumber is not coming back as a long
214 |
215 | # 2.0.0 (2018-06-02)
216 |
217 | #### TCP Client
218 |
219 | - Feature - Implemented connection pooling(defaulting to 1 connection) using [https://github.com/coopernurse/node-pool](https://github.com/coopernurse/node-pool), please see config in library and pass config as "poolOptions" when initing TCP client.
Example: ` { ..., poolOptions: { min: 1, max: 10 } } `
220 |
221 | - Change - subscriptions now use [https://github.com/nicdex/node-eventstore-client](https://github.com/nicdex/node-eventstore-client) for subscriptions - Causes breaking changes
222 |
223 | #### Breaking Changes
224 |
225 | #### TCP Client
226 |
227 | - Replacement - 'closeConnections' with 'close', which will close connection pool
228 | - Subscriptions - now return subscription object from tcp library instead of connection
229 | - Subscriptions - now return events in same format as normal getEvents
230 | - Subscriptions - onDropped arguments -> onDropped(subscription, reason, error)
231 | - subscribeToStream - no longer has "onConfirm" handler
232 |
233 | # 1.4.0 (2018-05-29)
234 |
235 | #### TCP Client
236 |
237 | - "created" property on read events will now return as a ISO-8601 string instead of date object
238 |
239 | #### Breaking Changes
240 |
241 | - TCP: To bring both HTTP and TCP read events results inline, "created" will now return as a ISO-8601 string
242 |
243 | # 1.3.3 (2018-05-29)
244 |
245 | #### HTTP Client
246 |
247 | - Add "created" property to events on read, as TCP client returns
248 |
249 | #### Dependencies
250 |
251 | - Use latest packages
252 |
253 | # 1.3.2 (2018-04-24)
254 |
255 | #### Dependencies
256 |
257 | - Use latest packages
258 |
259 | # 1.3.1 (2017-10-27)
260 |
261 | #### HTTP Client
262 |
263 | - Remove redundant url parsing logic, by setting base url on client create
264 |
265 | # 1.3.0 (2017-10-27)
266 |
267 | #### Dependencies
268 |
269 | - Use latest packages
270 | - TCP: upgrade node-eventstore-client from 0.1.7 to 0.1.9
271 |
272 | #### Dev
273 |
274 | - Requires nodejs >= v.7.6
275 |
276 | #### Misc
277 |
278 | - Convert library source to use es6 modules, and async/await
279 | - Use babel latest preset
280 |
281 | # 1.2.8 (2017-08-11)
282 |
283 | #### TCP Client
284 |
285 | - Improve tcp connection on error logging
286 |
287 | # 1.2.7 (2017-08-11)
288 |
289 | #### TCP Client
290 |
291 | - Update to latest version of newly named node-eventstore-client from eventstore-node
292 |
293 | # 1.2.6 (2017-07-26)
294 |
295 | #### HTTP Client
296 |
297 | - Feature: add embed option to getEvents and getAllStreamEvents. Options: 'body' and 'rich', defaults to 'body' as per previous versions
298 |
299 | # 1.2.5 (2017-04-18)
300 |
301 | #### TCP Client
302 |
303 | - Fix: deleting of projected streams(Expected version to any)
304 |
305 | # 1.2.4 (2017-04-18)
306 |
307 | #### TCP Client
308 |
309 | - Fix: add eventId and positionCreated properties to mapped events
310 |
311 | # 1.2.3 (2017-04-18)
312 |
313 | #### TCP Client
314 |
315 | - Feature: add deleteStream
316 |
317 | # 1.2.2 (2017-03-29)
318 |
319 | #### TCP Client
320 |
321 | - Fix: convert metadata in mapping
322 |
323 | # 1.2.1 (2017-03-29)
324 |
325 | #### TCP Client
326 |
327 | - Fix: filter deleted events on projected streams
328 |
329 | #### Breaking Changes
330 |
331 | - TCP: events, rename property eventStreamId to streamId
332 |
333 | # 1.2.0 (2017-03-29)
334 |
335 | #### Source
336 |
337 | - Convert to ES6
338 |
339 | #### Misc.
340 |
341 | - Fix: debug logs doing unnecessary stringify, increases performance all around
342 |
343 | #### Breaking Changes
344 |
345 | - None
346 |
347 | # 1.1.26 (2017-03-27)
348 |
349 | #### TCP Client
350 |
351 | - Add check stream exits
352 |
353 | # 1.1.25 (2017-03-27)
354 |
355 | #### TCP Client
356 |
357 | - Update to latest version of eventstore-node that inclues some fixes
358 |
359 | # 1.1.25 (2017-03-22)
360 |
361 | #### TCP Client
362 |
363 | - Changed write+read backend to [https://github.com/nicdex/eventstore-node](https://github.com/nicdex/eventstore-node)
364 | - New Feature: connection pooling so calls use single open connection
365 | - New Feature: ablility to close connections and get connections
366 |
367 | # 1.1.24 (2017-03-15)
368 |
369 | #### HTTP Client
370 |
371 | - New Feature: persistent subscriptions v1
372 | - Fix: deleteStream, return error object on stream 404
373 |
374 | # 1.1.23 (2017-03-15)
375 |
376 | #### HTTP Client
377 |
378 | - Fix checkStreamExists, return rejected promise on any error other than a 404
379 |
380 | #### TCP Client
381 |
382 | - Use latest event-store-client
383 |
384 | #### EventFactory
385 |
386 | - Added support for custom eventId(thanks @krazar)
387 |
388 | #### Dependencies
389 |
390 | - bluebird, 3.4.6 > 3.5.0
391 | - debug, 2.2.0 > 2.6.3
392 | - event-store-client, 0.0.10 > 0.0.11
393 | - lodash, 4.15.0 > 4.17.4
394 | - request-promise, 2.0.1 > 4.1.1 (requires request 2.81.0)
395 | - uuid, 3.0.0 > 3.0.1
396 |
397 | #### Misc
398 |
399 | - added missing debug logs
400 |
401 |
402 | # 1.1.22 (2017-03-09)
403 |
404 | #### HTTP Client
405 |
406 | - add timeout option
407 |
408 | # 1.1.21 (2017-01-04)
409 |
410 | #### All Clients
411 |
412 | - add resolveLinkTos optional param for all read functions
413 |
414 | # 1.1.20 (2016-12-22)
415 |
416 | #### HTTP Client
417 |
418 | - deleteStream, added option to hard delete streams(thanks @mjaric)
419 |
420 | #### TCP Client
421 |
422 | - SubscribeToStreamFrom, added missing event-store-client settings(maxLiveQueueSize, readBatchSize, debug)
423 |
424 | # 1.1.19 (2016-12-08)
425 |
426 | #### Dependencies
427 |
428 | - 'q' promise library replaced by bluebird (3.4.6)
429 |
430 | # 1.1.18 (2016-11-23)
431 |
432 | #### Dependencies
433 |
434 | - 'node-uuid' got deprecated and renamed to 'uuid'(3.0.0)
435 |
436 | # 1.1.17 (2016-11-17)
437 |
438 | #### TCP Client
439 |
440 | - clean up console log on live subscription
441 |
442 | # 1.1.16 (2016-11-10)
443 |
444 | #### TCP Client
445 |
446 | - Add Subcribe to stream to start a live subscription to a stream
447 |
448 | # 1.1.15 (2016-09-22)
449 |
450 | #### Aggregate Root
451 |
452 | - Fix: version of aggregrate not setting on event 0
453 |
454 | #### TCP Client
455 |
456 | - Upgrade to lastest event-store-client library(0.0.10)
457 |
458 | #### Misc.
459 |
460 | - Update to latest lodash(4.15.0)
461 |
462 | # 1.1.14 (2016-08-24)
463 |
464 | #### HTTP Client
465 |
466 | - Fix: GetEvents: When passing starting position of 0 for backward read, only event 0 should be returned. Was starting read over from the back of the stream(Potential breaking change)
467 |
468 | # 1.1.13 (2016-07-26)
469 |
470 | #### TCP Client
471 |
472 | - Fix: Create local references of events when writing
473 |
474 | # 1.1.12 (2016-07-26)
475 |
476 | #### HTTP Client
477 |
478 | - Fix: Only parse event data when defined
479 | - Fix: Return full error object on getAllStreamEvents
480 |
481 | #### TCP Client
482 |
483 | - Fix: Return full errors
484 | - Upgrade to lastest event-store-client library(0.0.9)
485 |
486 | # 1.1.11 (2016-07-18)
487 |
488 | #### TCP Client
489 |
490 | - Upgrade to lastest event-store-client library(0.0.8)
491 |
492 | # 1.1.10 (2016-06-28)
493 |
494 | #### TCP Client
495 |
496 | - Feature: subscribeToStreamFrom to allow resolveLinkTos setting
497 |
498 | # 1.1.9 (2016-06-28)
499 |
500 | #### TCP Client
501 |
502 | - Feature: add subscribeToStreamFrom
503 |
504 | #### HTTP Client
505 |
506 | - Feature: get state of partitioned projection
507 |
508 | #### Dependencies
509 |
510 | - replace underscore with lodash
511 | - upgrade version event-store-client 0.0.7
512 |
513 | # 1.1.8 (2016-06-20)
514 |
515 | #### HTTP Client
516 |
517 | - Fix: writeEvents return successful if empty array given
518 | - Fix: any get events function will default to 4096 count if greater is requested (warning also displayed)
519 | - Feature: add getAllStreamEvents function
520 |
521 | #### TCP Client
522 |
523 | - Feature: added start event number on getAllStreamEvents
524 | - Fix: any get events function will default to 4096 count if greater is requested (warning also displayed)
525 | - Change: default chunkSize of reads from 250 to 1000
526 |
527 | #### Tests
528 |
529 | - Added tests to TCP and HTTP client to check for undefined, empty array in writeEvents
530 |
531 | # 1.1.7 (2016-06-08)
532 |
533 | #### HTTP Client
534 |
535 | - Ping: returns successful if ping can be called, rejects if not
536 |
537 | # 1.1.6 (2016-06-07)
538 |
539 | #### HTTP Client
540 |
541 | - DeleteStream: deletes an existing stream, rejects if the stream does not exist
542 |
543 | # 1.1.5 (2016-06-07)
544 |
545 | #### HTTP Client
546 |
547 | - GetEvents return events in the correct order. Forwards and Backwards now return as expected. Reverse of what it used to be.
548 |
549 | # 1.1.4 (2016-04-15)
550 |
551 | #### TCP Client
552 |
553 | - Return rejected promise on failure to connect to Event Store instead of just logging it
554 |
555 | # 1.1.3 (2016-04-06)
556 |
557 | #### HTTP Client
558 |
559 | - Make checkStreamExists more accurate
560 | - Fix request-promise usage to include 'embed=body' as query string object(mono fix)
561 |
562 | # 1.1.2 (2016-04-04)
563 |
564 | #### TCP Client
565 |
566 | - Fix tcp client adding invalid 'host' property to config
567 |
568 | # 1.1.1 (2016-03-15)
569 |
570 | ## Breaking Changes
571 |
572 | #### HTTP client
573 |
574 | - 'getProjectionState' moved to 'projections.getState'
575 | - 'getAllProjectionsInfo' moved to 'projections.getAllProjectionsInfo'
576 |
577 | # 1.1.0 (2016-03-14)
578 |
579 | ## Breaking Changes
580 |
581 | #### Configuration
582 |
583 | - Removed wrapping `http` and `tcp` configuration properties
584 | - Removed protocol property, assigned internally
585 |
586 | ##### Previous Usage
587 | ```javascript
588 | var eventstore = require('geteventstore-promise');
589 |
590 | var client = eventstore.http({
591 | http:{
592 | hostname: 'localhost',
593 | protocol: 'http',
594 | port: 2113,
595 | credentials: {
596 | username: 'admin',
597 | password: 'changeit'
598 | }
599 | }
600 | });
601 |
602 | ```
603 |
604 | ##### New Usage
605 | ```javascript
606 | var eventstore = require('geteventstore-promise');
607 |
608 | var client = eventstore.http({
609 | hostname: 'localhost',
610 | port: 2113,
611 | credentials: {
612 | username: 'admin',
613 | password: 'changeit'
614 | }
615 | });
616 |
617 | ```
618 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 RemoteMetering
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/index.d.ts:
--------------------------------------------------------------------------------
1 | import {
2 | EventStoreSubscription,
3 | WriteResult as TCPWriteResult,
4 | DeleteResult as TCPDeleteResult,
5 | LiveProcessingStartedCallback,
6 | SubscriptionDroppedCallback,
7 | ConnectionSettings
8 | } from "node-eventstore-client";
9 |
10 | import {
11 | Options as TCPPoolOptions,
12 | Pool as TCPPool
13 | } from "generic-pool";
14 |
15 | export interface NewEvent {
16 | eventId: string;
17 | eventType: string;
18 | data: object;
19 | metadata?: object;
20 | }
21 |
22 | export interface Event {
23 | streamId: string;
24 | eventId: string;
25 | eventNumber: number;
26 | eventType: string;
27 | created: string;
28 | data: object;
29 | metadata?: object;
30 | isJson?: boolean;
31 | positionStreamId?: string;
32 | positionEventId?: string;
33 | positionEventNumber?: number;
34 | positionCreated?: string;
35 | }
36 |
37 | export type ProjectionMode = "onetime" | "continuous";
38 |
39 | export type ReadDirection = "forward" | "backward";
40 |
41 | export type EmbedType = "body" | "rich" | "PrettyBody" | "TryHarder";
42 |
43 | export interface UserCredentials {
44 | readonly username: string;
45 | readonly password: string;
46 | }
47 |
48 | export interface GossipSeed {
49 | readonly hostname: string;
50 | readonly port: number;
51 | }
52 |
53 | export interface HTTPConfig {
54 | protocol?: string;
55 | hostname: string;
56 | port: number;
57 | validateServer?: boolean;
58 | credentials: UserCredentials;
59 | }
60 |
61 | export interface TCPConfig extends ConnectionSettings {
62 | protocol?: string;
63 | hostname?: string;
64 | port?: number;
65 | useSslConnection?: boolean;
66 | validateServer?: boolean;
67 | gossipSeeds?: GossipSeed[];
68 | credentials: UserCredentials;
69 | poolOptions?: TCPPoolOptions;
70 | connectionNameGenerator?: () => string | Promise;
71 | }
72 |
73 | export interface HTTPWriteEventOptions {
74 | expectedVersion?: number;
75 | }
76 |
77 | export interface TCPWriteEventOptions {
78 | expectedVersion?: number;
79 | }
80 |
81 | export interface TCPWriteEventsOptions extends TCPWriteEventOptions {
82 | transactionWriteSize?: number;
83 | }
84 |
85 | export interface TCPReadResult {
86 | status: string;
87 | stream: string;
88 | fromEventNumber: Long;
89 | readDirection: string;
90 | events: Event[];
91 | nextEventNumber: Long;
92 | lastEventNumber: Long;
93 | isEndOfStream: boolean;
94 | }
95 |
96 | export interface HTTPReadResultAuthor {
97 | name: string;
98 | }
99 |
100 | export interface HTTPReadResultLink {
101 | uri: string;
102 | relation: string;
103 | }
104 |
105 | export interface HTTPReadResult {
106 | title: string,
107 | id: string,
108 | updated: string,
109 | streamId: string,
110 | author: HTTPReadResultAuthor,
111 | headOfStream: boolean,
112 | isEndOfStream: boolean,
113 | readDirection: ReadDirection,
114 | fromEventNumber: number;
115 | nextEventNumber: number;
116 | selfUrl: string,
117 | links: HTTPReadResultLink[],
118 | events: Event[]
119 | }
120 |
121 | export interface ProjectionStateOptions {
122 | partition?: string;
123 | }
124 |
125 | export interface PersistentSubscriptionOptions {
126 | resolveLinkTos?: boolean;
127 | startFrom?: number;
128 | extraStatistics?: boolean;
129 | messageTimeout?: number;
130 | maxRetryCount?: number;
131 | liveBufferSize?: number;
132 | readBatchSize?: number;
133 | historyBufferSize?: number;
134 | checkPointAfter?: number;
135 | minCheckPointCount?: number;
136 | maxCheckPointCount?: number;
137 | maxSubscriberCount?: number;
138 | namedConsumerStrategy?: string;
139 | }
140 |
141 | export interface PersistentSubscriptionAssertResult {
142 | correlationId: string;
143 | reason: string;
144 | result: string;
145 | msgTypeId: number;
146 | }
147 |
148 | export interface EventStoreCatchUpSubscription {
149 | stop(): void;
150 | close(): Promise;
151 | }
152 |
153 | export interface SubscribeToStreamFromSettings {
154 | resolveLinkTos?: boolean;
155 | readBatchSize?: number;
156 | }
157 |
158 | export interface MappedEventAppearedCallback {
159 | (subscription: TSubscription, event: Event): void | Promise;
160 | }
161 |
162 | export interface EventEnumeratorResult {
163 | isEndOfStream: boolean;
164 | events: Event[];
165 | }
166 |
167 | export class EventFactory {
168 | newEvent: (eventType: string, data: object, metadata?: object, eventId?: string) => NewEvent;
169 | }
170 |
171 | export class HTTPClient {
172 | constructor(config: HTTPConfig);
173 | checkStreamExists(streamName: string): Promise;
174 | writeEvent(streamName: string, eventType: string, data: object, metaData?: object, options?: HTTPWriteEventOptions): Promise;
175 | writeEvents(streamName: string, events: NewEvent[], options?: HTTPWriteEventOptions): Promise;
176 | getAllStreamEvents(streamName: string, chunkSize?: number, startPosition?: number, resolveLinkTos?: boolean, embed?: EmbedType): Promise;
177 | getEvents(streamName: string, startPosition?: number, count?: number, direction?: ReadDirection, resolveLinkTos?: boolean, embed?: EmbedType): Promise;
178 | getEventsByType(streamName: string, eventTypes: string[], startPosition?: number, count?: number, direction?: ReadDirection, resolveLinkTos?: boolean): Promise;
179 | readEventsForward(streamName: string, startPosition?: number, count?: number, resolveLinkTos?: boolean, embed?: EmbedType): Promise;
180 | readEventsBackward(streamName: string, startPosition?: number, count?: number, resolveLinkTos?: boolean, embed?: EmbedType): Promise;
181 | deleteStream(streamName: string, hardDelete?: boolean): Promise;
182 | ping(): Promise;
183 | admin: {
184 | scavenge(): Promise;
185 | shutdown(): Promise;
186 | };
187 | projections: {
188 | start(name: string): Promise;
189 | stop(name: string): Promise;
190 | reset(name: string): Promise;
191 | assert(name: string, projectionContent: string, mode?: ProjectionMode, enabled?: boolean, checkpointsEnabled?: boolean, emitEnabled?: boolean, trackEmittedStreams?: boolean): Promise;
192 | remove(name: string, deleteCheckpointStream?: boolean, deleteStateStream?: boolean): Promise;
193 | config(name: string): Promise