diff --git a/README.md b/README.md index 4a83506..d3d3822 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ If you want to dive fully into NestJS Telegraf then don't waste your time in thi ## Installation ```bash -$ npm i nestjs-telegraf +$ npm i nestjs-telegraf telegraf ``` ## Usage diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts index 1f9549d..b565b8e 100644 --- a/lib/decorators/listeners/cashtag.decorator.ts +++ b/lib/decorators/listeners/cashtag.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Cashtag handling. * * @see https://telegraf.js.org/#/?id=cashtag */ -export const Cashtag = createMissedListenerDecorator<[string | string[]]>( - 'cashtag', -); +export const Cashtag = createListenerDecorator('cashtag'); diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts index 9459e08..4279237 100644 --- a/lib/decorators/listeners/email.decorator.ts +++ b/lib/decorators/listeners/email.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Registers middleware for handling messages with email entity. * * @see https://telegraf.js.org/#/?id=telegraf-email */ -export const Email = createMissedListenerDecorator<[string | string[]]>( - 'email', -); +export const Email = createListenerDecorator('email'); diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts index d9edec9..2cefbb7 100644 --- a/lib/decorators/listeners/hashtag.decorator.ts +++ b/lib/decorators/listeners/hashtag.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Hashtag handling. * * @see https://telegraf.js.org/#/?id=hashtag */ -export const Hashtag = createMissedListenerDecorator<[string | string[]]>( - 'hashtag', -); +export const Hashtag = createListenerDecorator('hashtag'); diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts index 57d13fb..71918a7 100644 --- a/lib/decorators/listeners/inline-query.decorator.ts +++ b/lib/decorators/listeners/inline-query.decorator.ts @@ -1,11 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; -import { HearsTriggers } from 'telegraf/typings/composer'; +import { createListenerDecorator } from '../../utils'; /** * Registers middleware for handling inline_query actions with regular expressions. * * @see https://telegraf.js.org/#/?id=inlinequery */ -export const InlineQuery = createMissedListenerDecorator< - [HearsTriggers] ->('inlineQuery'); +export const InlineQuery = createListenerDecorator('inlineQuery'); diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts index bd9437b..aa44e3b 100644 --- a/lib/decorators/listeners/mention.decorator.ts +++ b/lib/decorators/listeners/mention.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Mention handling. * * @see https://telegraf.js.org/#/?id=mention */ -export const Mention = createMissedListenerDecorator<[string | string[]]>( - 'mention', -); +export const Mention = createListenerDecorator('mention'); diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts index 8ec5bed..4492e47 100644 --- a/lib/decorators/listeners/phone.decorator.ts +++ b/lib/decorators/listeners/phone.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Phone number handling. * * @see https://telegraf.js.org/#/?id=phone */ -export const Phone = createMissedListenerDecorator<[string | string[]]>( - 'phone', -); +export const Phone = createListenerDecorator('phone'); diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts index ed0ef8e..81a2628 100644 --- a/lib/decorators/listeners/settings.decorator.ts +++ b/lib/decorators/listeners/settings.decorator.ts @@ -1,8 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Handler for /settings command. * * @see https://telegraf.js.org/#/?id=settings */ -export const Settings = createMissedListenerDecorator<[]>('settings'); +export const Settings = createListenerDecorator('settings'); diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts index ec38818..1c130e6 100644 --- a/lib/decorators/listeners/text-link.decorator.ts +++ b/lib/decorators/listeners/text-link.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Registers middleware for handling messages with text_link entity. * * @see https://telegraf.js.org/#/?id=telegraf-textlink */ -export const TextLink = createMissedListenerDecorator<[string | string[]]>( - 'textLink', -); +export const TextLink = createListenerDecorator('textLink'); diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts index d17543c..37fc5d5 100644 --- a/lib/decorators/listeners/text-mention.decorator.ts +++ b/lib/decorators/listeners/text-mention.decorator.ts @@ -1,10 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Registers middleware for handling messages with text_mention entity. * * @see https://telegraf.js.org/#/?id=telegraf-textlink */ -export const TextMention = createMissedListenerDecorator<[string | string[]]>( - 'textMention', -); +export const TextMention = createListenerDecorator('textMention'); diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts index 17cfc89..5e001e9 100644 --- a/lib/decorators/listeners/url.decorator.ts +++ b/lib/decorators/listeners/url.decorator.ts @@ -1,8 +1,8 @@ -import { createMissedListenerDecorator } from '../../utils'; +import { createListenerDecorator } from '../../utils'; /** * Registers middleware for handling messages with url entity. * * @see https://telegraf.js.org/#/?id=telegraf-url */ -export const Url = createMissedListenerDecorator<[string | string[]]>('url'); +export const Url = createListenerDecorator('url'); diff --git a/lib/decorators/scene/scene-enter.decorator.ts b/lib/decorators/scene/scene-enter.decorator.ts index 96e3cdd..d198f60 100644 --- a/lib/decorators/scene/scene-enter.decorator.ts +++ b/lib/decorators/scene/scene-enter.decorator.ts @@ -1,3 +1,6 @@ import { createListenerDecorator } from '../../utils'; +import { Scenes } from 'telegraf'; -export const SceneEnter = createListenerDecorator('enter'); +export const SceneEnter = createListenerDecorator>( + 'enter', +); diff --git a/lib/decorators/scene/scene-leave.decorator.ts b/lib/decorators/scene/scene-leave.decorator.ts index 2440cf7..3f935ca 100644 --- a/lib/decorators/scene/scene-leave.decorator.ts +++ b/lib/decorators/scene/scene-leave.decorator.ts @@ -1,3 +1,6 @@ import { createListenerDecorator } from '../../utils'; +import { Scenes } from 'telegraf'; -export const SceneLeave = createListenerDecorator('leave'); +export const SceneLeave = createListenerDecorator>( + 'leave', +); diff --git a/lib/interfaces/telegraf-options.interface.ts b/lib/interfaces/telegraf-options.interface.ts index 3a25a4f..1d6005d 100644 --- a/lib/interfaces/telegraf-options.interface.ts +++ b/lib/interfaces/telegraf-options.interface.ts @@ -1,21 +1,14 @@ import { ModuleMetadata, Type } from '@nestjs/common/interfaces'; -import { Middleware, Context } from 'telegraf'; -import { - TelegrafOptions, - LaunchPollingOptions, - LaunchWebhookOptions, -} from 'telegraf/typings/telegraf'; +import { Middleware } from 'telegraf'; +import { LaunchOptions, TelegrafOptions } from '../types'; -export interface TelegrafModuleOptions { +export interface TelegrafModuleOptions { token: string; botName?: string; options?: TelegrafOptions; - launchOptions?: { - polling?: LaunchPollingOptions; - webhook?: LaunchWebhookOptions; - }; + launchOptions?: LaunchOptions; include?: Function[]; - middlewares?: ReadonlyArray>; + middlewares?: ReadonlyArray>; } export interface TelegrafOptionsFactory { diff --git a/lib/services/listeners-explorer.service.ts b/lib/services/listeners-explorer.service.ts index 5bfee9c..233a26b 100644 --- a/lib/services/listeners-explorer.service.ts +++ b/lib/services/listeners-explorer.service.ts @@ -5,7 +5,7 @@ import { MetadataScanner } from '@nestjs/core/metadata-scanner'; import { Module } from '@nestjs/core/injector/module'; import { ParamMetadata } from '@nestjs/core/helpers/interfaces'; import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator'; -import { BaseScene, Composer, Context, Stage, Telegraf } from 'telegraf'; +import { Composer, Context, Scenes, Telegraf } from 'telegraf'; import { MetadataAccessorService } from './metadata-accessor.service'; import { @@ -23,7 +23,7 @@ export class ListenersExplorerService extends BaseExplorerService implements OnModuleInit { private readonly telegrafParamsFactory = new TelegrafParamsFactory(); - private readonly stage = new Stage([]); + private readonly stage = new Scenes.Stage(); private bot: Telegraf; constructor( @@ -42,7 +42,7 @@ export class ListenersExplorerService } onModuleInit(): void { - this.bot = this.moduleRef.get>(this.botName, { + this.bot = this.moduleRef.get>(this.botName, { strict: false, }); this.bot.use(this.stage.middleware()); @@ -75,7 +75,7 @@ export class ListenersExplorerService const sceneId = this.metadataAccessor.getSceneMetadata( wrapper.instance.constructor, ); - const scene = new BaseScene(sceneId); + const scene = new Scenes.BaseScene(sceneId); this.stage.register(scene); this.registerListeners(scene, wrapper); diff --git a/lib/types/index.ts b/lib/types/index.ts index 7a39533..68795c2 100644 --- a/lib/types/index.ts +++ b/lib/types/index.ts @@ -1,4 +1,4 @@ -import { BaseScene, Composer, Middleware } from 'telegraf'; +import { Composer, Middleware, Telegraf } from 'telegraf'; export type Filter = T extends [] ? [] @@ -17,5 +17,5 @@ export type ComposerMethodArgs< U extends OnlyFunctionPropertyNames = OnlyFunctionPropertyNames > = Filter, Middleware>; -export type ComposerMethods = OnlyFunctionPropertyNames>; -export type SceneMethods = OnlyFunctionPropertyNames>; +export type LaunchOptions = Parameters[0]; +export type TelegrafOptions = ConstructorParameters[1]; diff --git a/lib/utils/create-bot-factory.util.ts b/lib/utils/create-bot-factory.util.ts index ea09caa..5eb4f8f 100644 --- a/lib/utils/create-bot-factory.util.ts +++ b/lib/utils/create-bot-factory.util.ts @@ -3,8 +3,8 @@ import { TelegrafModuleOptions } from '../interfaces'; export async function createBotFactory( options: TelegrafModuleOptions, -): Promise> { - const bot = new Telegraf(options.token, options.options); +): Promise> { + const bot = new Telegraf(options.token, options.options); bot.use(...(options.middlewares ?? [])); await bot.launch(options.launchOptions); diff --git a/lib/utils/create-listener-decorator.util.ts b/lib/utils/create-listener-decorator.util.ts index b880fcb..c423ff3 100644 --- a/lib/utils/create-listener-decorator.util.ts +++ b/lib/utils/create-listener-decorator.util.ts @@ -1,26 +1,14 @@ import { SetMetadata } from '@nestjs/common'; -import { BaseScene as Scene } from 'telegraf'; -import { ComposerMethodArgs, SceneMethods } from '../types'; +import { Composer } from 'telegraf'; +import { ComposerMethodArgs, OnlyFunctionPropertyNames } from '../types'; import { LISTENER_METADATA } from '../telegraf.constants'; import { ListenerMetadata } from '../interfaces'; -export function createListenerDecorator( - method: TMethod, -) { - return ( - ...args: ComposerMethodArgs, TMethod> - ): MethodDecorator => { - return SetMetadata(LISTENER_METADATA, { - method, - args, - } as ListenerMetadata); - }; -} - -export function createMissedListenerDecorator( - method: string, -) { - return (...args: TArgs): MethodDecorator => { +export function createListenerDecorator< + TComposer extends Composer, + TMethod extends OnlyFunctionPropertyNames = OnlyFunctionPropertyNames +>(method: TMethod) { + return (...args: ComposerMethodArgs): MethodDecorator => { return SetMetadata(LISTENER_METADATA, { method, args, diff --git a/package-lock.json b/package-lock.json index 94ef5d9..9f36498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,9 +13,6 @@ } ], "license": "MIT", - "dependencies": { - "telegraf": "3.38.0" - }, "devDependencies": { "@commitlint/cli": "11.0.0", "@commitlint/config-angular": "11.0.0", @@ -33,13 +30,15 @@ "prettier": "2.2.1", "reflect-metadata": "0.1.13", "rxjs": "6.6.3", + "telegraf": "*", "typedoc": "0.20.14", "typescript": "4.1.3" }, "peerDependencies": { "@nestjs/common": "^6.7.0 || ^7.0.0", "@nestjs/core": "^6.7.0 || ^7.0.0", - "reflect-metadata": "^0.1.13" + "reflect-metadata": "^0.1.13", + "telegraf": "^4.0.0" } }, "node_modules/@babel/code-frame": { @@ -107,9 +106,6 @@ }, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/@commitlint/cli/node_modules/chalk": { @@ -123,9 +119,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/@commitlint/cli/node_modules/color-convert": { @@ -242,9 +235,6 @@ }, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/@commitlint/format/node_modules/chalk": { @@ -258,9 +248,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/@commitlint/format/node_modules/color-convert": { @@ -358,9 +345,6 @@ }, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/@commitlint/load/node_modules/chalk": { @@ -374,9 +358,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" } }, "node_modules/@commitlint/load/node_modules/color-convert": { @@ -858,6 +839,18 @@ "node": ">=10" } }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -1061,9 +1054,6 @@ }, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/chalk": { @@ -1230,12 +1220,7 @@ "version": "3.8.2", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.2.tgz", "integrity": "sha512-FfApuSRgrR6G5s58casCBd9M2k+4ikuu4wbW6pJyYU7bd9zvFc9qf7vr5xmrZOhT9nn+8uwlH1oRR9jTnFoA3A==", - "dev": true, - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } + "dev": true }, "node_modules/core-util-is": { "version": "1.0.2", @@ -1500,15 +1485,6 @@ }, "engines": { "node": ">=6.0.0" - }, - "peerDependencies": { - "eslint": ">=5.0.0", - "prettier": ">=1.13.0" - }, - "peerDependenciesMeta": { - "eslint-config-prettier": { - "optional": true - } } }, "node_modules/eslint-scope": { @@ -1705,6 +1681,15 @@ "node": ">=0.10.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/execa": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", @@ -1828,9 +1813,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/find-versions": { @@ -1843,9 +1825,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/flat-cache": { @@ -1925,9 +1904,6 @@ "dev": true, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/get-stream": { @@ -2139,7 +2115,6 @@ "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.7.tgz", "integrity": "sha512-0fQlcCDq/xypoyYSJvEuzbDPHFf8ZF9IXKJxlrnvxABTSzK1VPT2RKYQKrcgJ+YD39swgoB6sbzywUqFxUiqjw==", "dev": true, - "hasInstallScript": true, "dependencies": { "chalk": "^4.0.0", "ci-info": "^2.0.0", @@ -2158,10 +2133,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/husky" } }, "node_modules/husky/node_modules/ansi-styles": { @@ -2724,9 +2695,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/lodash": { @@ -2952,9 +2920,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/meow/node_modules/type-fest": { @@ -2964,9 +2929,6 @@ "dev": true, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/merge-stream": { @@ -3030,7 +2992,8 @@ "node_modules/minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true }, "node_modules/minimist-options": { "version": "4.1.0", @@ -3049,7 +3012,14 @@ "node_modules/module-alias": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", - "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==", + "dev": true + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/natural-compare": { "version": "1.4.0", @@ -3067,6 +3037,7 @@ "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "dev": true, "engines": { "node": "4.x || >=6.0.0" } @@ -3182,9 +3153,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/p-locate": { @@ -3197,9 +3165,6 @@ }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/p-map": { @@ -3214,6 +3179,15 @@ "node": ">=10" } }, + "node_modules/p-timeout": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", + "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -3441,9 +3415,6 @@ }, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/find-up": { @@ -3481,9 +3452,6 @@ }, "engines": { "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/p-locate": { @@ -3696,26 +3664,13 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "dev": true }, "node_modules/sandwich-stream": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz", "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==", + "dev": true, "engines": { "node": ">= 0.10" } @@ -3745,9 +3700,6 @@ "dev": true, "engines": { "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/set-blocking": { @@ -4164,42 +4116,39 @@ } }, "node_modules/telegraf": { - "version": "3.38.0", - "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-3.38.0.tgz", - "integrity": "sha512-va4VlrKWp64JrowFoZX/NPzzA6q38kvaIukVXOWFO1V+jR1G8+hCfgJy4TX8Z3rwLJzwaBEet1QhikHDRZWl3A==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.0.0.tgz", + "integrity": "sha512-e4m9uJuAzzKe1gNUOn3z3NTLscfteV4GE4la5pfWFbm75OLWK3cp/qvz7Evy4oPpvc/bPlcDCyNgXnk4n2TBcw==", + "dev": true, "dependencies": { - "debug": "^4.0.1", - "minimist": "^1.2.0", + "abort-controller": "^3.0.0", + "debug": "^4.3.1", + "minimist": "^1.2.5", "module-alias": "^2.2.2", - "node-fetch": "^2.2.0", - "sandwich-stream": "^2.0.1", - "telegram-typings": "^3.6.0" + "node-fetch": "^2.6.1", + "p-timeout": "^4.1.0", + "sandwich-stream": "^2.0.2", + "typegram": "^3.1.4" }, "bin": { "telegraf": "bin/telegraf" }, "engines": { - "node": ">=8" + "node": ">=12" } }, "node_modules/telegraf/node_modules/debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" } }, - "node_modules/telegraf/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/telegram-typings": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/telegram-typings/-/telegram-typings-3.6.1.tgz", - "integrity": "sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw==" - }, "node_modules/text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", @@ -4322,9 +4271,6 @@ }, "engines": { "node": ">= 10.8.0" - }, - "peerDependencies": { - "typescript": "3.9.x || 4.0.x || 4.1.x" } }, "node_modules/typedoc-default-themes": { @@ -4336,6 +4282,12 @@ "node": ">= 8" } }, + "node_modules/typegram": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/typegram/-/typegram-3.1.4.tgz", + "integrity": "sha512-AsYxLLynwBgeUJNU+3oSYNPSB3bwb/uyzrEPvrPwC0HXCYhW+otNV5q4T8Sb43SQSAP71hWC8EzBgDtlGGBx0A==", + "dev": true + }, "node_modules/typescript": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", @@ -4605,9 +4557,6 @@ }, "engines": { "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/yargs/node_modules/p-locate": { @@ -4642,9 +4591,6 @@ "dev": true, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } } }, @@ -5297,6 +5243,15 @@ } } }, + "abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dev": true, + "requires": { + "event-target-shim": "^5.0.0" + } + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -5966,6 +5921,12 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "dev": true + }, "execa": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", @@ -7011,7 +6972,8 @@ "minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true }, "minimist-options": { "version": "4.1.0", @@ -7027,7 +6989,14 @@ "module-alias": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz", - "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==" + "integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "natural-compare": { "version": "1.4.0", @@ -7044,7 +7013,8 @@ "node-fetch": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "dev": true }, "normalize-package-data": { "version": "3.0.0", @@ -7153,6 +7123,12 @@ "aggregate-error": "^3.0.0" } }, + "p-timeout": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", + "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", + "dev": true + }, "p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -7528,7 +7504,8 @@ "sandwich-stream": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz", - "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==" + "integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==", + "dev": true }, "semver": { "version": "7.3.2", @@ -7900,38 +7877,32 @@ } }, "telegraf": { - "version": "3.38.0", - "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-3.38.0.tgz", - "integrity": "sha512-va4VlrKWp64JrowFoZX/NPzzA6q38kvaIukVXOWFO1V+jR1G8+hCfgJy4TX8Z3rwLJzwaBEet1QhikHDRZWl3A==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.0.0.tgz", + "integrity": "sha512-e4m9uJuAzzKe1gNUOn3z3NTLscfteV4GE4la5pfWFbm75OLWK3cp/qvz7Evy4oPpvc/bPlcDCyNgXnk4n2TBcw==", + "dev": true, "requires": { - "debug": "^4.0.1", - "minimist": "^1.2.0", + "abort-controller": "^3.0.0", + "debug": "^4.3.1", + "minimist": "^1.2.5", "module-alias": "^2.2.2", - "node-fetch": "^2.2.0", - "sandwich-stream": "^2.0.1", - "telegram-typings": "^3.6.0" + "node-fetch": "^2.6.1", + "p-timeout": "^4.1.0", + "sandwich-stream": "^2.0.2", + "typegram": "^3.1.4" }, "dependencies": { "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" } } }, - "telegram-typings": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/telegram-typings/-/telegram-typings-3.6.1.tgz", - "integrity": "sha512-njVv1EAhIZnmQVLocZEADYUyqA1WIXuVcDYlsp+mXua/XB0pxx+PKtMSPeZ/EE4wPWTw9h/hA9ASTT6yQelkiw==" - }, "text-extensions": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", @@ -8035,6 +8006,12 @@ "integrity": "sha512-6PEvV+/kWAJeUwEtrKgIsZQSbybW5DGCr6s2mMjHsDplpgN8iBHI52UbA+2C+c2TMCxBNMK9TMS6pdeIdwsLSw==", "dev": true }, + "typegram": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/typegram/-/typegram-3.1.4.tgz", + "integrity": "sha512-AsYxLLynwBgeUJNU+3oSYNPSB3bwb/uyzrEPvrPwC0HXCYhW+otNV5q4T8Sb43SQSAP71hWC8EzBgDtlGGBx0A==", + "dev": true + }, "typescript": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", diff --git a/package.json b/package.json index 59dee72..26eadb7 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,6 @@ "test": "", "typedoc:build": "typedoc --tsconfig ./tsconfig.typedoc.json" }, - "dependencies": { - "telegraf": "3.38.0" - }, "devDependencies": { "@commitlint/cli": "11.0.0", "@commitlint/config-angular": "11.0.0", @@ -63,13 +60,15 @@ "prettier": "2.2.1", "reflect-metadata": "0.1.13", "rxjs": "6.6.3", + "telegraf": "4.0.0", "typedoc": "0.20.14", "typescript": "4.1.3" }, "peerDependencies": { "@nestjs/common": "^6.7.0 || ^7.0.0", "@nestjs/core": "^6.7.0 || ^7.0.0", - "reflect-metadata": "^0.1.13" + "reflect-metadata": "^0.1.13", + "telegraf": "^4.0.0" }, "husky": { "hooks": { diff --git a/sample/01-complete-app/package.json b/sample/01-complete-app/package.json index f6eba6b..dc57e8b 100644 --- a/sample/01-complete-app/package.json +++ b/sample/01-complete-app/package.json @@ -24,11 +24,11 @@ "@nestjs/core": "7.6.5", "@nestjs/platform-express": "7.6.5", "dotenv": "8.2.0", - "nestjs-telegraf": "*", + "nestjs-telegraf": "2.0.0-beta.1", "reflect-metadata": "0.1.13", "rimraf": "3.0.2", "rxjs": "6.6.3", - "telegraf": "3.38.0" + "telegraf": "4.0.0" }, "devDependencies": { "@nestjs/cli": "7.5.4",