@effect-ak/tg-bot-client 0.2.0 → 0.2.2
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/dist/index.d.ts +2821 -0
- package/dist/index.js +462 -0
- package/dist/index.mjs +418 -0
- package/package.json +15 -16
- package/readme.md +1 -1
- package/dist/cjs/bot/factory/_service.js +0 -20
- package/dist/cjs/bot/factory/client-config.js +0 -29
- package/dist/cjs/bot/factory/make-bot.js +0 -20
- package/dist/cjs/bot/message-handler/_service.js +0 -12
- package/dist/cjs/bot/message-handler/types.js +0 -5
- package/dist/cjs/bot/message-handler/utils.js +0 -19
- package/dist/cjs/bot/run.js +0 -10
- package/dist/cjs/bot/update-poller/_service.js +0 -39
- package/dist/cjs/bot/update-poller/errors.js +0 -5
- package/dist/cjs/bot/update-poller/fetch-updates.js +0 -70
- package/dist/cjs/bot/update-poller/poll-and-handle.js +0 -50
- package/dist/cjs/bot/update-poller/settings.js +0 -23
- package/dist/cjs/client/_client.js +0 -25
- package/dist/cjs/client/config.js +0 -17
- package/dist/cjs/client/errors.js +0 -18
- package/dist/cjs/client/execute-request/_service.js +0 -20
- package/dist/cjs/client/execute-request/execute.js +0 -59
- package/dist/cjs/client/execute-request/payload.js +0 -24
- package/dist/cjs/client/file/_service.js +0 -22
- package/dist/cjs/client/file/get-file.js +0 -38
- package/dist/cjs/client/guards.js +0 -12
- package/dist/cjs/const.js +0 -20
- package/dist/cjs/index.js +0 -60
- package/dist/cjs/specification/api.js +0 -5
- package/dist/cjs/specification/types.js +0 -5
- package/dist/dts/bot/factory/_service.d.ts +0 -37
- package/dist/dts/bot/factory/client-config.d.ts +0 -3
- package/dist/dts/bot/factory/make-bot.d.ts +0 -7
- package/dist/dts/bot/message-handler/_service.d.ts +0 -6
- package/dist/dts/bot/message-handler/types.d.ts +0 -16
- package/dist/dts/bot/message-handler/utils.d.ts +0 -6
- package/dist/dts/bot/run.d.ts +0 -7
- package/dist/dts/bot/update-poller/_service.d.ts +0 -21
- package/dist/dts/bot/update-poller/errors.d.ts +0 -1
- package/dist/dts/bot/update-poller/fetch-updates.d.ts +0 -17
- package/dist/dts/bot/update-poller/poll-and-handle.d.ts +0 -16
- package/dist/dts/bot/update-poller/settings.d.ts +0 -6
- package/dist/dts/client/_client.d.ts +0 -8
- package/dist/dts/client/config.d.ts +0 -8
- package/dist/dts/client/errors.d.ts +0 -23
- package/dist/dts/client/execute-request/_service.d.ts +0 -15
- package/dist/dts/client/execute-request/execute.d.ts +0 -5
- package/dist/dts/client/execute-request/payload.d.ts +0 -1
- package/dist/dts/client/file/_service.d.ts +0 -16
- package/dist/dts/client/file/get-file.d.ts +0 -5
- package/dist/dts/client/guards.d.ts +0 -17
- package/dist/dts/const.d.ts +0 -12
- package/dist/dts/index.d.ts +0 -5
- package/dist/dts/specification/api.d.ts +0 -1030
- package/dist/dts/specification/types.d.ts +0 -1663
- package/dist/esm/bot/factory/_service.js +0 -12
- package/dist/esm/bot/factory/client-config.js +0 -20
- package/dist/esm/bot/factory/make-bot.js +0 -9
- package/dist/esm/bot/message-handler/_service.js +0 -4
- package/dist/esm/bot/message-handler/types.js +0 -1
- package/dist/esm/bot/message-handler/utils.js +0 -12
- package/dist/esm/bot/run.js +0 -6
- package/dist/esm/bot/update-poller/_service.js +0 -31
- package/dist/esm/bot/update-poller/errors.js +0 -1
- package/dist/esm/bot/update-poller/fetch-updates.js +0 -49
- package/dist/esm/bot/update-poller/poll-and-handle.js +0 -37
- package/dist/esm/bot/update-poller/settings.js +0 -15
- package/dist/esm/client/_client.js +0 -16
- package/dist/esm/client/config.js +0 -8
- package/dist/esm/client/errors.js +0 -9
- package/dist/esm/client/execute-request/_service.js +0 -12
- package/dist/esm/client/execute-request/execute.js +0 -37
- package/dist/esm/client/execute-request/payload.js +0 -21
- package/dist/esm/client/file/_service.js +0 -14
- package/dist/esm/client/file/get-file.js +0 -24
- package/dist/esm/client/guards.js +0 -7
- package/dist/esm/const.js +0 -13
- package/dist/esm/index.js +0 -5
- package/dist/esm/specification/api.js +0 -1
- package/dist/esm/specification/types.js +0 -1
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BotMessageHandlerSettings } from "../../bot/message-handler/types.js";
|
|
2
|
-
export type SafeSettings = ReturnType<typeof makeSettingsFrom>;
|
|
3
|
-
export declare const makeSettingsFrom: (input: BotMessageHandlerSettings) => {
|
|
4
|
-
readonly limit: number;
|
|
5
|
-
readonly timeout: number;
|
|
6
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ClientFileServiceInterface } from "./file/_service.js";
|
|
2
|
-
import { Api } from "../specification/api.js";
|
|
3
|
-
import type { TgBotClientSettingsInput } from "./guards.js";
|
|
4
|
-
export type TgBotClient = ReturnType<typeof makeTgBotClient>;
|
|
5
|
-
export declare const makeTgBotClient: (input: TgBotClientSettingsInput) => {
|
|
6
|
-
execute: <M extends keyof Api>(method: M, input: Parameters<Api[M]>[0]) => Promise<ReturnType<Api[M]>>;
|
|
7
|
-
getFile: (input: Parameters<ClientFileServiceInterface["getFile"]>[0]) => Promise<File>;
|
|
8
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as Context from "effect/Context";
|
|
2
|
-
import { TgBotClientSettingsInput } from "./guards.js";
|
|
3
|
-
export type TgBotClientConfigObject = Required<TgBotClientSettingsInput>;
|
|
4
|
-
export declare const makeTgBotClientConfig: (input: TgBotClientSettingsInput) => Required<TgBotClientSettingsInput>;
|
|
5
|
-
declare const TgBotClientConfig_base: Context.TagClass<TgBotClientConfig, "TgBotClientConfig", Required<TgBotClientSettingsInput>>;
|
|
6
|
-
export declare class TgBotClientConfig extends TgBotClientConfig_base {
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type ErrorReason = {
|
|
2
|
-
readonly type: "NotOkResponse";
|
|
3
|
-
readonly errorCode?: number;
|
|
4
|
-
readonly details?: string;
|
|
5
|
-
} | {
|
|
6
|
-
readonly type: "UnexpectedResponse";
|
|
7
|
-
readonly response: unknown;
|
|
8
|
-
} | {
|
|
9
|
-
readonly type: "ClientInternalError";
|
|
10
|
-
readonly cause: unknown;
|
|
11
|
-
} | {
|
|
12
|
-
readonly type: "UnableToGetFile";
|
|
13
|
-
readonly cause: unknown;
|
|
14
|
-
};
|
|
15
|
-
declare const TgBotClientError_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 & {
|
|
16
|
-
readonly _tag: "TgBotClientError";
|
|
17
|
-
} & Readonly<A>;
|
|
18
|
-
export declare class TgBotClientError extends TgBotClientError_base<{
|
|
19
|
-
reason: ErrorReason;
|
|
20
|
-
}> {
|
|
21
|
-
static readonly missingSuccess: TgBotClientError;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as Micro from "effect/Micro";
|
|
2
|
-
import * as Context from "effect/Context";
|
|
3
|
-
import type { Api } from "../../specification/api.js";
|
|
4
|
-
import { TgBotClientError } from "../errors.js";
|
|
5
|
-
import { TgBotClientConfig } from "../config.js";
|
|
6
|
-
export type ClientExecuteRequestServiceInterface = Micro.Micro.Success<typeof ClientExecuteRequestServiceDefault>;
|
|
7
|
-
declare const ClientExecuteRequestService_base: Context.TagClass<ClientExecuteRequestService, "ClientExecuteRequestService", {
|
|
8
|
-
execute: <M extends keyof Api>(method: M, input: Parameters<Api[M]>[0]) => Micro.Micro<ReturnType<Api[M]>, TgBotClientError>;
|
|
9
|
-
}>;
|
|
10
|
-
export declare class ClientExecuteRequestService extends ClientExecuteRequestService_base {
|
|
11
|
-
}
|
|
12
|
-
export declare const ClientExecuteRequestServiceDefault: Micro.Micro<{
|
|
13
|
-
readonly execute: <M extends keyof Api>(method: M, input: Parameters<Api[M]>[0]) => Micro.Micro<ReturnType<Api[M]>, TgBotClientError, never>;
|
|
14
|
-
}, never, TgBotClientConfig>;
|
|
15
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Micro from "effect/Micro";
|
|
2
|
-
import type { Api } from "../../specification/api.js";
|
|
3
|
-
import { TgBotClientError } from "../errors.js";
|
|
4
|
-
import { TgBotClientConfigObject } from "../config.js";
|
|
5
|
-
export declare const execute: <M extends keyof Api>(config: TgBotClientConfigObject, method: M, input: Parameters<Api[M]>[0]) => Micro.Micro<ReturnType<Api[M]>, TgBotClientError>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const makePayload: (body: object) => FormData | undefined;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Micro from "effect/Micro";
|
|
2
|
-
import * as Context from "effect/Context";
|
|
3
|
-
import { TgBotClientConfig } from "../config.js";
|
|
4
|
-
import { getFile } from "./get-file.js";
|
|
5
|
-
export type ClientFileServiceInterface = Context.Tag.Service<typeof ClientFileService>;
|
|
6
|
-
declare const ClientFileService_base: Context.TagClass<ClientFileService, "ClientFileService", {
|
|
7
|
-
getFile: (input: {
|
|
8
|
-
file_id: string;
|
|
9
|
-
}) => ReturnType<typeof getFile>;
|
|
10
|
-
}>;
|
|
11
|
-
export declare class ClientFileService extends ClientFileService_base {
|
|
12
|
-
}
|
|
13
|
-
export declare const ClientFileServiceDefault: Micro.Micro<{
|
|
14
|
-
readonly getFile: (input: Parameters<ClientFileServiceInterface["getFile"]>[0]) => Micro.Micro<File, import("../errors.js").TgBotClientError, never>;
|
|
15
|
-
}, never, TgBotClientConfig>;
|
|
16
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Micro from "effect/Micro";
|
|
2
|
-
import { TgBotClientError } from "../errors.js";
|
|
3
|
-
import { TgBotClientConfigObject } from "../config.js";
|
|
4
|
-
import { ClientExecuteRequestServiceInterface } from "../execute-request/_service.js";
|
|
5
|
-
export declare const getFile: (fileId: string, config: TgBotClientConfigObject, execute: ClientExecuteRequestServiceInterface) => Micro.Micro<File, TgBotClientError>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type FileContent = {
|
|
2
|
-
file_content: Uint8Array;
|
|
3
|
-
file_name: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const isFileContent: (input: unknown) => input is FileContent;
|
|
6
|
-
export type TgBotApiResponseSchema = {
|
|
7
|
-
ok: boolean;
|
|
8
|
-
error_code?: number;
|
|
9
|
-
description?: string;
|
|
10
|
-
result?: unknown;
|
|
11
|
-
};
|
|
12
|
-
export declare const isTgBotApiResponse: (input: unknown) => input is TgBotApiResponseSchema;
|
|
13
|
-
export type TgBotClientSettingsInput = {
|
|
14
|
-
["bot-token"]: string;
|
|
15
|
-
["base-url"]?: string;
|
|
16
|
-
};
|
|
17
|
-
export declare const isTgBotClientSettingsInput: (input: unknown) => input is TgBotClientSettingsInput;
|
package/dist/dts/const.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const defaultBaseUrl = "https://api.telegram.org";
|
|
2
|
-
export declare const MESSAGE_EFFECTS: {
|
|
3
|
-
readonly "\uD83D\uDD25": "5104841245755180586";
|
|
4
|
-
readonly "\uD83D\uDC4D": "5107584321108051014";
|
|
5
|
-
readonly "\uD83D\uDC4E": "5104858069142078462";
|
|
6
|
-
readonly "\u2764\uFE0F": "5159385139981059251";
|
|
7
|
-
readonly "\uD83C\uDF89": "5046509860389126442";
|
|
8
|
-
readonly "\uD83D\uDCA9": "5046589136895476101";
|
|
9
|
-
};
|
|
10
|
-
export type MessageEffect = keyof typeof MESSAGE_EFFECTS;
|
|
11
|
-
export declare const messageEffectIdCodes: MessageEffect[];
|
|
12
|
-
export declare const isMessageEffect: (input: unknown) => input is MessageEffect;
|