gramio 0.4.3 → 0.4.4

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.cjs CHANGED
@@ -6,10 +6,10 @@ var callbackData = require('@gramio/callback-data');
6
6
  var contexts = require('@gramio/contexts');
7
7
  var files = require('@gramio/files');
8
8
  var format = require('@gramio/format');
9
- var utils = require('./utils-BIdmQNPz.cjs');
9
+ var debug = require('debug');
10
+ var utils = require('./utils-CnG66NLH.cjs');
10
11
  var middlewareIo = require('middleware-io');
11
12
  var keyboards = require('@gramio/keyboards');
12
- require('debug');
13
13
 
14
14
  class Composer {
15
15
  composer = middlewareIo.Composer.builder();
@@ -518,7 +518,7 @@ class Bot {
518
518
  }
519
519
  }
520
520
  async _callApi(method, params = {}) {
521
- const debug$api$method = utils.debug$api.extend(method);
521
+ const debug$api$method = debug(`gramio:api:${method}`);
522
522
  let url = `${this.options.api.baseURL}${this.options.token}/${this.options.api.useTest ? "test/" : ""}${method}`;
523
523
  const reqOptions = {
524
524
  method: "POST",
@@ -1170,6 +1170,7 @@ const frameworks = {
1170
1170
  header: req.headers[SECRET_TOKEN_HEADER.toLowerCase()],
1171
1171
  unauthorized: () => res.writeHead(401).end(WRONG_TOKEN_ERROR)
1172
1172
  }),
1173
+ // TODO: Maybe unify it by 'WebRequest'
1173
1174
  "std/http": (req) => ({
1174
1175
  update: req.json(),
1175
1176
  header: req.headers.get(SECRET_TOKEN_HEADER),
@@ -1181,6 +1182,12 @@ const frameworks = {
1181
1182
  header: req.headers.get(SECRET_TOKEN_HEADER),
1182
1183
  response: () => responseOK,
1183
1184
  unauthorized: () => responseUnauthorized
1185
+ }),
1186
+ Request: (req) => ({
1187
+ update: req.json(),
1188
+ header: req.headers.get(SECRET_TOKEN_HEADER),
1189
+ response: () => responseOK,
1190
+ unauthorized: () => responseUnauthorized
1184
1191
  })
1185
1192
  };
1186
1193
 
package/dist/index.d.cts CHANGED
@@ -1050,6 +1050,12 @@ declare const frameworks: {
1050
1050
  response: () => Response;
1051
1051
  unauthorized: () => Response;
1052
1052
  };
1053
+ Request: (req: any) => {
1054
+ update: any;
1055
+ header: any;
1056
+ response: () => Response;
1057
+ unauthorized: () => Response;
1058
+ };
1053
1059
  };
1054
1060
 
1055
1061
  /** Union type of webhook handlers name */
package/dist/index.d.ts CHANGED
@@ -1050,6 +1050,12 @@ declare const frameworks: {
1050
1050
  response: () => Response;
1051
1051
  unauthorized: () => Response;
1052
1052
  };
1053
+ Request: (req: any) => {
1054
+ update: any;
1055
+ header: any;
1056
+ response: () => Response;
1057
+ unauthorized: () => Response;
1058
+ };
1053
1059
  };
1054
1060
 
1055
1061
  /** Union type of webhook handlers name */
package/dist/index.js CHANGED
@@ -8,10 +8,10 @@ import { isMediaUpload, convertJsonToFormData, extractFilesToFormData } from '@g
8
8
  export * from '@gramio/files';
9
9
  import { FormattableMap } from '@gramio/format';
10
10
  export * from '@gramio/format';
11
- import { E as ErrorKind, s as sleep, w as withRetries, T as TelegramError, d as debug$updates, a as debug$api, I as IS_BUN, b as simplifyObject } from './utils-CV4fnsQV.js';
11
+ import debug from 'debug';
12
+ import { E as ErrorKind, s as sleep, w as withRetries, T as TelegramError, d as debug$updates, I as IS_BUN, a as simplifyObject } from './utils-CJlBu70R.js';
12
13
  import { Composer as Composer$1, noopNext } from 'middleware-io';
