@anabranch/eventlog 0.2.0 → 0.3.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"eventlog.d.ts","sourceRoot":"","sources":["../src/eventlog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,aAAa,CAAA;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,QAAQ,CAAC,MAAM,GAAG,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC;IAE7D;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,EAC5B,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,GACnC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAanD;;;;;;;;;OASG;IACH,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC;IAaxC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,CAAC,EACN,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,aAAa,GACtB,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAcrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,OAAO,CAAC,CAAC,EACP,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAA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IACH,MAAM,CAAC,CAAC,EACN,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,aAAa,GACtB,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAWrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,OAAO,CAAC,CAAC,EACP,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,GAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,qBAAqB,CAAC;IAsDxD;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,IAAI,EAAE,0BAA0B,CAAC;IAazC;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAChB,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,uBAAuB,CAAC;CAYhD"}
package/esm/eventlog.js CHANGED
@@ -58,13 +58,9 @@ export class EventLog {
58
58
  * ```
59
59
  */
60
60
  static connect(connector) {
61
- return Task.of(async () => {
62
- try {
63
- return new EventLog(await connector.connect());
64
- }
65
- catch (error) {
66
- throw new EventLogConnectionFailed(error instanceof Error ? error.message : String(error), error);
67
- }
61
+ return Task.of(async () => new EventLog(await connector.connect()))
62
+ .mapErr((error) => {
63
+ return new EventLogConnectionFailed(error instanceof Error ? error.message : String(error), error);
68
64
  });
69
65
  }
70
66
  /**
@@ -78,13 +74,8 @@ export class EventLog {
78
74
  * ```
79
75
  */
80
76
  close() {
81
- return Task.of(async () => {
82
- try {
83
- await this.adapter.close();
84
- }
85
- catch (error) {
86
- throw new EventLogCloseFailed(error instanceof Error ? error.message : String(error), error);
87
- }
77
+ return Task.of(async () => await this.adapter.close()).mapErr((error) => {
78
+ return new EventLogCloseFailed(error instanceof Error ? error.message : String(error), error);
88
79
  });
89
80
  }
90
81
  /**
@@ -104,13 +95,9 @@ export class EventLog {
104
95
  * ```
105
96
  */
106
97
  append(topic, data, options) {
107
- return Task.of(async () => {
108
- try {
109
- return await this.adapter.append(topic, data, options);
110
- }
111
- catch (error) {
112
- throw new EventLogAppendFailed(topic, error instanceof Error ? error.message : String(error), error);
113
- }
98
+ return Task.of(async () => await this.adapter.append(topic, data, options))
99
+ .mapErr((error) => {
100
+ return new EventLogAppendFailed(topic, error instanceof Error ? error.message : String(error), error);
114
101
  });
115
102
  }
116
103
  /**
@@ -193,13 +180,8 @@ export class EventLog {
193
180
  * ```
194
181
  */
195
182
  commit(topic, consumerGroup, cursor) {
196
- return Task.of(async () => {
197
- try {
198
- await this.adapter.commitCursor(topic, consumerGroup, cursor);
199
- }
200
- catch (error) {
201
- throw new EventLogCommitCursorFailed(topic, consumerGroup, error instanceof Error ? error.message : String(error), error);
202
- }
183
+ return Task.of(async () => await this.adapter.commitCursor(topic, consumerGroup, cursor)).mapErr((error) => {
184
+ return new EventLogCommitCursorFailed(topic, consumerGroup, error instanceof Error ? error.message : String(error), error);
203
185
  });
204
186
  }
205
187
  /**
@@ -218,13 +200,8 @@ export class EventLog {
218
200
  * ```
219
201
  */
220
202
  getCommittedCursor(topic, consumerGroup) {
221
- return Task.of(async () => {
222
- try {
223
- return await this.adapter.getCursor(topic, consumerGroup);
224
- }
225
- catch (error) {
226
- throw new EventLogGetCursorFailed(topic, consumerGroup, error instanceof Error ? error.message : String(error), error);
227
- }
203
+ return Task.of(async () => await this.adapter.getCursor(topic, consumerGroup)).mapErr((error) => {
204
+ return new EventLogGetCursorFailed(topic, consumerGroup, error instanceof Error ? error.message : String(error), error);
228
205
  });
229
206
  }
230
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anabranch/eventlog",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Event log with Task/Stream semantics. In-memory adapter for event-sourced systems with cursor-based consumption.",
5
5
  "repository": {
6
6
  "type": "git",