gramio 0.0.45 → 0.0.47

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- [![Bot API](https://img.shields.io/badge/Bot%20API-7.7-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
5
+ [![Bot API](https://img.shields.io/badge/Bot%20API-7.8-blue?logo=telegram&style=flat&labelColor=000&color=3b82f6)](https://core.telegram.org/bots/api)
6
6
  [![npm](https://img.shields.io/npm/v/gramio?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/@gramio/core)
7
7
  [![JSR](https://jsr.io/badges/@gramio/core)](https://jsr.io/@gramio/core)
8
8
  [![JSR Score](https://jsr.io/badges/@gramio/core/score)](https://jsr.io/@gramio/core)
package/dist/bot.d.ts CHANGED
@@ -139,8 +139,15 @@ export declare class Bot<Errors extends ErrorDefinitions = {}, Derives extends D
139
139
  derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<typeof this, Update>>>(updateName: MaybeArray<Update>, handler: Handler): Bot<Errors, Derives & {
140
140
  [K in Update]: Awaited<ReturnType<Handler>>;
141
141
  }>;
142
+ decorate<Value extends Record<string, any>>(value: Value): Bot<Errors, Derives & {
143
+ global: {
144
+ [K in keyof Value]: Value[K];
145
+ };
146
+ }>;
142
147
  decorate<Name extends string, Value>(name: Name, value: Value): Bot<Errors, Derives & {
143
- global: { [K in Name]: Value; };
148
+ global: {
149
+ [K in Name]: Value;
150
+ };
144
151
  }>;
145
152
  /**
146
153
  * This hook called when the bot is `started`.
package/dist/bot.js CHANGED
@@ -297,12 +297,20 @@ let Bot = (() => {
297
297
  this.updates.composer.derive(updateNameOrHandler, handler);
298
298
  return this;
299
299
  }
300
- decorate(name, value) {
300
+ decorate(nameOrRecordValue, value) {
301
301
  for (const contextName of Object.keys(contexts_1.contextsMappings)) {
302
- // @ts-expect-error
303
- Object.defineProperty(contexts_1.contextsMappings[contextName].prototype, name, {
304
- value,
305
- });
302
+ if (typeof nameOrRecordValue === "string")
303
+ // @ts-expect-error
304
+ Object.defineProperty(contexts_1.contextsMappings[contextName].prototype, name, {
305
+ value,
306
+ });
307
+ else
308
+ Object.defineProperties(
309
+ // @ts-expect-error
310
+ contexts_1.contextsMappings[contextName].prototype, Object.keys(nameOrRecordValue).reduce((acc, key) => {
311
+ acc[key] = { value: nameOrRecordValue[key] };
312
+ return acc;
313
+ }, {}));
306
314
  }
307
315
  return this;
308
316
  }
@@ -472,9 +480,7 @@ let Bot = (() => {
472
480
  if (plugin._.composer.length) {
473
481
  this.use(plugin._.composer.composed);
474
482
  }
475
- for (const [key, value] of Object.entries(plugin._.decorators)) {
476
- this.decorate(key, value);
477
- }
483
+ this.decorate(plugin._.decorators);
478
484
  for (const [key, value] of Object.entries(plugin._.errorsDefinitions)) {
479
485
  if (this.errorsDefinitions[key])
480
486
  this.errorsDefinitions[key] = value;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,6 @@ export * from "./webhook/index";
11
11
  export * from "@gramio/contexts";
12
12
  export * from "@gramio/files";
13
13
  export * from "@gramio/keyboards";
14
- export * from "@gramio/types";
14
+ export type * from "@gramio/types";
15
15
  export * from "@gramio/format";
16
16
  export * from "@gramio/callback-data";
package/dist/index.js CHANGED
@@ -29,6 +29,5 @@ __exportStar(require("./webhook/index"), exports);
29
29
  __exportStar(require("@gramio/contexts"), exports);
30
30
  __exportStar(require("@gramio/files"), exports);
31
31
  __exportStar(require("@gramio/keyboards"), exports);
32
- __exportStar(require("@gramio/types"), exports);
33
32
  __exportStar(require("@gramio/format"), exports);
34
33
  __exportStar(require("@gramio/callback-data"), exports);
package/dist/plugin.d.ts CHANGED
@@ -112,8 +112,15 @@ export declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extend
112
112
  derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<AnyBot, Update>>>(updateName: MaybeArray<Update>, handler: Handler): Plugin<Errors, Derives & {
113
113
  [K in Update]: Awaited<ReturnType<Handler>>;
114
114
  }>;
115
+ decorate<Value extends Record<string, any>>(value: Value): Plugin<Errors, Derives & {
116
+ global: {
117
+ [K in keyof Value]: Value[K];
118
+ };
119
+ }>;
115
120
  decorate<Name extends string, Value>(name: Name, value: Value): Plugin<Errors, Derives & {
116
- global: { [K in Name]: Value; };
121
+ global: {
122
+ [K in Name]: Value;
123
+ };
117
124
  }>;
118
125
  /** Register handler to one or many Updates */
119
126
  on<T extends UpdateName>(updateName: MaybeArray<T>, handler: Handler<ContextType<AnyBot, T> & Derives["global"] & Derives[T]>): this;
package/dist/plugin.js CHANGED
@@ -155,8 +155,14 @@ let Plugin = (() => {
155
155
  this._.composer.derive(updateNameOrHandler, handler);
156
156
  return this;
157
157
  }
158
- decorate(name, value) {
159
- this._.decorators[name] = value;
158
+ decorate(nameOrValue, value) {
159
+ if (typeof nameOrValue === "string")
160
+ this._.decorators[nameOrValue] = value;
161
+ else {
162
+ for (const [name, value] of Object.entries(nameOrValue)) {
163
+ this._.decorators[name] = value;
164
+ }
165
+ }
160
166
  return this;
161
167
  }
162
168
  /** Register handler to one or many Updates */
package/package.json CHANGED
@@ -1,53 +1,49 @@
1
1
  {
2
- "name": "gramio",
3
- "type": "commonjs",
4
- "version": "0.0.45",
5
- "description": "Powerful Telegram Bot API framework",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "keywords": [
9
- "telegram",
10
- "telegram-bot",
11
- "telegram-bot-api",
12
- "bot",
13
- "framework",
14
- "types",
15
- "client",
16
- "webhook",
17
- "long-polling"
18
- ],
19
- "scripts": {
20
- "type": "tsc --noEmit",
21
- "lint": "bunx @biomejs/biome check ./src",
22
- "lint:fix": "bun lint --apply",
23
- "prepublishOnly": "tsc",
24
- "jsr": "bun scripts/release-jsr.ts",
25
- "try-deno": "deno publish --unstable-sloppy-imports --dry-run --allow-slow-types --allow-dirty"
26
- },
27
- "author": "kravets",
28
- "license": "ISC",
29
- "devDependencies": {
30
- "@biomejs/biome": "1.7.3",
31
- "@types/debug": "^4.1.12",
32
- "@types/node": "^20.14.10",
33
- "typescript": "^5.5.3"
34
- },
35
- "dependencies": {
36
- "@gramio/callback-data": "^0.0.3",
37
- "@gramio/contexts": "^0.0.20",
38
- "@gramio/files": "^0.0.10",
39
- "@gramio/format": "^0.1.3",
40
- "@gramio/keyboards": "^0.3.3",
41
- "@gramio/types": "^7.7.0",
42
- "debug": "^4.3.5",
43
- "inspectable": "^3.0.2",
44
- "middleware-io": "^2.8.1",
45
- "undici": "^6.19.2"
46
- },
47
- "overrides": {
48
- "@gramio/types": "^7.7.0"
49
- },
50
- "files": [
51
- "dist"
52
- ]
2
+ "name": "gramio",
3
+ "type": "commonjs",
4
+ "version": "0.0.47",
5
+ "description": "Powerful, extensible and really type-safe Telegram Bot API framework",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "keywords": [
9
+ "telegram",
10
+ "telegram-bot",
11
+ "telegram-bot-api",
12
+ "bot",
13
+ "framework",
14
+ "types",
15
+ "client",
16
+ "webhook",
17
+ "long-polling"
18
+ ],
19
+ "scripts": {
20
+ "type": "tsc --noEmit",
21
+ "lint": "bunx @biomejs/biome check ./src",
22
+ "lint:fix": "bun lint --apply",
23
+ "prepublishOnly": "tsc",
24
+ "jsr": "bun scripts/release-jsr.ts",
25
+ "try-deno": "deno publish --unstable-sloppy-imports --dry-run --allow-slow-types --allow-dirty"
26
+ },
27
+ "author": "kravets",
28
+ "license": "ISC",
29
+ "devDependencies": {
30
+ "@biomejs/biome": "1.7.3",
31
+ "@types/bun": "^1.1.6",
32
+ "@types/debug": "^4.1.12",
33
+ "@types/node": "^20.14.13",
34
+ "typescript": "^5.5.4"
35
+ },
36
+ "dependencies": {
37
+ "@gramio/callback-data": "^0.0.3",
38
+ "@gramio/contexts": "^0.0.21",
39
+ "@gramio/files": "^0.0.11",
40
+ "@gramio/format": "^0.1.3",
41
+ "@gramio/keyboards": "^0.3.3",
42
+ "@gramio/types": "^7.8.0",
43
+ "debug": "^4.3.6",
44
+ "inspectable": "^3.0.2",
45
+ "middleware-io": "^2.8.1",
46
+ "undici": "^6.19.5"
47
+ },
48
+ "files": ["dist"]
53
49
  }