@6qat/tcp-connection 0.2.4 → 0.2.7

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.
@@ -0,0 +1,31 @@
1
+ import { Context, Effect, Layer, Stream } from 'effect';
2
+ interface TcpStreamShape {
3
+ readonly stream: Stream.Stream<Uint8Array, Error>;
4
+ readonly send: (data: Uint8Array) => Effect.Effect<void>;
5
+ readonly sendText: (data: string) => Effect.Effect<void>;
6
+ readonly close: Effect.Effect<void>;
7
+ }
8
+ declare const TcpStream_base: Context.TagClass<TcpStream, "TcpStream", TcpStreamShape>;
9
+ declare class TcpStream extends TcpStream_base {
10
+ }
11
+ /**
12
+ * ConnectionConfigShape is an interface that defines the shape of the data
13
+ * needed to connect to the Cedro server.
14
+ */
15
+ interface ConnectionConfigShape {
16
+ host: string;
17
+ port: number;
18
+ magicToken?: string;
19
+ username?: string;
20
+ password?: string;
21
+ tickers?: string[];
22
+ }
23
+ declare const ConnectionConfig_base: Context.TagClass<ConnectionConfig, "ConnectionConfig", ConnectionConfigShape>;
24
+ /**
25
+ * ConnectionConfig is a Context.Tag that provides the connection configuration.
26
+ */
27
+ declare class ConnectionConfig extends ConnectionConfig_base {
28
+ }
29
+ declare const TcpStreamLive: () => Layer.Layer<TcpStream, Error, ConnectionConfig>;
30
+ declare const ConnectionConfigLive: (host: string, port: number, tickers: string[], magicToken: string, username: string, password: string) => Layer.Layer<ConnectionConfig, never, never>;
31
+ export { ConnectionConfig, ConnectionConfigLive, TcpStream, TcpStreamLive };
@@ -0,0 +1 @@
1
+ export * from './tcp-stream';
@@ -0,0 +1,38 @@
1
+ import { Context, Effect, Layer, Runtime, Stream } from 'effect';
2
+ declare const TcpConnectionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "TcpConnectionError";
4
+ } & Readonly<A>;
5
+ export declare class TcpConnectionError extends TcpConnectionError_base {
6
+ readonly errorType?: string | undefined;
7
+ constructor(errorType?: string | undefined);
8
+ }
9
+ export declare class TcpConnectionTimeoutError extends TcpConnectionError {
10
+ readonly message: string;
11
+ constructor(message: string);
12
+ }
13
+ export declare class TcpConnectionWriteError extends TcpConnectionError {
14
+ readonly message: string;
15
+ constructor(message: string);
16
+ }
17
+ export declare class TcpConnectionCloseError extends TcpConnectionError {
18
+ readonly message: string;
19
+ constructor(message: string);
20
+ }
21
+ declare const TcpConnection_base: Context.TagClass<TcpConnection, "TcpConnection", TcpConnectionShape>;
22
+ declare class TcpConnection extends TcpConnection_base {
23
+ }
24
+ interface TcpConnectionShape {
25
+ readonly incoming: Stream.Stream<Uint8Array, TcpConnectionError>;
26
+ readonly send: (data: Uint8Array) => Effect.Effect<void, TcpConnectionError>;
27
+ readonly sendWithRetry: (data: Uint8Array) => Effect.Effect<void, TcpConnectionError>;
28
+ }
29
+ declare const TcpConfig_base: Context.TagClass<TcpConfig, "TcpConfig", {
30
+ host: string;
31
+ port: number;
32
+ bufferSize?: number;
33
+ runtimeEffect?: Effect.Effect<Runtime.Runtime<never>, never, never>;
34
+ }>;
35
+ declare class TcpConfig extends TcpConfig_base {
36
+ }
37
+ declare const TcpConnectionLive: Layer.Layer<TcpConnection, TcpConnectionError, TcpConfig>;
38
+ export { TcpConfig, TcpConnection, TcpConnectionLive };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { Context, Effect, Layer, Stream } from 'effect';
2
+ declare const TcpStreamError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "TcpStreamError";
4
+ } & Readonly<A>;
5
+ export declare class TcpStreamError extends TcpStreamError_base<{
6
+ readonly message: string;
7
+ }> {
8
+ }
9
+ interface TcpStreamShape {
10
+ readonly stream: Stream.Stream<Uint8Array, TcpStreamError>;
11
+ readonly send: (data: Uint8Array) => Effect.Effect<void, TcpStreamError>;
12
+ readonly sendText: (data: string) => Effect.Effect<void, TcpStreamError>;
13
+ readonly close: Effect.Effect<void>;
14
+ }
15
+ declare const TcpStream_base: Context.TagClass<TcpStream, "TcpStream", TcpStreamShape>;
16
+ declare class TcpStream extends TcpStream_base {
17
+ }
18
+ /**
19
+ * ConnectionConfigShape is an interface that defines the shape of the data
20
+ * needed to connect to the server.
21
+ */
22
+ interface ConnectionConfigShape {
23
+ host: string;
24
+ port: number;
25
+ magicToken?: string;
26
+ username?: string;
27
+ password?: string;
28
+ tickers?: string[];
29
+ }
30
+ declare const ConnectionConfig_base: Context.TagClass<ConnectionConfig, "ConnectionConfig", ConnectionConfigShape>;
31
+ /**
32
+ * ConnectionConfig is a Context.Tag that provides the connection configuration.
33
+ */
34
+ declare class ConnectionConfig extends ConnectionConfig_base {
35
+ }
36
+ declare const TcpStreamLive: () => Layer.Layer<TcpStream, import("effect/Cause").UnknownException | import("effect/Cause").TimeoutException | TcpStreamError, ConnectionConfig>;
37
+ declare const ConnectionConfigLive: (host: string, port: number, tickers: string[], magicToken: string, username: string, password: string) => Layer.Layer<ConnectionConfig, never, never>;
38
+ export { ConnectionConfig, ConnectionConfigLive, TcpStream, TcpStreamLive };
@@ -0,0 +1,3 @@
1
+ import { Effect } from 'effect';
2
+ export declare const ping: (send: (data: Uint8Array) => Effect.Effect<void, never, never>) => Effect.Effect<import("effect/Fiber").RuntimeFiber<number, never>, never, never>;
3
+ export declare const sendWithRetry: (send: (data: Uint8Array) => Effect.Effect<void, never, never>, data: Uint8Array) => Effect.Effect<void, never, never>;
@@ -0,0 +1,38 @@
1
+ import { Context, Effect, Layer, Runtime, Stream } from 'effect';
2
+ declare const TcpConnectionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "TcpConnectionError";
4
+ } & Readonly<A>;
5
+ export declare class TcpConnectionError extends TcpConnectionError_base {
6
+ readonly errorType?: string | undefined;
7
+ constructor(errorType?: string | undefined);
8
+ }
9
+ export declare class TcpConnectionTimeoutError extends TcpConnectionError {
10
+ readonly message: string;
11
+ constructor(message: string);
12
+ }
13
+ export declare class TcpConnectionWriteError extends TcpConnectionError {
14
+ readonly message: string;
15
+ constructor(message: string);
16
+ }
17
+ export declare class TcpConnectionCloseError extends TcpConnectionError {
18
+ readonly message: string;
19
+ constructor(message: string);
20
+ }
21
+ declare const TcpConnection_base: Context.TagClass<TcpConnection, "TcpConnection", TcpConnectionShape>;
22
+ declare class TcpConnection extends TcpConnection_base {
23
+ }
24
+ interface TcpConnectionShape {
25
+ readonly incoming: Stream.Stream<Uint8Array, TcpConnectionError>;
26
+ readonly send: (data: Uint8Array) => Effect.Effect<void, TcpConnectionError>;
27
+ readonly sendWithRetry: (data: Uint8Array) => Effect.Effect<void, TcpConnectionError>;
28
+ }
29
+ declare const TcpConfig_base: Context.TagClass<TcpConfig, "TcpConfig", {
30
+ host: string;
31
+ port: number;
32
+ bufferSize?: number;
33
+ runtimeEffect?: Effect.Effect<Runtime.Runtime<never>, never, never>;
34
+ }>;
35
+ declare class TcpConfig extends TcpConfig_base {
36
+ }
37
+ declare const TcpConnectionLive: Layer.Layer<TcpConnection, TcpConnectionError, TcpConfig>;
38
+ export { TcpConfig, TcpConnection, TcpConnectionLive };
@@ -1,33 +1,38 @@
1
- import { Effect, Stream, Duration } from 'effect';
2
- import type { TimeoutException } from 'effect/Cause';
3
- declare const TcpConnectionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
4
- readonly _tag: "TcpConnectionError";
1
+ import { Context, Effect, Layer, Stream } from 'effect';
2
+ declare const TcpStreamError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "TcpStreamError";
5
4
  } & Readonly<A>;
