@aracna/telegram-bot 1.9.8 → 1.9.9

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/index.d.ts CHANGED
@@ -5,8 +5,6 @@ import { AnswerCallbackQuery } from '@aracna/telegram-bot-types';
5
5
  import { AnswerInlineQuery } from '@aracna/telegram-bot-types';
6
6
  import { AnswerPreCheckoutQuery } from '@aracna/telegram-bot-types';
7
7
  import { AnswerShippingQuery } from '@aracna/telegram-bot-types';
8
- import { API as API_2 } from '@aracna/core';
9
- import { APIConfig } from '@aracna/core';
10
8
  import { BanChatMember } from '@aracna/telegram-bot-types';
11
9
  import { BotCommand } from '@aracna/telegram-bot-types';
12
10
  import { CallbackQuery as CallbackQuery_2 } from '@aracna/telegram-bot-types';
@@ -50,6 +48,8 @@ import { PollAnswer } from '@aracna/telegram-bot-types';
50
48
  import { PreCheckoutQuery } from '@aracna/telegram-bot-types';
51
49
  import { PromoteChatMember } from '@aracna/telegram-bot-types';
52
50
  import { RequestMethod } from '@aracna/core';
51
+ import { RestAPI } from '@aracna/core';
52
+ import { RestApiConfig } from '@aracna/core';
53
53
  import { RestrictChatMember } from '@aracna/telegram-bot-types';
54
54
  import { SendAnimation } from '@aracna/telegram-bot-types';
55
55
  import { SendAudio } from '@aracna/telegram-bot-types';
@@ -97,9 +97,9 @@ declare class Answer extends Child {
97
97
  shippingQuery(id: string, ok: boolean, parameters?: Partial<AnswerShippingQuery>): Promise<boolean | FetchError>;
98
98
  }
99
99
 
100
- declare class API extends API_2 {
101
- post<V, W, X = undefined>(path: string, body?: W, config?: APIConfig<void>): Promise<V | FetchError<X>>;
102
- transformBody<V>(method: RequestMethod, path: string, body: V, config: APIConfig<void>): Promise<FormData>;
100
+ declare class API extends RestAPI {
101
+ post<V, W, X = undefined>(path: string, body?: W, config?: RestApiConfig<void>): Promise<V | FetchError<X>>;
102
+ transformBody<V>(method: RequestMethod, path: string, body: V, config: RestApiConfig<void>): Promise<FormData>;
103
103
  }
104
104
 
105
105
  declare class Ban extends Child {
package/modules/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { APIConfig, API as CoreAPI, FetchError, RequestMethod } from '@aracna/core';
2
- export declare class API extends CoreAPI {
3
- post<V, W, X = undefined>(path: string, body?: W, config?: APIConfig<void>): Promise<V | FetchError<X>>;
4
- transformBody<V>(method: RequestMethod, path: string, body: V, config: APIConfig<void>): Promise<FormData>;
1
+ import { FetchError, RequestMethod, RestAPI, RestApiConfig } from '@aracna/core';
2
+ export declare class API extends RestAPI {
3
+ post<V, W, X = undefined>(path: string, body?: W, config?: RestApiConfig<void>): Promise<V | FetchError<X>>;
4
+ transformBody<V>(method: RequestMethod, path: string, body: V, config: RestApiConfig<void>): Promise<FormData>;
5
5
  }
package/modules/api.js CHANGED
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.API = void 0;
4
4
  const core_1 = require("@aracna/core");
5
- class API extends core_1.API {
5
+ class API extends core_1.RestAPI {
6
6
  async post(path, body, config) {
7
7
  let response;
8
- response = await this.handle('POST', path, body, config);
8
+ response = await this.post(path, body, config);
9
9
  if (response instanceof Error)
10
10
  return response;
11
11
  return response.data.result;
@@ -14,7 +14,7 @@ class API extends core_1.API {
14
14
  switch (method) {
15
15
  case 'GET':
16
16
  case 'POST':
17
- await (0, core_1.useNodeFetch)(await (0, core_1.tcp)(() => Promise.resolve().then(() => require('node-fetch'))));
17
+ await (0, core_1.useNodeFetch)(await (0, core_1.importNodeFetch)());
18
18
  return (0, core_1.serializeFormData)(typeof body === 'object' ? body : {});
19
19
  default:
20
20
  return (0, core_1.serializeFormData)({});
@@ -113,7 +113,7 @@ class Telegram {
113
113
  let handler, potential;
114
114
  handler = dummy_1.Dummy.handler;
115
115
  handler.description = description;
116
- handler.id = core_1.ID.generate({ blacklist: this.handlerIDs });
116
+ handler.id = (0, core_1.generateRandomString)({ blacklist: this.handlerIDs });
117
117
  handler.key = key;
118
118
  handler.middleware = middleware;
119
119
  handler.type = type;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "author": "Dario Sechi",
3
3
  "devDependencies": {
4
- "@aracna/core": "^1.1.41",
5
- "@aracna/telegram-bot-types": "^1.2.4",
6
- "@microsoft/api-extractor": "^7.36.4",
7
- "@vitest/coverage-v8": "^0.34.2",
8
- "@vitest/ui": "^0.34.2",
4
+ "@aracna/core": "^1.1.73",
5
+ "@aracna/telegram-bot-types": "^1.2.9",
6
+ "@microsoft/api-extractor": "^7.39.0",
7
+ "@types/node": "^20.10.5",
8
+ "@vitest/coverage-v8": "^1.1.0",
9
+ "@vitest/ui": "^1.1.0",
9
10
  "dotenv": "^16.3.1",
10
- "fastify": "^4.21.0",
11
- "typescript": "^5.1.6",
12
- "vitest": "^0.34.2"
11
+ "fastify": "^4.25.1",
12
+ "typescript": "^5.3.3",
13
+ "vitest": "^1.1.0"
13
14
  },
14
15
  "license": "MIT",
15
16
  "main": "index.js",
@@ -18,12 +19,14 @@
18
19
  "@aracna/core": ">= 1.1.12",
19
20
  "@aracna/telegram-bot-types": ">= 1.2.0"
20
21
  },
21
- "scripts": {
22
- "test": "yarn vitest run",
23
- "build": "rm -rf dist && yarn tsc && yarn api-extractor run --local",
24
- "tarball": "yarn version && cp LICENSE package.json README.md dist/. && cd dist && yarn pack",
25
- "deploy": "yarn test && yarn build && yarn tarball && yarn publish dist/*.tgz && git push"
22
+ "publishConfig": {
23
+ "directory": "dist"
26
24
  },
27
25
  "types": "index.d.ts",
28
- "version": "1.9.8"
29
- }
26
+ "version": "1.9.9",
27
+ "scripts": {
28
+ "build": "rm -rf dist && pnpm tsc && pnpm api-extractor run --local",
29
+ "prepublish": "pnpm test && pnpm build && pnpm version patch && cp LICENSE package.json README.md dist",
30
+ "test": "vitest run"
31
+ }
32
+ }