@gramio/types
Advanced tools
Comparing version 7.0.0-rc to 7.0.1
{ | ||
"name": "@gramio/types", | ||
"version": "7.0.0-rc", | ||
"version": "7.0.1", | ||
"homepage": "https://github.com/kravetsone/gramio-types", | ||
"readme": "https://github.com/kravetsone/gramio-types", | ||
"description": "Telegram Bot Api types for gramio", | ||
"description": "Code-generated Telegram Bot API types", | ||
"author": "kravets", | ||
"license": "ISC", | ||
"keywords": [ | ||
"telegram", | ||
"bot", | ||
"tba", | ||
"types", | ||
"telegram-bot-api", | ||
"code-generated", | ||
"api" | ||
], | ||
"types": "types/index.d.ts", | ||
@@ -12,4 +23,2 @@ "scripts": { | ||
}, | ||
"author": "kravets", | ||
"license": "ISC", | ||
"devDependencies": { | ||
@@ -16,0 +25,0 @@ "@types/node": "^20.10.6", |
@@ -1,2 +0,2 @@ | ||
# @gramio/types - Code-generated Telegram Bot API types | ||
# Code-generated Telegram Bot API types | ||
@@ -12,2 +12,41 @@ ## Usage as an [NPM package](https://www.npmjs.com/package/@gramio/types) | ||
### Versioning | ||
7.0.x types - for 7.0 Telegram Bot API | ||
### Write you own type-safe TBA API wrapper | ||
```typescript | ||
import { stringify } from "node:querystring" | ||
import type { ApiMethods } from "@gramio/types" | ||
const TOKEN = "" | ||
const api = new Proxy<ApiMethods>({} as ApiMethods, { | ||
get: (_target, method: string) => async (args: Record<string, any>) => { | ||
const url = | ||
`http://api.telegram.org/bot` + | ||
TOKEN + | ||
"/" + | ||
method + | ||
`?` + | ||
stringify(args) | ||
const response = await fetch(url, { | ||
method: "GET", | ||
}) | ||
const data = await response.json() | ||
if (!response.ok) throw new Error("some error") | ||
return data.result | ||
}, | ||
}) | ||
api.sendMessage({ | ||
chat_id: 1, | ||
text: "msg", | ||
}) | ||
``` | ||
## Generate types | ||
@@ -19,7 +58,7 @@ | ||
``` | ||
```bash | ||
git clone https://github.com/kravetsone/gramio-types.git | ||
``` | ||
2. Clone [repo](https://github.com/ark0f/tg-bot-api) to the `src` folder | ||
2. Clone [repo](https://github.com/ark0f/tg-bot-api) with TBA parser to the `src` folder | ||
@@ -30,3 +69,3 @@ ```bash | ||
3. Run the JSON schema generator in the cloned folder | ||
3. Run the JSON schema generator in the `cloned` folder | ||
@@ -37,3 +76,3 @@ ```bash | ||
4. Run types code-generation from the root of the project | ||
4. Run types code-generation from the `root` of the project | ||
@@ -40,0 +79,0 @@ ```bash |
/** | ||
* Based on Bot Api v7.0.0 (29.12.2023) | ||
* Generated at 1/5/2024, 9:21:42 PM using {@link https://ark0f.github.io/tg-bot-api | [this repository]} | ||
* Generated at 1/6/2024, 8:29:32 PM using {@link https://ark0f.github.io/tg-bot-api | [this repository]} | ||
*/ | ||
@@ -5,0 +5,0 @@ import * as Params from "./api-params" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
377901
9249
0
86