Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-telegraf-decorators

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-telegraf-decorators - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

16

build/src/builder.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MetadataStorage_1 = require("./MetadataStorage");
var container_1 = require("./container");
var telegraf_1 = require("telegraf");
var MetadataStorage_1 = require("./MetadataStorage");
var WizardScene = require('telegraf/scenes/wizard');

@@ -14,3 +14,3 @@ var Stage = require('telegraf/stage');

bot.use(stage.middleware());
MetadataStorage_1.default.composerMetadata
MetadataStorage_1.MetadataArgsStorage.composerMetadata
.forEach(function (controller) {

@@ -30,3 +30,3 @@ var controllerInstance = container_1.getFromContainer(controller.target);

var scene = new Scene(controllerScene.options.data.scene);
MetadataStorage_1.default
MetadataStorage_1.MetadataArgsStorage
.handlers

@@ -43,3 +43,3 @@ .filter(function (value) { return controllerScene.target.prototype == value.target; })

var composer = new telegraf_1.Composer();
MetadataStorage_1.default
MetadataStorage_1.MetadataArgsStorage
.handlers

@@ -55,3 +55,3 @@ .filter(function (value) { return controller.target.prototype == value.target && value.type != "enter" && value.type != 'leave'; })

function buildWizard(bot, stage, wizard, controllerInstance) {
var group = MetadataStorage_1.default
var group = MetadataStorage_1.MetadataArgsStorage
.wizardStep

@@ -68,3 +68,3 @@ .sort(function (a, b) { return a.step - b.step; })

stepsMetadata.forEach(function (stepMethod) {
var handlers = MetadataStorage_1.default.handlers.filter(function (value) { return value.target == wizard.target.prototype && value.propertyName == stepMethod.propertyName; });
var handlers = MetadataStorage_1.MetadataArgsStorage.handlers.filter(function (value) { return value.target == wizard.target.prototype && value.propertyName == stepMethod.propertyName; });
if (handlers.length) {

@@ -86,3 +86,3 @@ handlers.forEach(function (handler) {

var wizardInstance = new (WizardScene.bind.apply(WizardScene, [void 0, wizard.options.data.name].concat(steps)))();
var handlers = MetadataStorage_1.default.handlers.filter(function (value) { return wizard.target.prototype == value.target && !MetadataStorage_1.default.wizardStep.find(function (value1) { return value1.propertyName == value.propertyName; }); });
var handlers = MetadataStorage_1.MetadataArgsStorage.handlers.filter(function (value) { return wizard.target.prototype == value.target && !MetadataStorage_1.MetadataArgsStorage.wizardStep.find(function (value1) { return value1.propertyName == value.propertyName; }); });
handlers.forEach(function (handler) {

@@ -96,3 +96,3 @@ wizardInstance[handler.type].apply(wizardInstance, handler.data.concat([function (ctx) {

function getInjectParams(ctx, target, methodName) {
return MetadataStorage_1.default
return MetadataStorage_1.MetadataArgsStorage
.paramMetadata

@@ -99,0 +99,0 @@ .filter(function (value) { return value.target == target.prototype && methodName === value.propertyName; })

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MetadataStorage_1 = require("./MetadataStorage");
var ParamsMetadata_1 = require("./metadata/ParamsMetadata");
var ComposerMetadata_1 = require("./metadata/ComposerMetadata");
var WizardStepMetadata_1 = require("./metadata/WizardStepMetadata");
var MetadataStorage_1 = require("./MetadataStorage");
function TFController(compose) {

@@ -33,3 +33,3 @@ return function (target, propertyKey, descriptor) {

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.wizardStep.push(new WizardStepMetadata_1.WizardStepMetadata(target, propertyKey, step));
MetadataStorage_1.MetadataArgsStorage.wizardStep.push(new WizardStepMetadata_1.WizardStepMetadata(target, propertyKey, step));
return descriptor;

@@ -53,3 +53,3 @@ };

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.composerMetadata.push(new ComposerMetadata_1.ComposerMetadata(target, options));
MetadataStorage_1.MetadataArgsStorage.composerMetadata.push(new ComposerMetadata_1.ComposerMetadata(target, options));
return descriptor;

@@ -61,3 +61,3 @@ };

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -74,3 +74,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -87,3 +87,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -100,3 +100,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -113,3 +113,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -126,3 +126,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -139,3 +139,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -152,3 +152,3 @@ target: target,

return function (target, propertyKey, descriptor) {
MetadataStorage_1.default.handlers.push({
MetadataStorage_1.MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -177,5 +177,5 @@ target: target,

return function () { return function (target, propertyKey, parameterIndex) {
MetadataStorage_1.default.paramMetadata.push(new ParamsMetadata_1.ParamsMetadata(target, propertyKey, parameterIndex, foo));
MetadataStorage_1.MetadataArgsStorage.paramMetadata.push(new ParamsMetadata_1.ParamsMetadata(target, propertyKey, parameterIndex, foo));
}; };
}
exports.createParamDecorator = createParamDecorator;

@@ -18,2 +18,2 @@ "use strict";

}());
exports.default = new MetadataStorage();
exports.MetadataArgsStorage = new MetadataStorage();

@@ -16,3 +16,2 @@ "use strict";

var src_1 = require("../src");
var MetadataStorage_1 = require("../src/MetadataStorage");
var BaseTextMessage = {

@@ -89,21 +88,21 @@ chat: { id: 1 },

it('add controller', function () {
expect(MetadataStorage_1.default.composerMetadata.find(function (value) { return value.target.prototype == TestController.prototype; })).toBeDefined();
expect(src_1.MetadataArgsStorage.composerMetadata.find(function (value) { return value.target.prototype == TestController.prototype; })).toBeDefined();
});
it('add start', function () {
expect(MetadataStorage_1.default.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "start"; })).toBeDefined();
expect(src_1.MetadataArgsStorage.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "start"; })).toBeDefined();
});
it('add help', function () {
expect(MetadataStorage_1.default.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "help"; })).toBeDefined();
expect(src_1.MetadataArgsStorage.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "help"; })).toBeDefined();
});
it('add action', function () {
expect(MetadataStorage_1.default.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "action"; })).toBeDefined();
expect(src_1.MetadataArgsStorage.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "action"; })).toBeDefined();
});
it('add command', function () {
expect(MetadataStorage_1.default.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "command"; })).toBeDefined();
expect(src_1.MetadataArgsStorage.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "command"; })).toBeDefined();
});
it('add hears', function () {
expect(MetadataStorage_1.default.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "hears"; })).toBeDefined();
expect(src_1.MetadataArgsStorage.handlers.find(function (value) { return value.target == TestController.prototype && value.type == "hears"; })).toBeDefined();
});
it('add inject parameters', function () {
expect(MetadataStorage_1.default.paramMetadata.find(function (value) { return value.target == TestController.prototype && value.propertyName == 'start'; })).toBeDefined();
expect(src_1.MetadataArgsStorage.paramMetadata.find(function (value) { return value.target == TestController.prototype && value.propertyName == 'start'; })).toBeDefined();
});