6
- export declare class TcpConnectionError extends TcpConnectionError_base {
7
- readonly errorType?: string | undefined;
8
- constructor(errorType?: string | undefined);
9
- }
10
- export declare class BunError extends TcpConnectionError {
5
+ export declare class TcpStreamError extends TcpStreamError_base<{
11
6
  readonly message: string;
12
- readonly errorType = "BunError";
13
- constructor(message: string);
7
+ }> {
8
+ }
9
+ interface TcpStreamShape {
10
+ readonly stream: Stream.Stream<Uint8Array, TcpStreamError>;
11
+ readonly send: (data: Uint8Array) => Effect.Effect<void, TcpStreamError>;
12
+ readonly sendText: (data: string) => Effect.Effect<void, TcpStreamError>;
13
+ readonly close: Effect.Effect<void>;
14
+ }
15
+ declare const TcpStream_base: Context.TagClass<TcpStream, "TcpStream", TcpStreamShape>;
16
+ export declare class TcpStream extends TcpStream_base {
14
17
  }
15
- export interface TcpStreamConfig {
16
- readonly host: string;
17
- readonly port: number;
18
- readonly bufferSize?: number;
19
- readonly connectTimeout?: Duration.DurationInput;
18
+ /**
19
+ * ConnectionConfigShape is an interface that defines the shape of the data
20
+ * needed to connect to the server.
21
+ */
22
+ interface ConnectionConfigShape {
23
+ host: string;
24
+ port: number;
25
+ magicToken?: string;
26
+ username?: string;
27
+ password?: string;
28
+ tickers?: string[];
20
29
  }
21
- export declare class TcpStream {
22
- private readonly incomingQueue;
23
- private readonly outgoingQueue;
24
- private readonly performShutdown;
25
- private constructor();
26
- static connect(config: TcpStreamConfig): Effect.Effect<TcpStream, TcpConnectionError | TimeoutException>;
27
- get incomingStream(): Stream.Stream<Uint8Array, TcpConnectionError>;
28
- write(data: Uint8Array): Effect.Effect<boolean, TcpConnectionError>;
29
- writeText(data: string): Effect.Effect<boolean, TcpConnectionError>;
30
- close(): Effect.Effect<void>;
31
- static managedStream(config: TcpStreamConfig): Stream.Stream<Uint8Array, TcpConnectionError | TimeoutException>;
30
+ declare const ConnectionConfig_base: Context.TagClass<ConnectionConfig, "ConnectionConfig", ConnectionConfigShape>;
31
+ /**
32
+ * ConnectionConfig is a Context.Tag that provides the connection configuration.
33
+ */
34
+ export declare class ConnectionConfig extends ConnectionConfig_base {
32
35
  }
36
+ export declare const TcpStreamLive: () => Layer.Layer<TcpStream, TcpStreamError | import("effect/Cause").UnknownException | import("effect/Cause").TimeoutException, ConnectionConfig>;
37
+ export declare const ConnectionConfigLive: (host: string, port: number, tickers: string[], magicToken: string, username: string, password: string) => Layer.Layer<ConnectionConfig, never, never>;
33
38
  export {};
@@ -1,12 +1,38 @@
1
- import { Effect, Stream, Duration } from 'effect';
2
- export interface TcpConnection {
3
- readonly stream: Stream.Stream<Uint8Array, Error>;
4
- readonly send: (data: Uint8Array) => Effect.Effect<void>;
5
- readonly sendText: (data: string) => Effect.Effect<void>;
1
+ import { Context, Effect, Layer, Stream } from 'effect';
2
+ declare const TcpStreamError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "TcpStreamError";
4
+ } & Readonly<A>;
5
+ export declare class TcpStreamError extends TcpStreamError_base<{
6
+ readonly message: string;
7
+ }> {
8
+ }
9
+ interface TcpStreamShape {
10
+ readonly stream: Stream.Stream<Uint8Array, TcpStreamError>;
11
+ readonly send: (data: Uint8Array) => Effect.Effect<void, TcpStreamError>;
12
+ readonly sendText: (data: string) => Effect.Effect<void, TcpStreamError>;
6
13
  readonly close: Effect.Effect<void>;
7
14
  }
8
- export declare const createTcpConnection: (options: {
15
+ declare const TcpStream_base: Context.TagClass<TcpStream, "TcpStream", TcpStreamShape>;
16
+ export declare class TcpStream extends TcpStream_base {
17
+ }
18
+ /**
19
+ * ConnectionConfigShape is an interface that defines the shape of the data
20
+ * needed to connect to the server.
21
+ */
22
+ interface ConnectionConfigShape {
9
23
  host: string;
10
24
  port: number;
11
- timeout?: Duration.Duration;
12
- }) => Effect.Effect<TcpConnection, Error>;
25
+ magicToken?: string;
26
+ username?: string;
27
+ password?: string;
28
+ tickers?: string[];
29
+ }
30
+ declare const ConnectionConfig_base: Context.TagClass<ConnectionConfig, "ConnectionConfig", ConnectionConfigShape>;
31
+ /**
32
+ * ConnectionConfig is a Context.Tag that provides the connection configuration.
33
+ */
34
+ export declare class ConnectionConfig extends ConnectionConfig_base {
35
+ }
36
+ export declare const TcpStreamLive: () => Layer.Layer<TcpStream, TcpStreamError | import("effect/Cause").UnknownException | import("effect/Cause").TimeoutException, ConnectionConfig>;
37
+ export declare const ConnectionConfigLive: (host: string, port: number, tickers: string[], magicToken: string, username: string, password: string) => Layer.Layer<ConnectionConfig, never, never>;
38
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Effect } from 'effect';
2
+ export declare const ping: (send: (data: Uint8Array) => Effect.Effect<void, never, never>) => Effect.Effect<import("effect/Fiber").RuntimeFiber<number, never>, never, never>;
3
+ export declare const sendWithRetry: (send: (data: Uint8Array) => Effect.Effect<void, never, never>, data: Uint8Array) => Effect.Effect<void, never, never>;
package/package.json CHANGED
@@ -1,32 +1,49 @@
1
1
  {
2
2
  "name": "@6qat/tcp-connection",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "TCP connection library with Effect.js integration",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "type": "module",
9
- "files": ["dist", "README.md"],
9
+ "files": [
10
+ "dist",
11
+ "README.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
10
20
  "scripts": {
11
- "build:main": "bun build --minify-syntax --minify-whitespace ./src/index.ts --outdir ./dist --target node --format esm",
21
+ "build:main": "bun build --minify-syntax --minify-whitespace ./src/index.ts --outdir ./dist --target bun --format esm",
12
22
  "build:types": "bun tsc --emitDeclarationOnly --outDir dist",
13
23
  "build": "bun run build:main && bun run build:types",
14
24
  "prepublishOnly": "bun run build",
15
- "test": "bun test",
25
+ "test": "vitest run --passWithNoTests",
16
26
  "format": "biome format --write ./src",
17
27
  "lint": "biome lint ."
18
28
  },
19
- "keywords": ["tcp", "connection", "effect", "bun"],
29
+ "keywords": [
30
+ "tcp",
31
+ "connection",
32
+ "effect",
33
+ "bun"
34
+ ],
20
35
  "author": "Your Name",
21
36
  "license": "MIT",
22
37
  "dependencies": {
23
- "effect": "^3.14.21"
38
+ "@effect/platform-bun": "^0.87.0",
39
+ "@effect/platform-node": "^0.104.0",
40
+ "effect": "3.19.14"
24
41
  },
25
42
  "devDependencies": {
26
- "@types/bun": "^1.2.11",
27
- "typescript": "^5.8.3"
43
+ "@effect/language-service": "^0.63.2",
44
+ "@types/bun": "^1.3.5",
45
+ "typescript": "^5.9.3"
28
46
  },
29
- "peerDependencies": {},
30
47
  "publishConfig": {
31
48
  "access": "public"
32
49
  }