gramio 0.4.1 → 0.4.2

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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CallbackData } from '@gramio/callback-data';
2
2
  export * from '@gramio/callback-data';
3
- import { Context, UpdateName, MaybeArray, ContextType, BotLike, Attachment } from '@gramio/contexts';
3
+ import { Context, UpdateName, ContextType, MaybeArray as MaybeArray$1, BotLike, Attachment } from '@gramio/contexts';
4
4
  export * from '@gramio/contexts';
5
5
  import { APIMethods, TelegramResponseParameters, TelegramAPIResponseError, TelegramUser, APIMethodParams, APIMethodReturn, SetWebhookParams, TelegramUpdate, TelegramReactionTypeEmojiEmoji, SetMyCommandsParams, TelegramBotCommand } from '@gramio/types';
6
6
  export * from '@gramio/types';
@@ -26,6 +26,8 @@ declare class TelegramError<T extends keyof APIMethods> extends Error {
26
26
  constructor(error: TelegramAPIResponseError, method: T, params: MaybeSuppressedParams<T>);
27
27
  }
28
28
 
29
+ type MaybeArray<T> = T | T[] | ReadonlyArray<T>;
30
+
29
31
  /** Base-composer without chainable type-safety */
30
32
  declare class Composer {
31
33
  protected composer: Composer$1<Context<AnyBot> & {
@@ -109,11 +111,11 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
109
111
  /** Composer */
110
112
  composer: Composer;
111
113
  /** Store plugin preRequests hooks */
112
- preRequests: [Hooks.PreRequest<any>, MaybeArray<keyof APIMethods> | undefined][];
114
+ preRequests: [Hooks.PreRequest<any>, MaybeArray$1<keyof APIMethods> | undefined][];
113
115
  /** Store plugin onResponses hooks */
114
- onResponses: [Hooks.OnResponse<any>, MaybeArray<keyof APIMethods> | undefined][];
116
+ onResponses: [Hooks.OnResponse<any>, MaybeArray$1<keyof APIMethods> | undefined][];
115
117
  /** Store plugin onResponseErrors hooks */
116
- onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray<keyof APIMethods> | undefined][];
118
+ onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray$1<keyof APIMethods> | undefined][];
117
119
  /**
118
120
  * Store plugin groups
119
121
  *
@@ -145,11 +147,11 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
145
147
  /** Composer */
146
148
  composer: Composer;
147
149
  /** Store plugin preRequests hooks */
148
- preRequests: [Hooks.PreRequest<any>, MaybeArray<keyof APIMethods> | undefined][];
150
+ preRequests: [Hooks.PreRequest<any>, MaybeArray$1<keyof APIMethods> | undefined][];
149
151
  /** Store plugin onResponses hooks */
150
- onResponses: [Hooks.OnResponse<any>, MaybeArray<keyof APIMethods> | undefined][];
152
+ onResponses: [Hooks.OnResponse<any>, MaybeArray$1<keyof APIMethods> | undefined][];
151
153
  /** Store plugin onResponseErrors hooks */
152
- onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray<keyof APIMethods> | undefined][];
154
+ onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray$1<keyof APIMethods> | undefined][];
153
155
  /**
154
156
  * Store plugin groups
155
157
  *
@@ -201,7 +203,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
201
203
  derive<Handler extends Hooks.Derive<Context<BotLike> & Derives["global"]>>(handler: Handler): Plugin<Errors, Derives & {
202
204
  global: Awaited<ReturnType<Handler>>;
203
205
  }>;
204
- derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<BotLike, Update> & Derives["global"] & Derives[Update]>>(updateName: MaybeArray<Update>, handler: Handler): Plugin<Errors, Derives & {
206
+ derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<BotLike, Update> & Derives["global"] & Derives[Update]>>(updateName: MaybeArray$1<Update>, handler: Handler): Plugin<Errors, Derives & {
205
207
  [K in Update]: Awaited<ReturnType<Handler>>;
206
208
  }>;
207
209
  decorate<Value extends Record<string, any>>(value: Value): Plugin<Errors, Derives & {
@@ -215,7 +217,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
215
217
  };
216
218
  }>;
217
219
  /** Register handler to one or many Updates */
