@ddd-ts/event-sourcing-esdb 0.0.36 → 0.0.38

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Aetherall
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.
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=esdb.event-store.d.ts.map
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=esdb.event-store.spec.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // export { ESDBEventStore } from "./esdb.event-store";
4
- //# sourceMappingURL=index.js.map
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -1,2 +1 @@
1
- export {};
2
1
  //# sourceMappingURL=bank.spec.d.ts.map
package/package.json CHANGED
@@ -1,29 +1,40 @@
1
1
  {
2
- "name": "@ddd-ts/event-sourcing-esdb",
3
- "version": "0.0.36",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "license": "MIT",
7
- "repository": {
8
- "url": "git+https://github.com/ddd-ts/monorepo"
9
- },
10
- "scripts": {
11
- "pretest:disabled": "docker compose -f docker/docker-compose.yml up -d",
12
- "wait:disabled": "sh -c 'until curl --silent localhost:2113/health; do sleep 1; done;'",
13
- "test:disabled": "jest --passWithNoTests --config node_modules/@ddd-ts/tools/jest.config.js",
14
- "posttest:disabled": "docker compose -f docker/docker-compose.yml down",
15
- "build": "tsc"
16
- },
17
- "dependencies": {
18
- "@ddd-ts/core": "0.0.36",
19
- "@eventstore/db-client": "^5.0.0"
20
- },
21
- "devDependencies": {
22
- "@ddd-ts/event-sourcing-inmemory": "0.0.36",
23
- "@ddd-ts/store-inmemory": "0.0.36",
24
- "@ddd-ts/tests": "0.0.36",
25
- "@ddd-ts/tools": "0.0.36",
26
- "@ddd-ts/types": "0.0.36",
27
- "@types/jest": "^29.5.1"
28
- }
29
- }
2
+ "name": "@ddd-ts/event-sourcing-esdb",
3
+ "version": "0.0.38",
4
+ "types": "dist/index.d.ts",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "url": "git+https://github.com/ddd-ts/monorepo"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "dependencies": {
13
+ "@ddd-ts/core": "0.0.38",
14
+ "@eventstore/db-client": "^5.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "@ddd-ts/event-sourcing-inmemory": "0.0.38",
18
+ "@ddd-ts/store-inmemory": "0.0.38",
19
+ "@ddd-ts/tests": "0.0.38",
20
+ "@ddd-ts/tools": "0.0.38",
21
+ "@ddd-ts/types": "0.0.38",
22
+ "@types/jest": "^29.5.1"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "main": "./dist/index.js",
32
+ "module": "./dist/index.mjs",
33
+ "scripts": {
34
+ "pretest:disabled": "docker compose -f docker/docker-compose.yml up -d",
35
+ "wait:disabled": "sh -c 'until curl --silent localhost:2113/health; do sleep 1; done;'",
36
+ "test:disabled": "jest --passWithNoTests --config node_modules/@ddd-ts/tools/jest.config.js",
37
+ "posttest:disabled": "docker compose -f docker/docker-compose.yml down",
38
+ "build": "tsdown --config node_modules/@ddd-ts/tools/tsdown.config.js"
39
+ }
40
+ }
@@ -1,252 +0,0 @@
1
- "use strict";
2
- // import { EventStoreDBClient, jsonEvent } from "@eventstore/db-client";
3
- // import {
4
- // EsAggregate,
5
- // Event,
6
- // Serializable,
7
- // closeable,
8
- // map,
9
- // Competitor,
10
- // EsChange,
11
- // EsFact,
12
- // EventStore,
13
- // Follower,
14
- // ProjectedStreamConfiguration,
15
- // } from "@ddd-ts/core";
16
- // import { Constructor } from "@ddd-ts/types";
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- // process.env.DEBUG = "esdb:*";
19
- // (BigInt as any).prototype.toJSON = function () {
20
- // return this.toString();
21
- // };
22
- // export class ESDBEventStore extends EventStore {
23
- // client: EventStoreDBClient;
24
- // namespace: string;
25
- // constructor() {
26
- // super();
27
- // this.namespace = Math.random().toString().substring(2, 8);
28
- // this.client = new EventStoreDBClient(
29
- // { endpoint: { address: "localhost", port: 2113 } },
30
- // { insecure: true },
31
- // );
32
- // }
33
- // private readonly subscriptions = new Set<() => Promise<any>>();
34
- // async close() {
35
- // await Promise.all([...this.subscriptions.values()].map((s) => s()));
36
- // this.client.dispose();
37
- // }
38
- // async clear() {
39
- // this.namespace = Math.random().toString().substring(2, 8);
40
- // }
41
- // private getAggregateStreamName(
42
- // AGGREGATE: Constructor<EsAggregate<any, any>>,
43
- // id: string,
44
- // ) {
45
- // return this.namespace + "." + AGGREGATE.name + "-" + id;
46
- // }
47
- // async appendToAggregateStream(
48
- // AGGREGATE: Constructor<EsAggregate<any, any>>,
49
- // id: { toString(): string },
50
- // changes: EsChange[],
51
- // expectedRevision: bigint,
52
- // ): Promise<void> {
53
- // const r = expectedRevision === -1n ? "no_stream" : expectedRevision;
54
- // const events = changes.map((c) =>
55
- // jsonEvent({ id: c.id, type: c.type, data: c.payload }),
56
- // );
57
- // const streamName = this.getAggregateStreamName(AGGREGATE, id.toString());
58
- // await this.client.appendToStream(streamName, events, {
59
- // expectedRevision: r,
60
- // });
61
- // }
62
- // async *readAggregateStream(
63
- // AGGREGATE: Constructor<EsAggregate<{ toString(): string }, Event[]>, any[]>,
64
- // id: { toString(): string },
65
- // from?: bigint,
66
- // ): AsyncIterable<EsFact> {
67
- // const streamName = this.getAggregateStreamName(AGGREGATE, id.toString());
68
- // for await (const event of this.client.readStream(streamName, {
69
- // fromRevision: from,
70
- // })) {
71
- // if (!event.event) {
72
- // throw new Error("no event");
73
- // }
74
- // yield {
75
- // id: event.event.id,
76
- // payload: event.event.data as Serializable,
77
- // type: event.event.type,
78
- // revision: event.event.revision,
79
- // };
80
- // }
81
- // }
82
- // private getProjectedStreamName(AGGREGATE: ProjectedStreamConfiguration[0]) {
83
- // return "$ce-" + this.namespace + "." + AGGREGATE.name;
84
- // }
85
- // private async ensureProjectedStream(config: ProjectedStreamConfiguration) {
86
- // if (config.length === 1) {
87
- // return this.getProjectedStreamName(config[0]);
88
- // }
89
- // const projectionNameSuffix = config
90
- // .map((a) => a.name)
91
- // .sort()
92
- // .join("-");
93
- // const stableProjectionName =
94
- // this.namespace + "." + "pj-" + projectionNameSuffix;
95
- // const streams = config.map((a) => this.getProjectedStreamName(a));
96
- // const query = `
97
- // fromStreams(${streams
98
- // .map((s) => `'${s}'`)
99
- // .join(
100
- // ", ",
101
- // )}).when({ $any: function(state, event) { linkTo('${stableProjectionName}', event) }})
102
- // `;
103
- // await this.client.createProjection(stableProjectionName, query, {
104
- // emitEnabled: true,
105
- // });
106
- // let status;
107
- // let attempts = 0;
108
- // do {
109
- // status = await this.client.getProjectionStatus(stableProjectionName);
110
- // if (status.progress < 100) {
111
- // await new Promise((resolve) => setTimeout(resolve, 500));
112
- // }
113
- // attempts++;
114
- // if (attempts > 40) {
115
- // if (status.status === "Running") {
116
- // return stableProjectionName;
117
- // }
118
- // throw new Error(
119
- // "projection not stable: \n" + JSON.stringify(status, null, 2),
120
- // );
121
- // }
122
- // } while (status.progress < 100);
123
- // return stableProjectionName;
124
- // }
125
- // async *readProjectedStream(
126
- // config: ProjectedStreamConfiguration,
127
- // from?: bigint,
128
- // ): AsyncIterable<EsFact> {
129
- // const stream = await this.ensureProjectedStream(config);
130
- // for await (const event of this.client.readStream(stream, {
131
- // fromRevision: from,
132
- // resolveLinkTos: true,
133
- // direction: "forwards",
134
- // })) {
135
- // if (!event.event) {
136
- // throw new Error("no event");
137
- // }
138
- // if (!event.link) {
139
- // throw new Error("no link");
140
- // }
141
- // yield {
142
- // id: event.event.id,
143
- // payload: event.event.data as Serializable,
144
- // type: event.event.type,
145
- // revision: event.link.revision,
146
- // };
147
- // }
148
- // }
149
- // async followProjectedStream(
150
- // AGGREGATE: ProjectedStreamConfiguration,
151
- // from: bigint = 0n,
152
- // ): Promise<Follower> {
153
- // const streamName = await this.ensureProjectedStream(AGGREGATE);
154
- // const position = from - 1n;
155
- // const fromRevision = position < 0n ? "start" : position;
156
- // const stream = this.client.subscribeToStream(streamName, {
157
- // fromRevision,
158
- // resolveLinkTos: true,
159
- // });
160
- // const hook = async () => void stream.destroy();
161
- // this.subscriptions.add(hook);
162
- // const mapped = map(stream, (e) => {
163
- // if (!e.event) {
164
- // throw new Error("no event");
165
- // }
166
- // if (!e.link) {
167
- // throw new Error("no link");
168
- // }
169
- // return {
170
- // id: e.event.id,
171
- // payload: e.event.data as Serializable,
172
- // type: e.event.type,
173
- // revision: e.link.revision,
174
- // };
175
- // });
176
- // return closeable(mapped, async () => {
177
- // await stream.unsubscribe();
178
- // this.subscriptions.delete(hook);
179
- // });
180
- // }
181
- // competeForProjectedStream(
182
- // AGGREGATE: ProjectedStreamConfiguration,
183
- // competitionName: string,
184
- // ): Promise<Competitor> {
185
- // throw new Error("Method not implemented.");
186
- // }
187
- // // async competeForProjectedStream(
188
- // // AGGREGATE: ProjectedStreamConfiguration,
189
- // // competitionName: string
190
- // // ): Promise<Competitor> {
191
- // // const streamName = this.getProjectedStreamName(AGGREGATE);
192
- // // try {
193
- // // await this.client.createPersistentSubscriptionToStream(
194
- // // streamName,
195
- // // competitionName,
196
- // // persistentSubscriptionToStreamSettingsFromDefaults({
197
- // // resolveLinkTos: true,
198
- // // })
199
- // // );
200
- // // } catch (error: any) {
201
- // // if (
202
- // // isCommandError(error) &&
203
- // // error.type === ErrorType.PERSISTENT_SUBSCRIPTION_EXISTS
204
- // // ) {
205
- // // // do nothing and use the existing one
206
- // // } else {
207
- // // throw error;
208
- // // }
209
- // // }
210
- // // const sub = this.client.subscribeToPersistentSubscriptionToStream(
211
- // // streamName,
212
- // // competitionName
213
- // // );
214
- // // return closeable(
215
- // // map(sub, (event) => {
216
- // // if (!event.event) {
217
- // // throw new Error(follow
218
- // // "[ESDB] listening projected stream : iterated over unreadable event"
219
- // // );
220
- // // }
221
- // // const revision =
222
- // // event.link?.revision !== undefined ? event.link?.revision : undefined;
223
- // // if (revision === undefined) {
224
- // // throw new Error(
225
- // // "[ESDB] listening projected stream : iterated over unreadable event"
226
- // // );
227
- // // }
228
- // // return {
229
- // // fact: {
230
- // // id: event.event.id,
231
- // // type: event.event.type,
232
- // // payload: event.event.data as Serializable,
233
- // // revision,
234
- // // },
235
- // // succeed: async () => {
236
- // // await sub.ack(event);
237
- // // },
238
- // // retry: async () => {
239
- // // await sub.nack("retry", "unknown", event);
240
- // // },
241
- // // skip: async () => {
242
- // // await sub.nack("skip", "unknown", event);
243
- // // },
244
- // // };
245
- // // }),
246
- // // async () => {
247
- // // await sub.unsubscribe();
248
- // // }
249
- // // );
250
- // // }
251
- // }
252
- //# sourceMappingURL=esdb.event-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esdb.event-store.js","sourceRoot":"","sources":["../src/esdb.event-store.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,WAAW;AACX,iBAAiB;AACjB,WAAW;AACX,kBAAkB;AAClB,eAAe;AACf,SAAS;AACT,gBAAgB;AAChB,cAAc;AACd,YAAY;AACZ,gBAAgB;AAChB,cAAc;AACd,kCAAkC;AAClC,yBAAyB;AACzB,+CAA+C;;AAE/C,gCAAgC;AAEhC,mDAAmD;AACnD,4BAA4B;AAC5B,KAAK;AAEL,mDAAmD;AACnD,gCAAgC;AAChC,uBAAuB;AACvB,oBAAoB;AACpB,eAAe;AACf,iEAAiE;AACjE,4CAA4C;AAC5C,4DAA4D;AAC5D,4BAA4B;AAC5B,SAAS;AACT,MAAM;AAEN,oEAAoE;AAEpE,oBAAoB;AACpB,2EAA2E;AAC3E,6BAA6B;AAC7B,MAAM;AAEN,oBAAoB;AACpB,iEAAiE;AACjE,MAAM;AAEN,oCAAoC;AACpC,qDAAqD;AACrD,kBAAkB;AAClB,QAAQ;AACR,+DAA+D;AAC/D,MAAM;AAEN,mCAAmC;AACnC,qDAAqD;AACrD,kCAAkC;AAClC,2BAA2B;AAC3B,gCAAgC;AAChC,uBAAuB;AACvB,2EAA2E;AAE3E,wCAAwC;AACxC,gEAAgE;AAChE,SAAS;AAET,gFAAgF;AAEhF,6DAA6D;AAC7D,6BAA6B;AAC7B,UAAU;AACV,MAAM;AAEN,gCAAgC;AAChC,mFAAmF;AACnF,kCAAkC;AAClC,qBAAqB;AACrB,+BAA+B;AAC/B,gFAAgF;AAEhF,qEAAqE;AACrE,4BAA4B;AAC5B,YAAY;AACZ,4BAA4B;AAC5B,uCAAuC;AACvC,UAAU;AAEV,gBAAgB;AAChB,8BAA8B;AAC9B,qDAAqD;AACrD,kCAAkC;AAClC,0CAA0C;AAC1C,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ent } from \"@eventstore/db-client\";\n// import {\n// EsAggregate,\n// Event,\n// Serializable,\n// closeable,\n// map,\n// Competitor,\n// EsChange,\n// EsFact,\n// EventStore,\n// Follower,\n// ProjectedStreamConfiguration,\n// } from \"@ddd-ts/core\";\n// import { Constructor } from \"@ddd-ts/types\";\n\n// process.env.DEBUG = \"esdb:*\";\n\n// (BigInt as any).prototype.toJSON = function () {\n// return this.toString();\n// };\n\n// export class ESDBEventStore extends EventStore {\n// client: EventStoreDBClient;\n// namespace: string;\n// constructor() {\n// super();\n// this.namespace = Math.random().toString().substring(2, 8);\n// this.client = new EventStoreDBClient(\n// { endpoint: { address: \"localhost\", port: 2113 } },\n// { insecure: true },\n// );\n// }\n\n// private readonly subscriptions = new Set<() => Promise<any>>();\n\n// async close() {\n// await Promise.all([...this.subscriptions.values()].map((s) => s()));\n// this.client.dispose();\n// }\n\n// async clear() {\n// this.namespace = Math.random().toString().substring(2, 8);\n// }\n\n// private getAggregateStreamName(\n// AGGREGATE: Constructor<EsAggregate<any, any>>,\n// id: string,\n// ) {\n// return this.namespace + \".\" + AGGREGATE.name + \"-\" + id;\n// }\n\n// async appendToAggregateStream(\n// AGGREGATE: Constructor<EsAggregate<any, any>>,\n// id: { toString(): string },\n// changes: EsChange[],\n// expectedRevision: bigint,\n// ): Promise<void> {\n// const r = expectedRevision === -1n ? \"no_stream\" : expectedRevision;\n\n// const events = changes.map((c) =>\n// jsonEvent({ id: c.id, type: c.type, data: c.payload }),\n// );\n\n// const streamName = this.getAggregateStreamName(AGGREGATE, id.toString());\n\n// await this.client.appendToStream(streamName, events, {\n// expectedRevision: r,\n// });\n// }\n\n// async *readAggregateStream(\n// AGGREGATE: Constructor<EsAggregate<{ toString(): string }, Event[]>, any[]>,\n// id: { toString(): string },\n// from?: bigint,\n// ): AsyncIterable<EsFact> {\n// const streamName = this.getAggregateStreamName(AGGREGATE, id.toString());\n\n// for await (const event of this.client.readStream(streamName, {\n// fromRevision: from,\n// })) {\n// if (!event.event) {\n// throw new Error(\"no event\");\n// }\n\n// yield {\n// id: event.event.id,\n// payload: event.event.data as Serializable,\n// type: event.event.type,\n// revision: event.event.revision,\n// };\n// }\n// }\n\n// private getProjectedStreamName(AGGREGATE: ProjectedStreamConfiguration[0]) {\n// return \"$ce-\" + this.namespace + \".\" + AGGREGATE.name;\n// }\n\n// private async ensureProjectedStream(config: ProjectedStreamConfiguration) {\n// if (config.length === 1) {\n// return this.getProjectedStreamName(config[0]);\n// }\n\n// const projectionNameSuffix = config\n// .map((a) => a.name)\n// .sort()\n// .join(\"-\");\n\n// const stableProjectionName =\n// this.namespace + \".\" + \"pj-\" + projectionNameSuffix;\n\n// const streams = config.map((a) => this.getProjectedStreamName(a));\n\n// const query = `\n// fromStreams(${streams\n// .map((s) => `'${s}'`)\n// .join(\n// \", \",\n// )}).when({ $any: function(state, event) { linkTo('${stableProjectionName}', event) }})\n// `;\n\n// await this.client.createProjection(stableProjectionName, query, {\n// emitEnabled: true,\n// });\n\n// let status;\n\n// let attempts = 0;\n// do {\n// status = await this.client.getProjectionStatus(stableProjectionName);\n// if (status.progress < 100) {\n// await new Promise((resolve) => setTimeout(resolve, 500));\n// }\n// attempts++;\n// if (attempts > 40) {\n// if (status.status === \"Running\") {\n// return stableProjectionName;\n// }\n// throw new Error(\n// \"projection not stable: \\n\" + JSON.stringify(status, null, 2),\n// );\n// }\n// } while (status.progress < 100);\n\n// return stableProjectionName;\n// }\n\n// async *readProjectedStream(\n// config: ProjectedStreamConfiguration,\n// from?: bigint,\n// ): AsyncIterable<EsFact> {\n// const stream = await this.ensureProjectedStream(config);\n\n// for await (const event of this.client.readStream(stream, {\n// fromRevision: from,\n// resolveLinkTos: true,\n// direction: \"forwards\",\n// })) {\n// if (!event.event) {\n// throw new Error(\"no event\");\n// }\n// if (!event.link) {\n// throw new Error(\"no link\");\n// }\n\n// yield {\n// id: event.event.id,\n// payload: event.event.data as Serializable,\n// type: event.event.type,\n// revision: event.link.revision,\n// };\n// }\n// }\n\n// async followProjectedStream(\n// AGGREGATE: ProjectedStreamConfiguration,\n// from: bigint = 0n,\n// ): Promise<Follower> {\n// const streamName = await this.ensureProjectedStream(AGGREGATE);\n\n// const position = from - 1n;\n// const fromRevision = position < 0n ? \"start\" : position;\n\n// const stream = this.client.subscribeToStream(streamName, {\n// fromRevision,\n// resolveLinkTos: true,\n// });\n\n// const hook = async () => void stream.destroy();\n\n// this.subscriptions.add(hook);\n\n// const mapped = map(stream, (e) => {\n// if (!e.event) {\n// throw new Error(\"no event\");\n// }\n// if (!e.link) {\n// throw new Error(\"no link\");\n// }\n// return {\n// id: e.event.id,\n// payload: e.event.data as Serializable,\n// type: e.event.type,\n// revision: e.link.revision,\n// };\n// });\n\n// return closeable(mapped, async () => {\n// await stream.unsubscribe();\n// this.subscriptions.delete(hook);\n// });\n// }\n\n// competeForProjectedStream(\n// AGGREGATE: ProjectedStreamConfiguration,\n// competitionName: string,\n// ): Promise<Competitor> {\n// throw new Error(\"Method not implemented.\");\n// }\n\n// // async competeForProjectedStream(\n// // AGGREGATE: ProjectedStreamConfiguration,\n// // competitionName: string\n// // ): Promise<Competitor> {\n// // const streamName = this.getProjectedStreamName(AGGREGATE);\n\n// // try {\n// // await this.client.createPersistentSubscriptionToStream(\n// // streamName,\n// // competitionName,\n// // persistentSubscriptionToStreamSettingsFromDefaults({\n// // resolveLinkTos: true,\n// // })\n// // );\n// // } catch (error: any) {\n// // if (\n// // isCommandError(error) &&\n// // error.type === ErrorType.PERSISTENT_SUBSCRIPTION_EXISTS\n// // ) {\n// // // do nothing and use the existing one\n// // } else {\n// // throw error;\n// // }\n// // }\n\n// // const sub = this.client.subscribeToPersistentSubscriptionToStream(\n// // streamName,\n// // competitionName\n// // );\n\n// // return closeable(\n// // map(sub, (event) => {\n// // if (!event.event) {\n// // throw new Error(follow\n// // \"[ESDB] listening projected stream : iterated over unreadable event\"\n// // );\n// // }\n// // const revision =\n// // event.link?.revision !== undefined ? event.link?.revision : undefined;\n\n// // if (revision === undefined) {\n// // throw new Error(\n// // \"[ESDB] listening projected stream : iterated over unreadable event\"\n// // );\n// // }\n// // return {\n// // fact: {\n// // id: event.event.id,\n// // type: event.event.type,\n// // payload: event.event.data as Serializable,\n// // revision,\n// // },\n// // succeed: async () => {\n// // await sub.ack(event);\n// // },\n// // retry: async () => {\n// // await sub.nack(\"retry\", \"unknown\", event);\n// // },\n// // skip: async () => {\n// // await sub.nack(\"skip\", \"unknown\", event);\n// // },\n// // };\n// // }),\n// // async () => {\n// // await sub.unsubscribe();\n// // }\n// // );\n// // }\n// }\n"]}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- // import { EsAggregateStoreSuite } from "@ddd-ts/tests";
3
- // import { ESDBEventStore } from "./esdb.event-store";
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- // describe.skip("ESDBEventStore", () => {
6
- // EsAggregateStoreSuite(new ESDBEventStore());
7
- // });
8
- it("should be tested", () => { });
9
- //# sourceMappingURL=esdb.event-store.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"esdb.event-store.spec.js","sourceRoot":"","sources":["../src/esdb.event-store.spec.ts"],"names":[],"mappings":";AAAA,yDAAyD;AACzD,uDAAuD;;AAEvD,0CAA0C;AAC1C,iDAAiD;AACjD,MAAM;AACN,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC","sourcesContent":["// import { EsAggregateStoreSuite } from \"@ddd-ts/tests\";\n// import { ESDBEventStore } from \"./esdb.event-store\";\n\n// describe.skip(\"ESDBEventStore\", () => {\n// EsAggregateStoreSuite(new ESDBEventStore());\n// });\nit(\"should be tested\", () => {});\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uDAAuD","sourcesContent":["// export { ESDBEventStore } from \"./esdb.event-store\";\n"]}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- // import { BankSuite } from "@ddd-ts/tests";
3
- // import { ESDBEventStore } from "../esdb.event-store";
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- // import {
6
- // InMemoryCheckpoint,
7
- // InMemorySnapshotter,
8
- // } from "@ddd-ts/event-sourcing-inmemory";
9
- // import { EsAggregatePersistorWithSnapshots } from "@ddd-ts/core";
10
- // import {
11
- // InMemoryDatabase,
12
- // InMemoryStore,
13
- // InMemoryTransactionPerformer,
14
- // } from "@ddd-ts/store-inmemory";
15
- // describe.skip("EventSourcingESDB", () => {
16
- // const es = new ESDBEventStore();
17
- // const database = new InMemoryDatabase();
18
- // const checkpoint = new InMemoryCheckpoint(database);
19
- // const transaction = new InMemoryTransactionPerformer(database);
20
- // BankSuite(
21
- // es,
22
- // checkpoint,
23
- // transaction,
24
- // (serializer, name) => {
25
- // const store = new InMemoryStore(name, database, serializer) as any;
26
- // return store;
27
- // },
28
- // (AGGREGATE, serializer, eventSerializers) => {
29
- // const persistor = class extends EsAggregatePersistorWithSnapshots(
30
- // AGGREGATE
31
- // ) { };
32
- // const snapshotter = new InMemorySnapshotter(database, serializer);
33
- // return new persistor(es, eventSerializers, snapshotter);
34
- // }
35
- // );
36
- // });
37
- it("should be tested", () => { });
38
- //# sourceMappingURL=bank.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bank.spec.js","sourceRoot":"","sources":["../../src/test/bank.spec.ts"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,wDAAwD;;AAExD,WAAW;AACX,wBAAwB;AACxB,yBAAyB;AACzB,4CAA4C;AAC5C,oEAAoE;AACpE,WAAW;AACX,sBAAsB;AACtB,mBAAmB;AACnB,kCAAkC;AAClC,mCAAmC;AAEnC,6CAA6C;AAC7C,qCAAqC;AACrC,6CAA6C;AAC7C,yDAAyD;AACzD,oEAAoE;AACpE,eAAe;AACf,UAAU;AACV,kBAAkB;AAClB,mBAAmB;AACnB,8BAA8B;AAC9B,4EAA4E;AAC5E,sBAAsB;AACtB,SAAS;AACT,qDAAqD;AACrD,2EAA2E;AAC3E,oBAAoB;AACpB,eAAe;AACf,2EAA2E;AAC3E,iEAAiE;AACjE,QAAQ;AACR,OAAO;AACP,MAAM;AACN,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC","sourcesContent":["// import { BankSuite } from \"@ddd-ts/tests\";\n// import { ESDBEventStore } from \"../esdb.event-store\";\n\n// import {\n// InMemoryCheckpoint,\n// InMemorySnapshotter,\n// } from \"@ddd-ts/event-sourcing-inmemory\";\n// import { EsAggregatePersistorWithSnapshots } from \"@ddd-ts/core\";\n// import {\n// InMemoryDatabase,\n// InMemoryStore,\n// InMemoryTransactionPerformer,\n// } from \"@ddd-ts/store-inmemory\";\n\n// describe.skip(\"EventSourcingESDB\", () => {\n// const es = new ESDBEventStore();\n// const database = new InMemoryDatabase();\n// const checkpoint = new InMemoryCheckpoint(database);\n// const transaction = new InMemoryTransactionPerformer(database);\n// BankSuite(\n// es,\n// checkpoint,\n// transaction,\n// (serializer, name) => {\n// const store = new InMemoryStore(name, database, serializer) as any;\n// return store;\n// },\n// (AGGREGATE, serializer, eventSerializers) => {\n// const persistor = class extends EsAggregatePersistorWithSnapshots(\n// AGGREGATE\n// ) { };\n// const snapshotter = new InMemorySnapshotter(database, serializer);\n// return new persistor(es, eventSerializers, snapshotter);\n// }\n// );\n// });\nit(\"should be tested\", () => {});\n"]}