@effect-ak/tg-bot-client 0.0.7 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  import { makeExecute } from "./execute-request.js";
2
2
  import { makeDownloadFile } from "./download-file.js";
3
- const defaultBaseUrl = "https://api.telegram.org";
3
+ import { defaultBaseUrl } from "./const.js";
4
4
  export const makeTgBotClient = (inputConfig) => {
5
5
  const config = {
6
6
  ...inputConfig,
@@ -1,3 +1,4 @@
1
+ export const defaultBaseUrl = "https://api.telegram.org";
1
2
  export const MESSAGE_EFFECTS = {
2
3
  "🔥": "5104841245755180586",
3
4
  "👍": "5107584321108051014",
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from "./client/const.js";
2
2
  export * from "./client/_client.js";
3
- export * from "./specification/api.js";
4
- export * from "./specification/types.js";
3
+ // export * from "./specification/api.js"
4
+ // export * from "./specification/types.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-ak/tg-bot-client",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Aleksandr Kondaurov",
@@ -32,17 +32,20 @@
32
32
  "@types/node": "^22.10.1",
33
33
  "effect": "^3.11.4",
34
34
  "node-html-parser": "^6.1.13",
35
+ "openapi-types": "^12.1.3",
35
36
  "ts-morph": "^24.0.0",
36
37
  "tsc-alias": "^1.8.10",
37
38
  "type-fest": "^4.30.0",
38
39
  "typescript": "^5.7.2",
39
40
  "vite-tsconfig-paths": "^5.1.4",
40
- "vitest": "^2.1.8"
41
+ "vitest": "^2.1.8",
42
+ "@redocly/cli": "^1.26.0"
41
43
  },
42
44
  "scripts": {
43
- "gen": "bun run codegen/main",
45
+ "gen": "bun run ./codegen/main",
44
46
  "build": "pnpm build-esm && pnpm build-cjs",
45
47
  "build-esm": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
46
- "build-cjs": "babel dist/esm --out-dir dist/cjs"
48
+ "build-cjs": "babel dist/esm --out-dir dist/cjs",
49
+ "gen-html": "redocly build-docs --output ../effect-ak.github.io/telegram-bot-api/index.html"
47
50
  }
48
51
  }
package/readme.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ![NPM Version](https://img.shields.io/npm/v/%40effect-ak%2Ftg-bot-client)
2
2
 
3
+ [OpenApi Specification](https://effect-ak.github.io/telegram-bot-api/)
4
+
3
5
  ### What is it?
4
6
 
5
7
  This is a client for interacting with the Telegram Bot API.
@@ -10,8 +12,15 @@ They only provide documentation in the form of a massive HTML page, which is ver
10
12
  ## Features:
11
13
  - **Pure TypeScript Client**: This is a clean client written in TypeScript with no abstractions.
12
14
  - **Complete**: The entire API is generated from the official documentation [https://core.telegram.org/bots/api](https://core.telegram.org/bots/api) using a [code generator](./codegen/main.ts).
13
- - **Inline Documentation**: No need to read lengthy official documentation. All types and comments are available in JS DOC, allowing you to develop your bot without leaving your IDE.
14
- - **Type Mapping**: Types from the documentation are converted to TypeScript types. For example, `Integer` becomes `number`, `True` becomes `boolean`, `String or Number` becomes `string | number`, and so on.
15
+ - ~~**Inline Documentation**: No need to read lengthy official documentation. All types and comments are available in JS DOC, allowing you to develop your bot without leaving your IDE.~~
16
+ - Codegenerator produces TypeScript code and OpenApi specification now! Documentation was removed from TypeScript interfaces in order to keep npm package smaller.
17
+
18
+ - **Type Mapping**: Types from the documentation are converted to TypeScript types:
19
+ - `Integer` becomes `number`
20
+ - `True` becomes `boolean`
21
+ - `String or Number` becomes `string | number`
22
+ - Enumerated types, such as `Type of the chat, can be either “private”, “group”, “supergroup” or “channel”` becomes a standard union of literal types `"private"| "group" | "supergroup" | "channel"`
23
+ - And so on
15
24
  - **Readable Method Names**: Method names, such as `SetChatAdministratorCustomTitleInput`, are converted to snake_case for easier code readability, e.g., `set_chat_administrator_custom_title`.
16
25
 
17
26
  ### Usage example
@@ -44,7 +53,7 @@ if you want, you can use unsafe alternative, `unsafeExecute`, which gives you th
44
53
  #### 1. Sending a Message with an Effect
45
54
 
46
55
  ```typescript
47
- import { MESSAGE_EFFECTS } from "effect-ak/tg-bot-client"
56
+ import { MESSAGE_EFFECTS } from "@effect-ak/tg-bot-client"
48
57
 
49
58
  await client.execute("send_message", {
50
59
  chat_id: "???", // replace ??? with the chat number