@synode/adapter-composite 1.0.0

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,35 @@
1
+ Synode Proprietary License
2
+
3
+ Copyright (c) 2026 Digitl Cloud GmbH. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person or organization
6
+ obtaining a copy of this software and associated documentation files (the
7
+ "Software"), to use the Software for personal, internal, and commercial
8
+ purposes, subject to the following conditions:
9
+
10
+ 1. PERMITTED USE. You may use, copy, and modify the Software for your own
11
+ personal, internal, or commercial purposes.
12
+
13
+ 2. NO REDISTRIBUTION. You may not distribute, publish, sublicense, or
14
+ otherwise make the Software or any derivative works available to third
15
+ parties, whether in source code or compiled form, free of charge or for
16
+ a fee.
17
+
18
+ 3. NO RESALE. You may not sell, rent, lease, or otherwise commercially
19
+ exploit the Software itself as a standalone product or as part of a
20
+ software distribution.
21
+
22
+ 4. NO HOSTING AS A SERVICE. You may not offer the Software to third parties
23
+ as a hosted, managed, or software-as-a-service product where the primary
24
+ value derives from the Software.
25
+
26
+ 5. ATTRIBUTION. You must retain this license notice and copyright notice in
27
+ all copies or substantial portions of the Software.
28
+
29
+ 6. NO WARRANTY. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
30
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES
33
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35
+ OTHER DEALINGS IN THE SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,48 @@
1
+
2
+ //#region src/index.ts
3
+ /**
4
+ * Adapter that fans out events to multiple child adapters in parallel.
5
+ *
6
+ * Each call to {@link write} forwards the event to every child adapter
7
+ * concurrently. {@link close} tears down all children in parallel.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const composite = new CompositeAdapter([
12
+ * new ConsoleAdapter(),
13
+ * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),
14
+ * ]);
15
+ * await generate(journey, { users: 10, adapter: composite });
16
+ * await composite.close();
17
+ * ```
18
+ */
19
+ var CompositeAdapter = class {
20
+ adapters;
21
+ /**
22
+ * @param adapters - Child adapters to write to in parallel
23
+ */
24
+ constructor(adapters) {
25
+ this.adapters = adapters;
26
+ }
27
+ /**
28
+ * Writes a single event to all child adapters concurrently.
29
+ *
30
+ * @param event - The generated event to forward
31
+ * @returns A promise that resolves when all child writes complete
32
+ */
33
+ async write(event) {
34
+ await Promise.all(this.adapters.map(async (a) => a.write(event)));
35
+ }
36
+ /**
37
+ * Closes all child adapters concurrently.
38
+ *
39
+ * @returns A promise that resolves when all children have been closed
40
+ */
41
+ async close() {
42
+ await Promise.all(this.adapters.map(async (a) => a.close?.()));
43
+ }
44
+ };
45
+
46
+ //#endregion
47
+ exports.CompositeAdapter = CompositeAdapter;
48
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Event, OutputAdapter } from '@synode/core';\n\n/**\n * Adapter that fans out events to multiple child adapters in parallel.\n *\n * Each call to {@link write} forwards the event to every child adapter\n * concurrently. {@link close} tears down all children in parallel.\n *\n * @example\n * ```ts\n * const composite = new CompositeAdapter([\n * new ConsoleAdapter(),\n * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),\n * ]);\n * await generate(journey, { users: 10, adapter: composite });\n * await composite.close();\n * ```\n */\nexport class CompositeAdapter implements OutputAdapter {\n private adapters: OutputAdapter[];\n\n /**\n * @param adapters - Child adapters to write to in parallel\n */\n constructor(adapters: OutputAdapter[]) {\n this.adapters = adapters;\n }\n\n /**\n * Writes a single event to all child adapters concurrently.\n *\n * @param event - The generated event to forward\n * @returns A promise that resolves when all child writes complete\n */\n async write(event: Event): Promise<void> {\n await Promise.all(this.adapters.map(async (a) => a.write(event)));\n }\n\n /**\n * Closes all child adapters concurrently.\n *\n * @returns A promise that resolves when all children have been closed\n */\n async close(): Promise<void> {\n await Promise.all(this.adapters.map(async (a) => a.close?.()));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAa,mBAAb,MAAuD;CACrD,AAAQ;;;;CAKR,YAAY,UAA2B;AACrC,OAAK,WAAW;;;;;;;;CASlB,MAAM,MAAM,OAA6B;AACvC,QAAM,QAAQ,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC;;;;;;;CAQnE,MAAM,QAAuB;AAC3B,QAAM,QAAQ,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Event, OutputAdapter } from "@synode/core";
2
+
3
+ //#region src/index.d.ts
4
+
5
+ /**
6
+ * Adapter that fans out events to multiple child adapters in parallel.
7
+ *
8
+ * Each call to {@link write} forwards the event to every child adapter
9
+ * concurrently. {@link close} tears down all children in parallel.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const composite = new CompositeAdapter([
14
+ * new ConsoleAdapter(),
15
+ * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),
16
+ * ]);
17
+ * await generate(journey, { users: 10, adapter: composite });
18
+ * await composite.close();
19
+ * ```
20
+ */
21
+ declare class CompositeAdapter implements OutputAdapter {
22
+ private adapters;
23
+ /**
24
+ * @param adapters - Child adapters to write to in parallel
25
+ */
26
+ constructor(adapters: OutputAdapter[]);
27
+ /**
28
+ * Writes a single event to all child adapters concurrently.
29
+ *
30
+ * @param event - The generated event to forward
31
+ * @returns A promise that resolves when all child writes complete
32
+ */
33
+ write(event: Event): Promise<void>;
34
+ /**
35
+ * Closes all child adapters concurrently.
36
+ *
37
+ * @returns A promise that resolves when all children have been closed
38
+ */
39
+ close(): Promise<void>;
40
+ }
41
+ //#endregion
42
+ export { CompositeAdapter };
43
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,43 @@
1
+ import { Event, OutputAdapter } from "@synode/core";
2
+
3
+ //#region src/index.d.ts
4
+
5
+ /**
6
+ * Adapter that fans out events to multiple child adapters in parallel.
7
+ *
8
+ * Each call to {@link write} forwards the event to every child adapter
9
+ * concurrently. {@link close} tears down all children in parallel.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const composite = new CompositeAdapter([
14
+ * new ConsoleAdapter(),
15
+ * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),
16
+ * ]);
17
+ * await generate(journey, { users: 10, adapter: composite });
18
+ * await composite.close();
19
+ * ```
20
+ */
21
+ declare class CompositeAdapter implements OutputAdapter {
22
+ private adapters;
23
+ /**
24
+ * @param adapters - Child adapters to write to in parallel
25
+ */
26
+ constructor(adapters: OutputAdapter[]);
27
+ /**
28
+ * Writes a single event to all child adapters concurrently.
29
+ *
30
+ * @param event - The generated event to forward
31
+ * @returns A promise that resolves when all child writes complete
32
+ */
33
+ write(event: Event): Promise<void>;
34
+ /**
35
+ * Closes all child adapters concurrently.
36
+ *
37
+ * @returns A promise that resolves when all children have been closed
38
+ */
39
+ close(): Promise<void>;
40
+ }
41
+ //#endregion
42
+ export { CompositeAdapter };
43
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,47 @@
1
+ //#region src/index.ts
2
+ /**
3
+ * Adapter that fans out events to multiple child adapters in parallel.
4
+ *
5
+ * Each call to {@link write} forwards the event to every child adapter
6
+ * concurrently. {@link close} tears down all children in parallel.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const composite = new CompositeAdapter([
11
+ * new ConsoleAdapter(),
12
+ * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),
13
+ * ]);
14
+ * await generate(journey, { users: 10, adapter: composite });
15
+ * await composite.close();
16
+ * ```
17
+ */
18
+ var CompositeAdapter = class {
19
+ adapters;
20
+ /**
21
+ * @param adapters - Child adapters to write to in parallel
22
+ */
23
+ constructor(adapters) {
24
+ this.adapters = adapters;
25
+ }
26
+ /**
27
+ * Writes a single event to all child adapters concurrently.
28
+ *
29
+ * @param event - The generated event to forward
30
+ * @returns A promise that resolves when all child writes complete
31
+ */
32
+ async write(event) {
33
+ await Promise.all(this.adapters.map(async (a) => a.write(event)));
34
+ }
35
+ /**
36
+ * Closes all child adapters concurrently.
37
+ *
38
+ * @returns A promise that resolves when all children have been closed
39
+ */
40
+ async close() {
41
+ await Promise.all(this.adapters.map(async (a) => a.close?.()));
42
+ }
43
+ };
44
+
45
+ //#endregion
46
+ export { CompositeAdapter };
47
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Event, OutputAdapter } from '@synode/core';\n\n/**\n * Adapter that fans out events to multiple child adapters in parallel.\n *\n * Each call to {@link write} forwards the event to every child adapter\n * concurrently. {@link close} tears down all children in parallel.\n *\n * @example\n * ```ts\n * const composite = new CompositeAdapter([\n * new ConsoleAdapter(),\n * new FileAdapter({ path: './out/events.jsonl', format: 'jsonl' }),\n * ]);\n * await generate(journey, { users: 10, adapter: composite });\n * await composite.close();\n * ```\n */\nexport class CompositeAdapter implements OutputAdapter {\n private adapters: OutputAdapter[];\n\n /**\n * @param adapters - Child adapters to write to in parallel\n */\n constructor(adapters: OutputAdapter[]) {\n this.adapters = adapters;\n }\n\n /**\n * Writes a single event to all child adapters concurrently.\n *\n * @param event - The generated event to forward\n * @returns A promise that resolves when all child writes complete\n */\n async write(event: Event): Promise<void> {\n await Promise.all(this.adapters.map(async (a) => a.write(event)));\n }\n\n /**\n * Closes all child adapters concurrently.\n *\n * @returns A promise that resolves when all children have been closed\n */\n async close(): Promise<void> {\n await Promise.all(this.adapters.map(async (a) => a.close?.()));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,IAAa,mBAAb,MAAuD;CACrD,AAAQ;;;;CAKR,YAAY,UAA2B;AACrC,OAAK,WAAW;;;;;;;;CASlB,MAAM,MAAM,OAA6B;AACvC,QAAM,QAAQ,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC;;;;;;;CAQnE,MAAM,QAAuB;AAC3B,QAAM,QAAQ,IAAI,KAAK,SAAS,IAAI,OAAO,MAAM,EAAE,SAAS,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@synode/adapter-composite",
3
+ "version": "1.0.0",
4
+ "description": "Composite adapter for Synode",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.mts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.mts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "author": "Digitl Cloud GmbH",
20
+ "license": "SEE LICENSE IN LICENSE",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/digitl-cloud/synode",
24
+ "directory": "packages/adapter-composite"
25
+ },
26
+ "peerDependencies": {
27
+ "@synode/core": "^1.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^24.12.0",
31
+ "eslint": "^9.39.4",
32
+ "eslint-config-prettier": "^10.1.8",
33
+ "typescript-eslint": "^8.58.0",
34
+ "tsdown": "^0.16.8",
35
+ "typescript": "^5.9.3",
36
+ "vitest": "^4.1.2",
37
+ "@synode/core": "1.0.0"
38
+ },
39
+ "scripts": {
40
+ "build": "tsdown",
41
+ "test": "vitest run",
42
+ "lint": "eslint src tests"
43
+ }
44
+ }