@@ -110,0 +109,0 @@ });

@@ -12,3 +12,3 @@ import { ParamsMetadata } from "./metadata/ParamsMetadata";

}
declare const _default: MetadataStorage;
export default _default;
export declare const MetadataArgsStorage: MetadataStorage;
export {};
{
"name": "ts-telegraf-decorators",
"version": "0.2.2",
"version": "0.2.3",
"author": "Ivan Surkov <panarama360@gmail.com>",

@@ -5,0 +5,0 @@ "main": "build/src/index.js",

@@ -14,2 +14,1 @@ import 'reflect-metadata'

}).startPolling()

@@ -1,2 +0,1 @@

import MetadataStorage from "./MetadataStorage";
import {IBotOptions} from "./interfaces/IBotOptions";

@@ -9,2 +8,3 @@ import {getFromContainer} from "./container";

import {WizardMetadata} from "./metadata/WizardMetadata";
import {MetadataArgsStorage} from "./MetadataStorage";

@@ -23,3 +23,3 @@ const WizardScene = require('telegraf/scenes/wizard')

MetadataStorage.composerMetadata
MetadataArgsStorage.composerMetadata
.forEach(controller => {

@@ -40,3 +40,3 @@ let controllerInstance = getFromContainer(controller.target)

const scene = new Scene(controllerScene.options.data.scene);
MetadataStorage
MetadataArgsStorage
.handlers

@@ -54,3 +54,3 @@ .filter(value => controllerScene.target.prototype == value.target)

const composer = new Composer();
MetadataStorage
MetadataArgsStorage
.handlers

@@ -67,3 +67,3 @@ .filter(value => controller.target.prototype == value.target && value.type != "enter" && value.type != 'leave')

function buildWizard(bot: any, stage: any, wizard: ComposerMetadata, controllerInstance: any) {
const group = MetadataStorage
const group = MetadataArgsStorage
.wizardStep

@@ -80,3 +80,3 @@ .sort((a, b) => a.step - b.step)

stepsMetadata.forEach(stepMethod => {
const handlers = MetadataStorage.handlers.filter(value => value.target == wizard.target.prototype && value.propertyName == stepMethod.propertyName);
const handlers = MetadataArgsStorage.handlers.filter(value => value.target == wizard.target.prototype && value.propertyName == stepMethod.propertyName);
if (handlers.length) {

@@ -100,3 +100,3 @@

const wizardInstance = new WizardScene(wizard.options.data.name, ...steps);
const handlers = MetadataStorage.handlers.filter(value => wizard.target.prototype == value.target && !MetadataStorage.wizardStep.find(value1 => value1.propertyName == value.propertyName))
const handlers = MetadataArgsStorage.handlers.filter(value => wizard.target.prototype == value.target && !MetadataArgsStorage.wizardStep.find(value1 => value1.propertyName == value.propertyName))
handlers.forEach(handler => {

@@ -113,3 +113,3 @@ wizardInstance[handler.type](...[...handler.data, (ctx) => {

return MetadataStorage
return MetadataArgsStorage
.paramMetadata

@@ -116,0 +116,0 @@ .filter(value => value.target == target.prototype && methodName === value.propertyName)

@@ -1,2 +0,1 @@

import MetadataStorage from "./MetadataStorage";
import * as tt from "telegraf/typings/telegram-types";

@@ -7,2 +6,3 @@ import {ParamsMetadata} from "./metadata/ParamsMetadata";

import {Composer as Comp, Context, ContextMessageUpdate} from "telegraf";
import {MetadataArgsStorage} from "./MetadataStorage";

@@ -36,3 +36,3 @@ export function TFController(compose?: (composer: Comp<any>) => void): Function {

return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.wizardStep.push(new WizardStepMetadata(target, propertyKey, step));
MetadataArgsStorage.wizardStep.push(new WizardStepMetadata(target, propertyKey, step));
return descriptor;

@@ -56,3 +56,3 @@ }

return function (target: Function, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.composerMetadata.push(new ComposerMetadata(target, options))
MetadataArgsStorage.composerMetadata.push(new ComposerMetadata(target, options))
return descriptor;

@@ -65,3 +65,3 @@ };

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -78,3 +78,3 @@ target,

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -92,3 +92,3 @@ target,

MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -105,3 +105,3 @@ target,

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -118,3 +118,3 @@ target,

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -131,3 +131,3 @@ target,

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -145,3 +145,3 @@ target,

MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -158,3 +158,3 @@ target,

return function (target: Object, propertyKey: string, descriptor: PropertyDescriptor) {
MetadataStorage.handlers.push({
MetadataArgsStorage.handlers.push({
propertyName: propertyKey,

@@ -188,4 +188,4 @@ target,

return () => (target: any, propertyKey: string, parameterIndex: number) => {
MetadataStorage.paramMetadata.push(new ParamsMetadata(target, propertyKey, parameterIndex, foo));
MetadataArgsStorage.paramMetadata.push(new ParamsMetadata(target, propertyKey, parameterIndex, foo));
}
}

@@ -24,2 +24,2 @@ import {ParamsMetadata} from "./metadata/ParamsMetadata";

export default new MetadataStorage();
export const MetadataArgsStorage = new MetadataStorage();

@@ -1,4 +0,15 @@

import {Action, buildBot, Command, Hears, Help, On, Start, TFContext, TFController, TFMessage} from "../src";
import {
Action,
buildBot,
Command,
Hears,
Help,
MetadataArgsStorage,
On,
Start,
TFContext,
TFController,
TFMessage
} from "../src";
import {Container} from "typedi";
import MetadataStorage from "../src/MetadataStorage";
import Telegraf from "telegraf";

@@ -48,27 +59,27 @@

it('add controller', function () {
expect(MetadataStorage.composerMetadata.find(value => value.target.prototype == TestController.prototype)).toBeDefined();
expect(MetadataArgsStorage.composerMetadata.find(value => value.target.prototype == TestController.prototype)).toBeDefined();
});
it('add start', function () {
expect(MetadataStorage.handlers.find(value => value.target == TestController.prototype && value.type == "start")).toBeDefined();
expect(MetadataArgsStorage.handlers.find(value => value.target == TestController.prototype && value.type == "start")).toBeDefined();
});
it('add help', function () {
expect(MetadataStorage.handlers.find(value => value.target == TestController.prototype && value.type == "help")).toBeDefined();
expect(MetadataArgsStorage.handlers.find(value => value.target == TestController.prototype && value.type == "help")).toBeDefined();
});
it('add action', function () {
expect(MetadataStorage.handlers.find(value => value.target == TestController.prototype && value.type == "action")).toBeDefined();
expect(MetadataArgsStorage.handlers.find(value => value.target == TestController.prototype && value.type == "action")).toBeDefined();
});
it('add command', function () {
expect(MetadataStorage.handlers.find(value => value.target == TestController.prototype && value.type == "command")).toBeDefined();
expect(MetadataArgsStorage.handlers.find(value => value.target == TestController.prototype && value.type == "command")).toBeDefined();
});
it('add hears', function () {
expect(MetadataStorage.handlers.find(value => value.target == TestController.prototype && value.type == "hears")).toBeDefined();
expect(MetadataArgsStorage.handlers.find(value => value.target == TestController.prototype && value.type == "hears")).toBeDefined();
});
it('add inject parameters', function () {
expect(MetadataStorage.paramMetadata.find(value => value.target == TestController.prototype && value.propertyName == 'start')).toBeDefined();
expect(MetadataArgsStorage.paramMetadata.find(value => value.target == TestController.prototype && value.propertyName == 'start')).toBeDefined();
});

@@ -75,0 +86,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc