nestjs-telegraf
Advanced tools
Comparing version 2.6.4 to 2.7.0
@@ -0,1 +1,2 @@ | ||
export * from './composer.decorator'; | ||
export * from './update.decorator'; | ||
@@ -2,0 +3,0 @@ export * from './scene.decorator'; |
@@ -17,2 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./composer.decorator"), exports); | ||
__exportStar(require("./update.decorator"), exports); | ||
@@ -19,0 +20,0 @@ __exportStar(require("./scene.decorator"), exports); |
@@ -24,4 +24,7 @@ import { OnModuleInit } from '@nestjs/common'; | ||
explore(): void; | ||
exploreUpdates(): void; | ||
private registerComposers; | ||
private registerUpdates; | ||
private registerScenes; | ||
private filterComposers; | ||
private filterUpdates; | ||
@@ -28,0 +31,0 @@ private filterScenes; |
@@ -43,10 +43,23 @@ "use strict"; | ||
}); | ||
this.explore(); | ||
this.bot.use(this.stage.middleware()); | ||
this.explore(); | ||
this.exploreUpdates(); | ||
} | ||
explore() { | ||
const modules = this.getModules(this.modulesContainer, this.telegrafOptions.include || []); | ||
this.registerUpdates(modules); | ||
this.registerComposers(modules); | ||
this.registerScenes(modules); | ||
} | ||
exploreUpdates() { | ||
const modules = this.getModules(this.modulesContainer, this.telegrafOptions.include || []); | ||
this.registerUpdates(modules); | ||
} | ||
registerComposers(modules) { | ||
const updates = this.flatMap(modules, (instance) => this.filterComposers(instance)); | ||
updates.forEach((wrapper) => { | ||
const composer = new telegraf_1.Composer(); | ||
this.registerListeners(composer, wrapper); | ||
this.stage.use(composer); | ||
}); | ||
} | ||
registerUpdates(modules) { | ||
@@ -58,4 +71,9 @@ const updates = this.flatMap(modules, (instance) => this.filterUpdates(instance)); | ||
const scenes = this.flatMap(modules, (wrapper) => this.filterScenes(wrapper)); | ||
const sceneIds = []; | ||
scenes.forEach((wrapper) => { | ||
const { sceneId, type, options } = this.metadataAccessor.getSceneMetadata(wrapper.instance.constructor); | ||
if (sceneIds.includes(sceneId)) { | ||
throw new Error(`Two scenes with the same id ${sceneId} were detected`); | ||
} | ||
sceneIds.push(sceneId); | ||
const scene = type === 'base' | ||
@@ -73,2 +91,11 @@ ? new telegraf_1.Scenes.BaseScene(sceneId, options || {}) | ||
} | ||
filterComposers(wrapper) { | ||
const { instance } = wrapper; | ||
if (!instance) | ||
return undefined; | ||
const isComposer = this.metadataAccessor.isComposer(wrapper.metatype); | ||
if (!isComposer) | ||
return undefined; | ||
return wrapper; | ||
} | ||
filterUpdates(wrapper) { | ||
@@ -75,0 +102,0 @@ const { instance } = wrapper; |
@@ -6,2 +6,3 @@ import { Reflector } from '@nestjs/core'; | ||
constructor(reflector: Reflector); | ||
isComposer(target: Function): boolean; | ||
isUpdate(target: Function): boolean; | ||
@@ -8,0 +9,0 @@ isScene(target: Function): boolean; |
@@ -20,2 +20,7 @@ "use strict"; | ||
} | ||
isComposer(target) { | ||
if (!target) | ||
return false; | ||
return !!this.reflector.get(telegraf_constants_1.COMPOSER_METADATA, target); | ||
} | ||
isUpdate(target) { | ||
@@ -22,0 +27,0 @@ if (!target) |
export declare const TELEGRAF_MODULE_OPTIONS = "TELEGRAF_MODULE_OPTIONS"; | ||
export declare const TELEGRAF_BOT_NAME = "TELEGRAF_BOT_NAME"; | ||
export declare const DEFAULT_BOT_NAME = "DEFAULT_BOT_NAME"; | ||
export declare const COMPOSER_METADATA = "COMPOSER_METADATA"; | ||
export declare const UPDATE_METADATA = "UPDATE_METADATA"; | ||
@@ -5,0 +6,0 @@ export declare const SCENE_METADATA = "SCENE_METADATA"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TELEGRAF_ALL_BOTS = exports.TELEGRAF_STAGE = exports.PARAM_ARGS_METADATA = exports.WIZARD_STEP_METADATA = exports.LISTENERS_METADATA = exports.SCENE_METADATA = exports.UPDATE_METADATA = exports.DEFAULT_BOT_NAME = exports.TELEGRAF_BOT_NAME = exports.TELEGRAF_MODULE_OPTIONS = void 0; | ||
exports.TELEGRAF_ALL_BOTS = exports.TELEGRAF_STAGE = exports.PARAM_ARGS_METADATA = exports.WIZARD_STEP_METADATA = exports.LISTENERS_METADATA = exports.SCENE_METADATA = exports.UPDATE_METADATA = exports.COMPOSER_METADATA = exports.DEFAULT_BOT_NAME = exports.TELEGRAF_BOT_NAME = exports.TELEGRAF_MODULE_OPTIONS = void 0; | ||
const constants_1 = require("@nestjs/common/constants"); | ||
@@ -8,2 +8,3 @@ exports.TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS'; | ||
exports.DEFAULT_BOT_NAME = 'DEFAULT_BOT_NAME'; | ||
exports.COMPOSER_METADATA = 'COMPOSER_METADATA'; | ||
exports.UPDATE_METADATA = 'UPDATE_METADATA'; | ||
@@ -10,0 +11,0 @@ exports.SCENE_METADATA = 'SCENE_METADATA'; |
MIT License | ||
Copyright (c) 2019 - present Hypeer (hello@hypeer.company) | ||
Copyright (c) 2019 - present Aleksandr Bukhalo (evilsprut@icloud.com) | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "nestjs-telegraf", | ||
"version": "2.6.4", | ||
"version": "2.7.0", | ||
"description": "Telegraf module for NestJS", | ||
@@ -17,10 +17,10 @@ "keywords": [ | ||
], | ||
"homepage": "https://nestjs-telegraf.hypeer.company", | ||
"homepage": "https://nestjs-telegraf.vercel.app", | ||
"bugs": { | ||
"url": "https://github.com/hypeertech/nestjs-telegraf/issues" | ||
"url": "https://github.com/evilsprut/nestjs-telegraf/issues" | ||
}, | ||
"repository": "git@github.com:hypeertech/nestjs-telegraf.git", | ||
"repository": "git@github.com:evilsprut/nestjs-telegraf.git", | ||
"funding": "https://hypeer.company/donate", | ||
"license": "MIT", | ||
"author": "Hypeer <hello@hypeer.company>", | ||
"author": "Aleksandr Bukhalo <evilsprut@icloud.com>", | ||
"contributors": [ | ||
@@ -40,3 +40,6 @@ { | ||
"test": "", | ||
"typedoc:build": "typedoc --tsconfig ./tsconfig.typedoc.json" | ||
"typedoc:build": "typedoc --tsconfig ./tsconfig.typedoc.json", | ||
"docs:dev": "vitepress dev", | ||
"docs:build": "vitepress build", | ||
"docs:preview": "vitepress preview" | ||
}, | ||
@@ -58,3 +61,3 @@ "husky": { | ||
"devDependencies": { | ||
"@commitlint/cli": "17.1.2", | ||
"@commitlint/cli": "17.4.4", | ||
"@commitlint/config-angular": "17.1.0", | ||
@@ -64,14 +67,15 @@ "@nestjs/common": "^9.0.11", | ||
"@types/lodash": "4.14.191", | ||
"@typescript-eslint/eslint-plugin": "5.44.0", | ||
"@typescript-eslint/eslint-plugin": "5.54.0", | ||
"@typescript-eslint/parser": "5.45.0", | ||
"eslint": "8.28.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint": "8.45.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"husky": "8.0.1", | ||
"lint-staged": "13.0.4", | ||
"prettier": "2.8.0", | ||
"lint-staged": "13.2.3", | ||
"prettier": "3.0.0", | ||
"reflect-metadata": "0.1.13", | ||
"telegraf": "4.12.2", | ||
"typedoc": "0.23.11", | ||
"typescript": "4.8.2" | ||
"typedoc": "0.24.8", | ||
"typescript": "4.8.2", | ||
"vitepress": "^1.0.0-beta.6" | ||
}, | ||
@@ -83,4 +87,4 @@ "peerDependencies": { | ||
"telegraf": "^4.0.0", | ||
"typescript": "^4.1.2" | ||
"typescript": "^4.1.2 || ^5.0.0" | ||
} | ||
} |
@@ -34,2 +34,2 @@ # NestJS Telegraf ![npm](https://img.shields.io/npm/dm/nestjs-telegraf) ![GitHub last commit](https://img.shields.io/github/last-commit/bukhalo/nestjs-telegraf) ![NPM](https://img.shields.io/npm/l/nestjs-telegraf) | ||
## Documentation | ||
Check out the [documentation site](https://nestjs-telegraf.hypeer.company). | ||
Check out the [documentation site](https://nestjs-telegraf.vercel.app). |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
93766
145
1619
18
1