13
14
  export * from '@gramio/keyboards';
14
- import 'debug';
15
15
 
16
16
  class Composer {
17
17
  composer = Composer$1.builder();
@@ -520,7 +520,7 @@ class Bot {
520
520
  }
521
521
  }
522
522
  async _callApi(method, params = {}) {
523
- const debug$api$method = debug$api.extend(method);
523
+ const debug$api$method = debug(`gramio:api:${method}`);
524
524
  let url = `${this.options.api.baseURL}${this.options.token}/${this.options.api.useTest ? "test/" : ""}${method}`;
525
525
  const reqOptions = {
526
526
  method: "POST",
@@ -1172,6 +1172,7 @@ const frameworks = {
1172
1172
  header: req.headers[SECRET_TOKEN_HEADER.toLowerCase()],
1173
1173
  unauthorized: () => res.writeHead(401).end(WRONG_TOKEN_ERROR)
1174
1174
  }),
1175
+ // TODO: Maybe unify it by 'WebRequest'
1175
1176
  "std/http": (req) => ({
1176
1177
  update: req.json(),
1177
1178
  header: req.headers.get(SECRET_TOKEN_HEADER),
@@ -1183,6 +1184,12 @@ const frameworks = {
1183
1184
  header: req.headers.get(SECRET_TOKEN_HEADER),
1184
1185
  response: () => responseOK,
1185
1186
  unauthorized: () => responseUnauthorized
1187
+ }),
1188
+ Request: (req) => ({
1189
+ update: req.json(),
1190
+ header: req.headers.get(SECRET_TOKEN_HEADER),
1191
+ response: () => responseOK,
1192
+ unauthorized: () => responseUnauthorized
1186
1193
  })
1187
1194
  };
1188
1195
 
@@ -40,9 +40,8 @@ function simplifyObject(obj) {
40
40
  return result;
41
41
  }
42
42
  const IS_BUN = typeof Bun !== "undefined";
43
- const $debugger = debug("gramio");
44
- const debug$api = $debugger.extend("api");
45
- const debug$updates = $debugger.extend("updates");
43
+ debug("gramio:api");
44
+ const debug$updates = debug("gramio:updates");
46
45
 
47
46
  async function suppressError(fn) {
48
47
  try {
@@ -67,4 +66,4 @@ async function withRetries(resultPromise) {
67
66
  return result;
68
67
  }
69
68
 
70
- export { ErrorKind as E, IS_BUN as I, TelegramError as T, debug$api as a, simplifyObject as b, debug$updates as d, sleep as s, withRetries as w };
69
+ export { ErrorKind as E, IS_BUN as I, TelegramError as T, simplifyObject as a, debug$updates as d, sleep as s, withRetries as w };
@@ -42,9 +42,8 @@ function simplifyObject(obj) {
42
42
  return result;
43
43
  }
44
44
  const IS_BUN = typeof Bun !== "undefined";
45
- const $debugger = debug("gramio");
46
- const debug$api = $debugger.extend("api");
47
- const debug$updates = $debugger.extend("updates");
45
+ debug("gramio:api");
46
+ const debug$updates = debug("gramio:updates");
48
47
 
49
48
  async function suppressError(fn) {
50
49
  try {
@@ -72,7 +71,6 @@ async function withRetries(resultPromise) {
72
71
  exports.ErrorKind = ErrorKind;
73
72
  exports.IS_BUN = IS_BUN;
74
73
  exports.TelegramError = TelegramError;
75
- exports.debug$api = debug$api;
76
74
  exports.debug$updates = debug$updates;
77
75
  exports.simplifyObject = simplifyObject;
78
76
  exports.sleep = sleep;
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var utils = require('./utils-BIdmQNPz.cjs');
3
+ var utils = require('./utils-CnG66NLH.cjs');
4
4
  require('debug');
5
5
 
6
6
 
package/dist/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- export { w as withRetries } from './utils-CV4fnsQV.js';
1
+ export { w as withRetries } from './utils-CJlBu70R.js';
2
2
  import 'debug';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "description": "Powerful, extensible and really type-safe Telegram Bot API framework",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",