218
- on<T extends UpdateName>(updateName: MaybeArray<T>, handler: Handler<ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
220
+ on<T extends UpdateName>(updateName: MaybeArray$1<T>, handler: Handler<ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
219
221
  /** Register handler to any Updates */
220
222
  use(handler: Handler<Context<BotLike> & Derives["global"]>): this;
221
223
  /**
@@ -238,21 +240,21 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
238
240
  *
239
241
  * [Documentation](https://gramio.dev/hooks/pre-request.html)
240
242
  * */
241
- preRequest<Methods extends keyof APIMethods, Handler extends Hooks.PreRequest<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
243
+ preRequest<Methods extends keyof APIMethods, Handler extends Hooks.PreRequest<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
242
244
  preRequest(handler: Hooks.PreRequest): this;
243
245
  /**
244
246
  * This hook called when API return successful response
245
247
  *
246
248
  * [Documentation](https://gramio.dev/hooks/on-response.html)
247
249
  * */
248
- onResponse<Methods extends keyof APIMethods, Handler extends Hooks.OnResponse<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
250
+ onResponse<Methods extends keyof APIMethods, Handler extends Hooks.OnResponse<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
249
251
  onResponse(handler: Hooks.OnResponse): this;
250
252
  /**
251
253
  * This hook called when API return an error
252
254
  *
253
255
  * [Documentation](https://gramio.dev/hooks/on-response-error.html)
254
256
  * */
255
- onResponseError<Methods extends keyof APIMethods, Handler extends Hooks.OnResponseError<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
257
+ onResponseError<Methods extends keyof APIMethods, Handler extends Hooks.OnResponseError<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
256
258
  onResponseError(handler: Hooks.OnResponseError): this;
257
259
  /**
258
260
  * This hook called when the bot is `started`.
@@ -305,7 +307,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
305
307
  * })
306
308
  * ```
307
309
  */
308
- onError<T extends UpdateName>(updateName: MaybeArray<T>, handler: Hooks.OnError<Errors, ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
310
+ onError<T extends UpdateName>(updateName: MaybeArray$1<T>, handler: Hooks.OnError<Errors, ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
309
311
  onError(handler: Hooks.OnError<Errors, Context<BotLike> & Derives["global"]>): this;
310
312
  /**
311
313
  * ! ** At the moment, it can only pick up types** */
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CallbackData } from '@gramio/callback-data';
2
2
  export * from '@gramio/callback-data';
3
- import { Context, UpdateName, MaybeArray, ContextType, BotLike, Attachment } from '@gramio/contexts';
3
+ import { Context, UpdateName, ContextType, MaybeArray as MaybeArray$1, BotLike, Attachment } from '@gramio/contexts';
4
4
  export * from '@gramio/contexts';
5
5
  import { APIMethods, TelegramResponseParameters, TelegramAPIResponseError, TelegramUser, APIMethodParams, APIMethodReturn, SetWebhookParams, TelegramUpdate, TelegramReactionTypeEmojiEmoji, SetMyCommandsParams, TelegramBotCommand } from '@gramio/types';
6
6
  export * from '@gramio/types';
@@ -26,6 +26,8 @@ declare class TelegramError<T extends keyof APIMethods> extends Error {
26
26
  constructor(error: TelegramAPIResponseError, method: T, params: MaybeSuppressedParams<T>);
27
27
  }
28
28
 
29
+ type MaybeArray<T> = T | T[] | ReadonlyArray<T>;
30
+
29
31
  /** Base-composer without chainable type-safety */
30
32
  declare class Composer {
31
33
  protected composer: Composer$1<Context<AnyBot> & {
@@ -109,11 +111,11 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
109
111
  /** Composer */
110
112
  composer: Composer;
111
113
  /** Store plugin preRequests hooks */
112
- preRequests: [Hooks.PreRequest<any>, MaybeArray<keyof APIMethods> | undefined][];
114
+ preRequests: [Hooks.PreRequest<any>, MaybeArray$1<keyof APIMethods> | undefined][];
113
115
  /** Store plugin onResponses hooks */
114
- onResponses: [Hooks.OnResponse<any>, MaybeArray<keyof APIMethods> | undefined][];
116
+ onResponses: [Hooks.OnResponse<any>, MaybeArray$1<keyof APIMethods> | undefined][];
115
117
  /** Store plugin onResponseErrors hooks */
116
- onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray<keyof APIMethods> | undefined][];
118
+ onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray$1<keyof APIMethods> | undefined][];
117
119
  /**
118
120
  * Store plugin groups
119
121
  *
@@ -145,11 +147,11 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
145
147
  /** Composer */
146
148
  composer: Composer;
147
149
  /** Store plugin preRequests hooks */
148
- preRequests: [Hooks.PreRequest<any>, MaybeArray<keyof APIMethods> | undefined][];
150
+ preRequests: [Hooks.PreRequest<any>, MaybeArray$1<keyof APIMethods> | undefined][];
149
151
  /** Store plugin onResponses hooks */
150
- onResponses: [Hooks.OnResponse<any>, MaybeArray<keyof APIMethods> | undefined][];
152
+ onResponses: [Hooks.OnResponse<any>, MaybeArray$1<keyof APIMethods> | undefined][];
151
153
  /** Store plugin onResponseErrors hooks */
152
- onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray<keyof APIMethods> | undefined][];
154
+ onResponseErrors: [Hooks.OnResponseError<any>, MaybeArray$1<keyof APIMethods> | undefined][];
153
155
  /**
154
156
  * Store plugin groups
155
157
  *
@@ -201,7 +203,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
201
203
  derive<Handler extends Hooks.Derive<Context<BotLike> & Derives["global"]>>(handler: Handler): Plugin<Errors, Derives & {
202
204
  global: Awaited<ReturnType<Handler>>;
203
205
  }>;
204
- derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<BotLike, Update> & Derives["global"] & Derives[Update]>>(updateName: MaybeArray<Update>, handler: Handler): Plugin<Errors, Derives & {
206
+ derive<Update extends UpdateName, Handler extends Hooks.Derive<ContextType<BotLike, Update> & Derives["global"] & Derives[Update]>>(updateName: MaybeArray$1<Update>, handler: Handler): Plugin<Errors, Derives & {
205
207
  [K in Update]: Awaited<ReturnType<Handler>>;
206
208
  }>;
207
209
  decorate<Value extends Record<string, any>>(value: Value): Plugin<Errors, Derives & {
@@ -215,7 +217,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
215
217
  };
216
218
  }>;
217
219
  /** Register handler to one or many Updates */
218
- on<T extends UpdateName>(updateName: MaybeArray<T>, handler: Handler<ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
220
+ on<T extends UpdateName>(updateName: MaybeArray$1<T>, handler: Handler<ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
219
221
  /** Register handler to any Updates */
220
222
  use(handler: Handler<Context<BotLike> & Derives["global"]>): this;
221
223
  /**
@@ -238,21 +240,21 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
238
240
  *
239
241
  * [Documentation](https://gramio.dev/hooks/pre-request.html)
240
242
  * */
241
- preRequest<Methods extends keyof APIMethods, Handler extends Hooks.PreRequest<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
243
+ preRequest<Methods extends keyof APIMethods, Handler extends Hooks.PreRequest<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
242
244
  preRequest(handler: Hooks.PreRequest): this;
243
245
  /**
244
246
  * This hook called when API return successful response
245
247
  *
246
248
  * [Documentation](https://gramio.dev/hooks/on-response.html)
247
249
  * */
248
- onResponse<Methods extends keyof APIMethods, Handler extends Hooks.OnResponse<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
250
+ onResponse<Methods extends keyof APIMethods, Handler extends Hooks.OnResponse<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
249
251
  onResponse(handler: Hooks.OnResponse): this;
250
252
  /**
251
253
  * This hook called when API return an error
252
254
  *
253
255
  * [Documentation](https://gramio.dev/hooks/on-response-error.html)
254
256
  * */
255
- onResponseError<Methods extends keyof APIMethods, Handler extends Hooks.OnResponseError<Methods>>(methods: MaybeArray<Methods>, handler: Handler): this;
257
+ onResponseError<Methods extends keyof APIMethods, Handler extends Hooks.OnResponseError<Methods>>(methods: MaybeArray$1<Methods>, handler: Handler): this;
256
258
  onResponseError(handler: Hooks.OnResponseError): this;
257
259
  /**
258
260
  * This hook called when the bot is `started`.
@@ -305,7 +307,7 @@ declare class Plugin<Errors extends ErrorDefinitions = {}, Derives extends Deriv
305
307
  * })
306
308
  * ```
307
309
  */
308
- onError<T extends UpdateName>(updateName: MaybeArray<T>, handler: Hooks.OnError<Errors, ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
310
+ onError<T extends UpdateName>(updateName: MaybeArray$1<T>, handler: Hooks.OnError<Errors, ContextType<BotLike, T> & Derives["global"] & Derives[T]>): this;
309
311
  onError(handler: Hooks.OnError<Errors, Context<BotLike> & Derives["global"]>): this;
310
312
  /**
311
313
  * ! ** At the moment, it can only pick up types** */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gramio",
3
3
  "type": "module",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
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",