@6qat/tcp-connection 0.2.3 → 0.2.6
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/README.md +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -19
- package/dist/m-cedro/src/tcp-stream.d.ts +31 -0
- package/dist/tcp-connection/src/index.d.ts +1 -0
- package/dist/tcp-connection/src/tcp-connection.d.ts +38 -0
- package/dist/tcp-connection/src/tcp-connection.test.d.ts +1 -0
- package/dist/tcp-connection/src/tcp-stream.d.ts +38 -0
- package/dist/tcp-connection/src/utils.d.ts +3 -0
- package/dist/tcp-connection.d.ts +26 -21
- package/dist/tcp-stream.d.ts +34 -8
- package/dist/utils.d.ts +3 -0
- package/package.json +28 -10
- /package/dist/{tcp-connection.test.d.ts → lab-effect/src/log-level.d.ts} +0 -0
|
@@ -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>;
|
package/dist/tcp-connection.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Effect,
|
|
2
|
-
import type { TimeoutException } from 'effect/Cause';
|
|
1
|
+
import { Context, Effect, Layer, Runtime, Stream } from 'effect';
|
|
3
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 & {
|
|
4
3
|
readonly _tag: "TcpConnectionError";
|
|
5
4
|
} & Readonly<A>;
|
|
@@ -7,27 +6,33 @@ export declare class TcpConnectionError extends TcpConnectionError_base {
|
|
|
7
6
|
readonly errorType?: string | undefined;
|
|
8
7
|
constructor(errorType?: string | undefined);
|
|
9
8
|
}
|
|
10
|
-
export declare class
|
|
9
|
+
export declare class TcpConnectionTimeoutError extends TcpConnectionError {
|
|
11
10
|
readonly message: string;
|
|
12
|
-
readonly errorType = "BunError";
|
|
13
11
|
constructor(message: string);
|
|
14
12
|
}
|
|
15
|
-
export
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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>;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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>;
|
|
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 {
|
|
32
36
|
}
|
|
33
|
-
|
|
37
|
+
declare const TcpConnectionLive: Layer.Layer<TcpConnection, TcpConnectionError, TcpConfig>;
|
|
38
|
+
export { TcpConfig, TcpConnection, TcpConnectionLive };
|
package/dist/tcp-stream.d.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { Effect,
|
|
2
|
-
|
|
3
|
-
readonly
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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 {};
|
package/dist/utils.d.ts
ADDED
|
@@ -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,30 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@6qat/tcp-connection",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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": [
|
|
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
|
|
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": "
|
|
25
|
+
"test": "vitest run --passWithNoTests",
|
|
16
26
|
"format": "biome format --write ./src",
|
|
17
27
|
"lint": "biome lint ."
|
|
18
28
|
},
|
|
19
|
-
"keywords": [
|
|
29
|
+
"keywords": [
|
|
30
|
+
"tcp",
|
|
31
|
+
"connection",
|
|
32
|
+
"effect",
|
|
33
|
+
"bun"
|
|
34
|
+
],
|
|
20
35
|
"author": "Your Name",
|
|
21
36
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@effect/platform-bun": "^0.87.0",
|
|
39
|
+
"@effect/platform-node": "^0.104.0",
|
|
40
|
+
"effect": "3.19.14"
|
|
25
41
|
},
|
|
26
|
-
"
|
|
27
|
-
"effect": "^
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@effect/language-service": "^0.63.2",
|
|
44
|
+
"@types/bun": "^1.3.5",
|
|
45
|
+
"typescript": "^5.9.3"
|
|
28
46
|
},
|
|
29
47
|
"publishConfig": {
|
|
30
48
|
"access": "public"
|
|
File without changes
|