From 6dd856876c3b6676cd39f6409748cc6cd8f98059 Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Mon, 31 Aug 2020 12:14:46 +0300
Subject: [PATCH 01/33] chore(deps): use development version of telegraf
package
---
package-lock.json | 47 +++++++++++++++++++++++------------------------
package.json | 2 +-
2 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 6025bcd..4681441 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -567,6 +567,21 @@
"type": "^1.0.1"
}
},
+ "debug": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+ "requires": {
+ "ms": "^2.1.1"
+ },
+ "dependencies": {
+ "ms": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+ }
+ }
+ },
"dedent": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
@@ -2729,38 +2744,17 @@
}
},
"telegraf": {
- "version": "3.38.0",
- "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-3.38.0.tgz",
- "integrity": "sha512-va4VlrKWp64JrowFoZX/NPzzA6q38kvaIukVXOWFO1V+jR1G8+hCfgJy4TX8Z3rwLJzwaBEet1QhikHDRZWl3A==",
+ "version": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976",
+ "from": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976",
"requires": {
"debug": "^4.0.1",
"minimist": "^1.2.0",
"module-alias": "^2.2.2",
"node-fetch": "^2.2.0",
"sandwich-stream": "^2.0.1",
- "telegram-typings": "^3.6.0"
- },
- "dependencies": {
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "ms": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
- }
+ "typegram": "^2.0.0"
}
},
- "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-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@@ -2840,6 +2834,11 @@
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
},
+ "typegram": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/typegram/-/typegram-2.1.0.tgz",
+ "integrity": "sha512-Cw/xS+KosABzRGxy8i+jqomw/+aKm1ntv0UpPxkyE5X20Iid/wMOcIqidLUPrhWEAT2FiDa5gO8h5g3XsjMVEw=="
+ },
"typescript": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
diff --git a/package.json b/package.json
index 61b0b97..1d7340b 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"test": ""
},
"dependencies": {
- "telegraf": "3.38.0"
+ "telegraf": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976"
},
"devDependencies": {
"@nestjs/common": "7.4.3",
From e999698fef69ab2ce03f5dc0b0d83e12e30f6c4a Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Mon, 31 Aug 2020 12:16:40 +0300
Subject: [PATCH 02/33] chore: remove legacy decorators
---
lib/decorators/action.decorator.ts | 8 --------
lib/decorators/cashtag.decorator.ts | 8 --------
lib/decorators/command.decorator.ts | 8 --------
lib/decorators/entity.decorator.ts | 8 --------
lib/decorators/game-query.decorator.ts | 8 --------
lib/decorators/hashtag.decorator.ts | 8 --------
lib/decorators/hears.decorator.ts | 8 --------
lib/decorators/help.decorator.ts | 8 --------
lib/decorators/inline-query.decorator.ts | 8 --------
lib/decorators/mention.decorator.ts | 8 --------
lib/decorators/on.decorator.ts | 8 --------
lib/decorators/phone.decorator.ts | 8 --------
lib/decorators/settings.decorator.ts | 8 --------
lib/decorators/start.decorator.ts | 8 --------
lib/decorators/use.decorator.ts | 8 --------
15 files changed, 120 deletions(-)
diff --git a/lib/decorators/action.decorator.ts b/lib/decorators/action.decorator.ts
index a6c7a99..e54ace0 100644
--- a/lib/decorators/action.decorator.ts
+++ b/lib/decorators/action.decorator.ts
@@ -17,11 +17,3 @@ export interface ActionOptions {
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
return SetMetadata(DECORATORS.ACTION, { triggers });
};
-
-/**
- * Registers middleware for handling callback_data actions with regular expressions.
- *
- * @see https://telegraf.js.org/#/?id=action
- * @deprecated since v2, use Action decorator instead.
- */
-export const TelegrafAction = Action;
diff --git a/lib/decorators/cashtag.decorator.ts b/lib/decorators/cashtag.decorator.ts
index e85efb3..b98b2da 100644
--- a/lib/decorators/cashtag.decorator.ts
+++ b/lib/decorators/cashtag.decorator.ts
@@ -15,11 +15,3 @@ export interface CashtagOptions {
export const Cashtag = (cashtag: TelegrafCashtagCashtag): MethodDecorator => {
return SetMetadata(DECORATORS.CASHTAG, { cashtag });
};
-
-/**
- * Cashtag handling.
- *
- * @see https://telegraf.js.org/#/?id=cashtag
- * @deprecated since v2, use Cashtag decorator instead.
- */
-export const TelegrafCashtag = Cashtag;
diff --git a/lib/decorators/command.decorator.ts b/lib/decorators/command.decorator.ts
index 6100612..2fb6e7a 100644
--- a/lib/decorators/command.decorator.ts
+++ b/lib/decorators/command.decorator.ts
@@ -15,11 +15,3 @@ export interface CommandOptions {
export const Command = (commands: TelegrafCommandCommands): MethodDecorator => {
return SetMetadata(DECORATORS.COMMAND, { commands });
};
-
-/**
- * Command handling.
- *
- * @see https://telegraf.js.org/#/?id=command
- * @deprecated since v2, use Command decorator instead.
- */
-export const TelegrafCommand = Command;
diff --git a/lib/decorators/entity.decorator.ts b/lib/decorators/entity.decorator.ts
index 53be71f..7c16011 100644
--- a/lib/decorators/entity.decorator.ts
+++ b/lib/decorators/entity.decorator.ts
@@ -20,11 +20,3 @@ export interface EntityOptions {
export const Entity = (entity: TelegrafEntityEntity): MethodDecorator => {
return SetMetadata(DECORATORS.ENTITY, { entity });
};
-
-/**
- * Entity handling.
- *
- * @see https://telegraf.js.org/#/?id=entity
- * @deprecated since v2, use Entity decorator instead.
- */
-export const TelegrafEntity = Entity;
diff --git a/lib/decorators/game-query.decorator.ts b/lib/decorators/game-query.decorator.ts
index c9d240b..dd1138c 100644
--- a/lib/decorators/game-query.decorator.ts
+++ b/lib/decorators/game-query.decorator.ts
@@ -9,11 +9,3 @@ import { DECORATORS } from '../telegraf.constants';
export const GameQuery = (): MethodDecorator => {
return SetMetadata(DECORATORS.GAME_QUERY, {});
};
-
-/**
- * Registers middleware for handling callback_data actions with game query.
- *
- * @see https://telegraf.js.org/#/?id=inlinequery
- * @deprecated since v2, use Action decorator instead.
- */
-export const TelegrafGameQuery = GameQuery;
diff --git a/lib/decorators/hashtag.decorator.ts b/lib/decorators/hashtag.decorator.ts
index 88e03cb..9269411 100644
--- a/lib/decorators/hashtag.decorator.ts
+++ b/lib/decorators/hashtag.decorator.ts
@@ -15,11 +15,3 @@ export interface HashtagOptions {
export const Hashtag = (hashtag: TelegrafHashtagHashtag): MethodDecorator => {
return SetMetadata(DECORATORS.HASHTAG, { hashtag });
};
-
-/**
- * Hashtag handling.
- *
- * @see https://telegraf.js.org/#/?id=hashtag
- * @deprecated since v2, use Hashtag decorator instead.
- */
-export const TelegrafHashtag = Hashtag;
diff --git a/lib/decorators/hears.decorator.ts b/lib/decorators/hears.decorator.ts
index ecb7c56..6e62bdd 100644
--- a/lib/decorators/hears.decorator.ts
+++ b/lib/decorators/hears.decorator.ts
@@ -17,11 +17,3 @@ export interface HearsOptions {
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
};
-
-/**
- * Registers middleware for handling text messages.
- *
- * @see https://telegraf.js.org/#/?id=hears
- * @deprecated since v2, use Hears decorator instead.
- */
-export const TelegrafHears = Hears;
diff --git a/lib/decorators/help.decorator.ts b/lib/decorators/help.decorator.ts
index ced12b1..159a5c5 100644
--- a/lib/decorators/help.decorator.ts
+++ b/lib/decorators/help.decorator.ts
@@ -9,11 +9,3 @@ import { DECORATORS } from '../telegraf.constants';
export const Help = (): MethodDecorator => {
return SetMetadata(DECORATORS.HELP, {});
};
-
-/**
- * Handler for /help command.
- *
- * @see https://telegraf.js.org/#/?id=help
- * @deprecated since v2, use Help decorator instead.
- */
-export const TelegrafHelp = Help;
diff --git a/lib/decorators/inline-query.decorator.ts b/lib/decorators/inline-query.decorator.ts
index 4345d1b..2979722 100644
--- a/lib/decorators/inline-query.decorator.ts
+++ b/lib/decorators/inline-query.decorator.ts
@@ -17,11 +17,3 @@ export const InlineQuery = (
): MethodDecorator => {
return SetMetadata(DECORATORS.INLINE_QUERY, { triggers });
};
-
-/**
- * Registers middleware for handling inline_query actions with regular expressions.
- *
- * @see https://telegraf.js.org/#/?id=inlinequery
- * @deprecated since v2, use InlineQuery decorator instead.
- */
-export const TelegrafInlineQuery = InlineQuery;
diff --git a/lib/decorators/mention.decorator.ts b/lib/decorators/mention.decorator.ts
index 7611c8e..004f41b 100644
--- a/lib/decorators/mention.decorator.ts
+++ b/lib/decorators/mention.decorator.ts
@@ -15,11 +15,3 @@ export interface MentionOptions {
export const Mention = (username: TelegrafMentionUsername): MethodDecorator => {
return SetMetadata(DECORATORS.MENTION, { username });
};
-
-/**
- * Mention handling.
- *
- * @see https://telegraf.js.org/#/?id=mention
- * @deprecated since v2, use Mention decorator instead.
- */
-export const TelegrafMention = Mention;
diff --git a/lib/decorators/on.decorator.ts b/lib/decorators/on.decorator.ts
index bc36c94..9e3752a 100644
--- a/lib/decorators/on.decorator.ts
+++ b/lib/decorators/on.decorator.ts
@@ -20,11 +20,3 @@ export interface OnOptions {
export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
};
-
-/**
- * Registers middleware for provided update type.
- *
- * @see https://telegraf.js.org/#/?id=on
- * @deprecated since v2, use On decorator instead.
- */
-export const TelegrafOn = On;
diff --git a/lib/decorators/phone.decorator.ts b/lib/decorators/phone.decorator.ts
index 90e6342..39a0b27 100644
--- a/lib/decorators/phone.decorator.ts
+++ b/lib/decorators/phone.decorator.ts
@@ -15,11 +15,3 @@ export interface PhoneOptions {
export const Phone = (phone: TelegrafPhonePhone): MethodDecorator => {
return SetMetadata(DECORATORS.PHONE, { phone });
};
-
-/**
- * Phone number handling.
- *
- * @see https://telegraf.js.org/#/?id=phone
- * @deprecated since v2, use Phone decorator instead.
- */
-export const TelegrafPhone = Phone;
diff --git a/lib/decorators/settings.decorator.ts b/lib/decorators/settings.decorator.ts
index 674af29..9378e7f 100644
--- a/lib/decorators/settings.decorator.ts
+++ b/lib/decorators/settings.decorator.ts
@@ -9,11 +9,3 @@ import { DECORATORS } from '../telegraf.constants';
export const Settings = (): MethodDecorator => {
return SetMetadata(DECORATORS.SETTINGS, {});
};
-
-/**
- * Handler for /settings command.
- *
- * @see https://telegraf.js.org/#/?id=settings
- * @deprecated since v2, use Settings decorator instead.
- */
-export const TelegrafSettings = Settings;
diff --git a/lib/decorators/start.decorator.ts b/lib/decorators/start.decorator.ts
index d11658e..9429753 100644
--- a/lib/decorators/start.decorator.ts
+++ b/lib/decorators/start.decorator.ts
@@ -9,11 +9,3 @@ import { DECORATORS } from '../telegraf.constants';
export const Start = (): MethodDecorator => {
return SetMetadata(DECORATORS.START, {});
};
-
-/**
- * Handler for /start command.
- *
- * @see https://telegraf.js.org/#/?id=start
- * @deprecated since v2, use Start decorator instead.
- */
-export const TelegrafStart = Start;
diff --git a/lib/decorators/use.decorator.ts b/lib/decorators/use.decorator.ts
index 8c47461..a7f68fa 100644
--- a/lib/decorators/use.decorator.ts
+++ b/lib/decorators/use.decorator.ts
@@ -9,11 +9,3 @@ import { DECORATORS } from '../telegraf.constants';
export const Use = (): MethodDecorator => {
return SetMetadata(DECORATORS.USE, {});
};
-
-/**
- * Registers a middleware.
- *
- * @see https://telegraf.js.org/#/?id=use
- * @deprecated since v2, use Use decorator instead.
- */
-export const TelegrafUse = Use;
From e892e5ad0807bc006245cdffb867378f79a80730 Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Mon, 31 Aug 2020 13:17:41 +0300
Subject: [PATCH 03/33] chore: bump version
---
package-lock.json | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 4681441..b6bfd80 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "nestjs-telegraf",
- "version": "1.3.0",
+ "version": "2.0.0-alpha.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 1d7340b..af0983f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "nestjs-telegraf",
- "version": "1.3.0",
+ "version": "2.0.0-alpha.1",
"description": "Telegraf module for NestJS",
"keywords": [
"nest",
From 678ad0d7c2577a2ab23ac4d3c2b71bc5a4f46b24 Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Thu, 10 Sep 2020 12:52:20 +0300
Subject: [PATCH 04/33] chore(deps): ugrade telegraf version
---
package-lock.json | 1127 +++++++++++++++++++++++----------------------
package.json | 2 +-
2 files changed, 585 insertions(+), 544 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index b6bfd80..888220d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,38 +5,61 @@
"requires": true,
"dependencies": {
"@babel/code-frame": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz",
- "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==",
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
+ "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
"dev": true,
"requires": {
- "@babel/highlight": "^7.8.3"
+ "@babel/highlight": "^7.10.4"
}
},
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
+ "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==",
+ "dev": true
+ },
"@babel/highlight": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz",
- "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==",
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
+ "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
"dev": true,
"requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
"chalk": "^2.0.0",
- "esutils": "^2.0.2",
"js-tokens": "^4.0.0"
}
},
- "@babel/runtime": {
- "version": "7.8.3",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.3.tgz",
- "integrity": "sha512-fVHx1rzEmwB130VTkLnxR+HmxcTjGzH12LYQcFFoBwakMd3aOMD4OsRN7tGG/UOYE2ektgFrS8uACAoRk1CY0w==",
+ "@eslint/eslintrc": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz",
+ "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==",
"dev": true,
"requires": {
- "regenerator-runtime": "^0.13.2"
+ "ajv": "^6.12.4",
+ "debug": "^4.1.1",
+ "espree": "^7.3.0",
+ "globals": "^12.1.0",
+ "ignore": "^4.0.6",
+ "import-fresh": "^3.2.1",
+ "js-yaml": "^3.13.1",
+ "lodash": "^4.17.19",
+ "minimatch": "^3.0.4",
+ "strip-json-comments": "^3.1.1"
+ },
+ "dependencies": {
+ "ignore": {
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
+ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "dev": true
+ }
}
},
"@nestjs/common": {
- "version": "7.4.3",
- "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-7.4.3.tgz",
- "integrity": "sha512-OeNnzPbUOk2dUuvf8/X0yBzDMhaR5IZP4Qzq8KpXVHk6xJewrscYlEpyMxymlSlnEYW3NWzj5woacvLbeps4Vg==",
+ "version": "7.4.4",
+ "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-7.4.4.tgz",
+ "integrity": "sha512-Cj94FJrnLcAU4URJrRmnsHRODZPJpX+EKKJ/Or9qvL9ULQwRWYmFcGQYaJ0nVV0hSBjn/jaAV1Cgqw74uk21KA==",
"dev": true,
"requires": {
"axios": "0.20.0",
@@ -44,20 +67,12 @@
"iterare": "1.2.1",
"tslib": "2.0.1",
"uuid": "8.3.0"
- },
- "dependencies": {
- "tslib": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
- "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==",
- "dev": true
- }
}
},
"@nestjs/core": {
- "version": "7.4.3",
- "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.4.3.tgz",
- "integrity": "sha512-YWC4x5G5cHhlBB/6oyw9ug781lSm9s6QqMRNKYjiR47A1HoxOcAJQ8NMrm9axgK9ZET547k0rl473vyjhPwwlg==",
+ "version": "7.4.4",
+ "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.4.4.tgz",
+ "integrity": "sha512-e3iID6s0JIaWDlZMIO+gkk5KDwHW+VUexvZOKXbTjtsBidtusbiT4JLr4ODkj8y3QSfQN9vouY9hWfwwQrxa/Q==",
"dev": true,
"requires": {
"@nuxtjs/opencollective": "0.2.2",
@@ -67,14 +82,32 @@
"path-to-regexp": "3.2.0",
"tslib": "2.0.1",
"uuid": "8.3.0"
- },
- "dependencies": {
- "tslib": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
- "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==",
- "dev": true
- }
+ }
+ },
+ "@nodelib/fs.scandir": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz",
+ "integrity": "sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.stat": "2.0.3",
+ "run-parallel": "^1.1.9"
+ }
+ },
+ "@nodelib/fs.stat": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz",
+ "integrity": "sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==",
+ "dev": true
+ },
+ "@nodelib/fs.walk": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz",
+ "integrity": "sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.scandir": "2.1.3",
+ "fastq": "^1.6.0"
}
},
"@nuxtjs/opencollective": {
@@ -101,9 +134,9 @@
"dev": true
},
"@types/json-schema": {
- "version": "7.0.5",
- "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz",
- "integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==",
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
+ "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==",
"dev": true
},
"@types/json5": {
@@ -119,45 +152,30 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.10.1.tgz",
- "integrity": "sha512-PQg0emRtzZFWq6PxBcdxRH3QIQiyFO3WCVpRL3fgj5oQS3CDs3AeAKfv4DxNhzn8ITdNJGJ4D3Qw8eAJf3lXeQ==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.0.tgz",
+ "integrity": "sha512-5e6q1TR7gS2P+8W2xndCu7gBh3BzmYEo70OyIdsmCmknHha/yNbz2vdevl+tP1uoaMOcrzg4gyrAijuV3DDBHA==",
"dev": true,
"requires": {
- "@typescript-eslint/experimental-utils": "3.10.1",
+ "@typescript-eslint/experimental-utils": "4.0.0",
+ "@typescript-eslint/scope-manager": "4.0.0",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
- },
- "dependencies": {
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "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
- }
}
},
"@typescript-eslint/experimental-utils": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz",
- "integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.0.0.tgz",
+ "integrity": "sha512-hbX6zR+a/vcpFVNJYN/Nbd7gmaMosDTxHEKcvmhWeWcq/0UDifrqmCfkkodbAKL46Fn4ekSBMTyq2zlNDzcQxw==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/types": "3.10.1",
- "@typescript-eslint/typescript-estree": "3.10.1",
+ "@typescript-eslint/scope-manager": "4.0.0",
+ "@typescript-eslint/types": "4.0.0",
+ "@typescript-eslint/typescript-estree": "4.0.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
@@ -219,69 +237,54 @@
"eslint-visitor-keys": "^1.1.0"
}
},
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "ms": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
+ "eslint-visitor-keys": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
"dev": true
}
}
},
+ "@typescript-eslint/scope-manager": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.0.0.tgz",
+ "integrity": "sha512-9gcWUPoWo7gk/+ZQPg7L1ySRmR5HLIy3Vu6/LfhQbuzIkGm6v2CGIjpVRISoDLFRovNRDImd4aP/sa8O4yIEBg==",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/types": "4.0.0",
+ "@typescript-eslint/visitor-keys": "4.0.0"
+ }
+ },
"@typescript-eslint/types": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz",
- "integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.0.0.tgz",
+ "integrity": "sha512-bK+c2VLzznX2fUWLK6pFDv3cXGTp7nHIuBMq1B9klA+QCsqLHOOqe5TQReAQDl7DN2RfH+neweo0oC5hYlG7Rg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz",
- "integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.0.0.tgz",
+ "integrity": "sha512-ewFMPi2pMLDNIXGMPdf8r7El2oPSZw9PEYB0j+WcpKd7AX2ARmajGa7RUHTukllWX2bj4vWX6JLE1Oih2BMokA==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "3.10.1",
- "@typescript-eslint/visitor-keys": "3.10.1",
+ "@typescript-eslint/types": "4.0.0",
+ "@typescript-eslint/visitor-keys": "4.0.0",
"debug": "^4.1.1",
- "glob": "^7.1.6",
+ "globby": "^11.0.1",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
- },
- "dependencies": {
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "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
- }
}
},
"@typescript-eslint/visitor-keys": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz",
- "integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.0.0.tgz",
+ "integrity": "sha512-sTouJbv6rjVJeTE4lpSBVYXq/u5K3gbB6LKt7ccFEZPTZB/VeQ0ssUz9q5Hx++sCqBbdF8PzrrgvEnicXAR6NQ==",
"dev": true,
"requires": {
- "eslint-visitor-keys": "^1.1.0"
+ "@typescript-eslint/types": "4.0.0",
+ "eslint-visitor-keys": "^2.0.0"
}
},
"acorn": {
@@ -291,9 +294,9 @@
"dev": true
},
"acorn-jsx": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz",
- "integrity": "sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==",
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
+ "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
"dev": true
},
"aggregate-error": {
@@ -319,9 +322,9 @@
}
},
"ansi-colors": {
- "version": "3.2.4",
- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz",
- "integrity": "sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
+ "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true
},
"ansi-escapes": {
@@ -376,6 +379,12 @@
"is-string": "^1.0.5"
}
},
+ "array-union": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
+ "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
+ "dev": true
+ },
"array.prototype.flat": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz",
@@ -486,6 +495,73 @@
"requires": {
"slice-ansi": "^3.0.0",
"string-width": "^4.2.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
+ "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
+ "dev": true,
+ "requires": {
+ "@types/color-name": "^1.1.1",
+ "color-convert": "^2.0.1"
+ }
+ },
+ "astral-regex": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
+ "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
+ "dev": true
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true
+ },
+ "emoji-regex": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "dev": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true
+ },
+ "slice-ansi": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz",
+ "integrity": "sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^4.0.0",
+ "astral-regex": "^2.0.0",
+ "is-fullwidth-code-point": "^3.0.0"
+ }
+ },
+ "string-width": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
+ "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
+ "dev": true,
+ "requires": {
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^6.0.0"
+ }
+ }
}
},
"color-convert": {
@@ -504,9 +580,9 @@
"dev": true
},
"commander": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/commander/-/commander-6.0.0.tgz",
- "integrity": "sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA==",
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-6.1.0.tgz",
+ "integrity": "sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA==",
"dev": true
},
"compare-versions": {
@@ -534,22 +610,36 @@
"dev": true
},
"cosmiconfig": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-6.0.0.tgz",
- "integrity": "sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==",
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz",
+ "integrity": "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==",
"dev": true,
"requires": {
"@types/parse-json": "^4.0.0",
- "import-fresh": "^3.1.0",
+ "import-fresh": "^3.2.1",
"parse-json": "^5.0.0",
"path-type": "^4.0.0",
- "yaml": "^1.7.2"
+ "yaml": "^1.10.0"
+ },
+ "dependencies": {
+ "parse-json": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.1.0.tgz",
+ "integrity": "sha512-+mi/lmVVNKFNVyLXV31ERiy2CY5E1/F6QtJFEzoChPRwwngMNXRDQ9GJ5WdE2Z2P4AujsOi0/+2qHID68KwfIQ==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.0.0",
+ "error-ex": "^1.3.1",
+ "json-parse-even-better-errors": "^2.3.0",
+ "lines-and-columns": "^1.1.6"
+ }
+ }
}
},
"cross-spawn": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz",
- "integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==",
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
+ "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
@@ -573,13 +663,6 @@
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
- },
- "dependencies": {
- "ms": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
- "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
- }
}
},
"dedent": {
@@ -603,6 +686,15 @@
"object-keys": "^1.0.12"
}
},
+ "dir-glob": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
+ "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
+ "dev": true,
+ "requires": {
+ "path-type": "^4.0.0"
+ }
+ },
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
@@ -613,9 +705,9 @@
}
},
"emoji-regex": {
- "version": "8.0.0",
- "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
- "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
+ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
"dev": true
},
"end-of-stream": {
@@ -628,12 +720,12 @@
}
},
"enquirer": {
- "version": "2.3.5",
- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.5.tgz",
- "integrity": "sha512-BNT1C08P9XD0vNg3J475yIUG+mVdp9T6towYFHUv897X0KoHBjB1shyrNmhmtHWKP17iSWgo7Gqh7BBuzLZMSA==",
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
+ "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
"dev": true,
"requires": {
- "ansi-colors": "^3.2.1"
+ "ansi-colors": "^4.1.1"
}
},
"error-ex": {
@@ -726,12 +818,13 @@
"dev": true
},
"eslint": {
- "version": "7.7.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.7.0.tgz",
- "integrity": "sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==",
+ "version": "7.8.1",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.1.tgz",
+ "integrity": "sha512-/2rX2pfhyUG0y+A123d0ccXtMm7DV7sH1m3lk9nk2DZ2LReq39FXHueR9xZwshE5MdfSf0xunSaMWRqyIA6M1w==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
+ "@eslint/eslintrc": "^0.1.3",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
@@ -741,7 +834,7 @@
"eslint-scope": "^5.1.0",
"eslint-utils": "^2.1.0",
"eslint-visitor-keys": "^1.3.0",
- "espree": "^7.2.0",
+ "espree": "^7.3.0",
"esquery": "^1.2.0",
"esutils": "^2.0.2",
"file-entry-cache": "^5.0.1",
@@ -804,14 +897,11 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
+ "eslint-visitor-keys": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
+ "dev": true
},
"has-flag": {
"version": "4.0.0",
@@ -819,16 +909,16 @@
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"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==",
+ "ignore": {
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
+ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"supports-color": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
- "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
@@ -863,6 +953,12 @@
"requires": {
"ms": "2.0.0"
}
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
}
}
},
@@ -885,63 +981,11 @@
"ms": "2.0.0"
}
},
- "find-up": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
- "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
- "dev": true,
- "requires": {
- "locate-path": "^2.0.0"
- }
- },
- "locate-path": {
+ "ms": {
"version": "2.0.0",
- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
- "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
- "dev": true,
- "requires": {
- "p-locate": "^2.0.0",
- "path-exists": "^3.0.0"
- }
- },
- "p-limit": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
- "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
- "dev": true,
- "requires": {
- "p-try": "^1.0.0"
- }
- },
- "p-locate": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
- "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
- "dev": true,
- "requires": {
- "p-limit": "^1.1.0"
- }
- },
- "p-try": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
- "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
- },
- "path-exists": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
- "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
- "dev": true
- },
- "pkg-dir": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz",
- "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=",
- "dev": true,
- "requires": {
- "find-up": "^2.1.0"
- }
}
}
},
@@ -984,6 +1028,12 @@
"esutils": "^2.0.2",
"isarray": "^1.0.0"
}
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
+ "dev": true
}
}
},
@@ -1004,23 +1054,39 @@
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
+ },
+ "dependencies": {
+ "eslint-visitor-keys": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
+ "dev": true
+ }
}
},
"eslint-visitor-keys": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
- "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
+ "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
},
"espree": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz",
- "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==",
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz",
+ "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==",
"dev": true,
"requires": {
- "acorn": "^7.3.1",
+ "acorn": "^7.4.0",
"acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.3.0"
+ },
+ "dependencies": {
+ "eslint-visitor-keys": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
+ "dev": true
+ }
}
},
"esprima": {
@@ -1047,12 +1113,20 @@
}
},
"esrecurse": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
- "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
+ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
"dev": true,
"requires": {
- "estraverse": "^4.1.0"
+ "estraverse": "^5.2.0"
+ },
+ "dependencies": {
+ "estraverse": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
+ "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
+ "dev": true
+ }
}
},
"estraverse": {
@@ -1117,6 +1191,20 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
+ "fast-glob": {
+ "version": "3.2.4",
+ "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz",
+ "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.0",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.2",
+ "picomatch": "^2.2.1"
+ }
+ },
"fast-json-stable-stringify": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
@@ -1135,6 +1223,15 @@
"integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==",
"dev": true
},
+ "fastq": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz",
+ "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==",
+ "dev": true,
+ "requires": {
+ "reusify": "^1.0.4"
+ }
+ },
"figures": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@@ -1163,13 +1260,12 @@
}
},
"find-up": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
- "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
+ "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
"dev": true,
"requires": {
- "locate-path": "^5.0.0",
- "path-exists": "^4.0.0"
+ "locate-path": "^2.0.0"
}
},
"find-versions": {
@@ -1275,6 +1371,20 @@
"type-fest": "^0.8.1"
}
},
+ "globby": {
+ "version": "11.0.1",
+ "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz",
+ "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==",
+ "dev": true,
+ "requires": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.1.1",
+ "ignore": "^5.1.4",
+ "merge2": "^1.3.0",
+ "slash": "^3.0.0"
+ }
+ },
"graceful-fs": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
@@ -1315,15 +1425,15 @@
"dev": true
},
"husky": {
- "version": "4.2.5",
- "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.5.tgz",
- "integrity": "sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==",
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.0.tgz",
+ "integrity": "sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA==",
"dev": true,
"requires": {
"chalk": "^4.0.0",
"ci-info": "^2.0.0",
"compare-versions": "^3.6.0",
- "cosmiconfig": "^6.0.0",
+ "cosmiconfig": "^7.0.0",
"find-versions": "^3.2.0",
"opencollective-postinstall": "^2.0.2",
"pkg-dir": "^4.2.0",
@@ -1343,9 +1453,9 @@
}
},
"chalk": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.0.0.tgz",
- "integrity": "sha512-N9oWFcegS0sFr9oh1oz2d7Npos6vNoWW9HvtCg5N1KRFpUhaAhvTv5Y58g880fZaEYSNm3qDz8SU1UrGvp+n7A==",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
+ "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
@@ -1367,16 +1477,74 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
+ "find-up": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^5.0.0",
+ "path-exists": "^4.0.0"
+ }
+ },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
+ "locate-path": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^4.1.0"
+ }
+ },
+ "p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "dev": true,
+ "requires": {
+ "p-try": "^2.0.0"
+ }
+ },
+ "p-locate": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "dev": true,
+ "requires": {
+ "p-limit": "^2.2.0"
+ }
+ },
+ "p-try": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+ "dev": true
+ },
+ "path-exists": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+ "dev": true
+ },
+ "pkg-dir": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
+ "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
+ "dev": true,
+ "requires": {
+ "find-up": "^4.0.0"
+ }
+ },
"supports-color": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
- "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
@@ -1385,9 +1553,9 @@
}
},
"ignore": {
- "version": "4.0.6",
- "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
- "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "version": "5.1.8",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz",
+ "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==",
"dev": true
},
"import-fresh": {
@@ -1435,9 +1603,9 @@
"dev": true
},
"is-callable": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz",
- "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==",
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz",
+ "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==",
"dev": true
},
"is-date-object": {
@@ -1453,9 +1621,9 @@
"dev": true
},
"is-fullwidth-code-point": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
- "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"dev": true
},
"is-glob": {
@@ -1486,9 +1654,9 @@
"dev": true
},
"is-regex": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz",
- "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==",
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz",
+ "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==",
"dev": true,
"requires": {
"has-symbols": "^1.0.1"
@@ -1555,10 +1723,10 @@
"esprima": "^4.0.0"
}
},
- "json-parse-better-errors": {
- "version": "1.0.2",
- "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
- "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
+ "json-parse-even-better-errors": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
+ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
"dev": true
},
"json-schema-traverse": {
@@ -1599,9 +1767,9 @@
"dev": true
},
"lint-staged": {
- "version": "10.2.13",
- "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.2.13.tgz",
- "integrity": "sha512-conwlukNV6aL9SiMWjFtDp5exeDnTMekdNPDZsKGnpfQuHcO0E3L3Bbf58lcR+M7vk6LpCilxDAVks/DDVBYlA==",
+ "version": "10.3.0",
+ "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.3.0.tgz",
+ "integrity": "sha512-an3VgjHqmJk0TORB/sdQl0CTkRg4E5ybYCXTTCSJ5h9jFwZbcgKIx5oVma5e7wp/uKt17s1QYFmYqT9MGVosGw==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
@@ -1621,12 +1789,6 @@
"stringify-object": "^3.3.0"
},
"dependencies": {
- "ansi-colors": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
- "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
- "dev": true
- },
"ansi-styles": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
@@ -1662,70 +1824,27 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
- "cosmiconfig": {
- "version": "7.0.0",
- "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz",
- "integrity": "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==",
- "dev": true,
- "requires": {
- "@types/parse-json": "^4.0.0",
- "import-fresh": "^3.2.1",
- "parse-json": "^5.0.0",
- "path-type": "^4.0.0",
- "yaml": "^1.10.0"
- }
- },
- "debug": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
- "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
- "dev": true,
- "requires": {
- "ms": "^2.1.1"
- }
- },
- "enquirer": {
- "version": "2.3.6",
- "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
- "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
- "dev": true,
- "requires": {
- "ansi-colors": "^4.1.1"
- }
- },
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"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
- },
"supports-color": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
- "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
- },
- "yaml": {
- "version": "1.10.0",
- "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz",
- "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==",
- "dev": true
}
}
},
"listr2": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/listr2/-/listr2-2.6.0.tgz",
- "integrity": "sha512-nwmqTJYQQ+AsKb4fCXH/6/UmLCEDL1jkRAdSn9M6cEUzoRGrs33YD/3N86gAZQnGZ6hxV18XSdlBcJ1GTmetJA==",
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/listr2/-/listr2-2.6.2.tgz",
+ "integrity": "sha512-6x6pKEMs8DSIpA/tixiYY2m/GcbgMplMVmhQAaLFxEtNSKLeWTGjtmU57xvv6QCm2XcqzyNXL/cTSVf4IChCRA==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
@@ -1780,9 +1899,9 @@
"dev": true
},
"supports-color": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
- "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
@@ -1800,26 +1919,16 @@
"parse-json": "^2.2.0",
"pify": "^2.0.0",
"strip-bom": "^3.0.0"
- },
- "dependencies": {
- "parse-json": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
- "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
- "dev": true,
- "requires": {
- "error-ex": "^1.2.0"
- }
- }
}
},
"locate-path": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
- "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
+ "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
"dev": true,
"requires": {
- "p-locate": "^4.1.0"
+ "p-locate": "^2.0.0",
+ "path-exists": "^3.0.0"
}
},
"lodash": {
@@ -1879,9 +1988,9 @@
"dev": true
},
"supports-color": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
- "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
@@ -1932,6 +2041,12 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
+ "is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true
+ },
"slice-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz",
@@ -1976,6 +2091,12 @@
"integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
"dev": true
},
+ "merge2": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
+ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==",
+ "dev": true
+ },
"micromatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz",
@@ -2021,10 +2142,9 @@
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q=="
},
"ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
- "dev": true
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"natural-compare": {
"version": "1.4.0",
@@ -2039,9 +2159,9 @@
"dev": true
},
"node-fetch": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
- "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
+ "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"normalize-package-data": {
"version": "2.5.0",
@@ -2139,9 +2259,9 @@
}
},
"opencollective-postinstall": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz",
- "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==",
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
+ "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==",
"dev": true
},
"optionator": {
@@ -2159,21 +2279,21 @@
}
},
"p-limit": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
- "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
+ "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"dev": true,
"requires": {
- "p-try": "^2.0.0"
+ "p-try": "^1.0.0"
}
},
"p-locate": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
- "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
+ "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
"dev": true,
"requires": {
- "p-limit": "^2.2.0"
+ "p-limit": "^1.1.0"
}
},
"p-map": {
@@ -2186,9 +2306,9 @@
}
},
"p-try": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
- "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
+ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
"dev": true
},
"parent-module": {
@@ -2201,21 +2321,18 @@
}
},
"parse-json": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz",
- "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
+ "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=",
"dev": true,
"requires": {
- "@babel/code-frame": "^7.0.0",
- "error-ex": "^1.3.1",
- "json-parse-better-errors": "^1.0.1",
- "lines-and-columns": "^1.1.6"
+ "error-ex": "^1.2.0"
}
},
"path-exists": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
- "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
+ "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
"dev": true
},
"path-is-absolute": {
@@ -2261,12 +2378,12 @@
"dev": true
},
"pkg-dir": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
- "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz",
+ "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=",
"dev": true,
"requires": {
- "find-up": "^4.0.0"
+ "find-up": "^2.1.0"
}
},
"please-upgrade-node": {
@@ -2342,57 +2459,6 @@
"requires": {
"find-up": "^2.0.0",
"read-pkg": "^2.0.0"
- },
- "dependencies": {
- "find-up": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz",
- "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=",
- "dev": true,
- "requires": {
- "locate-path": "^2.0.0"
- }
- },
- "locate-path": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
- "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=",
- "dev": true,
- "requires": {
- "p-locate": "^2.0.0",
- "path-exists": "^3.0.0"
- }
- },
- "p-limit": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
- "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
- "dev": true,
- "requires": {
- "p-try": "^1.0.0"
- }
- },
- "p-locate": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz",
- "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=",
- "dev": true,
- "requires": {
- "p-limit": "^1.1.0"
- }
- },
- "p-try": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz",
- "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=",
- "dev": true
- },
- "path-exists": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
- "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
- "dev": true
- }
}
},
"reflect-metadata": {
@@ -2401,12 +2467,6 @@
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
"dev": true
},
- "regenerator-runtime": {
- "version": "0.13.3",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz",
- "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==",
- "dev": true
- },
"regexpp": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
@@ -2438,6 +2498,12 @@
"signal-exit": "^3.0.2"
}
},
+ "reusify": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
+ "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==",
+ "dev": true
+ },
"rimraf": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
@@ -2447,13 +2513,27 @@
"glob": "^7.1.3"
}
},
+ "run-parallel": {
+ "version": "1.1.9",
+ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz",
+ "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==",
+ "dev": true
+ },
"rxjs": {
- "version": "6.6.2",
- "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz",
- "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==",
+ "version": "6.6.3",
+ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.3.tgz",
+ "integrity": "sha512-trsQc+xYYXZ3urjOiJOuCOa5N3jAZ3eiSpQB5hIT8zGlL2QfnHLJ2r7GMkBGuIausdJN1OneaI6gQlsqNHHmZQ==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "1.13.0",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
+ "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
+ "dev": true
+ }
}
},
"sandwich-stream": {
@@ -2507,47 +2587,14 @@
"dev": true
},
"slice-ansi": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz",
- "integrity": "sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
+ "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==",
"dev": true,
"requires": {
- "ansi-styles": "^4.0.0",
- "astral-regex": "^2.0.0",
- "is-fullwidth-code-point": "^3.0.0"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "astral-regex": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
- "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
- "dev": true
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- }
+ "ansi-styles": "^3.2.0",
+ "astral-regex": "^1.0.0",
+ "is-fullwidth-code-point": "^2.0.0"
}
},
"spdx-correct": {
@@ -2595,14 +2642,31 @@
"dev": true
},
"string-width": {
- "version": "4.2.0",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
- "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+ "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
"dev": true,
"requires": {
- "emoji-regex": "^8.0.0",
- "is-fullwidth-code-point": "^3.0.0",
- "strip-ansi": "^6.0.0"
+ "emoji-regex": "^7.0.1",
+ "is-fullwidth-code-point": "^2.0.0",
+ "strip-ansi": "^5.1.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
+ "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^4.1.0"
+ }
+ }
}
},
"string.prototype.trimend": {
@@ -2690,69 +2754,18 @@
"lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
- },
- "dependencies": {
- "ansi-regex": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
- "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
- "dev": true
- },
- "emoji-regex": {
- "version": "7.0.3",
- "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
- "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
- "dev": true
- },
- "is-fullwidth-code-point": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
- "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
- "dev": true
- },
- "slice-ansi": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
- "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==",
- "dev": true,
- "requires": {
- "ansi-styles": "^3.2.0",
- "astral-regex": "^1.0.0",
- "is-fullwidth-code-point": "^2.0.0"
- }
- },
- "string-width": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
- "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
- "dev": true,
- "requires": {
- "emoji-regex": "^7.0.1",
- "is-fullwidth-code-point": "^2.0.0",
- "strip-ansi": "^5.1.0"
- }
- },
- "strip-ansi": {
- "version": "5.2.0",
- "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
- "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
- "dev": true,
- "requires": {
- "ansi-regex": "^4.1.0"
- }
- }
}
},
"telegraf": {
- "version": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976",
- "from": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976",
+ "version": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09",
+ "from": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09",
"requires": {
"debug": "^4.0.1",
"minimist": "^1.2.0",
"module-alias": "^2.2.2",
"node-fetch": "^2.2.0",
"sandwich-stream": "^2.0.1",
- "typegram": "^2.0.0"
+ "typegram": "^2.2.1"
}
},
"text-table": {
@@ -2799,9 +2812,9 @@
}
},
"tslib": {
- "version": "1.11.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.11.1.tgz",
- "integrity": "sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
+ "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==",
"dev": true
},
"tsutils": {
@@ -2811,6 +2824,14 @@
"dev": true,
"requires": {
"tslib": "^1.8.1"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "1.13.0",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
+ "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
+ "dev": true
+ }
}
},
"type": {
@@ -2835,9 +2856,9 @@
"dev": true
},
"typegram": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/typegram/-/typegram-2.1.0.tgz",
- "integrity": "sha512-Cw/xS+KosABzRGxy8i+jqomw/+aKm1ntv0UpPxkyE5X20Iid/wMOcIqidLUPrhWEAT2FiDa5gO8h5g3XsjMVEw=="
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/typegram/-/typegram-2.2.1.tgz",
+ "integrity": "sha512-PaHbV/oeqE8y0g6nO1pcQJl2R7EpZe7B05emprGf46DMVKCS865jpa0WgBNJh0W2G1jq5rebqMdttw/errZqZQ=="
},
"typescript": {
"version": "4.0.2",
@@ -2846,9 +2867,9 @@
"dev": true
},
"uri-js": {
- "version": "4.2.2",
- "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
- "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",
+ "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==",
"dev": true,
"requires": {
"punycode": "^2.1.0"
@@ -2932,6 +2953,29 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
+ },
+ "emoji-regex": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
+ "dev": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
+ "dev": true
+ },
+ "string-width": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
+ "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
+ "dev": true,
+ "requires": {
+ "emoji-regex": "^8.0.0",
+ "is-fullwidth-code-point": "^3.0.0",
+ "strip-ansi": "^6.0.0"
+ }
}
}
},
@@ -2951,13 +2995,10 @@
}
},
"yaml": {
- "version": "1.7.2",
- "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz",
- "integrity": "sha512-qXROVp90sb83XtAoqE8bP9RwAkTTZbugRUTm5YeFCBfNRPEp2YzTeqWiz7m5OORHzEvrA/qcGS8hp/E+MMROYw==",
- "dev": true,
- "requires": {
- "@babel/runtime": "^7.6.3"
- }
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.0.tgz",
+ "integrity": "sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==",
+ "dev": true
}
}
}
diff --git a/package.json b/package.json
index dc31d77..06cdf3b 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"test": ""
},
"dependencies": {
- "telegraf": "git://github.com/telegraf/telegraf.git#8f55d0c191f9fca2da7318b06a0e63bedf788976"
+ "telegraf": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09"
},
"devDependencies": {
"@nestjs/common": "7.4.4",
From 6ecd61be4a1da0052f97ee25c32c7994bbdd0063 Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Thu, 10 Sep 2020 12:52:46 +0300
Subject: [PATCH 05/33] fix: telegraf context usage
---
lib/interfaces/context.interface.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/interfaces/context.interface.ts b/lib/interfaces/context.interface.ts
index 418bbac..b45bc97 100644
--- a/lib/interfaces/context.interface.ts
+++ b/lib/interfaces/context.interface.ts
@@ -1,4 +1,4 @@
-import { TelegrafContext } from 'telegraf/typings/context';
+import { Context as TelegrafContext } from 'telegraf';
export interface Context extends TelegrafContext {
[key: string]: any;
From 744da0a92255c410fee0940cfc66752266e0ff5a Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Sun, 13 Sep 2020 11:28:42 +0300
Subject: [PATCH 06/33] refactor: cleanup context interface
---
lib/interfaces/context.interface.ts | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/lib/interfaces/context.interface.ts b/lib/interfaces/context.interface.ts
index b45bc97..d670e24 100644
--- a/lib/interfaces/context.interface.ts
+++ b/lib/interfaces/context.interface.ts
@@ -1,11 +1,3 @@
import { Context as TelegrafContext } from 'telegraf';
-export interface Context extends TelegrafContext {
- [key: string]: any;
-}
-
-/**
- * Removed type from Telegraf v3.38.0, added for backward compatibility.
- * TODO: remove on next major release
- */
-export interface ContextMessageUpdate extends Context {}
+export interface Context extends TelegrafContext {}
From b83a9bc5d80ce1f8ef74989adbf8a3bd1fa6d349 Mon Sep 17 00:00:00 2001
From: Aleksandr Bukhalo
Date: Sun, 13 Sep 2020 11:33:07 +0300
Subject: [PATCH 07/33] refactor: remove all ts-ignore
---
lib/telegraf.explorer.ts | 7 -------
1 file changed, 7 deletions(-)
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index 4ddefd6..42aa3c5 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -178,12 +178,10 @@ export class TelegrafExplorer implements OnModuleInit {
}
handleTelegrafSettings(instance: object, key: string) {
- // @ts-ignore
this.telegraf.settings(instance[key].bind(instance));
}
handleTelegrafEntity(instance: object, key: string, metadata: EntityOptions) {
- // @ts-ignore
this.telegraf.entity(metadata.entity, instance[key].bind(instance));
}
@@ -192,12 +190,10 @@ export class TelegrafExplorer implements OnModuleInit {
key: string,
metadata: MentionOptions,
) {
- // @ts-ignore
this.telegraf.mention(metadata.username, instance[key].bind(instance));
}
handleTelegrafPhone(instance: object, key: string, metadata: PhoneOptions) {
- // @ts-ignore
this.telegraf.phone(metadata.phone, instance[key].bind(instance));
}
@@ -206,7 +202,6 @@ export class TelegrafExplorer implements OnModuleInit {
key: string,
metadata: HashtagOptions,
) {
- // @ts-ignore
this.telegraf.hashtag(metadata.hashtag, instance[key].bind(instance));
}
@@ -215,7 +210,6 @@ export class TelegrafExplorer implements OnModuleInit {
key: string,
metadata: CashtagOptions,
) {
- // @ts-ignore
this.telegraf.cashtag(metadata.cashtag, instance[key].bind(instance));
}
@@ -229,7 +223,6 @@ export class TelegrafExplorer implements OnModuleInit {
metadata: InlineQueryOptions,
) {
if (metadata.triggers) {
- // @ts-ignore
this.telegraf.inlineQuery(
metadata.triggers,
instance[key].bind(instance),
From c3a280320f1cdc860b2aa40c91827e1fc77e45e7 Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 23 Dec 2020 17:43:22 +0300
Subject: [PATCH 08/33] chore(): use develop telegraf version
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 06cdf3b..2a1e16f 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
"test": ""
},
"dependencies": {
- "telegraf": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09"
+ "telegraf": "https://github.com/telegraf/telegraf.git#develop"
},
"devDependencies": {
"@nestjs/common": "7.4.4",
From e11325ea6601fcabf5cf24ddc0bc91fd4f787dd0 Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 23 Dec 2020 17:44:03 +0300
Subject: [PATCH 09/33] chore(): use master branch dependencie versions
---
package.json | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/package.json b/package.json
index 2a1e16f..16b1ffc 100644
--- a/package.json
+++ b/package.json
@@ -36,19 +36,19 @@
"telegraf": "https://github.com/telegraf/telegraf.git#develop"
},
"devDependencies": {
- "@nestjs/common": "7.4.4",
- "@nestjs/core": "7.4.4",
- "@typescript-eslint/eslint-plugin": "4.0.0",
- "@typescript-eslint/parser": "3.10.1",
- "eslint": "7.8.1",
- "eslint-config-prettier": "6.11.0",
- "eslint-plugin-import": "2.22.0",
- "husky": "4.3.0",
- "lint-staged": "10.3.0",
- "prettier": "2.1.1",
+ "@nestjs/common": "7.6.1",
+ "@nestjs/core": "7.6.1",
+ "@typescript-eslint/eslint-plugin": "4.9.1",
+ "@typescript-eslint/parser": "4.9.1",
+ "eslint": "7.15.0",
+ "eslint-config-prettier": "7.0.0",
+ "eslint-plugin-import": "2.22.1",
+ "husky": "4.3.5",
+ "lint-staged": "10.5.3",
+ "prettier": "2.2.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.6.3",
- "typescript": "4.0.2"
+ "typescript": "4.1.2"
},
"peerDependencies": {
"@nestjs/common": "^6.7.0 || ^7.0.0",
From 23ea7632e1d74d7d3f1746abde0985f8995cfb3d Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 23 Dec 2020 17:54:25 +0300
Subject: [PATCH 10/33] chore(): update package-lock
---
package-lock.json | 1239 +++++++++++++++------------------------------
1 file changed, 401 insertions(+), 838 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 888220d..d141bbc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,18 +5,18 @@
"requires": true,
"dependencies": {
"@babel/code-frame": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
- "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
+ "version": "7.12.11",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz",
+ "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==",
"dev": true,
"requires": {
"@babel/highlight": "^7.10.4"
}
},
"@babel/helper-validator-identifier": {
- "version": "7.10.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
- "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==",
+ "version": "7.12.11",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz",
+ "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==",
"dev": true
},
"@babel/highlight": {
@@ -28,12 +28,64 @@
"@babel/helper-validator-identifier": "^7.10.4",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
+ }
}
},
"@eslint/eslintrc": {
- "version": "0.1.3",
- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz",
- "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==",
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.2.tgz",
+ "integrity": "sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==",
"dev": true,
"requires": {
"ajv": "^6.12.4",
@@ -57,31 +109,30 @@
}
},
"@nestjs/common": {
- "version": "7.4.4",
- "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-7.4.4.tgz",
- "integrity": "sha512-Cj94FJrnLcAU4URJrRmnsHRODZPJpX+EKKJ/Or9qvL9ULQwRWYmFcGQYaJ0nVV0hSBjn/jaAV1Cgqw74uk21KA==",
+ "version": "7.6.1",
+ "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-7.6.1.tgz",
+ "integrity": "sha512-Tq95a6a0kP3rxtV49xal168QNx49JPfO3s6SZ01sCJMWJVtGy8KCaC8YHAx7+KYamH43K6bd9Qv0K9R8lZxEtg==",
"dev": true,
"requires": {
- "axios": "0.20.0",
- "cli-color": "2.0.0",
+ "axios": "0.21.0",
"iterare": "1.2.1",
- "tslib": "2.0.1",
- "uuid": "8.3.0"
+ "tslib": "2.0.3",
+ "uuid": "8.3.2"
}
},
"@nestjs/core": {
- "version": "7.4.4",
- "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.4.4.tgz",
- "integrity": "sha512-e3iID6s0JIaWDlZMIO+gkk5KDwHW+VUexvZOKXbTjtsBidtusbiT4JLr4ODkj8y3QSfQN9vouY9hWfwwQrxa/Q==",
+ "version": "7.6.1",
+ "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-7.6.1.tgz",
+ "integrity": "sha512-Rd0hqV2TsseMfZFTZBQH6zlNe5Hif5kVe5KNOnXADghKVaSLOO9SQ+VVPqXzeRYvC+xvJxnSdDyeTIriVsgMlg==",
"dev": true,
"requires": {
- "@nuxtjs/opencollective": "0.2.2",
+ "@nuxtjs/opencollective": "0.3.2",
"fast-safe-stringify": "2.0.7",
"iterare": "1.2.1",
"object-hash": "2.0.3",
"path-to-regexp": "3.2.0",
- "tslib": "2.0.1",
- "uuid": "8.3.0"
+ "tslib": "2.0.3",
+ "uuid": "8.3.2"
}
},
"@nodelib/fs.scandir": {
@@ -111,28 +162,16 @@
}
},
"@nuxtjs/opencollective": {
- "version": "0.2.2",
- "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.2.2.tgz",
- "integrity": "sha512-69gFVDs7mJfNjv9Zs5DFVD+pvBW+k1TaHSOqUWqAyTTfLcKI/EMYQgvEvziRd+zAFtUOoye6MfWh0qvinGISPw==",
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz",
+ "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==",
"dev": true,
"requires": {
- "chalk": "^2.4.1",
- "consola": "^2.3.0",
- "node-fetch": "^2.3.0"
+ "chalk": "^4.1.0",
+ "consola": "^2.15.0",
+ "node-fetch": "^2.6.1"
}
},
- "@types/color-name": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
- "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
- "dev": true
- },
- "@types/eslint-visitor-keys": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
- "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
- "dev": true
- },
"@types/json-schema": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
@@ -152,13 +191,13 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.0.0.tgz",
- "integrity": "sha512-5e6q1TR7gS2P+8W2xndCu7gBh3BzmYEo70OyIdsmCmknHha/yNbz2vdevl+tP1uoaMOcrzg4gyrAijuV3DDBHA==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.1.tgz",
+ "integrity": "sha512-QRLDSvIPeI1pz5tVuurD+cStNR4sle4avtHhxA+2uyixWGFjKzJ+EaFVRW6dA/jOgjV5DTAjOxboQkRDE8cRlQ==",
"dev": true,
"requires": {
- "@typescript-eslint/experimental-utils": "4.0.0",
- "@typescript-eslint/scope-manager": "4.0.0",
+ "@typescript-eslint/experimental-utils": "4.9.1",
+ "@typescript-eslint/scope-manager": "4.9.1",
"debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
@@ -167,108 +206,55 @@
}
},
"@typescript-eslint/experimental-utils": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.0.0.tgz",
- "integrity": "sha512-hbX6zR+a/vcpFVNJYN/Nbd7gmaMosDTxHEKcvmhWeWcq/0UDifrqmCfkkodbAKL46Fn4ekSBMTyq2zlNDzcQxw==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.9.1.tgz",
+ "integrity": "sha512-c3k/xJqk0exLFs+cWSJxIjqLYwdHCuLWhnpnikmPQD2+NGAx9KjLYlBDcSI81EArh9FDYSL6dslAUSwILeWOxg==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
- "@typescript-eslint/scope-manager": "4.0.0",
- "@typescript-eslint/types": "4.0.0",
- "@typescript-eslint/typescript-estree": "4.0.0",
+ "@typescript-eslint/scope-manager": "4.9.1",
+ "@typescript-eslint/types": "4.9.1",
+ "@typescript-eslint/typescript-estree": "4.9.1",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.10.1.tgz",
- "integrity": "sha512-Ug1RcWcrJP02hmtaXVS3axPPTTPnZjupqhgj+NnZ6BCkwSImWk/283347+x9wN+lqOdK9Eo3vsyiyDHgsmiEJw==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.9.1.tgz",
+ "integrity": "sha512-Gv2VpqiomvQ2v4UL+dXlQcZ8zCX4eTkoIW+1aGVWT6yTO+6jbxsw7yQl2z2pPl/4B9qa5JXeIbhJpONKjXIy3g==",
"dev": true,
"requires": {
- "@types/eslint-visitor-keys": "^1.0.0",
- "@typescript-eslint/experimental-utils": "3.10.1",
- "@typescript-eslint/types": "3.10.1",
- "@typescript-eslint/typescript-estree": "3.10.1",
- "eslint-visitor-keys": "^1.1.0"
- },
- "dependencies": {
- "@typescript-eslint/experimental-utils": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.10.1.tgz",
- "integrity": "sha512-DewqIgscDzmAfd5nOGe4zm6Bl7PKtMG2Ad0KG8CUZAHlXfAKTF9Ol5PXhiMh39yRL2ChRH1cuuUGOcVyyrhQIw==",
- "dev": true,
- "requires": {
- "@types/json-schema": "^7.0.3",
- "@typescript-eslint/types": "3.10.1",
- "@typescript-eslint/typescript-estree": "3.10.1",
- "eslint-scope": "^5.0.0",
- "eslint-utils": "^2.0.0"
- }
- },
- "@typescript-eslint/types": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.10.1.tgz",
- "integrity": "sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==",
- "dev": true
- },
- "@typescript-eslint/typescript-estree": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.10.1.tgz",
- "integrity": "sha512-QbcXOuq6WYvnB3XPsZpIwztBoquEYLXh2MtwVU+kO8jgYCiv4G5xrSP/1wg4tkvrEE+esZVquIPX/dxPlePk1w==",
- "dev": true,
- "requires": {
- "@typescript-eslint/types": "3.10.1",
- "@typescript-eslint/visitor-keys": "3.10.1",
- "debug": "^4.1.1",
- "glob": "^7.1.6",
- "is-glob": "^4.0.1",
- "lodash": "^4.17.15",
- "semver": "^7.3.2",
- "tsutils": "^3.17.1"
- }
- },
- "@typescript-eslint/visitor-keys": {
- "version": "3.10.1",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz",
- "integrity": "sha512-9JgC82AaQeglebjZMgYR5wgmfUdUc+EitGUUMW8u2nDckaeimzW+VsoLV6FoimPv2id3VQzfjwBxEMVz08ameQ==",
- "dev": true,
- "requires": {
- "eslint-visitor-keys": "^1.1.0"
- }
- },
- "eslint-visitor-keys": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
- "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
- "dev": true
- }
+ "@typescript-eslint/scope-manager": "4.9.1",
+ "@typescript-eslint/types": "4.9.1",
+ "@typescript-eslint/typescript-estree": "4.9.1",
+ "debug": "^4.1.1"
}
},
"@typescript-eslint/scope-manager": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.0.0.tgz",
- "integrity": "sha512-9gcWUPoWo7gk/+ZQPg7L1ySRmR5HLIy3Vu6/LfhQbuzIkGm6v2CGIjpVRISoDLFRovNRDImd4aP/sa8O4yIEBg==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.9.1.tgz",
+ "integrity": "sha512-sa4L9yUfD/1sg9Kl8OxPxvpUcqxKXRjBeZxBuZSSV1v13hjfEJkn84n0An2hN8oLQ1PmEl2uA6FkI07idXeFgQ==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.0.0",
- "@typescript-eslint/visitor-keys": "4.0.0"
+ "@typescript-eslint/types": "4.9.1",
+ "@typescript-eslint/visitor-keys": "4.9.1"
}
},
"@typescript-eslint/types": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.0.0.tgz",
- "integrity": "sha512-bK+c2VLzznX2fUWLK6pFDv3cXGTp7nHIuBMq1B9klA+QCsqLHOOqe5TQReAQDl7DN2RfH+neweo0oC5hYlG7Rg==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.9.1.tgz",
+ "integrity": "sha512-fjkT+tXR13ks6Le7JiEdagnwEFc49IkOyys7ueWQ4O8k4quKPwPJudrwlVOJCUQhXo45PrfIvIarcrEjFTNwUA==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.0.0.tgz",
- "integrity": "sha512-ewFMPi2pMLDNIXGMPdf8r7El2oPSZw9PEYB0j+WcpKd7AX2ARmajGa7RUHTukllWX2bj4vWX6JLE1Oih2BMokA==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.9.1.tgz",
+ "integrity": "sha512-bzP8vqwX6Vgmvs81bPtCkLtM/Skh36NE6unu6tsDeU/ZFoYthlTXbBmpIrvosgiDKlWTfb2ZpPELHH89aQjeQw==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.0.0",
- "@typescript-eslint/visitor-keys": "4.0.0",
+ "@typescript-eslint/types": "4.9.1",
+ "@typescript-eslint/visitor-keys": "4.9.1",
"debug": "^4.1.1",
"globby": "^11.0.1",
"is-glob": "^4.0.1",
@@ -278,19 +264,27 @@
}
},
"@typescript-eslint/visitor-keys": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.0.0.tgz",
- "integrity": "sha512-sTouJbv6rjVJeTE4lpSBVYXq/u5K3gbB6LKt7ccFEZPTZB/VeQ0ssUz9q5Hx++sCqBbdF8PzrrgvEnicXAR6NQ==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.9.1.tgz",
+ "integrity": "sha512-9gspzc6UqLQHd7lXQS7oWs+hrYggspv/rk6zzEMhCbYwPE/sF7oxo7GAjkS35Tdlt7wguIG+ViWCPtVZHz/ybQ==",
"dev": true,
"requires": {
- "@typescript-eslint/types": "4.0.0",
+ "@typescript-eslint/types": "4.9.1",
"eslint-visitor-keys": "^2.0.0"
}
},
+ "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==",
+ "requires": {
+ "event-target-shim": "^5.0.0"
+ }
+ },
"acorn": {
- "version": "7.4.0",
- "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
- "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
+ "version": "7.4.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true
},
"acorn-jsx": {
@@ -310,9 +304,9 @@
}
},
"ajv": {
- "version": "6.12.4",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz",
- "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==",
+ "version": "6.12.6",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
+ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
@@ -345,18 +339,18 @@
}
},
"ansi-regex": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
- "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
+ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
"dev": true
},
"ansi-styles": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
- "color-convert": "^1.9.0"
+ "color-convert": "^2.0.1"
}
},
"argparse": {
@@ -369,13 +363,15 @@
}
},
"array-includes": {
- "version": "3.1.1",
- "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz",
- "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==",
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.2.tgz",
+ "integrity": "sha512-w2GspexNQpx+PutG3QpT437/BenZBj0M/MZGn5mzv/MofYqo0xmRHzn4lFsoDlWJ+THYsGJmFlW68WlDFx7VRw==",
"dev": true,
"requires": {
+ "call-bind": "^1.0.0",
"define-properties": "^1.1.3",
- "es-abstract": "^1.17.0",
+ "es-abstract": "^1.18.0-next.1",
+ "get-intrinsic": "^1.0.1",
"is-string": "^1.0.5"
}
},
@@ -386,13 +382,14 @@
"dev": true
},
"array.prototype.flat": {
- "version": "1.2.3",
- "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz",
- "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==",
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz",
+ "integrity": "sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg==",
"dev": true,
"requires": {
+ "call-bind": "^1.0.0",
"define-properties": "^1.1.3",
- "es-abstract": "^1.17.0-next.1"
+ "es-abstract": "^1.18.0-next.1"
}
},
"astral-regex": {
@@ -402,9 +399,9 @@
"dev": true
},
"axios": {
- "version": "0.20.0",
- "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
- "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==",
+ "version": "0.21.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz",
+ "integrity": "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==",
"dev": true,
"requires": {
"follow-redirects": "^1.10.0"
@@ -435,6 +432,16 @@
"fill-range": "^7.0.1"
}
},
+ "call-bind": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.0.tgz",
+ "integrity": "sha512-AEXsYIyyDY3MCzbwdhzG3Jx1R0J2wetQyUynn6dYHAO+bg8l1k7jwZtRv4ryryFs7EP+NDlikJlVe59jr0cM2w==",
+ "dev": true,
+ "requires": {
+ "function-bind": "^1.1.1",
+ "get-intrinsic": "^1.0.0"
+ }
+ },
"callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@@ -442,14 +449,13 @@
"dev": true
},
"chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
+ "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
"dev": true,
"requires": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
}
},
"ci-info": {
@@ -464,20 +470,6 @@
"integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==",
"dev": true
},
- "cli-color": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.0.tgz",
- "integrity": "sha512-a0VZ8LeraW0jTuCkuAGMNufareGHhyZU9z8OGsW0gXd1hZGi1SRuNRXdbGkraBBKnhyUhyebFWnRbp+dIn0f0A==",
- "dev": true,
- "requires": {
- "ansi-regex": "^2.1.1",
- "d": "^1.0.1",
- "es5-ext": "^0.10.51",
- "es6-iterator": "^2.0.3",
- "memoizee": "^0.4.14",
- "timers-ext": "^0.1.7"
- }
- },
"cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@@ -497,37 +489,12 @@
"string-width": "^4.2.0"
},
"dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
"astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
"dev": true
},
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -565,24 +532,24 @@
}
},
"color-convert": {
- "version": "1.9.3",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
- "color-name": "1.1.3"
+ "color-name": "~1.1.4"
}
},
"color-name": {
- "version": "1.1.3",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
- "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
},
"commander": {
- "version": "6.1.0",
- "resolved": "https://registry.npmjs.org/commander/-/commander-6.1.0.tgz",
- "integrity": "sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA==",
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
+ "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
"dev": true
},
"compare-versions": {
@@ -647,22 +614,12 @@
"which": "^2.0.1"
}
},
- "d": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
- "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
- "dev": true,
- "requires": {
- "es5-ext": "^0.10.50",
- "type": "^1.0.1"
- }
- },
"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==",
"requires": {
- "ms": "^2.1.1"
+ "ms": "2.1.2"
}
},
"dedent": {
@@ -738,20 +695,21 @@
}
},
"es-abstract": {
- "version": "1.17.6",
- "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz",
- "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==",
+ "version": "1.18.0-next.1",
+ "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz",
+ "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==",
"dev": true,
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
- "is-callable": "^1.2.0",
- "is-regex": "^1.1.0",
- "object-inspect": "^1.7.0",
+ "is-callable": "^1.2.2",
+ "is-negative-zero": "^2.0.0",
+ "is-regex": "^1.1.1",
+ "object-inspect": "^1.8.0",
"object-keys": "^1.1.1",
- "object.assign": "^4.1.0",
+ "object.assign": "^4.1.1",
"string.prototype.trimend": "^1.0.1",
"string.prototype.trimstart": "^1.0.1"
}
@@ -767,50 +725,6 @@
"is-symbol": "^1.0.2"
}
},
- "es5-ext": {
- "version": "0.10.53",
- "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz",
- "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==",
- "dev": true,
- "requires": {
- "es6-iterator": "~2.0.3",
- "es6-symbol": "~3.1.3",
- "next-tick": "~1.0.0"
- }
- },
- "es6-iterator": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
- "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
- "dev": true,
- "requires": {
- "d": "1",
- "es5-ext": "^0.10.35",
- "es6-symbol": "^3.1.1"
- }
- },
- "es6-symbol": {
- "version": "3.1.3",
- "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
- "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
- "dev": true,
- "requires": {
- "d": "^1.0.1",
- "ext": "^1.1.2"
- }
- },
- "es6-weak-map": {
- "version": "2.0.3",
- "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
- "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
- "dev": true,
- "requires": {
- "d": "1",
- "es5-ext": "^0.10.46",
- "es6-iterator": "^2.0.3",
- "es6-symbol": "^3.1.1"
- }
- },
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@@ -818,26 +732,26 @@
"dev": true
},
"eslint": {
- "version": "7.8.1",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.1.tgz",
- "integrity": "sha512-/2rX2pfhyUG0y+A123d0ccXtMm7DV7sH1m3lk9nk2DZ2LReq39FXHueR9xZwshE5MdfSf0xunSaMWRqyIA6M1w==",
+ "version": "7.15.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.15.0.tgz",
+ "integrity": "sha512-Vr64xFDT8w30wFll643e7cGrIkPEU50yIiI36OdSIDoSGguIeaLzBo0vpGvzo9RECUqq7htURfwEtKqwytkqzA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
- "@eslint/eslintrc": "^0.1.3",
+ "@eslint/eslintrc": "^0.2.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.0.1",
"doctrine": "^3.0.0",
"enquirer": "^2.3.5",
- "eslint-scope": "^5.1.0",
+ "eslint-scope": "^5.1.1",
"eslint-utils": "^2.1.0",
- "eslint-visitor-keys": "^1.3.0",
- "espree": "^7.3.0",
+ "eslint-visitor-keys": "^2.0.0",
+ "espree": "^7.3.1",
"esquery": "^1.2.0",
"esutils": "^2.0.2",
- "file-entry-cache": "^5.0.1",
+ "file-entry-cache": "^6.0.0",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^5.0.0",
"globals": "^12.1.0",
@@ -862,78 +776,19 @@
"v8-compile-cache": "^2.0.3"
},
"dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
- "eslint-visitor-keys": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
- "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
- "dev": true
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
- },
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
}
}
},
"eslint-config-prettier": {
- "version": "6.11.0",
- "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz",
- "integrity": "sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA==",
- "dev": true,
- "requires": {
- "get-stdin": "^6.0.0"
- }
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-7.0.0.tgz",
+ "integrity": "sha512-8Y8lGLVPPZdaNA7JXqnvETVC7IiVRgAP6afQu9gOQRn90YY3otMNh+x7Vr2vMePQntF+5erdSUBqSzCmU/AxaQ==",
+ "dev": true
},
"eslint-import-resolver-node": {
"version": "0.3.4",
@@ -990,9 +845,9 @@
}
},
"eslint-plugin-import": {
- "version": "2.22.0",
- "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz",
- "integrity": "sha512-66Fpf1Ln6aIS5Gr/55ts19eUuoDhAbZgnr6UxK5hbDx6l/QgQgx61AePq+BV4PP2uXQFClgMVzep5zZ94qqsxg==",
+ "version": "2.22.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.22.1.tgz",
+ "integrity": "sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==",
"dev": true,
"requires": {
"array-includes": "^3.1.1",
@@ -1000,7 +855,7 @@
"contains-path": "^0.1.0",
"debug": "^2.6.9",
"doctrine": "1.5.0",
- "eslint-import-resolver-node": "^0.3.3",
+ "eslint-import-resolver-node": "^0.3.4",
"eslint-module-utils": "^2.6.0",
"has": "^1.0.3",
"minimatch": "^3.0.4",
@@ -1038,12 +893,12 @@
}
},
"eslint-scope": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz",
- "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==",
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
+ "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"dev": true,
"requires": {
- "esrecurse": "^4.1.0",
+ "esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
}
},
@@ -1071,13 +926,13 @@
"dev": true
},
"espree": {
- "version": "7.3.0",
- "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz",
- "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==",
+ "version": "7.3.1",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz",
+ "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==",
"dev": true,
"requires": {
"acorn": "^7.4.0",
- "acorn-jsx": "^5.2.0",
+ "acorn-jsx": "^5.3.1",
"eslint-visitor-keys": "^1.3.0"
},
"dependencies": {
@@ -1141,20 +996,15 @@
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
"dev": true
},
- "event-emitter": {
- "version": "0.3.5",
- "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
- "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
- "dev": true,
- "requires": {
- "d": "1",
- "es5-ext": "~0.10.14"
- }
+ "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=="
},
"execa": {
- "version": "4.0.3",
- "resolved": "https://registry.npmjs.org/execa/-/execa-4.0.3.tgz",
- "integrity": "sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A==",
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz",
+ "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.0",
@@ -1168,23 +1018,6 @@
"strip-final-newline": "^2.0.0"
}
},
- "ext": {
- "version": "1.4.0",
- "resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz",
- "integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==",
- "dev": true,
- "requires": {
- "type": "^2.0.0"
- },
- "dependencies": {
- "type": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz",
- "integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==",
- "dev": true
- }
- }
- },
"fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -1224,9 +1057,9 @@
"dev": true
},
"fastq": {
- "version": "1.8.0",
- "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz",
- "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==",
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.0.tgz",
+ "integrity": "sha512-NL2Qc5L3iQEsyYzweq7qfgy5OtXCmGzGvhElGEd/SoFWEMOEczNh5s5ocaF01HDetxz+p8ecjNPA6cZxxIHmzA==",
"dev": true,
"requires": {
"reusify": "^1.0.4"
@@ -1242,12 +1075,12 @@
}
},
"file-entry-cache": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
- "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==",
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz",
+ "integrity": "sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA==",
"dev": true,
"requires": {
- "flat-cache": "^2.0.1"
+ "flat-cache": "^3.0.4"
}
},
"fill-range": {
@@ -1278,26 +1111,25 @@
}
},
"flat-cache": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
- "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==",
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz",
+ "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==",
"dev": true,
"requires": {
- "flatted": "^2.0.0",
- "rimraf": "2.6.3",
- "write": "1.0.3"
+ "flatted": "^3.1.0",
+ "rimraf": "^3.0.2"
}
},
"flatted": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz",
- "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.0.tgz",
+ "integrity": "sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA==",
"dev": true
},
"follow-redirects": {
- "version": "1.13.0",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
- "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
+ "version": "1.13.1",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
+ "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==",
"dev": true
},
"fs.realpath": {
@@ -1318,18 +1150,23 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
+ "get-intrinsic": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.0.2.tgz",
+ "integrity": "sha512-aeX0vrFm21ILl3+JpFFRNe9aUvp6VFZb2/CTbgLb8j75kOhvoNYjt9d8KA/tJG4gSo8nzEDedRl0h7vDmBYRVg==",
+ "dev": true,
+ "requires": {
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-symbols": "^1.0.1"
+ }
+ },
"get-own-enumerable-property-symbols": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz",
"integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==",
"dev": true
},
- "get-stdin": {
- "version": "6.0.0",
- "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
- "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
- "dev": true
- },
"get-stream": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz",
@@ -1401,9 +1238,9 @@
}
},
"has-flag": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
- "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
},
"has-symbols": {
@@ -1425,9 +1262,9 @@
"dev": true
},
"husky": {
- "version": "4.3.0",
- "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.0.tgz",
- "integrity": "sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA==",
+ "version": "4.3.5",
+ "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.5.tgz",
+ "integrity": "sha512-E5S/1HMoDDaqsH8kDF5zeKEQbYqe3wL9zJDyqyYqc8I4vHBtAoxkDBGXox0lZ9RI+k5GyB728vZdmnM4bYap+g==",
"dev": true,
"requires": {
"chalk": "^4.0.0",
@@ -1442,41 +1279,6 @@
"which-pm-runs": "^1.0.0"
},
"dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
@@ -1487,12 +1289,6 @@
"path-exists": "^4.0.0"
}
},
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
- },
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
@@ -1540,15 +1336,6 @@
"requires": {
"find-up": "^4.0.0"
}
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
}
}
},
@@ -1559,9 +1346,9 @@
"dev": true
},
"import-fresh": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
- "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz",
+ "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==",
"dev": true,
"requires": {
"parent-module": "^1.0.0",
@@ -1603,11 +1390,20 @@
"dev": true
},
"is-callable": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.1.tgz",
- "integrity": "sha512-wliAfSzx6V+6WfMOmus1xy0XvSgf/dlStkvTfq7F0g4bOIW0PSUbnyse3NhDwdyYS1ozfUtAAySqTws3z9Eqgg==",
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz",
+ "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==",
"dev": true
},
+ "is-core-module": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
+ "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==",
+ "dev": true,
+ "requires": {
+ "has": "^1.0.3"
+ }
+ },
"is-date-object": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
@@ -1635,6 +1431,12 @@
"is-extglob": "^2.1.1"
}
},
+ "is-negative-zero": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz",
+ "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==",
+ "dev": true
+ },
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
@@ -1647,12 +1449,6 @@
"integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
"dev": true
},
- "is-promise": {
- "version": "2.2.2",
- "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
- "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==",
- "dev": true
- },
"is-regex": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz",
@@ -1714,9 +1510,9 @@
"dev": true
},
"js-yaml": {
- "version": "3.14.0",
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
- "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==",
+ "version": "3.14.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
+ "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
@@ -1767,84 +1563,32 @@
"dev": true
},
"lint-staged": {
- "version": "10.3.0",
- "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.3.0.tgz",
- "integrity": "sha512-an3VgjHqmJk0TORB/sdQl0CTkRg4E5ybYCXTTCSJ5h9jFwZbcgKIx5oVma5e7wp/uKt17s1QYFmYqT9MGVosGw==",
+ "version": "10.5.3",
+ "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.5.3.tgz",
+ "integrity": "sha512-TanwFfuqUBLufxCc3RUtFEkFraSPNR3WzWcGF39R3f2J7S9+iF9W0KTVLfSy09lYGmZS5NDCxjNvhGMSJyFCWg==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"cli-truncate": "^2.1.0",
- "commander": "^6.0.0",
+ "commander": "^6.2.0",
"cosmiconfig": "^7.0.0",
- "debug": "^4.1.1",
+ "debug": "^4.2.0",
"dedent": "^0.7.0",
"enquirer": "^2.3.6",
- "execa": "^4.0.3",
- "listr2": "^2.6.0",
+ "execa": "^4.1.0",
+ "listr2": "^3.2.2",
"log-symbols": "^4.0.0",
"micromatch": "^4.0.2",
"normalize-path": "^3.0.0",
"please-upgrade-node": "^3.2.0",
"string-argv": "0.3.1",
"stringify-object": "^3.3.0"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
- }
}
},
"listr2": {
- "version": "2.6.2",
- "resolved": "https://registry.npmjs.org/listr2/-/listr2-2.6.2.tgz",
- "integrity": "sha512-6x6pKEMs8DSIpA/tixiYY2m/GcbgMplMVmhQAaLFxEtNSKLeWTGjtmU57xvv6QCm2XcqzyNXL/cTSVf4IChCRA==",
+ "version": "3.2.3",
+ "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.2.3.tgz",
+ "integrity": "sha512-vUb80S2dSUi8YxXahO8/I/s29GqnOL8ozgHVLjfWQXa03BNEeS1TpBLjh2ruaqq5ufx46BRGvfymdBSuoXET5w==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
@@ -1853,60 +1597,8 @@
"indent-string": "^4.0.0",
"log-update": "^4.0.0",
"p-map": "^4.0.0",
- "rxjs": "^6.6.2",
+ "rxjs": "^6.6.3",
"through": "^2.3.8"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
- }
}
},
"load-json-file": {
@@ -1944,58 +1636,6 @@
"dev": true,
"requires": {
"chalk": "^4.0.0"
- },
- "dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "chalk": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
- "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
- "has-flag": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
- "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
- "dev": true
- },
- "supports-color": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
- "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
- "dev": true,
- "requires": {
- "has-flag": "^4.0.0"
- }
- }
}
},
"log-update": {
@@ -2010,37 +1650,12 @@
"wrap-ansi": "^6.2.0"
},
"dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
"astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
"integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==",
"dev": true
},
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
"is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
@@ -2060,29 +1675,13 @@
}
}
},
- "lru-queue": {
- "version": "0.1.0",
- "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
- "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=",
+ "lru-cache": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
+ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
- "es5-ext": "~0.10.2"
- }
- },
- "memoizee": {
- "version": "0.4.14",
- "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.14.tgz",
- "integrity": "sha512-/SWFvWegAIYAO4NQMpcX+gcra0yEZu4OntmUdrBaWrJncxOqAziGFlHxc7yjKVK2uu3lpPW27P27wkR82wA8mg==",
- "dev": true,
- "requires": {
- "d": "1",
- "es5-ext": "^0.10.45",
- "es6-weak-map": "^2.0.2",
- "event-emitter": "^0.3.5",
- "is-promise": "^2.1",
- "lru-queue": "0.1",
- "next-tick": "1",
- "timers-ext": "^0.1.5"
+ "yallist": "^4.0.0"
}
},
"merge-stream": {
@@ -2127,15 +1726,6 @@
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
- "mkdirp": {
- "version": "0.5.5",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
- "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
- "dev": true,
- "requires": {
- "minimist": "^1.2.5"
- }
- },
"module-alias": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/module-alias/-/module-alias-2.2.2.tgz",
@@ -2152,12 +1742,6 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
"dev": true
},
- "next-tick": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
- "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
- "dev": true
- },
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
@@ -2205,9 +1789,9 @@
"dev": true
},
"object-inspect": {
- "version": "1.8.0",
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz",
- "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==",
+ "version": "1.9.0",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
+ "integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==",
"dev": true
},
"object-keys": {
@@ -2217,26 +1801,26 @@
"dev": true
},
"object.assign": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz",
- "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==",
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz",
+ "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==",
"dev": true,
"requires": {
- "define-properties": "^1.1.2",
- "function-bind": "^1.1.1",
- "has-symbols": "^1.0.0",
- "object-keys": "^1.0.11"
+ "call-bind": "^1.0.0",
+ "define-properties": "^1.1.3",
+ "has-symbols": "^1.0.1",
+ "object-keys": "^1.1.1"
}
},
"object.values": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz",
- "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==",
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.2.tgz",
+ "integrity": "sha512-MYC0jvJopr8EK6dPBiO8Nb9mvjdypOachO5REGk6MXzujbBrAisKo3HmdEI6kZDL6fC31Mwee/5YbtMebixeag==",
"dev": true,
"requires": {
+ "call-bind": "^1.0.0",
"define-properties": "^1.1.3",
- "es-abstract": "^1.17.0-next.1",
- "function-bind": "^1.1.1",
+ "es-abstract": "^1.18.0-next.1",
"has": "^1.0.3"
}
},
@@ -2402,9 +1986,9 @@
"dev": true
},
"prettier": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz",
- "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==",
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
+ "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
},
"progress": {
@@ -2474,11 +2058,12 @@
"dev": true
},
"resolve": {
- "version": "1.17.0",
- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
- "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
+ "version": "1.19.0",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
+ "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==",
"dev": true,
"requires": {
+ "is-core-module": "^2.1.0",
"path-parse": "^1.0.6"
}
},
@@ -2505,18 +2090,18 @@
"dev": true
},
"rimraf": {
- "version": "2.6.3",
- "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
- "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
+ "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}
},
"run-parallel": {
- "version": "1.1.9",
- "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz",
- "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==",
+ "version": "1.1.10",
+ "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz",
+ "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==",
"dev": true
},
"rxjs": {
@@ -2542,10 +2127,13 @@
"integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ=="
},
"semver": {
- "version": "7.3.2",
- "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
- "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
- "dev": true
+ "version": "7.3.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
+ "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
+ "dev": true,
+ "requires": {
+ "lru-cache": "^6.0.0"
+ }
},
"semver-compare": {
"version": "1.0.0",
@@ -2595,6 +2183,32 @@
"ansi-styles": "^3.2.0",
"astral-regex": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "dev": true,
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "dev": true,
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
+ "dev": true
+ }
}
},
"spdx-correct": {
@@ -2624,9 +2238,9 @@
}
},
"spdx-license-ids": {
- "version": "3.0.5",
- "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz",
- "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==",
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.7.tgz",
+ "integrity": "sha512-U+MTEOO0AiDzxwFvoa4JVnMV6mZlJKk2sBLt90s7G0Gd0Mlknc7kxEn3nuDPNZRta7O2uy8oLcZLVT+4sqNZHQ==",
"dev": true
},
"sprintf-js": {
@@ -2670,23 +2284,23 @@
}
},
"string.prototype.trimend": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz",
- "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==",
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz",
+ "integrity": "sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw==",
"dev": true,
"requires": {
- "define-properties": "^1.1.3",
- "es-abstract": "^1.17.5"
+ "call-bind": "^1.0.0",
+ "define-properties": "^1.1.3"
}
},
"string.prototype.trimstart": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz",
- "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==",
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz",
+ "integrity": "sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg==",
"dev": true,
"requires": {
- "define-properties": "^1.1.3",
- "es-abstract": "^1.17.5"
+ "call-bind": "^1.0.0",
+ "define-properties": "^1.1.3"
}
},
"stringify-object": {
@@ -2707,14 +2321,6 @@
"dev": true,
"requires": {
"ansi-regex": "^5.0.0"
- },
- "dependencies": {
- "ansi-regex": {
- "version": "5.0.0",
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
- "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
- "dev": true
- }
}
},
"strip-bom": {
@@ -2736,12 +2342,12 @@
"dev": true
},
"supports-color": {
- "version": "5.5.0",
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
- "has-flag": "^3.0.0"
+ "has-flag": "^4.0.0"
}
},
"table": {
@@ -2757,15 +2363,16 @@
}
},
"telegraf": {
- "version": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09",
- "from": "git://github.com/telegraf/telegraf.git#addd845af3a20948ba0ee32fe6b1b4374bff1f09",
+ "version": "git+https://github.com/telegraf/telegraf.git#7ed1903580ea93dbaf7b737d0196889d46708cf5",
+ "from": "git+https://github.com/telegraf/telegraf.git#develop",
"requires": {
- "debug": "^4.0.1",
- "minimist": "^1.2.0",
+ "abort-controller": "^3.0.0",
+ "debug": "^4.2.0",
+ "minimist": "^1.2.5",
"module-alias": "^2.2.2",
- "node-fetch": "^2.2.0",
- "sandwich-stream": "^2.0.1",
- "typegram": "^2.2.1"
+ "node-fetch": "^2.6.1",
+ "sandwich-stream": "^2.0.2",
+ "typegram": "^3.0.0"
}
},
"text-table": {
@@ -2780,16 +2387,6 @@
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true
},
- "timers-ext": {
- "version": "0.1.7",
- "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
- "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
- "dev": true,
- "requires": {
- "es5-ext": "~0.10.46",
- "next-tick": "1"
- }
- },
"to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -2812,9 +2409,9 @@
}
},
"tslib": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.1.tgz",
- "integrity": "sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ==",
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.0.3.tgz",
+ "integrity": "sha512-uZtkfKblCEQtZKBF6EBXVZeQNl82yqtDQdv+eck8u7tdPxjLu2/lp5/uPW+um2tpuxINHWy3GhiccY7QgEaVHQ==",
"dev": true
},
"tsutils": {
@@ -2827,19 +2424,13 @@
},
"dependencies": {
"tslib": {
- "version": "1.13.0",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
- "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
- "type": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
- "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==",
- "dev": true
- },
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -2856,14 +2447,14 @@
"dev": true
},
"typegram": {
- "version": "2.2.1",
- "resolved": "https://registry.npmjs.org/typegram/-/typegram-2.2.1.tgz",
- "integrity": "sha512-PaHbV/oeqE8y0g6nO1pcQJl2R7EpZe7B05emprGf46DMVKCS865jpa0WgBNJh0W2G1jq5rebqMdttw/errZqZQ=="
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/typegram/-/typegram-3.1.1.tgz",
+ "integrity": "sha512-uXBGUGXhEKDyw1dAqdNWOR98nQO2a/2tnZPvEFruU6zr4t1dQIi+zziZIDNct93rnImOJbAaHH6Bsdc4l8mQoQ=="
},
"typescript": {
- "version": "4.0.2",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
- "integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==",
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.2.tgz",
+ "integrity": "sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ==",
"dev": true
},
"uri-js": {
@@ -2876,15 +2467,15 @@
}
},
"uuid": {
- "version": "8.3.0",
- "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz",
- "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==",
+ "version": "8.3.2",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
+ "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true
},
"v8-compile-cache": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
- "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz",
+ "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==",
"dev": true
},
"validate-npm-package-license": {
@@ -2929,31 +2520,6 @@
"strip-ansi": "^6.0.0"
},
"dependencies": {
- "ansi-styles": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
- "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
- "dev": true,
- "requires": {
- "@types/color-name": "^1.1.1",
- "color-convert": "^2.0.1"
- }
- },
- "color-convert": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
- "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
- "dev": true,
- "requires": {
- "color-name": "~1.1.4"
- }
- },
- "color-name": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
- "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
- "dev": true
- },
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -2985,14 +2551,11 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
- "write": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz",
- "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==",
- "dev": true,
- "requires": {
- "mkdirp": "^0.5.1"
- }
+ "yallist": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
+ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
+ "dev": true
},
"yaml": {
"version": "1.10.0",
From b1a6fc33190feeef847780e45a1e1d1ad2855381 Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 23 Dec 2020 21:35:40 +0300
Subject: [PATCH 11/33] feat(wip): rework listener decorators
---
lib/decorators/action.decorator.ts | 19 -------------
lib/decorators/cashtag.decorator.ts | 17 -----------
lib/decorators/command.decorator.ts | 17 -----------
lib/decorators/{ => core}/update.decorator.ts | 4 +--
lib/decorators/entity.decorator.ts | 22 ---------------
lib/decorators/hashtag.decorator.ts | 17 -----------
lib/decorators/hears.decorator.ts | 19 -------------
lib/decorators/help.decorator.ts | 11 --------
lib/decorators/inline-query.decorator.ts | 28 -------------------
lib/decorators/listeners/action.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/cashtag.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/command.decorator.ts | 25 +++++++++++++++++
.../{ => listeners}/game-query.decorator.ts | 5 ++--
lib/decorators/listeners/hashtag.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/hears.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/help.decorator.ts | 12 ++++++++
.../listeners/inline-query.decorator.ts | 27 ++++++++++++++++++
lib/decorators/listeners/mention.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/on.decorator.ts | 25 +++++++++++++++++
lib/decorators/listeners/phone.decorator.ts | 25 +++++++++++++++++
.../listeners/settings.decorator.ts | 12 ++++++++
lib/decorators/listeners/start.decorator.ts | 12 ++++++++
lib/decorators/listeners/use.decorator.ts | 12 ++++++++
lib/decorators/mention.decorator.ts | 17 -----------
lib/decorators/on.decorator.ts | 22 ---------------
lib/decorators/phone.decorator.ts | 17 -----------
lib/decorators/settings.decorator.ts | 11 --------
lib/decorators/start.decorator.ts | 11 --------
lib/decorators/use.decorator.ts | 11 --------
lib/enums/listener-type.enum.ts | 16 +++++++++++
lib/telegraf.constants.ts | 23 ++-------------
lib/telegraf.provider.ts | 11 ++++----
lib/telegraf.types.ts | 13 +++++++++
33 files changed, 318 insertions(+), 268 deletions(-)
delete mode 100644 lib/decorators/action.decorator.ts
delete mode 100644 lib/decorators/cashtag.decorator.ts
delete mode 100644 lib/decorators/command.decorator.ts
rename lib/decorators/{ => core}/update.decorator.ts (53%)
delete mode 100644 lib/decorators/entity.decorator.ts
delete mode 100644 lib/decorators/hashtag.decorator.ts
delete mode 100644 lib/decorators/hears.decorator.ts
delete mode 100644 lib/decorators/help.decorator.ts
delete mode 100644 lib/decorators/inline-query.decorator.ts
create mode 100644 lib/decorators/listeners/action.decorator.ts
create mode 100644 lib/decorators/listeners/cashtag.decorator.ts
create mode 100644 lib/decorators/listeners/command.decorator.ts
rename lib/decorators/{ => listeners}/game-query.decorator.ts (54%)
create mode 100644 lib/decorators/listeners/hashtag.decorator.ts
create mode 100644 lib/decorators/listeners/hears.decorator.ts
create mode 100644 lib/decorators/listeners/help.decorator.ts
create mode 100644 lib/decorators/listeners/inline-query.decorator.ts
create mode 100644 lib/decorators/listeners/mention.decorator.ts
create mode 100644 lib/decorators/listeners/on.decorator.ts
create mode 100644 lib/decorators/listeners/phone.decorator.ts
create mode 100644 lib/decorators/listeners/settings.decorator.ts
create mode 100644 lib/decorators/listeners/start.decorator.ts
create mode 100644 lib/decorators/listeners/use.decorator.ts
delete mode 100644 lib/decorators/mention.decorator.ts
delete mode 100644 lib/decorators/on.decorator.ts
delete mode 100644 lib/decorators/phone.decorator.ts
delete mode 100644 lib/decorators/settings.decorator.ts
delete mode 100644 lib/decorators/start.decorator.ts
delete mode 100644 lib/decorators/use.decorator.ts
create mode 100644 lib/enums/listener-type.enum.ts
create mode 100644 lib/telegraf.types.ts
diff --git a/lib/decorators/action.decorator.ts b/lib/decorators/action.decorator.ts
deleted file mode 100644
index e54ace0..0000000
--- a/lib/decorators/action.decorator.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-import { HearsTriggers } from 'telegraf/typings/composer';
-import { Context } from '../interfaces';
-
-export type TelegrafActionTriggers = HearsTriggers;
-
-export interface ActionOptions {
- triggers: TelegrafActionTriggers;
-}
-
-/**
- * Registers middleware for handling callback_data actions with regular expressions.
- *
- * @see https://telegraf.js.org/#/?id=action
- */
-export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
- return SetMetadata(DECORATORS.ACTION, { triggers });
-};
diff --git a/lib/decorators/cashtag.decorator.ts b/lib/decorators/cashtag.decorator.ts
deleted file mode 100644
index b98b2da..0000000
--- a/lib/decorators/cashtag.decorator.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafCashtagCashtag = string | string[];
-
-export interface CashtagOptions {
- cashtag: TelegrafCashtagCashtag;
-}
-
-/**
- * Cashtag handling.
- *
- * @see https://telegraf.js.org/#/?id=cashtag
- */
-export const Cashtag = (cashtag: TelegrafCashtagCashtag): MethodDecorator => {
- return SetMetadata(DECORATORS.CASHTAG, { cashtag });
-};
diff --git a/lib/decorators/command.decorator.ts b/lib/decorators/command.decorator.ts
deleted file mode 100644
index 2fb6e7a..0000000
--- a/lib/decorators/command.decorator.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafCommandCommands = string | string[];
-
-export interface CommandOptions {
- commands: TelegrafCommandCommands;
-}
-
-/**
- * Command handling.
- *
- * @see https://telegraf.js.org/#/?id=command
- */
-export const Command = (commands: TelegrafCommandCommands): MethodDecorator => {
- return SetMetadata(DECORATORS.COMMAND, { commands });
-};
diff --git a/lib/decorators/update.decorator.ts b/lib/decorators/core/update.decorator.ts
similarity index 53%
rename from lib/decorators/update.decorator.ts
rename to lib/decorators/core/update.decorator.ts
index 1946199..a2ea7f2 100644
--- a/lib/decorators/update.decorator.ts
+++ b/lib/decorators/core/update.decorator.ts
@@ -1,8 +1,8 @@
import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
+import { TELEGRAF_UPDATE } from '../../telegraf.constants';
/**
* `@Update` decorator, it's like NestJS `@Controller` decorator,
* but for Telegram Bot API updates.
*/
-export const Update = (): ClassDecorator => SetMetadata(DECORATORS.UPDATE, {});
+export const Update = (): ClassDecorator => SetMetadata(TELEGRAF_UPDATE, true);
diff --git a/lib/decorators/entity.decorator.ts b/lib/decorators/entity.decorator.ts
deleted file mode 100644
index 7c16011..0000000
--- a/lib/decorators/entity.decorator.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafEntityEntity =
- | string
- | string[]
- | RegExp
- | RegExp[]
- | Function;
-
-export interface EntityOptions {
- entity: TelegrafEntityEntity;
-}
-
-/**
- * Entity handling.
- *
- * @see https://telegraf.js.org/#/?id=entity
- */
-export const Entity = (entity: TelegrafEntityEntity): MethodDecorator => {
- return SetMetadata(DECORATORS.ENTITY, { entity });
-};
diff --git a/lib/decorators/hashtag.decorator.ts b/lib/decorators/hashtag.decorator.ts
deleted file mode 100644
index 9269411..0000000
--- a/lib/decorators/hashtag.decorator.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafHashtagHashtag = string | string[];
-
-export interface HashtagOptions {
- hashtag: TelegrafHashtagHashtag;
-}
-
-/**
- * Hashtag handling.
- *
- * @see https://telegraf.js.org/#/?id=hashtag
- */
-export const Hashtag = (hashtag: TelegrafHashtagHashtag): MethodDecorator => {
- return SetMetadata(DECORATORS.HASHTAG, { hashtag });
-};
diff --git a/lib/decorators/hears.decorator.ts b/lib/decorators/hears.decorator.ts
deleted file mode 100644
index 6e62bdd..0000000
--- a/lib/decorators/hears.decorator.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-import { HearsTriggers } from 'telegraf/typings/composer';
-import { Context } from '../interfaces';
-
-export type TelegrafHearsTriggers = HearsTriggers;
-
-export interface HearsOptions {
- triggers: TelegrafHearsTriggers;
-}
-
-/**
- * Registers middleware for handling text messages.
- *
- * @see https://telegraf.js.org/#/?id=hears
- */
-export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
- return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
-};
diff --git a/lib/decorators/help.decorator.ts b/lib/decorators/help.decorator.ts
deleted file mode 100644
index 159a5c5..0000000
--- a/lib/decorators/help.decorator.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-/**
- * Handler for /help command.
- *
- * @see https://telegraf.js.org/#/?id=help
- */
-export const Help = (): MethodDecorator => {
- return SetMetadata(DECORATORS.HELP, {});
-};
diff --git a/lib/decorators/inline-query.decorator.ts b/lib/decorators/inline-query.decorator.ts
deleted file mode 100644
index 71706de..0000000
--- a/lib/decorators/inline-query.decorator.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-import * as tt from 'telegraf/typings/telegram-types';
-
-export type TelegrafInlineQueryTriggers = string | string[] | RegExp | RegExp[];
-
-export interface InlineQueryOptions {
- triggers?: TelegrafInlineQueryTriggers;
- updateType:
- | tt.UpdateType
- | tt.UpdateType[]
- | tt.MessageSubTypes
- | tt.MessageSubTypes[];
-}
-
-/**
- * Registers middleware for handling inline_query actions with regular expressions.
- *
- * @see https://telegraf.js.org/#/?id=inlinequery
- */
-export const InlineQuery = (
- triggers?: TelegrafInlineQueryTriggers,
-): MethodDecorator => {
- return SetMetadata(DECORATORS.INLINE_QUERY, {
- triggers,
- updateType: 'inline_query',
- });
-};
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
new file mode 100644
index 0000000..1933405
--- /dev/null
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { TelegrafActionTriggers } from '../../telegraf.types';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+export interface ActionOptions {
+ triggers: TelegrafActionTriggers;
+}
+
+/**
+ * Registers middleware for handling callback_data actions with regular expressions.
+ *
+ * @see https://telegraf.js.org/#/?id=action
+ */
+export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Action),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ triggers,
+ } as ActionOptions),
+ );
+};
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
new file mode 100644
index 0000000..692bdf0
--- /dev/null
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { TelegrafCashtag } from '../../telegraf.types';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+export interface CashtagOptions {
+ cashtag: TelegrafCashtag;
+}
+
+/**
+ * Cashtag handling.
+ *
+ * @see https://telegraf.js.org/#/?id=cashtag
+ */
+export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Cashtag),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ cashtag,
+ } as CashtagOptions),
+ );
+};
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
new file mode 100644
index 0000000..ee3de72
--- /dev/null
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafCommand } from '../../telegraf.types';
+
+export interface CommandOptions {
+ commands: TelegrafCommand;
+}
+
+/**
+ * Command handling.
+ *
+ * @see https://telegraf.js.org/#/?id=command
+ */
+export const Command = (commands: TelegrafCommand): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Command),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ commands,
+ } as CommandOptions),
+ );
+};
diff --git a/lib/decorators/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
similarity index 54%
rename from lib/decorators/game-query.decorator.ts
rename to lib/decorators/listeners/game-query.decorator.ts
index dd1138c..9bb173d 100644
--- a/lib/decorators/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,5 +1,6 @@
import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
+import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
/**
* Registers middleware for handling callback_data actions with game query.
@@ -7,5 +8,5 @@ import { DECORATORS } from '../telegraf.constants';
* @see https://telegraf.js.org/#/?id=inlinequery
*/
export const GameQuery = (): MethodDecorator => {
- return SetMetadata(DECORATORS.GAME_QUERY, {});
+ return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.GameQuery);
};
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
new file mode 100644
index 0000000..5447cfa
--- /dev/null
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafHashtag } from '../../telegraf.types';
+
+export interface HashtagOptions {
+ hashtag: TelegrafHashtag;
+}
+
+/**
+ * Hashtag handling.
+ *
+ * @see https://telegraf.js.org/#/?id=hashtag
+ */
+export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hashtag),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ hashtag,
+ } as HashtagOptions),
+ );
+};
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
new file mode 100644
index 0000000..f3c6986
--- /dev/null
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafHearsTriggers } from '../../telegraf.types';
+
+export interface HearsOptions {
+ triggers: TelegrafHearsTriggers;
+}
+
+/**
+ * Registers middleware for handling text messages.
+ *
+ * @see https://telegraf.js.org/#/?id=hears
+ */
+export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hears),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ triggers,
+ } as HearsOptions),
+ );
+};
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
new file mode 100644
index 0000000..ea16432
--- /dev/null
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -0,0 +1,12 @@
+import { SetMetadata } from '@nestjs/common';
+import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+/**
+ * Handler for /help command.
+ *
+ * @see https://telegraf.js.org/#/?id=help
+ */
+export const Help = (): MethodDecorator => {
+ return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Help);
+};
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
new file mode 100644
index 0000000..2299f6b
--- /dev/null
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -0,0 +1,27 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
+
+export interface InlineQueryOptions {
+ triggers: TelegrafInlineQueryTriggers;
+}
+
+/**
+ * Registers middleware for handling inline_query actions with regular expressions.
+ *
+ * @see https://telegraf.js.org/#/?id=inlinequery
+ */
+export const InlineQuery = (
+ triggers: TelegrafInlineQueryTriggers,
+): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.InlineQuery),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ triggers,
+ } as InlineQueryOptions),
+ );
+};
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
new file mode 100644
index 0000000..d9de1d7
--- /dev/null
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafMention } from '../../telegraf.types';
+
+export interface MentionOptions {
+ mention: TelegrafMention;
+}
+
+/**
+ * Mention handling.
+ *
+ * @see https://telegraf.js.org/#/?id=mention
+ */
+export const Mention = (mention: TelegrafMention): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Mention),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ mention,
+ } as MentionOptions),
+ );
+};
diff --git a/lib/decorators/listeners/on.decorator.ts b/lib/decorators/listeners/on.decorator.ts
new file mode 100644
index 0000000..37b25a4
--- /dev/null
+++ b/lib/decorators/listeners/on.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafUpdateType } from '../../telegraf.types';
+
+export interface OnOptions {
+ updateTypes: TelegrafUpdateType;
+}
+
+/**
+ * Registers middleware for provided update type.
+ *
+ * @see https://telegraf.js.org/#/?id=on
+ */
+export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.On),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ updateTypes,
+ } as OnOptions),
+ );
+};
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
new file mode 100644
index 0000000..d5f956b
--- /dev/null
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafPhone } from '../../telegraf.types';
+
+export interface PhoneOptions {
+ phone: TelegrafPhone;
+}
+
+/**
+ * Phone number handling.
+ *
+ * @see https://telegraf.js.org/#/?id=phone
+ */
+export const Phone = (phone: TelegrafPhone): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Phone),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ phone,
+ } as PhoneOptions),
+ );
+};
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
new file mode 100644
index 0000000..2087c93
--- /dev/null
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -0,0 +1,12 @@
+import { SetMetadata } from '@nestjs/common';
+import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+/**
+ * Handler for /settings command.
+ *
+ * @see https://telegraf.js.org/#/?id=settings
+ */
+export const Settings = (): MethodDecorator => {
+ return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Settings);
+};
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
new file mode 100644
index 0000000..9031bda
--- /dev/null
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -0,0 +1,12 @@
+import { SetMetadata } from '@nestjs/common';
+import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+/**
+ * Handler for /start command.
+ *
+ * @see https://telegraf.js.org/#/?id=start
+ */
+export const Start = (): MethodDecorator => {
+ return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Start);
+};
diff --git a/lib/decorators/listeners/use.decorator.ts b/lib/decorators/listeners/use.decorator.ts
new file mode 100644
index 0000000..c2e911e
--- /dev/null
+++ b/lib/decorators/listeners/use.decorator.ts
@@ -0,0 +1,12 @@
+import { SetMetadata } from '@nestjs/common';
+import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+
+/**
+ * Registers a middleware.
+ *
+ * @see https://telegraf.js.org/#/?id=use
+ */
+export const Use = (): MethodDecorator => {
+ return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Use);
+};
diff --git a/lib/decorators/mention.decorator.ts b/lib/decorators/mention.decorator.ts
deleted file mode 100644
index 004f41b..0000000
--- a/lib/decorators/mention.decorator.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafMentionUsername = string | string[];
-
-export interface MentionOptions {
- username: TelegrafMentionUsername;
-}
-
-/**
- * Mention handling.
- *
- * @see https://telegraf.js.org/#/?id=mention
- */
-export const Mention = (username: TelegrafMentionUsername): MethodDecorator => {
- return SetMetadata(DECORATORS.MENTION, { username });
-};
diff --git a/lib/decorators/on.decorator.ts b/lib/decorators/on.decorator.ts
deleted file mode 100644
index 9e3752a..0000000
--- a/lib/decorators/on.decorator.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-import { UpdateType, MessageSubTypes } from 'telegraf/typings/telegram-types';
-
-export type TelegrafOnUpdateTypes =
- | UpdateType
- | UpdateType[]
- | MessageSubTypes
- | MessageSubTypes[];
-
-export interface OnOptions {
- updateTypes: TelegrafOnUpdateTypes;
-}
-
-/**
- * Registers middleware for provided update type.
- *
- * @see https://telegraf.js.org/#/?id=on
- */
-export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
- return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
-};
diff --git a/lib/decorators/phone.decorator.ts b/lib/decorators/phone.decorator.ts
deleted file mode 100644
index 39a0b27..0000000
--- a/lib/decorators/phone.decorator.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-export type TelegrafPhonePhone = string | string[];
-
-export interface PhoneOptions {
- phone: TelegrafPhonePhone;
-}
-
-/**
- * Phone number handling.
- *
- * @see https://telegraf.js.org/#/?id=phone
- */
-export const Phone = (phone: TelegrafPhonePhone): MethodDecorator => {
- return SetMetadata(DECORATORS.PHONE, { phone });
-};
diff --git a/lib/decorators/settings.decorator.ts b/lib/decorators/settings.decorator.ts
deleted file mode 100644
index 9378e7f..0000000
--- a/lib/decorators/settings.decorator.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-/**
- * Handler for /settings command.
- *
- * @see https://telegraf.js.org/#/?id=settings
- */
-export const Settings = (): MethodDecorator => {
- return SetMetadata(DECORATORS.SETTINGS, {});
-};
diff --git a/lib/decorators/start.decorator.ts b/lib/decorators/start.decorator.ts
deleted file mode 100644
index 9429753..0000000
--- a/lib/decorators/start.decorator.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-/**
- * Handler for /start command.
- *
- * @see https://telegraf.js.org/#/?id=start
- */
-export const Start = (): MethodDecorator => {
- return SetMetadata(DECORATORS.START, {});
-};
diff --git a/lib/decorators/use.decorator.ts b/lib/decorators/use.decorator.ts
deleted file mode 100644
index a7f68fa..0000000
--- a/lib/decorators/use.decorator.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-
-/**
- * Registers a middleware.
- *
- * @see https://telegraf.js.org/#/?id=use
- */
-export const Use = (): MethodDecorator => {
- return SetMetadata(DECORATORS.USE, {});
-};
diff --git a/lib/enums/listener-type.enum.ts b/lib/enums/listener-type.enum.ts
new file mode 100644
index 0000000..5ebf548
--- /dev/null
+++ b/lib/enums/listener-type.enum.ts
@@ -0,0 +1,16 @@
+export enum ListenerType {
+ Use = 'use',
+ On = 'on',
+ Hears = 'hears',
+ Command = 'command',
+ Start = 'start',
+ Help = 'help',
+ Settings = 'settings',
+ Mention = 'mention',
+ Phone = 'phone',
+ Hashtag = 'hashtag',
+ Cashtag = 'cashtag',
+ Action = 'action',
+ InlineQuery = 'inlineQuery',
+ GameQuery = 'gameQuery',
+}
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 1affe84..88b4194 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,23 +1,6 @@
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
export const TELEGRAF_PROVIDER = 'TelegrafProvider';
-export const DECORATORS_PREFIX = 'TELEGRAF';
-export const DECORATORS = {
- USE: `${DECORATORS_PREFIX}/USE`,
- ON: `${DECORATORS_PREFIX}/ON`,
- HEARS: `${DECORATORS_PREFIX}/HEARS`,
- COMMAND: `${DECORATORS_PREFIX}/COMMAND`,
- START: `${DECORATORS_PREFIX}/START`,
- HELP: `${DECORATORS_PREFIX}/HELP`,
- SETTINGS: `${DECORATORS_PREFIX}/SETTINGS`,
- ENTITY: `${DECORATORS_PREFIX}/ENTITY`,
- MENTION: `${DECORATORS_PREFIX}/MENTION`,
- PHONE: `${DECORATORS_PREFIX}/PHONE`,
- HASHTAG: `${DECORATORS_PREFIX}/HASHTAG`,
- CASHTAG: `${DECORATORS_PREFIX}/CASHTAG`,
- ACTION: `${DECORATORS_PREFIX}/ACTION`,
- INLINE_QUERY: `${DECORATORS_PREFIX}/INLINE_QUERY`,
- GAME_QUERY: `${DECORATORS_PREFIX}/GAME_QUERY`,
- UPDATE: `${DECORATORS_PREFIX}/UPDATE`,
- UPDATE_HOOK: `${DECORATORS_PREFIX}/UPDATE_HOOK`,
-};
+export const TELEGRAF_UPDATE = 'TELEGRAF_UPDATE';
+export const TELEGRAF_LISTENER_TYPE = 'TELEGRAF_LISTENER_TYPE';
+export const TELEGRAF_LISTENER_OPTIONS = 'TELEGRAF_LISTENER_OPTIONS';
diff --git a/lib/telegraf.provider.ts b/lib/telegraf.provider.ts
index 58be5b1..f6bfb2f 100644
--- a/lib/telegraf.provider.ts
+++ b/lib/telegraf.provider.ts
@@ -10,7 +10,8 @@ import { Context, TelegrafModuleOptions } from './interfaces';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
@Injectable()
-export class TelegrafProvider extends Telegraf
+export class TelegrafProvider
+ extends Telegraf
implements OnApplicationBootstrap, OnApplicationShutdown {
private logger = new Logger('Telegraf');
private readonly launchOptions;
@@ -20,18 +21,18 @@ export class TelegrafProvider extends Telegraf
this.launchOptions = options.launchOptions;
}
- async onApplicationBootstrap() {
- this.catch((err, ctx: Context) => {
+ async onApplicationBootstrap(): Promise {
+ this.catch(async (err, ctx) => {
this.logger.error(
`Encountered an error for ${ctx.updateType} update type`,
- err,
+ err as string,
);
});
await this.launch(this.launchOptions);
}
- async onApplicationShutdown() {
+ async onApplicationShutdown(): Promise {
await this.stop();
}
}
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
new file mode 100644
index 0000000..f46c261
--- /dev/null
+++ b/lib/telegraf.types.ts
@@ -0,0 +1,13 @@
+import { Context, Composer } from 'telegraf';
+
+export type TelegrafActionTriggers = Parameters['action']>[0];
+export type TelegrafHearsTriggers = Parameters['hears']>[0];
+export type TelegrafInlineQueryTriggers = Parameters<
+ Composer['inlineQuery']
+>[0];
+export type TelegrafCashtag = Parameters['cashtag']>[0];
+export type TelegrafHashtag = Parameters['hashtag']>[0];
+export type TelegrafCommand = Parameters['command']>[0];
+export type TelegrafMention = Parameters['mention']>[0];
+export type TelegrafPhone = Parameters['phone']>[0];
+export type TelegrafUpdateType = Parameters['on']>[0];
From b394f5274b40a1554eeacc54a2dabdd70d07b38b Mon Sep 17 00:00:00 2001
From: unknown
Date: Wed, 23 Dec 2020 21:48:07 +0300
Subject: [PATCH 12/33] feat(wip): add updates decorators
---
.../{listeners => core}/on.decorator.ts | 0
.../{listeners => core}/use.decorator.ts | 0
lib/decorators/index.ts | 2 +-
lib/decorators/update-hooks.decorators.ts | 104 ------------------
lib/decorators/updates.decorator.ts | 70 ++++++++++++
5 files changed, 71 insertions(+), 105 deletions(-)
rename lib/decorators/{listeners => core}/on.decorator.ts (100%)
rename lib/decorators/{listeners => core}/use.decorator.ts (100%)
delete mode 100644 lib/decorators/update-hooks.decorators.ts
create mode 100644 lib/decorators/updates.decorator.ts
diff --git a/lib/decorators/listeners/on.decorator.ts b/lib/decorators/core/on.decorator.ts
similarity index 100%
rename from lib/decorators/listeners/on.decorator.ts
rename to lib/decorators/core/on.decorator.ts
diff --git a/lib/decorators/listeners/use.decorator.ts b/lib/decorators/core/use.decorator.ts
similarity index 100%
rename from lib/decorators/listeners/use.decorator.ts
rename to lib/decorators/core/use.decorator.ts
diff --git a/lib/decorators/index.ts b/lib/decorators/index.ts
index 03af4ba..c49f9c0 100644
--- a/lib/decorators/index.ts
+++ b/lib/decorators/index.ts
@@ -15,4 +15,4 @@ export * from './settings.decorator';
export * from './start.decorator';
export * from './update.decorator';
export * from './update-hooks.decorators';
-export * from './use.decorator';
+export * from './core/use.decorator';
diff --git a/lib/decorators/update-hooks.decorators.ts b/lib/decorators/update-hooks.decorators.ts
deleted file mode 100644
index 75621d8..0000000
--- a/lib/decorators/update-hooks.decorators.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { DECORATORS } from '../telegraf.constants';
-import * as tt from 'telegraf/typings/telegram-types';
-
-export interface UpdateHookOptions {
- updateType:
- | tt.UpdateType
- | tt.UpdateType[]
- | tt.MessageSubTypes
- | tt.MessageSubTypes[];
-}
-
-/**
- * New incoming message of any kind — text, photo, sticker, etc.
- * @constructor
- */
-export const Message = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'message',
- });
-};
-
-/**
- * New version of a message that is known to the bot and was edited
- * @constructor
- */
-export const EditedMessage = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'edited_message',
- });
-};
-
-/**
- * New incoming channel post of any kind — text, photo, sticker, etc.
- * @constructor
- */
-export const ChannelPost = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'channel_post',
- });
-};
-
-/**
- * New version of a channel post that is known to the bot and was edited
- * @constructor
- */
-export const EditedChannelPost = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'edited_channel_post',
- });
-};
-
-/**
- * New incoming inline query
- * See this decorator in inline-query.decorator.ts
- * @constructor
- */
-// export const InlineQuery = (): MethodDecorator => {
-// return SetMetadata(DECORATORS.UPDATE_HOOK, {
-// updateType: 'inline_query',
-// });
-// };
-
-/**
- * The result of an inline query that was chosen by a user and sent to their chat partner.
- * @constructor
- */
-export const ChosenInlineResult = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'chosen_inline_result',
- });
-};
-
-/**
- * New incoming callback query
- * @constructor
- */
-export const CallbackQuery = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'callback_query',
- });
-};
-
-/**
- * New incoming shipping query. Only for invoices with flexible price
- * @constructor
- */
-export const ShippingQuery = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'shipping_query',
- });
-};
-
-/**
- * New incoming pre-checkout query. Contains full information about checkout
- * @constructor
- */
-export const PreCheckoutQuery = (): MethodDecorator => {
- return SetMetadata(DECORATORS.UPDATE_HOOK, {
- updateType: 'pre_checkout_query',
- });
-};
-
-// Two more decorators are missing here. For 'poll' and 'poll_answer' update types.
diff --git a/lib/decorators/updates.decorator.ts b/lib/decorators/updates.decorator.ts
new file mode 100644
index 0000000..b186a21
--- /dev/null
+++ b/lib/decorators/updates.decorator.ts
@@ -0,0 +1,70 @@
+import { On } from './core/on.decorator';
+
+/**
+ * New incoming message of any kind — text, photo, sticker, etc.
+ * @constructor
+ */
+export const Message = (): MethodDecorator => On('message');
+
+/**
+ * New version of a message that is known to the bot and was edited
+ * @constructor
+ */
+export const EditedMessage = (): MethodDecorator => On('edited_message');
+
+/**
+ * New incoming channel post of any kind — text, photo, sticker, etc.
+ * @constructor
+ */
+export const ChannelPost = (): MethodDecorator => On('channel_post');
+
+/**
+ * New version of a channel post that is known to the bot and was edited
+ * @constructor
+ */
+export const EditedChannelPost = (): MethodDecorator =>
+ On('edited_channel_post');
+
+/**
+ * New incoming inline query
+ * See this decorator in inline-query.decorator.ts
+ * @constructor
+ */
+// export const InlineQuery = (): MethodDecorator => On('inline_query');
+
+/**
+ * The result of an inline query that was chosen by a user and sent to their chat partner.
+ * @constructor
+ */
+export const ChosenInlineResult = (): MethodDecorator =>
+ On('chosen_inline_result');
+
+/**
+ * New incoming callback query
+ * @constructor
+ */
+export const CallbackQuery = (): MethodDecorator => On('callback_query');
+
+/**
+ * New incoming shipping query. Only for invoices with flexible price
+ * @constructor
+ */
+export const ShippingQuery = (): MethodDecorator => On('shipping_query');
+
+/**
+ * New incoming pre-checkout query. Contains full information about checkout
+ * @constructor
+ */
+export const PreCheckoutQuery = (): MethodDecorator => On('pre_checkout_query');
+
+/**
+ * New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot
+ * @constructor
+ */
+export const Poll = (): MethodDecorator => On('poll');
+
+/**
+ * A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
+ * @constructor
+ */
+export const PollAnswer = (): MethodDecorator => On('poll_answer');
From 61c6c07482d522ac9eef0d36ea656486585d62e0 Mon Sep 17 00:00:00 2001
From: unknown
Date: Fri, 25 Dec 2020 23:11:16 +0300
Subject: [PATCH 13/33] feat(wip): rewrite explorer logic & update launch
options & add miss decorators
---
lib/decorators/core/index.ts | 3 +
lib/decorators/index.ts | 19 +-
lib/decorators/listeners/command.decorator.ts | 6 +-
lib/decorators/listeners/email.decorator.ts | 25 ++
lib/decorators/listeners/index.ts | 16 +
.../listeners/text-link.decorator.ts | 25 ++
.../listeners/text-mention.decorator.ts | 25 ++
lib/decorators/listeners/url.decorator.ts | 25 ++
lib/decorators/updates.decorator.ts | 70 ----
lib/enums/index.ts | 1 +
lib/enums/listener-type.enum.ts | 4 +
lib/interfaces/context.interface.ts | 1 +
lib/interfaces/telegraf-options.interface.ts | 13 +-
.../decorators/middleware.decorator.ts | 4 +
lib/telegraf-metadata.accessor.ts | 202 +-----------
lib/telegraf.explorer.ts | 308 +++++++-----------
lib/telegraf.types.ts | 11 +-
17 files changed, 271 insertions(+), 487 deletions(-)
create mode 100644 lib/decorators/core/index.ts
create mode 100644 lib/decorators/listeners/email.decorator.ts
create mode 100644 lib/decorators/listeners/index.ts
create mode 100644 lib/decorators/listeners/text-link.decorator.ts
create mode 100644 lib/decorators/listeners/text-mention.decorator.ts
create mode 100644 lib/decorators/listeners/url.decorator.ts
delete mode 100644 lib/decorators/updates.decorator.ts
create mode 100644 lib/enums/index.ts
create mode 100644 lib/middleware/decorators/middleware.decorator.ts
diff --git a/lib/decorators/core/index.ts b/lib/decorators/core/index.ts
new file mode 100644
index 0000000..c7875e3
--- /dev/null
+++ b/lib/decorators/core/index.ts
@@ -0,0 +1,3 @@
+export * from './on.decorator';
+export * from './update.decorator';
+export * from './use.decorator';
diff --git a/lib/decorators/index.ts b/lib/decorators/index.ts
index c49f9c0..dd680b1 100644
--- a/lib/decorators/index.ts
+++ b/lib/decorators/index.ts
@@ -1,18 +1,3 @@
-export * from './action.decorator';
-export * from './cashtag.decorator';
-export * from './command.decorator';
-export * from './entity.decorator';
-export * from './game-query.decorator';
-export * from './hashtag.decorator';
-export * from './hears.decorator';
-export * from './help.decorator';
export * from './inject-bot.decorator';
-export * from './inline-query.decorator';
-export * from './mention.decorator';
-export * from './on.decorator';
-export * from './phone.decorator';
-export * from './settings.decorator';
-export * from './start.decorator';
-export * from './update.decorator';
-export * from './update-hooks.decorators';
-export * from './core/use.decorator';
+export * from './core';
+export * from './listeners';
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index ee3de72..683b405 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -7,7 +7,7 @@ import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafCommand } from '../../telegraf.types';
export interface CommandOptions {
- commands: TelegrafCommand;
+ command: TelegrafCommand;
}
/**
@@ -15,11 +15,11 @@ export interface CommandOptions {
*
* @see https://telegraf.js.org/#/?id=command
*/
-export const Command = (commands: TelegrafCommand): MethodDecorator => {
+export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Command),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
- commands,
+ command: command,
} as CommandOptions),
);
};
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
new file mode 100644
index 0000000..a0b0b91
--- /dev/null
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafEmail } from '../../telegraf.types';
+
+export interface EmailOptions {
+ email: TelegrafEmail;
+}
+
+/**
+ * Registers middleware for handling messages with email entity.
+ *
+ * @see https://telegraf.js.org/#/?id=telegraf-email
+ */
+export const Email = (email: TelegrafEmail): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Email),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ email,
+ } as EmailOptions),
+ );
+};
diff --git a/lib/decorators/listeners/index.ts b/lib/decorators/listeners/index.ts
new file mode 100644
index 0000000..2108a90
--- /dev/null
+++ b/lib/decorators/listeners/index.ts
@@ -0,0 +1,16 @@
+export * from './action.decorator';
+export * from './cashtag.decorator';
+export * from './command.decorator';
+export * from './game-query.decorator';
+export * from './hashtag.decorator';
+export * from './hears.decorator';
+export * from './help.decorator';
+export * from './inline-query.decorator';
+export * from './mention.decorator';
+export * from './phone.decorator';
+export * from './settings.decorator';
+export * from './start.decorator';
+export * from './email.decorator';
+export * from './url.decorator';
+export * from './text-link.decorator';
+export * from './text-mention.decorator';
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
new file mode 100644
index 0000000..f6a484e
--- /dev/null
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafTextLink } from '../../telegraf.types';
+
+export interface TextLinkOptions {
+ link: TelegrafTextLink;
+}
+
+/**
+ * Registers middleware for handling messages with text_link entity.
+ *
+ * @see https://telegraf.js.org/#/?id=telegraf-textlink
+ */
+export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextLink),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ link,
+ } as TextLinkOptions),
+ );
+};
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
new file mode 100644
index 0000000..aea29ce
--- /dev/null
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafTextMention } from '../../telegraf.types';
+
+export interface TextMentionOptions {
+ mention: TelegrafTextMention;
+}
+
+/**
+ * Registers middleware for handling messages with text_mention entity.
+ *
+ * @see https://telegraf.js.org/#/?id=telegraf-textlink
+ */
+export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextMention),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ mention,
+ } as TextMentionOptions),
+ );
+};
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
new file mode 100644
index 0000000..e8c1448
--- /dev/null
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -0,0 +1,25 @@
+import { applyDecorators, SetMetadata } from '@nestjs/common';
+import {
+ TELEGRAF_LISTENER_OPTIONS,
+ TELEGRAF_LISTENER_TYPE,
+} from '../../telegraf.constants';
+import { ListenerType } from '../../enums/listener-type.enum';
+import { TelegrafUrl } from '../../telegraf.types';
+
+export interface UrlOptions {
+ url: TelegrafUrl;
+}
+
+/**
+ * Registers middleware for handling messages with url entity.
+ *
+ * @see https://telegraf.js.org/#/?id=telegraf-url
+ */
+export const Url = (url: TelegrafUrl): MethodDecorator => {
+ return applyDecorators(
+ SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Url),
+ SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ url,
+ } as UrlOptions),
+ );
+};
diff --git a/lib/decorators/updates.decorator.ts b/lib/decorators/updates.decorator.ts
deleted file mode 100644
index b186a21..0000000
--- a/lib/decorators/updates.decorator.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { On } from './core/on.decorator';
-
-/**
- * New incoming message of any kind — text, photo, sticker, etc.
- * @constructor
- */
-export const Message = (): MethodDecorator => On('message');
-
-/**
- * New version of a message that is known to the bot and was edited
- * @constructor
- */
-export const EditedMessage = (): MethodDecorator => On('edited_message');
-
-/**
- * New incoming channel post of any kind — text, photo, sticker, etc.
- * @constructor
- */
-export const ChannelPost = (): MethodDecorator => On('channel_post');
-
-/**
- * New version of a channel post that is known to the bot and was edited
- * @constructor
- */
-export const EditedChannelPost = (): MethodDecorator =>
- On('edited_channel_post');
-
-/**
- * New incoming inline query
- * See this decorator in inline-query.decorator.ts
- * @constructor
- */
-// export const InlineQuery = (): MethodDecorator => On('inline_query');
-
-/**
- * The result of an inline query that was chosen by a user and sent to their chat partner.
- * @constructor
- */
-export const ChosenInlineResult = (): MethodDecorator =>
- On('chosen_inline_result');
-
-/**
- * New incoming callback query
- * @constructor
- */
-export const CallbackQuery = (): MethodDecorator => On('callback_query');
-
-/**
- * New incoming shipping query. Only for invoices with flexible price
- * @constructor
- */
-export const ShippingQuery = (): MethodDecorator => On('shipping_query');
-
-/**
- * New incoming pre-checkout query. Contains full information about checkout
- * @constructor
- */
-export const PreCheckoutQuery = (): MethodDecorator => On('pre_checkout_query');
-
-/**
- * New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot
- * @constructor
- */
-export const Poll = (): MethodDecorator => On('poll');
-
-/**
- * A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
- * @constructor
- */
-export const PollAnswer = (): MethodDecorator => On('poll_answer');
diff --git a/lib/enums/index.ts b/lib/enums/index.ts
new file mode 100644
index 0000000..1f890a3
--- /dev/null
+++ b/lib/enums/index.ts
@@ -0,0 +1 @@
+export * from './listener-type.enum';
diff --git a/lib/enums/listener-type.enum.ts b/lib/enums/listener-type.enum.ts
index 5ebf548..932382f 100644
--- a/lib/enums/listener-type.enum.ts
+++ b/lib/enums/listener-type.enum.ts
@@ -10,6 +10,10 @@ export enum ListenerType {
Phone = 'phone',
Hashtag = 'hashtag',
Cashtag = 'cashtag',
+ Email = 'email',
+ Url = 'url',
+ TextLink = 'textLink',
+ TextMention = 'textMention',
Action = 'action',
InlineQuery = 'inlineQuery',
GameQuery = 'gameQuery',
diff --git a/lib/interfaces/context.interface.ts b/lib/interfaces/context.interface.ts
index d670e24..97001b3 100644
--- a/lib/interfaces/context.interface.ts
+++ b/lib/interfaces/context.interface.ts
@@ -1,3 +1,4 @@
import { Context as TelegrafContext } from 'telegraf';
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Context extends TelegrafContext {}
diff --git a/lib/interfaces/telegraf-options.interface.ts b/lib/interfaces/telegraf-options.interface.ts
index 13c729d..9f7dc6d 100644
--- a/lib/interfaces/telegraf-options.interface.ts
+++ b/lib/interfaces/telegraf-options.interface.ts
@@ -1,17 +1,10 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
-import {
- TelegrafOptions,
- LaunchPollingOptions,
- LaunchWebhookOptions,
-} from 'telegraf/typings/telegraf';
+import { TelegrafLaunchOption, TelegrafOption } from '../telegraf.types';
export interface TelegrafModuleOptions {
token: string;
- options?: TelegrafOptions;
- launchOptions?: {
- polling?: LaunchPollingOptions;
- webhook?: LaunchWebhookOptions;
- };
+ options?: TelegrafOption;
+ launchOptions?: TelegrafLaunchOption;
}
export interface TelegrafOptionsFactory {
diff --git a/lib/middleware/decorators/middleware.decorator.ts b/lib/middleware/decorators/middleware.decorator.ts
new file mode 100644
index 0000000..29541ec
--- /dev/null
+++ b/lib/middleware/decorators/middleware.decorator.ts
@@ -0,0 +1,4 @@
+import { SetMetadata } from '@nestjs/common';
+
+export const Middleware = (): ClassDecorator =>
+ SetMetadata('TELEGRAF_MIDDLEWARE', true);
diff --git a/lib/telegraf-metadata.accessor.ts b/lib/telegraf-metadata.accessor.ts
index b204d60..504db39 100644
--- a/lib/telegraf-metadata.accessor.ts
+++ b/lib/telegraf-metadata.accessor.ts
@@ -1,204 +1,20 @@
-import { Injectable, Type } from '@nestjs/common';
+import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
- ActionOptions,
- CashtagOptions,
- CommandOptions,
- EntityOptions,
- HashtagOptions,
- HearsOptions,
- InlineQueryOptions,
- MentionOptions,
- OnOptions,
- PhoneOptions,
- UpdateHookOptions,
-} from './decorators';
-import { DECORATORS } from './telegraf.constants';
+ TELEGRAF_LISTENER_TYPE,
+ TELEGRAF_MODULE_OPTIONS,
+} from './telegraf.constants';
+import { ListenerType } from './enums/listener-type.enum';
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
- isUpdate(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.UPDATE, target);
+ getListenerType(target: Function): ListenerType | undefined {
+ return this.reflector.get(TELEGRAF_LISTENER_TYPE, target);
}
- isUpdateHook(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.UPDATE_HOOK, target);
- }
-
- getUpdateHookMetadata(
- target: Type | Function,
- ): UpdateHookOptions | undefined {
- return this.reflector.get(DECORATORS.UPDATE_HOOK, target);
- }
-
- isTelegrafUse(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.USE, target);
- }
-
- isTelegrafOn(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.ON, target);
- }
-
- getTelegrafOnMetadata(target: Type | Function): OnOptions | undefined {
- return this.reflector.get(DECORATORS.ON, target);
- }
-
- isTelegrafHears(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.HEARS, target);
- }
-
- getTelegrafHearsMetadata(
- target: Type | Function,
- ): HearsOptions | undefined {
- return this.reflector.get(DECORATORS.HEARS, target);
- }
-
- isTelegrafCommand(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.COMMAND, target);
- }
-
- getTelegrafCommandMetadata(
- target: Type | Function,
- ): CommandOptions | undefined {
- return this.reflector.get(DECORATORS.COMMAND, target);
- }
-
- isTelegrafStart(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.START, target);
- }
-
- isTelegrafHelp(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.HELP, target);
- }
-
- isTelegrafSettings(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.SETTINGS, target);
- }
-
- isTelegrafEntity(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.ENTITY, target);
- }
-
- getTelegrafEntityMetadata(
- target: Type | Function,
- ): EntityOptions | undefined {
- return this.reflector.get(DECORATORS.ENTITY, target);
- }
-
- isTelegrafMention(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.MENTION, target);
- }
-
- getTelegrafMentionMetadata(
- target: Type | Function,
- ): MentionOptions | undefined {
- return this.reflector.get(DECORATORS.MENTION, target);
- }
-
- isTelegrafPhone(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.PHONE, target);
- }
-
- getTelegrafPhoneMetadata(
- target: Type | Function,
- ): PhoneOptions | undefined {
- return this.reflector.get(DECORATORS.PHONE, target);
- }
-
- isTelegrafHashtag(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.HASHTAG, target);
- }
-
- getTelegrafHashtagMetadata(
- target: Type | Function,
- ): HashtagOptions | undefined {
- return this.reflector.get(DECORATORS.HASHTAG, target);
- }
-
- isTelegrafCashtag(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.CASHTAG, target);
- }
-
- getTelegrafCashtagMetadata(
- target: Type | Function,
- ): CashtagOptions | undefined {
- return this.reflector.get(DECORATORS.CASHTAG, target);
- }
-
- isTelegrafAction(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.ACTION, target);
- }
-
- getTelegrafActionMetadata(
- target: Type | Function,
- ): ActionOptions | undefined {
- return this.reflector.get(DECORATORS.ACTION, target);
- }
-
- isTelegrafInlineQuery(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.INLINE_QUERY, target);
- }
-
- getTelegrafInlineQueryMetadata(
- target: Type | Function,
- ): InlineQueryOptions | undefined {
- return this.reflector.get(DECORATORS.INLINE_QUERY, target);
- }
-
- isTelegrafGameQuery(target: Type | Function): boolean {
- if (!target) {
- return false;
- }
- return !!this.reflector.get(DECORATORS.GAME_QUERY, target);
+ getListenerOptions(target: Function): unknown | undefined {
+ return this.reflector.get(TELEGRAF_MODULE_OPTIONS, target);
}
}
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index 42aa3c5..da3a6b6 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -1,22 +1,24 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { DiscoveryService, ModuleRef } from '@nestjs/core';
-import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
import { TelegrafProvider } from './telegraf.provider';
import { TELEGRAF_PROVIDER } from './telegraf.constants';
+import { ListenerType } from './enums/listener-type.enum';
import {
ActionOptions,
CashtagOptions,
CommandOptions,
- EntityOptions,
+ EmailOptions,
HashtagOptions,
HearsOptions,
InlineQueryOptions,
MentionOptions,
OnOptions,
PhoneOptions,
- UpdateHookOptions,
+ TextLinkOptions,
+ TextMentionOptions,
+ UrlOptions,
} from './decorators';
@Injectable()
@@ -30,209 +32,129 @@ export class TelegrafExplorer implements OnModuleInit {
private telegraf: TelegrafProvider;
- onModuleInit() {
+ onModuleInit(): void {
this.telegraf = this.moduleRef.get(TELEGRAF_PROVIDER, {
strict: false,
});
this.explore();
}
- explore() {
- /**
- * Update providers section is only for decorators under Update decorator
- */
- const updateProviders: InstanceWrapper[] = this.discoveryService
+ explore(): void {
+ this.discoveryService
.getProviders()
- .filter((wrapper: InstanceWrapper) =>
- this.metadataAccessor.isUpdate(wrapper.metatype),
- );
+ .filter((wrapper) => wrapper.instance)
+ .forEach((wrapper) => {
+ const { instance } = wrapper;
- updateProviders.forEach((wrapper: InstanceWrapper) => {
- const { instance } = wrapper;
+ const prototype = Object.getPrototypeOf(instance);
+ this.metadataScanner.scanFromPrototype(
+ instance,
+ prototype,
+ (methodKey: string) => {
+ this.registerIfListener(instance, methodKey);
+ },
+ );
+ });
+ }
- this.metadataScanner.scanFromPrototype(
- instance,
- Object.getPrototypeOf(instance),
- (key: string) => {
- if (this.metadataAccessor.isUpdateHook(instance[key])) {
- const metadata = this.metadataAccessor.getUpdateHookMetadata(
- instance[key],
- );
- this.handleUpdateHook(instance, key, metadata);
- }
- },
- );
- });
+ private registerIfListener(
+ instance: Record,
+ methodKey: string,
+ ): void {
+ const methodRef = instance[methodKey];
+ const middlewareFn = methodRef.bind(instance);
- const providers: InstanceWrapper[] = this.discoveryService.getProviders();
+ const listenerType = this.metadataAccessor.getListenerType(methodRef);
+ if (!listenerType) return;
- providers.forEach((wrapper: InstanceWrapper) => {
- const { instance } = wrapper;
+ const listenerOptions = this.metadataAccessor.getListenerOptions(methodRef);
- if (!instance) {
- return;
+ switch (listenerType) {
+ case ListenerType.On: {
+ const { updateTypes } = listenerOptions as OnOptions;
+ this.telegraf.on(updateTypes, middlewareFn);
+ break;
+ }
+ case ListenerType.Use: {
+ this.telegraf.use(middlewareFn);
+ break;
+ }
+ case ListenerType.Start: {
+ this.telegraf.start(middlewareFn);
+ break;
+ }
+ case ListenerType.Help: {
+ this.telegraf.help(middlewareFn);
+ break;
+ }
+ case ListenerType.Settings: {
+ this.telegraf.settings(middlewareFn);
+ break;
+ }
+ case ListenerType.Hears: {
+ const { triggers } = listenerOptions as HearsOptions;
+ this.telegraf.hears(triggers, middlewareFn);
+ break;
+ }
+ case ListenerType.Command: {
+ const { command } = listenerOptions as CommandOptions;
+ this.telegraf.command(command, middlewareFn);
+ break;
+ }
+ case ListenerType.Action: {
+ const { triggers } = listenerOptions as ActionOptions;
+ this.telegraf.action(triggers, middlewareFn);
+ break;
+ }
+ case ListenerType.Mention: {
+ const { mention } = listenerOptions as MentionOptions;
+ this.telegraf.mention(mention, middlewareFn);
+ break;
+ }
+ case ListenerType.Phone: {
+ const { phone } = listenerOptions as PhoneOptions;
+ this.telegraf.phone(phone, middlewareFn);
+ break;
+ }
+ case ListenerType.Hashtag: {
+ const { hashtag } = listenerOptions as HashtagOptions;
+ this.telegraf.hashtag(hashtag, middlewareFn);
+ break;
+ }
+ case ListenerType.Cashtag: {
+ const { cashtag } = listenerOptions as CashtagOptions;
+ this.telegraf.cashtag(cashtag, middlewareFn);
+ break;
+ }
+ case ListenerType.Email: {
+ const { email } = listenerOptions as EmailOptions;
+ this.telegraf.email(email, middlewareFn);
+ break;
+ }
+ case ListenerType.Url: {
+ const { url } = listenerOptions as UrlOptions;
+ this.telegraf.url(url, middlewareFn);
+ break;
+ }
+ case ListenerType.TextLink: {
+ const { link } = listenerOptions as TextLinkOptions;
+ this.telegraf.textLink(link, middlewareFn);
+ break;
+ }
+ case ListenerType.TextMention: {
+ const { mention } = listenerOptions as TextMentionOptions;
+ this.telegraf.textMention(mention, middlewareFn);
+ break;
+ }
+ case ListenerType.InlineQuery: {
+ const { triggers } = listenerOptions as InlineQueryOptions;
+ this.telegraf.inlineQuery(triggers, middlewareFn);
+ break;
+ }
+ case ListenerType.GameQuery: {
+ this.telegraf.gameQuery(middlewareFn);
+ break;
}
-
- this.metadataScanner.scanFromPrototype(
- instance,
- Object.getPrototypeOf(instance),
- (key: string) => {
- if (this.metadataAccessor.isTelegrafUse(instance[key])) {
- this.handleTelegrafUse(instance, key);
- } else if (this.metadataAccessor.isTelegrafOn(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafOnMetadata(
- instance[key],
- );
- this.handleTelegrafOn(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafHears(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafHearsMetadata(
- instance[key],
- );
- this.handleTelegrafHears(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafCommand(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafCommandMetadata(
- instance[key],
- );
- this.handleTelegrafCommand(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafStart(instance[key])) {
- this.handleTelegrafStart(instance, key);
- } else if (this.metadataAccessor.isTelegrafHelp(instance[key])) {
- this.handleTelegrafHelp(instance, key);
- } else if (this.metadataAccessor.isTelegrafSettings(instance[key])) {
- this.handleTelegrafSettings(instance, key);
- } else if (this.metadataAccessor.isTelegrafEntity(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafEntityMetadata(
- instance[key],
- );
- this.handleTelegrafEntity(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafMention(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafMentionMetadata(
- instance[key],
- );
- this.handleTelegrafMention(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafPhone(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafPhoneMetadata(
- instance[key],
- );
- this.handleTelegrafPhone(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafHashtag(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafHashtagMetadata(
- instance[key],
- );
- this.handleTelegrafHashtag(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafCashtag(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafCashtagMetadata(
- instance[key],
- );
- this.handleTelegrafCashtag(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafAction(instance[key])) {
- const metadata = this.metadataAccessor.getTelegrafActionMetadata(
- instance[key],
- );
- this.handleTelegrafAction(instance, key, metadata);
- } else if (
- this.metadataAccessor.isTelegrafInlineQuery(instance[key])
- ) {
- const metadata = this.metadataAccessor.getTelegrafInlineQueryMetadata(
- instance[key],
- );
- this.handleTelegrafInlineQuery(instance, key, metadata);
- } else if (this.metadataAccessor.isTelegrafGameQuery(instance[key])) {
- this.handleTelegrafGameQuery(instance, key);
- }
- },
- );
- });
- }
-
- handleUpdateHook(instance: object, key: string, metadata: UpdateHookOptions) {
- this.telegraf.on(metadata.updateType, instance[key].bind(instance));
- }
-
- handleTelegrafUse(instance: object, key: string) {
- this.telegraf.use(instance[key].bind(instance));
- }
-
- handleTelegrafOn(instance: object, key: string, metadata: OnOptions) {
- this.telegraf.on(metadata.updateTypes, instance[key].bind(instance));
- }
-
- handleTelegrafHears(instance: object, key: string, metadata: HearsOptions) {
- this.telegraf.hears(metadata.triggers, instance[key].bind(instance));
- }
-
- handleTelegrafCommand(
- instance: object,
- key: string,
- metadata: CommandOptions,
- ) {
- this.telegraf.command(metadata.commands, instance[key].bind(instance));
- }
-
- handleTelegrafStart(instance: object, key: string) {
- this.telegraf.start(instance[key].bind(instance));
- }
-
- handleTelegrafHelp(instance: object, key: string) {
- this.telegraf.help(instance[key].bind(instance));
- }
-
- handleTelegrafSettings(instance: object, key: string) {
- this.telegraf.settings(instance[key].bind(instance));
- }
-
- handleTelegrafEntity(instance: object, key: string, metadata: EntityOptions) {
- this.telegraf.entity(metadata.entity, instance[key].bind(instance));
- }
-
- handleTelegrafMention(
- instance: object,
- key: string,
- metadata: MentionOptions,
- ) {
- this.telegraf.mention(metadata.username, instance[key].bind(instance));
- }
-
- handleTelegrafPhone(instance: object, key: string, metadata: PhoneOptions) {
- this.telegraf.phone(metadata.phone, instance[key].bind(instance));
- }
-
- handleTelegrafHashtag(
- instance: object,
- key: string,
- metadata: HashtagOptions,
- ) {
- this.telegraf.hashtag(metadata.hashtag, instance[key].bind(instance));
- }
-
- handleTelegrafCashtag(
- instance: object,
- key: string,
- metadata: CashtagOptions,
- ) {
- this.telegraf.cashtag(metadata.cashtag, instance[key].bind(instance));
- }
-
- handleTelegrafAction(instance: object, key: string, metadata: ActionOptions) {
- this.telegraf.action(metadata.triggers, instance[key].bind(instance));
- }
-
- handleTelegrafInlineQuery(
- instance: object,
- key: string,
- metadata: InlineQueryOptions,
- ) {
- if (metadata.triggers) {
- this.telegraf.inlineQuery(
- metadata.triggers,
- instance[key].bind(instance),
- );
- } else {
- this.telegraf.on(metadata.updateType, instance[key].bind(instance));
}
}
-
- handleTelegrafGameQuery(instance: object, key: string) {
- this.telegraf.gameQuery(instance[key].bind(instance));
- }
}
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index f46c261..e2b5e52 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -1,13 +1,22 @@
-import { Context, Composer } from 'telegraf';
+import { Composer, Telegraf } from 'telegraf';
+import { Context } from './interfaces';
export type TelegrafActionTriggers = Parameters['action']>[0];
export type TelegrafHearsTriggers = Parameters['hears']>[0];
export type TelegrafInlineQueryTriggers = Parameters<
Composer['inlineQuery']
>[0];
+export type TelegrafEmail = Parameters['email']>[0];
+export type TelegrafUrl = Parameters['url']>[0];
+export type TelegrafTextLink = Parameters['textLink']>[0];
+export type TelegrafTextMention = Parameters<
+ Composer['textMention']
+>[0];
export type TelegrafCashtag = Parameters['cashtag']>[0];
export type TelegrafHashtag = Parameters['hashtag']>[0];
export type TelegrafCommand = Parameters['command']>[0];
export type TelegrafMention = Parameters['mention']>[0];
export type TelegrafPhone = Parameters['phone']>[0];
export type TelegrafUpdateType = Parameters['on']>[0];
+export type TelegrafOption = ConstructorParameters[1];
+export type TelegrafLaunchOption = Parameters[0];
From c85460dc10191ccbfe230c915af89a4b25ff49b2 Mon Sep 17 00:00:00 2001
From: unknown
Date: Fri, 25 Dec 2020 23:57:17 +0300
Subject: [PATCH 14/33] feat(wip): upgrade types
---
lib/telegraf.types.ts | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index e2b5e52..9b50ff3 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -1,22 +1,26 @@
+import { Type } from '@nestjs/common/interfaces/type.interface';
import { Composer, Telegraf } from 'telegraf';
import { Context } from './interfaces';
-export type TelegrafActionTriggers = Parameters['action']>[0];
-export type TelegrafHearsTriggers = Parameters['hears']>[0];
-export type TelegrafInlineQueryTriggers = Parameters<
- Composer['inlineQuery']
+type CtxComposer = Composer;
+
+type ComposerMethodFirstArg = Parameters<
+ CtxComposer[T]
>[0];
-export type TelegrafEmail = Parameters['email']>[0];
-export type TelegrafUrl = Parameters['url']>[0];
-export type TelegrafTextLink = Parameters['textLink']>[0];
-export type TelegrafTextMention = Parameters<
- Composer['textMention']
->[0];
-export type TelegrafCashtag = Parameters['cashtag']>[0];
-export type TelegrafHashtag = Parameters['hashtag']>[0];
-export type TelegrafCommand = Parameters['command']>[0];
-export type TelegrafMention = Parameters['mention']>[0];
-export type TelegrafPhone = Parameters['phone']>[0];
-export type TelegrafUpdateType = Parameters['on']>[0];
-export type TelegrafOption = ConstructorParameters[1];
+
+export type TelegrafActionTriggers = ComposerMethodFirstArg<'action'>;
+export type TelegrafHearsTriggers = ComposerMethodFirstArg<'hears'>;
+export type TelegrafInlineQueryTriggers = ComposerMethodFirstArg<'inlineQuery'>;
+export type TelegrafEmail = ComposerMethodFirstArg<'email'>;
+export type TelegrafUrl = ComposerMethodFirstArg<'url'>;
+export type TelegrafTextLink = ComposerMethodFirstArg<'textLink'>;
+export type TelegrafTextMention = ComposerMethodFirstArg<'textMention'>;
+export type TelegrafCashtag = ComposerMethodFirstArg<'cashtag'>;
+export type TelegrafHashtag = ComposerMethodFirstArg<'hashtag'>;
+export type TelegrafCommand = ComposerMethodFirstArg<'command'>;
+export type TelegrafMention = ComposerMethodFirstArg<'mention'>;
+export type TelegrafPhone = ComposerMethodFirstArg<'phone'>;
+export type TelegrafUpdateType = ComposerMethodFirstArg<'on'>;
+
+export type TelegrafOption = ConstructorParameters>>[1];
export type TelegrafLaunchOption = Parameters[0];
From 80853be80c8cc18cbe23b19f550e8104839a9762 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 14:54:10 +0300
Subject: [PATCH 15/33] refactor(wip): remove core module & change tokens
---
lib/decorators/core/on.decorator.ts | 8 +-
lib/decorators/core/update.decorator.ts | 5 +-
lib/decorators/core/use.decorator.ts | 4 +-
lib/decorators/inject-bot.decorator.ts | 4 +-
lib/decorators/listeners/action.decorator.ts | 8 +-
lib/decorators/listeners/cashtag.decorator.ts | 8 +-
lib/decorators/listeners/command.decorator.ts | 8 +-
lib/decorators/listeners/email.decorator.ts | 8 +-
.../listeners/game-query.decorator.ts | 4 +-
lib/decorators/listeners/hashtag.decorator.ts | 8 +-
lib/decorators/listeners/hears.decorator.ts | 8 +-
lib/decorators/listeners/help.decorator.ts | 4 +-
.../listeners/inline-query.decorator.ts | 8 +-
lib/decorators/listeners/mention.decorator.ts | 8 +-
lib/decorators/listeners/phone.decorator.ts | 8 +-
.../listeners/settings.decorator.ts | 4 +-
lib/decorators/listeners/start.decorator.ts | 4 +-
.../listeners/text-link.decorator.ts | 8 +-
.../listeners/text-mention.decorator.ts | 8 +-
lib/decorators/listeners/url.decorator.ts | 8 +-
lib/index.ts | 8 --
lib/telegraf-core.module.ts | 91 -------------------
lib/telegraf-metadata.accessor.ts | 14 ++-
lib/telegraf.constants.ts | 7 +-
lib/telegraf.explorer.ts | 16 ++--
lib/telegraf.module.ts | 71 +++++++++++++--
26 files changed, 155 insertions(+), 185 deletions(-)
delete mode 100644 lib/telegraf-core.module.ts
diff --git a/lib/decorators/core/on.decorator.ts b/lib/decorators/core/on.decorator.ts
index 37b25a4..3bef944 100644
--- a/lib/decorators/core/on.decorator.ts
+++ b/lib/decorators/core/on.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUpdateType } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface OnOptions {
*/
export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.On),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.On),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
updateTypes,
} as OnOptions),
);
diff --git a/lib/decorators/core/update.decorator.ts b/lib/decorators/core/update.decorator.ts
index a2ea7f2..fde0d76 100644
--- a/lib/decorators/core/update.decorator.ts
+++ b/lib/decorators/core/update.decorator.ts
@@ -1,8 +1,9 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_UPDATE } from '../../telegraf.constants';
+import { TELEGRAF_UPDATE_METADATA } from '../../telegraf.constants';
/**
* `@Update` decorator, it's like NestJS `@Controller` decorator,
* but for Telegram Bot API updates.
*/
-export const Update = (): ClassDecorator => SetMetadata(TELEGRAF_UPDATE, true);
+export const Update = (): ClassDecorator =>
+ SetMetadata(TELEGRAF_UPDATE_METADATA, true);
diff --git a/lib/decorators/core/use.decorator.ts b/lib/decorators/core/use.decorator.ts
index c2e911e..72fc62e 100644
--- a/lib/decorators/core/use.decorator.ts
+++ b/lib/decorators/core/use.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=use
*/
export const Use = (): MethodDecorator => {
- return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Use);
+ return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Use);
};
diff --git a/lib/decorators/inject-bot.decorator.ts b/lib/decorators/inject-bot.decorator.ts
index 84f1c50..76ef284 100644
--- a/lib/decorators/inject-bot.decorator.ts
+++ b/lib/decorators/inject-bot.decorator.ts
@@ -1,4 +1,4 @@
import { Inject } from '@nestjs/common';
-import { TELEGRAF_PROVIDER } from '../telegraf.constants';
+import { TelegrafProvider } from '../telegraf.provider';
-export const InjectBot = (): ParameterDecorator => Inject(TELEGRAF_PROVIDER);
+export const InjectBot = (): ParameterDecorator => Inject(TelegrafProvider);
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
index 1933405..502b1b0 100644
--- a/lib/decorators/listeners/action.decorator.ts
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafActionTriggers } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface ActionOptions {
*/
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Action),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Action),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as ActionOptions),
);
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
index 692bdf0..d9784cf 100644
--- a/lib/decorators/listeners/cashtag.decorator.ts
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafCashtag } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface CashtagOptions {
*/
export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Cashtag),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Cashtag),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
cashtag,
} as CashtagOptions),
);
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index 683b405..eb4b01e 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafCommand } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface CommandOptions {
*/
export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Command),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Command),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
command: command,
} as CommandOptions),
);
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
index a0b0b91..9f890fe 100644
--- a/lib/decorators/listeners/email.decorator.ts
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafEmail } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface EmailOptions {
*/
export const Email = (email: TelegrafEmail): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Email),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Email),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
email,
} as EmailOptions),
);
diff --git a/lib/decorators/listeners/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
index 9bb173d..25e0410 100644
--- a/lib/decorators/listeners/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=inlinequery
*/
export const GameQuery = (): MethodDecorator => {
- return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.GameQuery);
+ return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.GameQuery);
};
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
index 5447cfa..4c86618 100644
--- a/lib/decorators/listeners/hashtag.decorator.ts
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHashtag } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HashtagOptions {
*/
export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hashtag),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hashtag),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
hashtag,
} as HashtagOptions),
);
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index f3c6986..cef3453 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHearsTriggers } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HearsOptions {
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hears),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hears),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as HearsOptions),
);
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
index ea16432..2fec408 100644
--- a/lib/decorators/listeners/help.decorator.ts
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=help
*/
export const Help = (): MethodDecorator => {
- return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Help);
+ return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Help);
};
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
index 2299f6b..70da417 100644
--- a/lib/decorators/listeners/inline-query.decorator.ts
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
@@ -19,8 +19,8 @@ export const InlineQuery = (
triggers: TelegrafInlineQueryTriggers,
): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.InlineQuery),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.InlineQuery),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as InlineQueryOptions),
);
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
index d9de1d7..a703a23 100644
--- a/lib/decorators/listeners/mention.decorator.ts
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface MentionOptions {
*/
export const Mention = (mention: TelegrafMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Mention),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Mention),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
mention,
} as MentionOptions),
);
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
index d5f956b..b0b794b 100644
--- a/lib/decorators/listeners/phone.decorator.ts
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafPhone } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface PhoneOptions {
*/
export const Phone = (phone: TelegrafPhone): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Phone),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Phone),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
phone,
} as PhoneOptions),
);
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
index 2087c93..6bbb86b 100644
--- a/lib/decorators/listeners/settings.decorator.ts
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=settings
*/
export const Settings = (): MethodDecorator => {
- return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Settings);
+ return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Settings);
};
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
index 9031bda..b6d3025 100644
--- a/lib/decorators/listeners/start.decorator.ts
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
+import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=start
*/
export const Start = (): MethodDecorator => {
- return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Start);
+ return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Start);
};
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
index f6a484e..7dedd6f 100644
--- a/lib/decorators/listeners/text-link.decorator.ts
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextLink } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextLinkOptions {
*/
export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextLink),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextLink),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
link,
} as TextLinkOptions),
);
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
index aea29ce..b098c4e 100644
--- a/lib/decorators/listeners/text-mention.decorator.ts
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextMentionOptions {
*/
export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextMention),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextMention),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
mention,
} as TextMentionOptions),
);
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
index e8c1448..e38167e 100644
--- a/lib/decorators/listeners/url.decorator.ts
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- TELEGRAF_LISTENER_OPTIONS,
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_OPTIONS_METADATA,
+ LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUrl } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface UrlOptions {
*/
export const Url = (url: TelegrafUrl): MethodDecorator => {
return applyDecorators(
- SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Url),
- SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
+ SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Url),
+ SetMetadata(LISTENER_OPTIONS_METADATA, {
url,
} as UrlOptions),
);
diff --git a/lib/index.ts b/lib/index.ts
index 39b657d..bca10ec 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,11 +1,3 @@
-export * as Composer from 'telegraf/composer';
-export * as Markup from 'telegraf/markup';
-export * as BaseScene from 'telegraf/scenes/base';
-export * as session from 'telegraf/session';
-export * as Stage from 'telegraf/stage';
-export * as WizardScene from 'telegraf/scenes/wizard';
-export * as Extra from 'telegraf/extra';
-
export * from './decorators';
export * from './interfaces';
export * from './telegraf.module';
diff --git a/lib/telegraf-core.module.ts b/lib/telegraf-core.module.ts
deleted file mode 100644
index 9be69ed..0000000
--- a/lib/telegraf-core.module.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import { DiscoveryModule } from '@nestjs/core';
-import { Module, DynamicModule, Provider, Type } from '@nestjs/common';
-import {
- TelegrafModuleOptions,
- TelegrafModuleAsyncOptions,
- TelegrafOptionsFactory,
-} from './interfaces';
-import {
- TELEGRAF_MODULE_OPTIONS,
- TELEGRAF_PROVIDER,
-} from './telegraf.constants';
-import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
-import { TelegrafExplorer } from './telegraf.explorer';
-import { TelegrafProvider } from './telegraf.provider';
-
-@Module({
- imports: [DiscoveryModule],
- providers: [TelegrafMetadataAccessor, TelegrafExplorer],
-})
-export class TelegrafCoreModule {
- public static forRoot(options: TelegrafModuleOptions): DynamicModule {
- const telegrafProvider = {
- provide: TELEGRAF_PROVIDER,
- useClass: TelegrafProvider,
- inject: [TELEGRAF_MODULE_OPTIONS],
- };
- return {
- module: TelegrafCoreModule,
- providers: [
- { provide: TELEGRAF_MODULE_OPTIONS, useValue: options },
- telegrafProvider,
- ],
- exports: [telegrafProvider],
- };
- }
-
- public static forRootAsync(
- options: TelegrafModuleAsyncOptions,
- ): DynamicModule {
- const telegrafProvider = {
- provide: TELEGRAF_PROVIDER,
- useClass: TelegrafProvider,
- inject: [TELEGRAF_MODULE_OPTIONS],
- };
- const asyncProviders = this.createAsyncProviders(options);
- return {
- module: TelegrafCoreModule,
- imports: options.imports,
- providers: [...asyncProviders, telegrafProvider],
- exports: [telegrafProvider],
- };
- }
-
- private static createAsyncProviders(
- options: TelegrafModuleAsyncOptions,
- ): Provider[] {
- if (options.useExisting || options.useFactory) {
- return [this.createAsyncOptionsProvider(options)];
- }
- const useClass = options.useClass as Type;
- return [
- this.createAsyncOptionsProvider(options),
- {
- provide: useClass,
- useClass,
- },
- ];
- }
-
- private static createAsyncOptionsProvider(
- options: TelegrafModuleAsyncOptions,
- ): Provider {
- if (options.useFactory) {
- return {
- provide: TELEGRAF_MODULE_OPTIONS,
- useFactory: options.useFactory,
- inject: options.inject || [],
- };
- }
- // `as Type` is a workaround for microsoft/TypeScript#31603
- const inject = [
- (options.useClass || options.useExisting) as Type,
- ];
- return {
- provide: TELEGRAF_MODULE_OPTIONS,
- useFactory: async (optionsFactory: TelegrafOptionsFactory) =>
- await optionsFactory.createTelegrafOptions(),
- inject,
- };
- }
-}
diff --git a/lib/telegraf-metadata.accessor.ts b/lib/telegraf-metadata.accessor.ts
index 504db39..f61bb3a 100644
--- a/lib/telegraf-metadata.accessor.ts
+++ b/lib/telegraf-metadata.accessor.ts
@@ -1,17 +1,25 @@
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
- TELEGRAF_LISTENER_TYPE,
+ LISTENER_TYPE_METADATA,
TELEGRAF_MODULE_OPTIONS,
+ TELEGRAF_UPDATE_METADATA,
} from './telegraf.constants';
-import { ListenerType } from './enums/listener-type.enum';
+import { ListenerType } from './enums';
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
+ isUpdate(target: Function): boolean {
+ return !!this.reflector.get(
+ TELEGRAF_UPDATE_METADATA,
+ target,
+ );
+ }
+
getListenerType(target: Function): ListenerType | undefined {
- return this.reflector.get(TELEGRAF_LISTENER_TYPE, target);
+ return this.reflector.get(LISTENER_TYPE_METADATA, target);
}
getListenerOptions(target: Function): unknown | undefined {
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 88b4194..16fa981 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,6 +1,5 @@
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
-export const TELEGRAF_PROVIDER = 'TelegrafProvider';
-export const TELEGRAF_UPDATE = 'TELEGRAF_UPDATE';
-export const TELEGRAF_LISTENER_TYPE = 'TELEGRAF_LISTENER_TYPE';
-export const TELEGRAF_LISTENER_OPTIONS = 'TELEGRAF_LISTENER_OPTIONS';
+export const TELEGRAF_UPDATE_METADATA = 'TELEGRAF_UPDATE_METADATA';
+export const LISTENER_TYPE_METADATA = 'LISTENER_TYPE_METADATA';
+export const LISTENER_OPTIONS_METADATA = 'LISTENER_OPTIONS_METADATA';
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index da3a6b6..fa805b9 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -3,8 +3,7 @@ import { DiscoveryService, ModuleRef } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
import { TelegrafProvider } from './telegraf.provider';
-import { TELEGRAF_PROVIDER } from './telegraf.constants';
-import { ListenerType } from './enums/listener-type.enum';
+import { ListenerType } from './enums';
import {
ActionOptions,
CashtagOptions,
@@ -33,7 +32,7 @@ export class TelegrafExplorer implements OnModuleInit {
private telegraf: TelegrafProvider;
onModuleInit(): void {
- this.telegraf = this.moduleRef.get(TELEGRAF_PROVIDER, {
+ this.telegraf = this.moduleRef.get(TelegrafProvider, {
strict: false,
});
this.explore();
@@ -50,13 +49,18 @@ export class TelegrafExplorer implements OnModuleInit {
this.metadataScanner.scanFromPrototype(
instance,
prototype,
- (methodKey: string) => {
- this.registerIfListener(instance, methodKey);
- },
+ (methodKey: string) => this.registerIfUpdate(instance, methodKey),
);
});
}
+ private registerIfUpdate(
+ instance: Record,
+ methodKey: string,
+ ): void {
+ const isUpdate = this.metadataAccessor.isUpdate(instance);
+ }
+
private registerIfListener(
instance: Record,
methodKey: string,
diff --git a/lib/telegraf.module.ts b/lib/telegraf.module.ts
index fb3cdeb..77bf8b5 100644
--- a/lib/telegraf.module.ts
+++ b/lib/telegraf.module.ts
@@ -1,27 +1,84 @@
-import { Module, DynamicModule } from '@nestjs/common';
-import { TelegrafCoreModule } from './telegraf-core.module';
+import { DiscoveryModule } from '@nestjs/core';
+import { Module, DynamicModule, Provider } from '@nestjs/common';
import {
TelegrafModuleOptions,
TelegrafModuleAsyncOptions,
+ TelegrafOptionsFactory,
} from './interfaces';
+import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
+import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
+import { TelegrafExplorer } from './telegraf.explorer';
+import { TelegrafProvider } from './telegraf.provider';
-@Module({})
+@Module({
+ imports: [DiscoveryModule],
+ providers: [TelegrafMetadataAccessor, TelegrafExplorer],
+})
export class TelegrafModule {
public static forRoot(options: TelegrafModuleOptions): DynamicModule {
+ const providers = [...this.createProviders(options), TelegrafProvider];
+
return {
module: TelegrafModule,
- imports: [TelegrafCoreModule.forRoot(options)],
- exports: [TelegrafCoreModule],
+ providers,
+ exports: providers,
};
}
+ private static createProviders(options: TelegrafModuleOptions): Provider[] {
+ return [
+ {
+ provide: TELEGRAF_MODULE_OPTIONS,
+ useValue: options,
+ },
+ ];
+ }
+
public static forRootAsync(
options: TelegrafModuleAsyncOptions,
): DynamicModule {
+ const providers = [...this.createAsyncProviders(options), TelegrafProvider];
+
return {
module: TelegrafModule,
- imports: [TelegrafCoreModule.forRootAsync(options)],
- exports: [TelegrafCoreModule],
+ imports: options.imports || [],
+ providers,
+ exports: providers,
+ };
+ }
+
+ private static createAsyncProviders(
+ options: TelegrafModuleAsyncOptions,
+ ): Provider[] {
+ if (options.useExisting || options.useFactory) {
+ return [this.createAsyncOptionsProvider(options)];
+ }
+
+ return [
+ this.createAsyncOptionsProvider(options),
+ {
+ provide: options.useClass,
+ useClass: options.useClass,
+ },
+ ];
+ }
+
+ private static createAsyncOptionsProvider(
+ options: TelegrafModuleAsyncOptions,
+ ): Provider {
+ if (options.useFactory) {
+ return {
+ provide: TELEGRAF_MODULE_OPTIONS,
+ useFactory: options.useFactory,
+ inject: options.inject || [],
+ };
+ }
+
+ return {
+ provide: TELEGRAF_MODULE_OPTIONS,
+ useFactory: async (optionsFactory: TelegrafOptionsFactory) =>
+ await optionsFactory.createTelegrafOptions(),
+ inject: [options.useExisting || options.useClass],
};
}
}
From d02a52a7ae16a8c2843ea0a543b9233fea5bb73b Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 16:11:09 +0300
Subject: [PATCH 16/33] feat(): mvp
---
.npmignore | 1 -
index.d.ts | 1 -
index.js | 6 ---
index.ts | 1 -
lib/decorators/core/on.decorator.ts | 8 ++--
lib/decorators/core/update.decorator.ts | 5 +--
lib/decorators/core/use.decorator.ts | 4 +-
lib/decorators/listeners/action.decorator.ts | 8 ++--
lib/decorators/listeners/cashtag.decorator.ts | 8 ++--
lib/decorators/listeners/command.decorator.ts | 8 ++--
lib/decorators/listeners/email.decorator.ts | 8 ++--
.../listeners/game-query.decorator.ts | 4 +-
lib/decorators/listeners/hashtag.decorator.ts | 8 ++--
lib/decorators/listeners/hears.decorator.ts | 8 ++--
lib/decorators/listeners/help.decorator.ts | 4 +-
.../listeners/inline-query.decorator.ts | 8 ++--
lib/decorators/listeners/mention.decorator.ts | 8 ++--
lib/decorators/listeners/phone.decorator.ts | 8 ++--
.../listeners/settings.decorator.ts | 4 +-
lib/decorators/listeners/start.decorator.ts | 4 +-
.../listeners/text-link.decorator.ts | 8 ++--
.../listeners/text-mention.decorator.ts | 8 ++--
lib/decorators/listeners/url.decorator.ts | 8 ++--
lib/telegraf.constants.ts | 7 ++--
lib/telegraf.explorer.ts | 41 ++++++++++---------
...essor.ts => telegraf.metadata-accessor.ts} | 14 +++----
lib/telegraf.module.ts | 2 +-
package.json | 2 +-
tsconfig.json | 2 +-
29 files changed, 99 insertions(+), 107 deletions(-)
delete mode 100644 index.d.ts
delete mode 100644 index.js
delete mode 100644 index.ts
rename lib/{telegraf-metadata.accessor.ts => telegraf.metadata-accessor.ts} (73%)
diff --git a/.npmignore b/.npmignore
index 130fdb1..267876c 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,6 +1,5 @@
# source
lib
-index.ts
package-lock.json
tsconfig.json
.prettierrc
diff --git a/index.d.ts b/index.d.ts
deleted file mode 100644
index 5703fb5..0000000
--- a/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './dist';
diff --git a/index.js b/index.js
deleted file mode 100644
index a82ea05..0000000
--- a/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-"use strict";
-function __export(m) {
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
-}
-exports.__esModule = true;
-__export(require("./dist"));
\ No newline at end of file
diff --git a/index.ts b/index.ts
deleted file mode 100644
index 5703fb5..0000000
--- a/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './dist';
diff --git a/lib/decorators/core/on.decorator.ts b/lib/decorators/core/on.decorator.ts
index 3bef944..17b052b 100644
--- a/lib/decorators/core/on.decorator.ts
+++ b/lib/decorators/core/on.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUpdateType } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface OnOptions {
*/
export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.On),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.On),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
updateTypes,
} as OnOptions),
);
diff --git a/lib/decorators/core/update.decorator.ts b/lib/decorators/core/update.decorator.ts
index fde0d76..2002fec 100644
--- a/lib/decorators/core/update.decorator.ts
+++ b/lib/decorators/core/update.decorator.ts
@@ -1,9 +1,8 @@
import { SetMetadata } from '@nestjs/common';
-import { TELEGRAF_UPDATE_METADATA } from '../../telegraf.constants';
+import { UPDATE_METADATA } from '../../telegraf.constants';
/**
* `@Update` decorator, it's like NestJS `@Controller` decorator,
* but for Telegram Bot API updates.
*/
-export const Update = (): ClassDecorator =>
- SetMetadata(TELEGRAF_UPDATE_METADATA, true);
+export const Update = (): ClassDecorator => SetMetadata(UPDATE_METADATA, true);
diff --git a/lib/decorators/core/use.decorator.ts b/lib/decorators/core/use.decorator.ts
index 72fc62e..8b393e6 100644
--- a/lib/decorators/core/use.decorator.ts
+++ b/lib/decorators/core/use.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
+import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=use
*/
export const Use = (): MethodDecorator => {
- return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Use);
+ return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Use);
};
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
index 502b1b0..1a8a5a1 100644
--- a/lib/decorators/listeners/action.decorator.ts
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafActionTriggers } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface ActionOptions {
*/
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Action),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Action),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
triggers,
} as ActionOptions),
);
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
index d9784cf..8b4f859 100644
--- a/lib/decorators/listeners/cashtag.decorator.ts
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafCashtag } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface CashtagOptions {
*/
export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Cashtag),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Cashtag),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
cashtag,
} as CashtagOptions),
);
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index eb4b01e..15d4d36 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafCommand } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface CommandOptions {
*/
export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Command),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Command),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
command: command,
} as CommandOptions),
);
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
index 9f890fe..23aad1b 100644
--- a/lib/decorators/listeners/email.decorator.ts
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafEmail } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface EmailOptions {
*/
export const Email = (email: TelegrafEmail): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Email),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Email),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
email,
} as EmailOptions),
);
diff --git a/lib/decorators/listeners/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
index 25e0410..898b1d5 100644
--- a/lib/decorators/listeners/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
+import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=inlinequery
*/
export const GameQuery = (): MethodDecorator => {
- return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.GameQuery);
+ return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.GameQuery);
};
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
index 4c86618..4d344c6 100644
--- a/lib/decorators/listeners/hashtag.decorator.ts
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHashtag } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HashtagOptions {
*/
export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hashtag),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Hashtag),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
hashtag,
} as HashtagOptions),
);
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index cef3453..1f2f93e 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHearsTriggers } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HearsOptions {
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hears),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Hears),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
triggers,
} as HearsOptions),
);
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
index 2fec408..9909f1d 100644
--- a/lib/decorators/listeners/help.decorator.ts
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
+import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=help
*/
export const Help = (): MethodDecorator => {
- return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Help);
+ return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Help);
};
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
index 70da417..f9a4efd 100644
--- a/lib/decorators/listeners/inline-query.decorator.ts
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
@@ -19,8 +19,8 @@ export const InlineQuery = (
triggers: TelegrafInlineQueryTriggers,
): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.InlineQuery),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.InlineQuery),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
triggers,
} as InlineQueryOptions),
);
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
index a703a23..db25ff8 100644
--- a/lib/decorators/listeners/mention.decorator.ts
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface MentionOptions {
*/
export const Mention = (mention: TelegrafMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Mention),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Mention),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
mention,
} as MentionOptions),
);
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
index b0b794b..f327762 100644
--- a/lib/decorators/listeners/phone.decorator.ts
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafPhone } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface PhoneOptions {
*/
export const Phone = (phone: TelegrafPhone): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Phone),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Phone),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
phone,
} as PhoneOptions),
);
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
index 6bbb86b..8c25331 100644
--- a/lib/decorators/listeners/settings.decorator.ts
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
+import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=settings
*/
export const Settings = (): MethodDecorator => {
- return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Settings);
+ return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Settings);
};
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
index b6d3025..6de6e55 100644
--- a/lib/decorators/listeners/start.decorator.ts
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
-import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
+import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=start
*/
export const Start = (): MethodDecorator => {
- return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Start);
+ return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Start);
};
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
index 7dedd6f..cfefc96 100644
--- a/lib/decorators/listeners/text-link.decorator.ts
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextLink } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextLinkOptions {
*/
export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextLink),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.TextLink),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
link,
} as TextLinkOptions),
);
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
index b098c4e..fc8cecc 100644
--- a/lib/decorators/listeners/text-mention.decorator.ts
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextMentionOptions {
*/
export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextMention),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.TextMention),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
mention,
} as TextMentionOptions),
);
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
index e38167e..b104dd2 100644
--- a/lib/decorators/listeners/url.decorator.ts
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
- LISTENER_OPTIONS_METADATA,
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUrl } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface UrlOptions {
*/
export const Url = (url: TelegrafUrl): MethodDecorator => {
return applyDecorators(
- SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Url),
- SetMetadata(LISTENER_OPTIONS_METADATA, {
+ SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Url),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
url,
} as UrlOptions),
);
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 16fa981..6bba348 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,5 +1,6 @@
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
-export const TELEGRAF_UPDATE_METADATA = 'TELEGRAF_UPDATE_METADATA';
-export const LISTENER_TYPE_METADATA = 'LISTENER_TYPE_METADATA';
-export const LISTENER_OPTIONS_METADATA = 'LISTENER_OPTIONS_METADATA';
+export const UPDATE_METADATA = 'UPDATE_METADATA';
+export const UPDATE_LISTENER_TYPE_METADATA = 'UPDATE_LISTENER_TYPE_METADATA';
+export const UPDATE_LISTENER_OPTIONS_METADATA =
+ 'UPDATE_LISTENER_OPTIONS_METADATA';
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index fa805b9..4df95e5 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -1,7 +1,7 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { DiscoveryService, ModuleRef } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
-import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
+import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
import { TelegrafProvider } from './telegraf.provider';
import { ListenerType } from './enums';
import {
@@ -19,6 +19,7 @@ import {
TextMentionOptions,
UrlOptions,
} from './decorators';
+import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
@Injectable()
export class TelegrafExplorer implements OnModuleInit {
@@ -39,29 +40,29 @@ export class TelegrafExplorer implements OnModuleInit {
}
explore(): void {
- this.discoveryService
+ const updateInstanceWrappers = this.filterUpdateClass();
+
+ updateInstanceWrappers.forEach((wrapper) => {
+ const { instance } = wrapper;
+
+ const prototype = Object.getPrototypeOf(instance);
+ this.metadataScanner.scanFromPrototype(
+ instance,
+ prototype,
+ (methodKey: string) =>
+ this.registerIfUpdateListener(instance, methodKey),
+ );
+ });
+ }
+
+ private filterUpdateClass(): InstanceWrapper[] {
+ return this.discoveryService
.getProviders()
.filter((wrapper) => wrapper.instance)
- .forEach((wrapper) => {
- const { instance } = wrapper;
-
- const prototype = Object.getPrototypeOf(instance);
- this.metadataScanner.scanFromPrototype(
- instance,
- prototype,
- (methodKey: string) => this.registerIfUpdate(instance, methodKey),
- );
- });
+ .filter((wrapper) => this.metadataAccessor.isUpdate(wrapper.instance));
}
- private registerIfUpdate(
- instance: Record,
- methodKey: string,
- ): void {
- const isUpdate = this.metadataAccessor.isUpdate(instance);
- }
-
- private registerIfListener(
+ private registerIfUpdateListener(
instance: Record,
methodKey: string,
): void {
diff --git a/lib/telegraf-metadata.accessor.ts b/lib/telegraf.metadata-accessor.ts
similarity index 73%
rename from lib/telegraf-metadata.accessor.ts
rename to lib/telegraf.metadata-accessor.ts
index f61bb3a..29b5c68 100644
--- a/lib/telegraf-metadata.accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
- LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_TYPE_METADATA,
TELEGRAF_MODULE_OPTIONS,
- TELEGRAF_UPDATE_METADATA,
+ UPDATE_METADATA,
} from './telegraf.constants';
import { ListenerType } from './enums';
@@ -12,14 +12,14 @@ export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
isUpdate(target: Function): boolean {
- return !!this.reflector.get(
- TELEGRAF_UPDATE_METADATA,
- target,
- );
+ return !!this.reflector.get(UPDATE_METADATA, target);
}
getListenerType(target: Function): ListenerType | undefined {
- return this.reflector.get(LISTENER_TYPE_METADATA, target);
+ return this.reflector.get(
+ UPDATE_LISTENER_TYPE_METADATA,
+ target,
+ );
}
getListenerOptions(target: Function): unknown | undefined {
diff --git a/lib/telegraf.module.ts b/lib/telegraf.module.ts
index 77bf8b5..f0e82a2 100644
--- a/lib/telegraf.module.ts
+++ b/lib/telegraf.module.ts
@@ -6,7 +6,7 @@ import {
TelegrafOptionsFactory,
} from './interfaces';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
-import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
+import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
import { TelegrafExplorer } from './telegraf.explorer';
import { TelegrafProvider } from './telegraf.provider';
diff --git a/package.json b/package.json
index 16b1ffc..9756227 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "nestjs-telegraf",
- "version": "2.0.0-alpha.1",
+ "version": "2.0.0",
"description": "Telegraf module for NestJS",
"keywords": [
"nest",
diff --git a/tsconfig.json b/tsconfig.json
index bb13608..e47f6d2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -13,6 +13,6 @@
"rootDir": "./lib",
"skipLibCheck": true
},
- "include": ["lib/**/*", "../index.ts"],
+ "include": ["lib/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
From 0dc981dc9525703a164509b4c3bb14c5f61cac25 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 16:23:54 +0300
Subject: [PATCH 17/33] feat(): add sample app
---
package.json | 5 ++++-
sample/app.module.ts | 13 +++++++++++++
sample/app.update.ts | 9 +++++++++
sample/main.ts | 7 +++++++
tsconfig.json | 4 ++--
5 files changed, 35 insertions(+), 3 deletions(-)
create mode 100644 sample/app.module.ts
create mode 100644 sample/app.update.ts
create mode 100644 sample/main.ts
diff --git a/package.json b/package.json
index 9756227..d842c0e 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,8 @@
"precommit": "lint-staged",
"prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public",
- "test": ""
+ "test": "",
+ "sample-app": "ts-node --transpile-only -r tsconfig-paths/register sample/main.ts"
},
"dependencies": {
"telegraf": "https://github.com/telegraf/telegraf.git#develop"
@@ -48,6 +49,8 @@
"prettier": "2.2.1",
"reflect-metadata": "0.1.13",
"rxjs": "6.6.3",
+ "ts-node": "^9.1.1",
+ "tsconfig-paths": "^3.9.0",
"typescript": "4.1.2"
},
"peerDependencies": {
diff --git a/sample/app.module.ts b/sample/app.module.ts
new file mode 100644
index 0000000..e35a9f4
--- /dev/null
+++ b/sample/app.module.ts
@@ -0,0 +1,13 @@
+import { Module } from '@nestjs/common';
+import { TelegrafModule } from '../lib';
+import { AppUpdate } from './app.update';
+
+@Module({
+ imports: [
+ TelegrafModule.forRoot({
+ token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8',
+ }),
+ ],
+ providers: [AppUpdate],
+})
+export class AppModule {}
diff --git a/sample/app.update.ts b/sample/app.update.ts
new file mode 100644
index 0000000..a0dc748
--- /dev/null
+++ b/sample/app.update.ts
@@ -0,0 +1,9 @@
+import { On, Update } from '../lib/decorators';
+
+@Update()
+export class AppUpdate {
+ @On('message')
+ onMessage(): void {
+ console.log('New message received');
+ }
+}
diff --git a/sample/main.ts b/sample/main.ts
new file mode 100644
index 0000000..42c2fa5
--- /dev/null
+++ b/sample/main.ts
@@ -0,0 +1,7 @@
+import { NestFactory } from '@nestjs/core';
+import { AppModule } from './app.module';
+
+async function bootstrap() {
+ await NestFactory.createApplicationContext(AppModule);
+}
+bootstrap();
diff --git a/tsconfig.json b/tsconfig.json
index e47f6d2..921d963 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,10 +9,10 @@
"experimentalDecorators": true,
"target": "es6",
"sourceMap": false,
+ "baseUrl": "./",
"outDir": "./dist",
- "rootDir": "./lib",
"skipLibCheck": true
},
- "include": ["lib/**/*"],
+ "include": ["lib/**/*", "sample/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
From 66309b9415f377fecf1deedd700f3443b2b2eaf0 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 16:24:38 +0300
Subject: [PATCH 18/33] fix(): update decorator detection
---
lib/decorators/listeners/hears.decorator.ts | 2 +-
lib/telegraf.explorer.ts | 20 ++++++++------------
lib/telegraf.metadata-accessor.ts | 9 ++++++---
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index 1f2f93e..760409a 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -3,7 +3,7 @@ import {
UPDATE_LISTENER_OPTIONS_METADATA,
UPDATE_LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerType } from '../../enums';
import { TelegrafHearsTriggers } from '../../telegraf.types';
export interface HearsOptions {
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index 4df95e5..0d2751b 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -24,33 +24,27 @@ import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
@Injectable()
export class TelegrafExplorer implements OnModuleInit {
constructor(
- private readonly moduleRef: ModuleRef,
+ private readonly telegraf: TelegrafProvider,
private readonly discoveryService: DiscoveryService,
private readonly metadataAccessor: TelegrafMetadataAccessor,
private readonly metadataScanner: MetadataScanner,
) {}
- private telegraf: TelegrafProvider;
-
onModuleInit(): void {
- this.telegraf = this.moduleRef.get(TelegrafProvider, {
- strict: false,
- });
this.explore();
}
explore(): void {
- const updateInstanceWrappers = this.filterUpdateClass();
+ const updateClasses = this.filterUpdateClass();
- updateInstanceWrappers.forEach((wrapper) => {
+ updateClasses.forEach((wrapper) => {
const { instance } = wrapper;
const prototype = Object.getPrototypeOf(instance);
this.metadataScanner.scanFromPrototype(
instance,
prototype,
- (methodKey: string) =>
- this.registerIfUpdateListener(instance, methodKey),
+ (methodKey: string) => this.registerIfListener(instance, methodKey),
);
});
}
@@ -59,10 +53,12 @@ export class TelegrafExplorer implements OnModuleInit {
return this.discoveryService
.getProviders()
.filter((wrapper) => wrapper.instance)
- .filter((wrapper) => this.metadataAccessor.isUpdate(wrapper.instance));
+ .filter((wrapper) =>
+ this.metadataAccessor.isUpdate(wrapper.instance.constructor),
+ );
}
- private registerIfUpdateListener(
+ private registerIfListener(
instance: Record,
methodKey: string,
): void {
diff --git a/lib/telegraf.metadata-accessor.ts b/lib/telegraf.metadata-accessor.ts
index 29b5c68..e79e9e1 100644
--- a/lib/telegraf.metadata-accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
UPDATE_LISTENER_TYPE_METADATA,
- TELEGRAF_MODULE_OPTIONS,
UPDATE_METADATA,
+ UPDATE_LISTENER_OPTIONS_METADATA,
} from './telegraf.constants';
import { ListenerType } from './enums';
@@ -22,7 +22,10 @@ export class TelegrafMetadataAccessor {
);
}
- getListenerOptions(target: Function): unknown | undefined {
- return this.reflector.get(TELEGRAF_MODULE_OPTIONS, target);
+ getListenerOptions(target: Function): unknown | undefined {
+ return this.reflector.get(
+ UPDATE_LISTENER_OPTIONS_METADATA,
+ target,
+ );
}
}
From 1ecc43f2a9c9032a83dd254875755d2d8e595d02 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 16:29:43 +0300
Subject: [PATCH 19/33] refactor(): remove unused decorator
---
lib/middleware/decorators/middleware.decorator.ts | 4 ----
1 file changed, 4 deletions(-)
delete mode 100644 lib/middleware/decorators/middleware.decorator.ts
diff --git a/lib/middleware/decorators/middleware.decorator.ts b/lib/middleware/decorators/middleware.decorator.ts
deleted file mode 100644
index 29541ec..0000000
--- a/lib/middleware/decorators/middleware.decorator.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-
-export const Middleware = (): ClassDecorator =>
- SetMetadata('TELEGRAF_MIDDLEWARE', true);
From f10df2e96057cb61e5009cdc8a3ccf1bd1cabadf Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 16:48:04 +0300
Subject: [PATCH 20/33] feat(sample): make echo bot
---
sample/app.module.ts | 3 ++-
sample/app.update.ts | 32 ++++++++++++++++++++++++++++++--
sample/echo.service.ts | 8 ++++++++
3 files changed, 40 insertions(+), 3 deletions(-)
create mode 100644 sample/echo.service.ts
diff --git a/sample/app.module.ts b/sample/app.module.ts
index e35a9f4..19b71ac 100644
--- a/sample/app.module.ts
+++ b/sample/app.module.ts
@@ -1,5 +1,6 @@
import { Module } from '@nestjs/common';
import { TelegrafModule } from '../lib';
+import { EchoService } from './echo.service';
import { AppUpdate } from './app.update';
@Module({
@@ -8,6 +9,6 @@ import { AppUpdate } from './app.update';
token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8',
}),
],
- providers: [AppUpdate],
+ providers: [EchoService, AppUpdate],
})
export class AppModule {}
diff --git a/sample/app.update.ts b/sample/app.update.ts
index a0dc748..dab2a76 100644
--- a/sample/app.update.ts
+++ b/sample/app.update.ts
@@ -1,9 +1,37 @@
-import { On, Update } from '../lib/decorators';
+import { Telegraf } from 'telegraf';
+import { Help, InjectBot, On, Start, Update } from '../lib/decorators';
+import { Context } from '../lib/interfaces';
+import { EchoService } from './echo.service';
@Update()
export class AppUpdate {
+ constructor(
+ @InjectBot()
+ private readonly bot: Telegraf,
+ private readonly echoService: EchoService,
+ ) {}
+
+ @Start()
+ async onStart(ctx: Context): Promise {
+ const me = await this.bot.telegram.getMe();
+ await ctx.reply(`Hey, I'm ${me.first_name}`);
+ }
+
+ @Help()
+ async onHelp(ctx: Context): Promise {
+ await ctx.reply('Send me any text');
+ }
+
@On('message')
- onMessage(): void {
+ async onMessage(ctx: Context): Promise {
console.log('New message received');
+
+ if ('text' in ctx.message) {
+ const messageText = ctx.message.text;
+ const echoText = this.echoService.echo(messageText);
+ await ctx.reply(echoText);
+ } else {
+ await ctx.reply('Only text messages');
+ }
}
}
diff --git a/sample/echo.service.ts b/sample/echo.service.ts
new file mode 100644
index 0000000..2603cc2
--- /dev/null
+++ b/sample/echo.service.ts
@@ -0,0 +1,8 @@
+import { Injectable } from '@nestjs/common';
+
+@Injectable()
+export class EchoService {
+ echo(text: string): string {
+ return `Echo: ${text}`;
+ }
+}
From 36f67ce29d5f5ae20f2bede9dbc9dd1fe949bd50 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sat, 26 Dec 2020 23:19:30 +0300
Subject: [PATCH 21/33] refactor(): reply switch with dynamic telegraf method
call
---
lib/decorators/core/index.ts | 3 +-
.../{ => core}/inject-bot.decorator.ts | 2 +-
lib/decorators/core/use.decorator.ts | 12 --
lib/decorators/index.ts | 1 -
lib/decorators/listeners/action.decorator.ts | 14 +--
lib/decorators/listeners/cashtag.decorator.ts | 14 +--
lib/decorators/listeners/command.decorator.ts | 14 +--
lib/decorators/listeners/email.decorator.ts | 14 +--
.../listeners/game-query.decorator.ts | 6 +-
lib/decorators/listeners/hashtag.decorator.ts | 14 +--
lib/decorators/listeners/hears.decorator.ts | 14 +--
lib/decorators/listeners/help.decorator.ts | 6 +-
lib/decorators/listeners/index.ts | 2 +
.../listeners/inline-query.decorator.ts | 14 +--
lib/decorators/listeners/mention.decorator.ts | 14 +--
.../{core => listeners}/on.decorator.ts | 14 +--
lib/decorators/listeners/phone.decorator.ts | 14 +--
.../listeners/settings.decorator.ts | 6 +-
lib/decorators/listeners/start.decorator.ts | 6 +-
.../listeners/text-link.decorator.ts | 16 +--
.../listeners/text-mention.decorator.ts | 16 +--
lib/decorators/listeners/url.decorator.ts | 14 +--
lib/decorators/listeners/use.decorator.ts | 12 ++
lib/enums/index.ts | 2 +-
...-type.enum.ts => listener-menthod.enum.ts} | 2 +-
lib/enums/update-paramtypes.enum.ts | 5 +
lib/telegraf.constants.ts | 4 +-
lib/telegraf.explorer.ts | 115 ++----------------
lib/telegraf.metadata-accessor.ts | 20 ++-
29 files changed, 106 insertions(+), 284 deletions(-)
rename lib/decorators/{ => core}/inject-bot.decorator.ts (66%)
delete mode 100644 lib/decorators/core/use.decorator.ts
rename lib/decorators/{core => listeners}/on.decorator.ts (56%)
create mode 100644 lib/decorators/listeners/use.decorator.ts
rename lib/enums/{listener-type.enum.ts => listener-menthod.enum.ts} (93%)
create mode 100644 lib/enums/update-paramtypes.enum.ts
diff --git a/lib/decorators/core/index.ts b/lib/decorators/core/index.ts
index c7875e3..7d609ad 100644
--- a/lib/decorators/core/index.ts
+++ b/lib/decorators/core/index.ts
@@ -1,3 +1,2 @@
-export * from './on.decorator';
export * from './update.decorator';
-export * from './use.decorator';
+export * from './inject-bot.decorator';
diff --git a/lib/decorators/inject-bot.decorator.ts b/lib/decorators/core/inject-bot.decorator.ts
similarity index 66%
rename from lib/decorators/inject-bot.decorator.ts
rename to lib/decorators/core/inject-bot.decorator.ts
index 76ef284..f697bd7 100644
--- a/lib/decorators/inject-bot.decorator.ts
+++ b/lib/decorators/core/inject-bot.decorator.ts
@@ -1,4 +1,4 @@
import { Inject } from '@nestjs/common';
-import { TelegrafProvider } from '../telegraf.provider';
+import { TelegrafProvider } from '../../telegraf.provider';
export const InjectBot = (): ParameterDecorator => Inject(TelegrafProvider);
diff --git a/lib/decorators/core/use.decorator.ts b/lib/decorators/core/use.decorator.ts
deleted file mode 100644
index 8b393e6..0000000
--- a/lib/decorators/core/use.decorator.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
-
-/**
- * Registers a middleware.
- *
- * @see https://telegraf.js.org/#/?id=use
- */
-export const Use = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Use);
-};
diff --git a/lib/decorators/index.ts b/lib/decorators/index.ts
index dd680b1..f6f8104 100644
--- a/lib/decorators/index.ts
+++ b/lib/decorators/index.ts
@@ -1,3 +1,2 @@
-export * from './inject-bot.decorator';
export * from './core';
export * from './listeners';
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
index 1a8a5a1..4fae6e7 100644
--- a/lib/decorators/listeners/action.decorator.ts
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -1,14 +1,10 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
import { TelegrafActionTriggers } from '../../telegraf.types';
-import { ListenerType } from '../../enums/listener-type.enum';
-
-export interface ActionOptions {
- triggers: TelegrafActionTriggers;
-}
/**
* Registers middleware for handling callback_data actions with regular expressions.
@@ -17,9 +13,7 @@ export interface ActionOptions {
*/
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Action),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- triggers,
- } as ActionOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Action),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
);
};
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
index 8b4f859..a43dbcc 100644
--- a/lib/decorators/listeners/cashtag.decorator.ts
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -1,14 +1,10 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
import { TelegrafCashtag } from '../../telegraf.types';
-import { ListenerType } from '../../enums/listener-type.enum';
-
-export interface CashtagOptions {
- cashtag: TelegrafCashtag;
-}
/**
* Cashtag handling.
@@ -17,9 +13,7 @@ export interface CashtagOptions {
*/
export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Cashtag),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- cashtag,
- } as CashtagOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Cashtag),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [cashtag]),
);
};
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index 15d4d36..6c668d6 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafCommand } from '../../telegraf.types';
-export interface CommandOptions {
- command: TelegrafCommand;
-}
-
/**
* Command handling.
*
@@ -17,9 +13,7 @@ export interface CommandOptions {
*/
export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Command),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- command: command,
- } as CommandOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Command),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [command]),
);
};
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
index 23aad1b..5658bdb 100644
--- a/lib/decorators/listeners/email.decorator.ts
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafEmail } from '../../telegraf.types';
-export interface EmailOptions {
- email: TelegrafEmail;
-}
-
/**
* Registers middleware for handling messages with email entity.
*
@@ -17,9 +13,7 @@ export interface EmailOptions {
*/
export const Email = (email: TelegrafEmail): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Email),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- email,
- } as EmailOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Email),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [email]),
);
};
diff --git a/lib/decorators/listeners/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
index 898b1d5..525791c 100644
--- a/lib/decorators/listeners/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,6 +1,6 @@
import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
/**
* Registers middleware for handling callback_data actions with game query.
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=inlinequery
*/
export const GameQuery = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.GameQuery);
+ return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.GameQuery);
};
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
index 4d344c6..012e723 100644
--- a/lib/decorators/listeners/hashtag.decorator.ts
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafHashtag } from '../../telegraf.types';
-export interface HashtagOptions {
- hashtag: TelegrafHashtag;
-}
-
/**
* Hashtag handling.
*
@@ -17,9 +13,7 @@ export interface HashtagOptions {
*/
export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Hashtag),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- hashtag,
- } as HashtagOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Hashtag),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [hashtag]),
);
};
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index 760409a..8c2bfd2 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums';
+import { ListenerMethod } from '../../enums';
import { TelegrafHearsTriggers } from '../../telegraf.types';
-export interface HearsOptions {
- triggers: TelegrafHearsTriggers;
-}
-
/**
* Registers middleware for handling text messages.
*
@@ -17,9 +13,7 @@ export interface HearsOptions {
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Hears),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- triggers,
- } as HearsOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Hears),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
);
};
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
index 9909f1d..c7a17fb 100644
--- a/lib/decorators/listeners/help.decorator.ts
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -1,6 +1,6 @@
import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
/**
* Handler for /help command.
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=help
*/
export const Help = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Help);
+ return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Help);
};
diff --git a/lib/decorators/listeners/index.ts b/lib/decorators/listeners/index.ts
index 2108a90..a332f5a 100644
--- a/lib/decorators/listeners/index.ts
+++ b/lib/decorators/listeners/index.ts
@@ -1,3 +1,5 @@
+export * from './on.decorator';
+export * from './use.decorator';
export * from './action.decorator';
export * from './cashtag.decorator';
export * from './command.decorator';
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
index f9a4efd..641af40 100644
--- a/lib/decorators/listeners/inline-query.decorator.ts
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
-export interface InlineQueryOptions {
- triggers: TelegrafInlineQueryTriggers;
-}
-
/**
* Registers middleware for handling inline_query actions with regular expressions.
*
@@ -19,9 +15,7 @@ export const InlineQuery = (
triggers: TelegrafInlineQueryTriggers,
): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.InlineQuery),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- triggers,
- } as InlineQueryOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.InlineQuery),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
);
};
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
index db25ff8..9eaeaee 100644
--- a/lib/decorators/listeners/mention.decorator.ts
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafMention } from '../../telegraf.types';
-export interface MentionOptions {
- mention: TelegrafMention;
-}
-
/**
* Mention handling.
*
@@ -17,9 +13,7 @@ export interface MentionOptions {
*/
export const Mention = (mention: TelegrafMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Mention),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- mention,
- } as MentionOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Mention),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [mention]),
);
};
diff --git a/lib/decorators/core/on.decorator.ts b/lib/decorators/listeners/on.decorator.ts
similarity index 56%
rename from lib/decorators/core/on.decorator.ts
rename to lib/decorators/listeners/on.decorator.ts
index 17b052b..c467e51 100644
--- a/lib/decorators/core/on.decorator.ts
+++ b/lib/decorators/listeners/on.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafUpdateType } from '../../telegraf.types';
-export interface OnOptions {
- updateTypes: TelegrafUpdateType;
-}
-
/**
* Registers middleware for provided update type.
*
@@ -17,9 +13,7 @@ export interface OnOptions {
*/
export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.On),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- updateTypes,
- } as OnOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.On),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [updateTypes]),
);
};
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
index f327762..b217804 100644
--- a/lib/decorators/listeners/phone.decorator.ts
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafPhone } from '../../telegraf.types';
-export interface PhoneOptions {
- phone: TelegrafPhone;
-}
-
/**
* Phone number handling.
*
@@ -17,9 +13,7 @@ export interface PhoneOptions {
*/
export const Phone = (phone: TelegrafPhone): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Phone),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- phone,
- } as PhoneOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Phone),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [phone]),
);
};
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
index 8c25331..d53048c 100644
--- a/lib/decorators/listeners/settings.decorator.ts
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -1,6 +1,6 @@
import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
/**
* Handler for /settings command.
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=settings
*/
export const Settings = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Settings);
+ return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Settings);
};
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
index 6de6e55..ec13aa0 100644
--- a/lib/decorators/listeners/start.decorator.ts
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -1,6 +1,6 @@
import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_TYPE_METADATA } from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
/**
* Handler for /start command.
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=start
*/
export const Start = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Start);
+ return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Start);
};
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
index cfefc96..9f7fa44 100644
--- a/lib/decorators/listeners/text-link.decorator.ts
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -1,25 +1,19 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafTextLink } from '../../telegraf.types';
-export interface TextLinkOptions {
- link: TelegrafTextLink;
-}
-
/**
* Registers middleware for handling messages with text_link entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
+export const TextLink = (link: TelegrafTextLink): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.TextLink),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- link,
- } as TextLinkOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.TextLink),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [link]),
);
};
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
index fc8cecc..0791ab6 100644
--- a/lib/decorators/listeners/text-mention.decorator.ts
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -1,25 +1,19 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafTextMention } from '../../telegraf.types';
-export interface TextMentionOptions {
- mention: TelegrafTextMention;
-}
-
/**
* Registers middleware for handling messages with text_mention entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
+export const TextMention = (mention: TelegrafTextMention): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.TextMention),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- mention,
- } as TextMentionOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.TextMention),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [mention]),
);
};
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
index b104dd2..04f9704 100644
--- a/lib/decorators/listeners/url.decorator.ts
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -1,15 +1,11 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
} from '../../telegraf.constants';
-import { ListenerType } from '../../enums/listener-type.enum';
+import { ListenerMethod } from '../../enums';
import { TelegrafUrl } from '../../telegraf.types';
-export interface UrlOptions {
- url: TelegrafUrl;
-}
-
/**
* Registers middleware for handling messages with url entity.
*
@@ -17,9 +13,7 @@ export interface UrlOptions {
*/
export const Url = (url: TelegrafUrl): MethodDecorator => {
return applyDecorators(
- SetMetadata(UPDATE_LISTENER_TYPE_METADATA, ListenerType.Url),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, {
- url,
- } as UrlOptions),
+ SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Url),
+ SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [url]),
);
};
diff --git a/lib/decorators/listeners/use.decorator.ts b/lib/decorators/listeners/use.decorator.ts
new file mode 100644
index 0000000..84c7d2c
--- /dev/null
+++ b/lib/decorators/listeners/use.decorator.ts
@@ -0,0 +1,12 @@
+import { SetMetadata } from '@nestjs/common';
+import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
+import { ListenerMethod } from '../../enums';
+
+/**
+ * Registers a middleware.
+ *
+ * @see https://telegraf.js.org/#/?id=use
+ */
+export const Use = (): MethodDecorator => {
+ return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Use);
+};
diff --git a/lib/enums/index.ts b/lib/enums/index.ts
index 1f890a3..5f145a0 100644
--- a/lib/enums/index.ts
+++ b/lib/enums/index.ts
@@ -1 +1 @@
-export * from './listener-type.enum';
+export * from './listener-menthod.enum';
diff --git a/lib/enums/listener-type.enum.ts b/lib/enums/listener-menthod.enum.ts
similarity index 93%
rename from lib/enums/listener-type.enum.ts
rename to lib/enums/listener-menthod.enum.ts
index 932382f..05a55eb 100644
--- a/lib/enums/listener-type.enum.ts
+++ b/lib/enums/listener-menthod.enum.ts
@@ -1,4 +1,4 @@
-export enum ListenerType {
+export enum ListenerMethod {
Use = 'use',
On = 'on',
Hears = 'hears',
diff --git a/lib/enums/update-paramtypes.enum.ts b/lib/enums/update-paramtypes.enum.ts
new file mode 100644
index 0000000..e5a3303
--- /dev/null
+++ b/lib/enums/update-paramtypes.enum.ts
@@ -0,0 +1,5 @@
+export enum UpdateParamtypes {
+ CONTEXT,
+ NEXT,
+ MESSAGE,
+}
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 6bba348..ce4f7f1 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,6 +1,8 @@
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
export const UPDATE_METADATA = 'UPDATE_METADATA';
-export const UPDATE_LISTENER_TYPE_METADATA = 'UPDATE_LISTENER_TYPE_METADATA';
+export const UPDATE_LISTENER_METHOD_METADATA =
+ 'UPDATE_LISTENER_METHOD_METADATA';
export const UPDATE_LISTENER_OPTIONS_METADATA =
'UPDATE_LISTENER_OPTIONS_METADATA';
+export const UPDATE_ARGS_METADATA = 'UPDATE_ARGS_METADATA';
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index 0d2751b..6d9f427 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -1,24 +1,8 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
-import { DiscoveryService, ModuleRef } from '@nestjs/core';
+import { DiscoveryService } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
import { TelegrafProvider } from './telegraf.provider';
-import { ListenerType } from './enums';
-import {
- ActionOptions,
- CashtagOptions,
- CommandOptions,
- EmailOptions,
- HashtagOptions,
- HearsOptions,
- InlineQueryOptions,
- MentionOptions,
- OnOptions,
- PhoneOptions,
- TextLinkOptions,
- TextMentionOptions,
- UrlOptions,
-} from './decorators';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
@Injectable()
@@ -35,7 +19,7 @@ export class TelegrafExplorer implements OnModuleInit {
}
explore(): void {
- const updateClasses = this.filterUpdateClass();
+ const updateClasses = this.filterUpdateClasses();
updateClasses.forEach((wrapper) => {
const { instance } = wrapper;
@@ -49,7 +33,7 @@ export class TelegrafExplorer implements OnModuleInit {
});
}
- private filterUpdateClass(): InstanceWrapper[] {
+ private filterUpdateClasses(): InstanceWrapper[] {
return this.discoveryService
.getProviders()
.filter((wrapper) => wrapper.instance)
@@ -65,97 +49,12 @@ export class TelegrafExplorer implements OnModuleInit {
const methodRef = instance[methodKey];
const middlewareFn = methodRef.bind(instance);
- const listenerType = this.metadataAccessor.getListenerType(methodRef);
- if (!listenerType) return;
+ const listenerMethod = this.metadataAccessor.getListenerMethod(methodRef);
+ if (!listenerMethod) return;
const listenerOptions = this.metadataAccessor.getListenerOptions(methodRef);
- switch (listenerType) {
- case ListenerType.On: {
- const { updateTypes } = listenerOptions as OnOptions;
- this.telegraf.on(updateTypes, middlewareFn);
- break;
- }
- case ListenerType.Use: {
- this.telegraf.use(middlewareFn);
- break;
- }
- case ListenerType.Start: {
- this.telegraf.start(middlewareFn);
- break;
- }
- case ListenerType.Help: {
- this.telegraf.help(middlewareFn);
- break;
- }
- case ListenerType.Settings: {
- this.telegraf.settings(middlewareFn);
- break;
- }
- case ListenerType.Hears: {
- const { triggers } = listenerOptions as HearsOptions;
- this.telegraf.hears(triggers, middlewareFn);
- break;
- }
- case ListenerType.Command: {
- const { command } = listenerOptions as CommandOptions;
- this.telegraf.command(command, middlewareFn);
- break;
- }
- case ListenerType.Action: {
- const { triggers } = listenerOptions as ActionOptions;
- this.telegraf.action(triggers, middlewareFn);
- break;
- }
- case ListenerType.Mention: {
- const { mention } = listenerOptions as MentionOptions;
- this.telegraf.mention(mention, middlewareFn);
- break;
- }
- case ListenerType.Phone: {
- const { phone } = listenerOptions as PhoneOptions;
- this.telegraf.phone(phone, middlewareFn);
- break;
- }
- case ListenerType.Hashtag: {
- const { hashtag } = listenerOptions as HashtagOptions;
- this.telegraf.hashtag(hashtag, middlewareFn);
- break;
- }
- case ListenerType.Cashtag: {
- const { cashtag } = listenerOptions as CashtagOptions;
- this.telegraf.cashtag(cashtag, middlewareFn);
- break;
- }
- case ListenerType.Email: {
- const { email } = listenerOptions as EmailOptions;
- this.telegraf.email(email, middlewareFn);
- break;
- }
- case ListenerType.Url: {
- const { url } = listenerOptions as UrlOptions;
- this.telegraf.url(url, middlewareFn);
- break;
- }
- case ListenerType.TextLink: {
- const { link } = listenerOptions as TextLinkOptions;
- this.telegraf.textLink(link, middlewareFn);
- break;
- }
- case ListenerType.TextMention: {
- const { mention } = listenerOptions as TextMentionOptions;
- this.telegraf.textMention(mention, middlewareFn);
- break;
- }
- case ListenerType.InlineQuery: {
- const { triggers } = listenerOptions as InlineQueryOptions;
- this.telegraf.inlineQuery(triggers, middlewareFn);
- break;
- }
- case ListenerType.GameQuery: {
- this.telegraf.gameQuery(middlewareFn);
- break;
- }
- }
+ // NOTE: Disable spread operator checking because of error: "Expected at least 1 arguments, but got 1 or more."
+ (this.telegraf as any)[listenerMethod](...listenerOptions, middlewareFn);
}
}
diff --git a/lib/telegraf.metadata-accessor.ts b/lib/telegraf.metadata-accessor.ts
index e79e9e1..bb86898 100644
--- a/lib/telegraf.metadata-accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -1,31 +1,25 @@
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
- UPDATE_LISTENER_TYPE_METADATA,
+ UPDATE_LISTENER_METHOD_METADATA,
UPDATE_METADATA,
UPDATE_LISTENER_OPTIONS_METADATA,
} from './telegraf.constants';
-import { ListenerType } from './enums';
+import { ListenerMethod } from './enums';
@Injectable()
export class TelegrafMetadataAccessor {
constructor(private readonly reflector: Reflector) {}
isUpdate(target: Function): boolean {
- return !!this.reflector.get(UPDATE_METADATA, target);
+ return !!this.reflector.get(UPDATE_METADATA, target);
}
- getListenerType(target: Function): ListenerType | undefined {
- return this.reflector.get(
- UPDATE_LISTENER_TYPE_METADATA,
- target,
- );
+ getListenerMethod(target: Function): ListenerMethod | undefined {
+ return this.reflector.get(UPDATE_LISTENER_METHOD_METADATA, target);
}
- getListenerOptions(target: Function): unknown | undefined {
- return this.reflector.get(
- UPDATE_LISTENER_OPTIONS_METADATA,
- target,
- );
+ getListenerOptions(target: Function): unknown[] {
+ return this.reflector.get(UPDATE_LISTENER_OPTIONS_METADATA, target) || [];
}
}
From 16969365f2455a7ee41045779a9195f29659f88c Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 27 Dec 2020 11:03:25 +0300
Subject: [PATCH 22/33] refactor(): remove unused const
---
lib/telegraf.constants.ts | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index ce4f7f1..2b61bcc 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -5,4 +5,3 @@ export const UPDATE_LISTENER_METHOD_METADATA =
'UPDATE_LISTENER_METHOD_METADATA';
export const UPDATE_LISTENER_OPTIONS_METADATA =
'UPDATE_LISTENER_OPTIONS_METADATA';
-export const UPDATE_ARGS_METADATA = 'UPDATE_ARGS_METADATA';
From b3dc258c70150c79b7d49d1362d2bc9fba365ae9 Mon Sep 17 00:00:00 2001
From: unknown
Date: Sun, 27 Dec 2020 21:35:01 +0300
Subject: [PATCH 23/33] !feat(): use dynamic types for listener decorators
---
lib/decorators/listeners/action.decorator.ts | 15 +------
lib/decorators/listeners/cashtag.decorator.ts | 15 +------
lib/decorators/listeners/command.decorator.ts | 15 +------
lib/decorators/listeners/email.decorator.ts | 15 +------
.../listeners/game-query.decorator.ts | 8 +---
lib/decorators/listeners/hashtag.decorator.ts | 15 +------
lib/decorators/listeners/hears.decorator.ts | 15 +------
lib/decorators/listeners/help.decorator.ts | 8 +---
.../listeners/inline-query.decorator.ts | 17 +-------
lib/decorators/listeners/mention.decorator.ts | 15 +------
lib/decorators/listeners/on.decorator.ts | 15 +------
lib/decorators/listeners/phone.decorator.ts | 15 +------
.../listeners/settings.decorator.ts | 8 +---
lib/decorators/listeners/start.decorator.ts | 8 +---
.../listeners/text-link.decorator.ts | 15 +------
.../listeners/text-mention.decorator.ts | 15 +------
lib/decorators/listeners/url.decorator.ts | 15 +------
lib/decorators/listeners/use.decorator.ts | 8 +---
lib/enums/index.ts | 1 -
lib/enums/listener-menthod.enum.ts | 20 ---------
lib/enums/update-paramtypes.enum.ts | 5 ---
lib/helpers/create-update-decorator.helper.ts | 15 +++++++
lib/interfaces/listener-metadata.interface.ts | 6 +++
lib/telegraf.constants.ts | 7 ++--
lib/telegraf.explorer.ts | 17 +++++---
lib/telegraf.metadata-accessor.ts | 13 ++----
lib/telegraf.provider.ts | 4 +-
lib/telegraf.types.ts | 42 +++++++++----------
28 files changed, 97 insertions(+), 270 deletions(-)
delete mode 100644 lib/enums/index.ts
delete mode 100644 lib/enums/listener-menthod.enum.ts
delete mode 100644 lib/enums/update-paramtypes.enum.ts
create mode 100644 lib/helpers/create-update-decorator.helper.ts
create mode 100644 lib/interfaces/listener-metadata.interface.ts
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
index 4fae6e7..6a4c2ac 100644
--- a/lib/decorators/listeners/action.decorator.ts
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafActionTriggers } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling callback_data actions with regular expressions.
*
* @see https://telegraf.js.org/#/?id=action
*/
-export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Action),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
- );
-};
+export const Action = createUpdateDecorator('action');
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
index a43dbcc..ab48729 100644
--- a/lib/decorators/listeners/cashtag.decorator.ts
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafCashtag } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Cashtag handling.
*
* @see https://telegraf.js.org/#/?id=cashtag
*/
-export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Cashtag),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [cashtag]),
- );
-};
+export const Cashtag = createUpdateDecorator('cashtag');
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index 6c668d6..ec6e958 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafCommand } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Command handling.
*
* @see https://telegraf.js.org/#/?id=command
*/
-export const Command = (command: TelegrafCommand): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Command),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [command]),
- );
-};
+export const Command = createUpdateDecorator('command');
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
index 5658bdb..2364d71 100644
--- a/lib/decorators/listeners/email.decorator.ts
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafEmail } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling messages with email entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-email
*/
-export const Email = (email: TelegrafEmail): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Email),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [email]),
- );
-};
+export const Email = createUpdateDecorator('email');
diff --git a/lib/decorators/listeners/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
index 525791c..3b8c227 100644
--- a/lib/decorators/listeners/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,12 +1,8 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling callback_data actions with game query.
*
* @see https://telegraf.js.org/#/?id=inlinequery
*/
-export const GameQuery = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.GameQuery);
-};
+export const GameQuery = createUpdateDecorator('gameQuery');
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
index 012e723..3c7514a 100644
--- a/lib/decorators/listeners/hashtag.decorator.ts
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafHashtag } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Hashtag handling.
*
* @see https://telegraf.js.org/#/?id=hashtag
*/
-export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Hashtag),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [hashtag]),
- );
-};
+export const Hashtag = createUpdateDecorator('hashtag');
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index 8c2bfd2..b8f19a9 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafHearsTriggers } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling text messages.
*
* @see https://telegraf.js.org/#/?id=hears
*/
-export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Hears),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
- );
-};
+export const Hears = createUpdateDecorator('hears');
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
index c7a17fb..599d646 100644
--- a/lib/decorators/listeners/help.decorator.ts
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -1,12 +1,8 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Handler for /help command.
*
* @see https://telegraf.js.org/#/?id=help
*/
-export const Help = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Help);
-};
+export const Help = createUpdateDecorator('help');
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
index 641af40..abbdd39 100644
--- a/lib/decorators/listeners/inline-query.decorator.ts
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -1,21 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling inline_query actions with regular expressions.
*
* @see https://telegraf.js.org/#/?id=inlinequery
*/
-export const InlineQuery = (
- triggers: TelegrafInlineQueryTriggers,
-): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.InlineQuery),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [triggers]),
- );
-};
+export const InlineQuery = createUpdateDecorator('inlineQuery');
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
index 9eaeaee..d6be512 100644
--- a/lib/decorators/listeners/mention.decorator.ts
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafMention } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Mention handling.
*
* @see https://telegraf.js.org/#/?id=mention
*/
-export const Mention = (mention: TelegrafMention): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Mention),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [mention]),
- );
-};
+export const Mention = createUpdateDecorator('mention');
diff --git a/lib/decorators/listeners/on.decorator.ts b/lib/decorators/listeners/on.decorator.ts
index c467e51..a6f717c 100644
--- a/lib/decorators/listeners/on.decorator.ts
+++ b/lib/decorators/listeners/on.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafUpdateType } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for provided update type.
*
* @see https://telegraf.js.org/#/?id=on
*/
-export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.On),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [updateTypes]),
- );
-};
+export const On = createUpdateDecorator('on');
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
index b217804..8feb92f 100644
--- a/lib/decorators/listeners/phone.decorator.ts
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafPhone } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Phone number handling.
*
* @see https://telegraf.js.org/#/?id=phone
*/
-export const Phone = (phone: TelegrafPhone): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Phone),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [phone]),
- );
-};
+export const Phone = createUpdateDecorator('phone');
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
index d53048c..8f705f9 100644
--- a/lib/decorators/listeners/settings.decorator.ts
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -1,12 +1,8 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Handler for /settings command.
*
* @see https://telegraf.js.org/#/?id=settings
*/
-export const Settings = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Settings);
-};
+export const Settings = createUpdateDecorator('settings');
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
index ec13aa0..6a084f0 100644
--- a/lib/decorators/listeners/start.decorator.ts
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -1,12 +1,8 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Handler for /start command.
*
* @see https://telegraf.js.org/#/?id=start
*/
-export const Start = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Start);
-};
+export const Start = createUpdateDecorator('start');
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
index 9f7fa44..0e91ad7 100644
--- a/lib/decorators/listeners/text-link.decorator.ts
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafTextLink } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling messages with text_link entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TextLink = (link: TelegrafTextLink): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.TextLink),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [link]),
- );
-};
+export const TextLink = createUpdateDecorator('textLink');
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
index 0791ab6..ebd30e3 100644
--- a/lib/decorators/listeners/text-mention.decorator.ts
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafTextMention } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling messages with text_mention entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TextMention = (mention: TelegrafTextMention): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.TextMention),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [mention]),
- );
-};
+export const TextMention = createUpdateDecorator('textMention');
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
index 04f9704..36653fe 100644
--- a/lib/decorators/listeners/url.decorator.ts
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -1,19 +1,8 @@
-import { applyDecorators, SetMetadata } from '@nestjs/common';
-import {
- UPDATE_LISTENER_OPTIONS_METADATA,
- UPDATE_LISTENER_METHOD_METADATA,
-} from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
-import { TelegrafUrl } from '../../telegraf.types';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers middleware for handling messages with url entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-url
*/
-export const Url = (url: TelegrafUrl): MethodDecorator => {
- return applyDecorators(
- SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Url),
- SetMetadata(UPDATE_LISTENER_OPTIONS_METADATA, [url]),
- );
-};
+export const Url = createUpdateDecorator('url');
diff --git a/lib/decorators/listeners/use.decorator.ts b/lib/decorators/listeners/use.decorator.ts
index 84c7d2c..a0b1ec4 100644
--- a/lib/decorators/listeners/use.decorator.ts
+++ b/lib/decorators/listeners/use.decorator.ts
@@ -1,12 +1,8 @@
-import { SetMetadata } from '@nestjs/common';
-import { UPDATE_LISTENER_METHOD_METADATA } from '../../telegraf.constants';
-import { ListenerMethod } from '../../enums';
+import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
/**
* Registers a middleware.
*
* @see https://telegraf.js.org/#/?id=use
*/
-export const Use = (): MethodDecorator => {
- return SetMetadata(UPDATE_LISTENER_METHOD_METADATA, ListenerMethod.Use);
-};
+export const Use = createUpdateDecorator('use');
diff --git a/lib/enums/index.ts b/lib/enums/index.ts
deleted file mode 100644
index 5f145a0..0000000
--- a/lib/enums/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './listener-menthod.enum';
diff --git a/lib/enums/listener-menthod.enum.ts b/lib/enums/listener-menthod.enum.ts
deleted file mode 100644
index 05a55eb..0000000
--- a/lib/enums/listener-menthod.enum.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export enum ListenerMethod {
- Use = 'use',
- On = 'on',
- Hears = 'hears',
- Command = 'command',
- Start = 'start',
- Help = 'help',
- Settings = 'settings',
- Mention = 'mention',
- Phone = 'phone',
- Hashtag = 'hashtag',
- Cashtag = 'cashtag',
- Email = 'email',
- Url = 'url',
- TextLink = 'textLink',
- TextMention = 'textMention',
- Action = 'action',
- InlineQuery = 'inlineQuery',
- GameQuery = 'gameQuery',
-}
diff --git a/lib/enums/update-paramtypes.enum.ts b/lib/enums/update-paramtypes.enum.ts
deleted file mode 100644
index e5a3303..0000000
--- a/lib/enums/update-paramtypes.enum.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export enum UpdateParamtypes {
- CONTEXT,
- NEXT,
- MESSAGE,
-}
diff --git a/lib/helpers/create-update-decorator.helper.ts b/lib/helpers/create-update-decorator.helper.ts
new file mode 100644
index 0000000..3db5787
--- /dev/null
+++ b/lib/helpers/create-update-decorator.helper.ts
@@ -0,0 +1,15 @@
+import { SetMetadata } from '@nestjs/common';
+import { UpdateMethodArgs, UpdateMethods } from '../telegraf.types';
+import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
+import { ListenerMetadata } from '../interfaces/listener-metadata.interface';
+
+export function createUpdateDecorator(
+ method: Method,
+) {
+ return (...args: UpdateMethodArgs): MethodDecorator => {
+ return SetMetadata(UPDATE_LISTENER_METADATA, {
+ method,
+ args,
+ } as ListenerMetadata);
+ };
+}
diff --git a/lib/interfaces/listener-metadata.interface.ts b/lib/interfaces/listener-metadata.interface.ts
new file mode 100644
index 0000000..b4f7f5c
--- /dev/null
+++ b/lib/interfaces/listener-metadata.interface.ts
@@ -0,0 +1,6 @@
+import { UpdateMethods } from '../telegraf.types';
+
+export interface ListenerMetadata {
+ method: UpdateMethods;
+ args: unknown[];
+}
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 2b61bcc..1790594 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,7 +1,6 @@
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
export const UPDATE_METADATA = 'UPDATE_METADATA';
-export const UPDATE_LISTENER_METHOD_METADATA =
- 'UPDATE_LISTENER_METHOD_METADATA';
-export const UPDATE_LISTENER_OPTIONS_METADATA =
- 'UPDATE_LISTENER_OPTIONS_METADATA';
+export const UPDATE_LISTENER_METADATA = 'UPDATE_LISTENER_METADATA';
+
+export const SCENE_METADATA = 'SCENE_METADATA';
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf.explorer.ts
index 6d9f427..f52d601 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf.explorer.ts
@@ -1,9 +1,10 @@
import { Injectable, OnModuleInit } from '@nestjs/common';
import { DiscoveryService } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
+import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
+import { Composer } from 'telegraf';
import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
import { TelegrafProvider } from './telegraf.provider';
-import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
@Injectable()
export class TelegrafExplorer implements OnModuleInit {
@@ -49,12 +50,16 @@ export class TelegrafExplorer implements OnModuleInit {
const methodRef = instance[methodKey];
const middlewareFn = methodRef.bind(instance);
- const listenerMethod = this.metadataAccessor.getListenerMethod(methodRef);
- if (!listenerMethod) return;
+ const listenerMetadata = this.metadataAccessor.getListenerMetadata(
+ methodRef,
+ );
+ if (!listenerMetadata) return;
- const listenerOptions = this.metadataAccessor.getListenerOptions(methodRef);
+ const { method, args } = listenerMetadata;
+ const composerMiddlewareFn = Composer[method](...args, middlewareFn);
- // NOTE: Disable spread operator checking because of error: "Expected at least 1 arguments, but got 1 or more."
- (this.telegraf as any)[listenerMethod](...listenerOptions, middlewareFn);
+ console.log('composerMiddlewareFn', composerMiddlewareFn);
+
+ this.telegraf.use(composerMiddlewareFn);
}
}
diff --git a/lib/telegraf.metadata-accessor.ts b/lib/telegraf.metadata-accessor.ts
index bb86898..c2ec1ef 100644
--- a/lib/telegraf.metadata-accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -1,11 +1,10 @@
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
- UPDATE_LISTENER_METHOD_METADATA,
+ UPDATE_LISTENER_METADATA,
UPDATE_METADATA,
- UPDATE_LISTENER_OPTIONS_METADATA,
} from './telegraf.constants';
-import { ListenerMethod } from './enums';
+import { ListenerMetadata } from './interfaces/listener-metadata.interface';
@Injectable()
export class TelegrafMetadataAccessor {
@@ -15,11 +14,7 @@ export class TelegrafMetadataAccessor {
return !!this.reflector.get(UPDATE_METADATA, target);
}
- getListenerMethod(target: Function): ListenerMethod | undefined {
- return this.reflector.get(UPDATE_LISTENER_METHOD_METADATA, target);
- }
-
- getListenerOptions(target: Function): unknown[] {
- return this.reflector.get(UPDATE_LISTENER_OPTIONS_METADATA, target) || [];
+ getListenerMetadata(target: Function): ListenerMetadata | undefined {
+ return this.reflector.get(UPDATE_LISTENER_METADATA, target);
}
}
diff --git a/lib/telegraf.provider.ts b/lib/telegraf.provider.ts
index f6bfb2f..0602704 100644
--- a/lib/telegraf.provider.ts
+++ b/lib/telegraf.provider.ts
@@ -10,8 +10,8 @@ import { Context, TelegrafModuleOptions } from './interfaces';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
@Injectable()
-export class TelegrafProvider
- extends Telegraf
+export class TelegrafProvider
+ extends Telegraf
implements OnApplicationBootstrap, OnApplicationShutdown {
private logger = new Logger('Telegraf');
private readonly launchOptions;
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index 9b50ff3..fbb6737 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -1,26 +1,24 @@
-import { Type } from '@nestjs/common/interfaces/type.interface';
-import { Composer, Telegraf } from 'telegraf';
-import { Context } from './interfaces';
+import { Composer, Middleware, Telegraf } from 'telegraf';
-type CtxComposer = Composer;
+export type Filter = T extends []
+ ? []
+ : T extends [infer Head, ...infer Tail]
+ ? Head extends F
+ ? Filter
+ : [Head, ...Filter]
+ : [];
-type ComposerMethodFirstArg = Parameters<
- CtxComposer[T]
->[0];
+export type UpdateMethods = Exclude<
+ keyof Composer,
+ 'middleware' | 'guard' | 'filter' | 'drop'
+>;
+export type UpdateMethodArgs = Filter<
+ Parameters[T]>,
+ Middleware
+>;
+// type Test0 = Filter<[['foo', 'bar', 'booz'], ...Middleware[]], Middleware>;
+// type Test1 = UpdateMethodArgs<'on'>;
+// type Test2 = Parameters['on']>;
-export type TelegrafActionTriggers = ComposerMethodFirstArg<'action'>;
-export type TelegrafHearsTriggers = ComposerMethodFirstArg<'hears'>;
-export type TelegrafInlineQueryTriggers = ComposerMethodFirstArg<'inlineQuery'>;
-export type TelegrafEmail = ComposerMethodFirstArg<'email'>;
-export type TelegrafUrl = ComposerMethodFirstArg<'url'>;
-export type TelegrafTextLink = ComposerMethodFirstArg<'textLink'>;
-export type TelegrafTextMention = ComposerMethodFirstArg<'textMention'>;
-export type TelegrafCashtag = ComposerMethodFirstArg<'cashtag'>;
-export type TelegrafHashtag = ComposerMethodFirstArg<'hashtag'>;
-export type TelegrafCommand = ComposerMethodFirstArg<'command'>;
-export type TelegrafMention = ComposerMethodFirstArg<'mention'>;
-export type TelegrafPhone = ComposerMethodFirstArg<'phone'>;
-export type TelegrafUpdateType = ComposerMethodFirstArg<'on'>;
-
-export type TelegrafOption = ConstructorParameters>>[1];
+export type TelegrafOption = ConstructorParameters[1];
export type TelegrafLaunchOption = Parameters[0];
From 8c727902266ebfa8f51d56ce7b7a386cdcaabf35 Mon Sep 17 00:00:00 2001
From: Arthur
Date: Tue, 29 Dec 2020 22:41:06 +0300
Subject: [PATCH 24/33] !feat(): add scene support & many refactor
---
lib/decorators/core/index.ts | 1 +
lib/decorators/core/inject-bot.decorator.ts | 4 +-
lib/decorators/core/scene.decorator.ts | 8 ++
lib/decorators/index.ts | 1 +
lib/decorators/scene/index.ts | 2 +
lib/decorators/scene/scene-enter.decorator.ts | 6 ++
lib/decorators/scene/scene-leave.decorator.ts | 6 ++
lib/enums/scene-event-type.enum.ts | 4 +
lib/index.ts | 1 -
lib/interfaces/context.interface.ts | 4 -
lib/interfaces/index.ts | 1 -
lib/telegraf-scene.explorer.ts | 74 +++++++++++++++++++
...xplorer.ts => telegraf-update.explorer.ts} | 20 +++--
lib/telegraf.constants.ts | 2 +
lib/telegraf.metadata-accessor.ts | 9 +++
lib/telegraf.module.ts | 56 +++++++++-----
lib/telegraf.provider.ts | 38 ----------
lib/telegraf.providers.ts | 22 ++++++
sample/app.constants.ts | 1 +
sample/app.module.ts | 5 +-
sample/app.update.ts | 14 +++-
sample/interfaces/context.interface.ts | 4 +
sample/scenes/hello.scene.ts | 29 ++++++++
23 files changed, 232 insertions(+), 80 deletions(-)
create mode 100644 lib/decorators/core/scene.decorator.ts
create mode 100644 lib/decorators/scene/index.ts
create mode 100644 lib/decorators/scene/scene-enter.decorator.ts
create mode 100644 lib/decorators/scene/scene-leave.decorator.ts
create mode 100644 lib/enums/scene-event-type.enum.ts
delete mode 100644 lib/interfaces/context.interface.ts
create mode 100644 lib/telegraf-scene.explorer.ts
rename lib/{telegraf.explorer.ts => telegraf-update.explorer.ts} (77%)
delete mode 100644 lib/telegraf.provider.ts
create mode 100644 lib/telegraf.providers.ts
create mode 100644 sample/app.constants.ts
create mode 100644 sample/interfaces/context.interface.ts
create mode 100644 sample/scenes/hello.scene.ts
diff --git a/lib/decorators/core/index.ts b/lib/decorators/core/index.ts
index 7d609ad..baddc8e 100644
--- a/lib/decorators/core/index.ts
+++ b/lib/decorators/core/index.ts
@@ -1,2 +1,3 @@
export * from './update.decorator';
+export * from './scene.decorator';
export * from './inject-bot.decorator';
diff --git a/lib/decorators/core/inject-bot.decorator.ts b/lib/decorators/core/inject-bot.decorator.ts
index f697bd7..d010fbe 100644
--- a/lib/decorators/core/inject-bot.decorator.ts
+++ b/lib/decorators/core/inject-bot.decorator.ts
@@ -1,4 +1,4 @@
import { Inject } from '@nestjs/common';
-import { TelegrafProvider } from '../../telegraf.provider';
+import { Telegraf } from 'telegraf';
-export const InjectBot = (): ParameterDecorator => Inject(TelegrafProvider);
+export const InjectBot = (): ParameterDecorator => Inject(Telegraf);
diff --git a/lib/decorators/core/scene.decorator.ts b/lib/decorators/core/scene.decorator.ts
new file mode 100644
index 0000000..391c842
--- /dev/null
+++ b/lib/decorators/core/scene.decorator.ts
@@ -0,0 +1,8 @@
+import { SetMetadata } from '@nestjs/common';
+import { SCENE_METADATA } from '../../telegraf.constants';
+
+/**
+ * TODO
+ */
+export const Scene = (id: string): ClassDecorator =>
+ SetMetadata(SCENE_METADATA, id);
diff --git a/lib/decorators/index.ts b/lib/decorators/index.ts
index f6f8104..31fa986 100644
--- a/lib/decorators/index.ts
+++ b/lib/decorators/index.ts
@@ -1,2 +1,3 @@
export * from './core';
export * from './listeners';
+export * from './scene';
diff --git a/lib/decorators/scene/index.ts b/lib/decorators/scene/index.ts
new file mode 100644
index 0000000..b1d61b2
--- /dev/null
+++ b/lib/decorators/scene/index.ts
@@ -0,0 +1,2 @@
+export * from './scene-enter.decorator';
+export * from './scene-leave.decorator';
diff --git a/lib/decorators/scene/scene-enter.decorator.ts b/lib/decorators/scene/scene-enter.decorator.ts
new file mode 100644
index 0000000..7307e48
--- /dev/null
+++ b/lib/decorators/scene/scene-enter.decorator.ts
@@ -0,0 +1,6 @@
+import { SetMetadata } from '@nestjs/common';
+import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
+import { SceneEventType } from '../../enums/scene-event-type.enum';
+
+export const SceneEnter = (): MethodDecorator =>
+ SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Enter);
diff --git a/lib/decorators/scene/scene-leave.decorator.ts b/lib/decorators/scene/scene-leave.decorator.ts
new file mode 100644
index 0000000..09eb509
--- /dev/null
+++ b/lib/decorators/scene/scene-leave.decorator.ts
@@ -0,0 +1,6 @@
+import { SetMetadata } from '@nestjs/common';
+import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
+import { SceneEventType } from '../../enums/scene-event-type.enum';
+
+export const SceneLeave = (): MethodDecorator =>
+ SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Leave);
diff --git a/lib/enums/scene-event-type.enum.ts b/lib/enums/scene-event-type.enum.ts
new file mode 100644
index 0000000..ebd37d2
--- /dev/null
+++ b/lib/enums/scene-event-type.enum.ts
@@ -0,0 +1,4 @@
+export enum SceneEventType {
+ Enter = 'enter',
+ Leave = 'leave',
+}
diff --git a/lib/index.ts b/lib/index.ts
index bca10ec..a27fc83 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,4 +1,3 @@
export * from './decorators';
export * from './interfaces';
export * from './telegraf.module';
-export * from './telegraf.provider';
diff --git a/lib/interfaces/context.interface.ts b/lib/interfaces/context.interface.ts
deleted file mode 100644
index 97001b3..0000000
--- a/lib/interfaces/context.interface.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { Context as TelegrafContext } from 'telegraf';
-
-// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface Context extends TelegrafContext {}
diff --git a/lib/interfaces/index.ts b/lib/interfaces/index.ts
index 3b25926..23e7d9f 100644
--- a/lib/interfaces/index.ts
+++ b/lib/interfaces/index.ts
@@ -1,2 +1 @@
-export * from './context.interface';
export * from './telegraf-options.interface';
diff --git a/lib/telegraf-scene.explorer.ts b/lib/telegraf-scene.explorer.ts
new file mode 100644
index 0000000..74baad9
--- /dev/null
+++ b/lib/telegraf-scene.explorer.ts
@@ -0,0 +1,74 @@
+import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
+import { DiscoveryService } from '@nestjs/core';
+import { MetadataScanner } from '@nestjs/core/metadata-scanner';
+import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
+import { BaseScene as Scene, Stage, Telegraf } from 'telegraf';
+import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
+
+@Injectable()
+export class TelegrafSceneExplorer implements OnModuleInit {
+ constructor(
+ @Inject(Telegraf)
+ private readonly telegraf: Telegraf,
+ private readonly discoveryService: DiscoveryService,
+ private readonly metadataAccessor: TelegrafMetadataAccessor,
+ private readonly metadataScanner: MetadataScanner,
+ ) {}
+
+ onModuleInit(): void {
+ this.explore();
+ }
+
+ private explore(): void {
+ const sceneClasses = this.filterSceneClasses();
+ const stage = new Stage();
+
+ sceneClasses.forEach((wrapper) => {
+ const { instance } = wrapper;
+
+ const sceneId = this.metadataAccessor.getSceneMetadata(
+ instance.constructor,
+ );
+ const scene = new Scene(sceneId);
+ stage.register(scene);
+
+ const prototype = Object.getPrototypeOf(instance);
+ this.metadataScanner.scanFromPrototype(
+ instance,
+ prototype,
+ (methodKey: string) =>
+ this.registerIfListener(scene, instance, methodKey),
+ );
+
+ stage.register(scene);
+ });
+
+ this.telegraf.use(stage.middleware());
+ }
+
+ private filterSceneClasses(): InstanceWrapper[] {
+ return this.discoveryService
+ .getProviders()
+ .filter((wrapper) => wrapper.instance)
+ .filter((wrapper) =>
+ this.metadataAccessor.isScene(wrapper.instance.constructor),
+ );
+ }
+
+ private registerIfListener(
+ scene: Scene,
+ instance: Record,
+ methodKey: string,
+ ): void {
+ const methodRef = instance[methodKey];
+ const middlewareFn = methodRef.bind(instance);
+
+ const listenerMetadata = this.metadataAccessor.getListenerMetadata(
+ methodRef,
+ );
+ if (!listenerMetadata) return;
+
+ const { method, args } = listenerMetadata;
+ (scene[method] as any)(...args, middlewareFn);
+ }
+}
diff --git a/lib/telegraf.explorer.ts b/lib/telegraf-update.explorer.ts
similarity index 77%
rename from lib/telegraf.explorer.ts
rename to lib/telegraf-update.explorer.ts
index f52d601..4e4640c 100644
--- a/lib/telegraf.explorer.ts
+++ b/lib/telegraf-update.explorer.ts
@@ -1,15 +1,15 @@
-import { Injectable, OnModuleInit } from '@nestjs/common';
+import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
import { DiscoveryService } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
-import { Composer } from 'telegraf';
+import { Telegraf } from 'telegraf';
import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
-import { TelegrafProvider } from './telegraf.provider';
@Injectable()
-export class TelegrafExplorer implements OnModuleInit {
+export class TelegrafUpdateExplorer implements OnModuleInit {
constructor(
- private readonly telegraf: TelegrafProvider,
+ @Inject(Telegraf)
+ private readonly telegraf: Telegraf,
private readonly discoveryService: DiscoveryService,
private readonly metadataAccessor: TelegrafMetadataAccessor,
private readonly metadataScanner: MetadataScanner,
@@ -19,7 +19,7 @@ export class TelegrafExplorer implements OnModuleInit {
this.explore();
}
- explore(): void {
+ private explore(): void {
const updateClasses = this.filterUpdateClasses();
updateClasses.forEach((wrapper) => {
@@ -56,10 +56,8 @@ export class TelegrafExplorer implements OnModuleInit {
if (!listenerMetadata) return;
const { method, args } = listenerMetadata;
- const composerMiddlewareFn = Composer[method](...args, middlewareFn);
-
- console.log('composerMiddlewareFn', composerMiddlewareFn);
-
- this.telegraf.use(composerMiddlewareFn);
+ // NOTE: Use "any" to disable "Expected at least 1 arguments, but got 1 or more." error.
+ // Use telegraf instance for non-scene listeners
+ (this.telegraf[method] as any)(...args, middlewareFn);
}
}
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index 1790594..e7ce73e 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,6 +1,8 @@
+export const STAGE_MIDDLEWARE = 'StageMiddleware';
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
export const UPDATE_METADATA = 'UPDATE_METADATA';
export const UPDATE_LISTENER_METADATA = 'UPDATE_LISTENER_METADATA';
export const SCENE_METADATA = 'SCENE_METADATA';
+export const SCENE_LISTENER_METADATA = 'SCENE_LISTENER_METADATA';
diff --git a/lib/telegraf.metadata-accessor.ts b/lib/telegraf.metadata-accessor.ts
index c2ec1ef..19e58b5 100644
--- a/lib/telegraf.metadata-accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import {
+ SCENE_METADATA,
UPDATE_LISTENER_METADATA,
UPDATE_METADATA,
} from './telegraf.constants';
@@ -14,7 +15,15 @@ export class TelegrafMetadataAccessor {
return !!this.reflector.get(UPDATE_METADATA, target);
}
+ isScene(target: Function): boolean {
+ return !!this.reflector.get(SCENE_METADATA, target);
+ }
+
getListenerMetadata(target: Function): ListenerMetadata | undefined {
return this.reflector.get(UPDATE_LISTENER_METADATA, target);
}
+
+ getSceneMetadata(target: Function): string | undefined {
+ return this.reflector.get(SCENE_METADATA, target);
+ }
}
diff --git a/lib/telegraf.module.ts b/lib/telegraf.module.ts
index f0e82a2..f40ca9e 100644
--- a/lib/telegraf.module.ts
+++ b/lib/telegraf.module.ts
@@ -1,22 +1,53 @@
-import { DiscoveryModule } from '@nestjs/core';
-import { Module, DynamicModule, Provider } from '@nestjs/common';
+import { DiscoveryModule, ModuleRef } from '@nestjs/core';
+import {
+ DynamicModule,
+ Inject,
+ Module,
+ OnApplicationBootstrap,
+ OnApplicationShutdown,
+ Provider,
+} from '@nestjs/common';
+import { Telegraf } from 'telegraf';
import {
- TelegrafModuleOptions,
TelegrafModuleAsyncOptions,
+ TelegrafModuleOptions,
TelegrafOptionsFactory,
} from './interfaces';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
-import { TelegrafExplorer } from './telegraf.explorer';
-import { TelegrafProvider } from './telegraf.provider';
+import { TelegrafUpdateExplorer } from './telegraf-update.explorer';
+import { TelegrafSceneExplorer } from './telegraf-scene.explorer';
+import { createProviders, TelegrafProvider } from './telegraf.providers';
@Module({
imports: [DiscoveryModule],
- providers: [TelegrafMetadataAccessor, TelegrafExplorer],
+ providers: [
+ TelegrafMetadataAccessor,
+ TelegrafSceneExplorer,
+ TelegrafUpdateExplorer,
+ ],
})
-export class TelegrafModule {
+export class TelegrafModule
+ implements OnApplicationBootstrap, OnApplicationShutdown {
+ constructor(
+ @Inject(TELEGRAF_MODULE_OPTIONS)
+ private readonly options: TelegrafModuleOptions,
+ private readonly moduleRef: ModuleRef,
+ ) {}
+
+ async onApplicationBootstrap(): Promise {
+ const { launchOptions } = this.options;
+ const telegraf = this.moduleRef.get(Telegraf);
+ await telegraf.launch(launchOptions);
+ }
+
+ async onApplicationShutdown(): Promise {
+ const telegraf = this.moduleRef.get(Telegraf);
+ await telegraf.stop();
+ }
+
public static forRoot(options: TelegrafModuleOptions): DynamicModule {
- const providers = [...this.createProviders(options), TelegrafProvider];
+ const providers = [...createProviders(options), TelegrafProvider];
return {
module: TelegrafModule,
@@ -25,15 +56,6 @@ export class TelegrafModule {
};
}
- private static createProviders(options: TelegrafModuleOptions): Provider[] {
- return [
- {
- provide: TELEGRAF_MODULE_OPTIONS,
- useValue: options,
- },
- ];
- }
-
public static forRootAsync(
options: TelegrafModuleAsyncOptions,
): DynamicModule {
diff --git a/lib/telegraf.provider.ts b/lib/telegraf.provider.ts
deleted file mode 100644
index 0602704..0000000
--- a/lib/telegraf.provider.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import {
- Injectable,
- Inject,
- OnApplicationBootstrap,
- Logger,
- OnApplicationShutdown,
-} from '@nestjs/common';
-import { Telegraf } from 'telegraf';
-import { Context, TelegrafModuleOptions } from './interfaces';
-import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
-
-@Injectable()
-export class TelegrafProvider
- extends Telegraf
- implements OnApplicationBootstrap, OnApplicationShutdown {
- private logger = new Logger('Telegraf');
- private readonly launchOptions;
-
- constructor(@Inject(TELEGRAF_MODULE_OPTIONS) options: TelegrafModuleOptions) {
- super(options.token, options.options);
- this.launchOptions = options.launchOptions;
- }
-
- async onApplicationBootstrap(): Promise {
- this.catch(async (err, ctx) => {
- this.logger.error(
- `Encountered an error for ${ctx.updateType} update type`,
- err as string,
- );
- });
-
- await this.launch(this.launchOptions);
- }
-
- async onApplicationShutdown(): Promise {
- await this.stop();
- }
-}
diff --git a/lib/telegraf.providers.ts b/lib/telegraf.providers.ts
new file mode 100644
index 0000000..b7ac54a
--- /dev/null
+++ b/lib/telegraf.providers.ts
@@ -0,0 +1,22 @@
+import { Provider } from '@nestjs/common';
+import { session, Telegraf } from 'telegraf';
+import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
+import { TelegrafModuleOptions } from './interfaces';
+
+export const TelegrafProvider = {
+ provide: Telegraf,
+ inject: [TELEGRAF_MODULE_OPTIONS],
+ useFactory: (options: TelegrafModuleOptions) => {
+ const telegraf = new Telegraf(options.token, options.options);
+ return telegraf;
+ },
+};
+
+export function createProviders(options: TelegrafModuleOptions): Provider[] {
+ return [
+ {
+ provide: TELEGRAF_MODULE_OPTIONS,
+ useValue: options,
+ },
+ ];
+}
diff --git a/sample/app.constants.ts b/sample/app.constants.ts
new file mode 100644
index 0000000..b9cfdda
--- /dev/null
+++ b/sample/app.constants.ts
@@ -0,0 +1 @@
+export const HELLO_SCENE_ID = 'HELLO_SCENE_ID';
diff --git a/sample/app.module.ts b/sample/app.module.ts
index 19b71ac..8d4f95d 100644
--- a/sample/app.module.ts
+++ b/sample/app.module.ts
@@ -2,13 +2,14 @@ import { Module } from '@nestjs/common';
import { TelegrafModule } from '../lib';
import { EchoService } from './echo.service';
import { AppUpdate } from './app.update';
+import { HelloScene } from './scenes/hello.scene';
@Module({
imports: [
TelegrafModule.forRoot({
- token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8',
+ token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8', // Don't steal >:(
}),
],
- providers: [EchoService, AppUpdate],
+ providers: [EchoService, AppUpdate, HelloScene],
})
export class AppModule {}
diff --git a/sample/app.update.ts b/sample/app.update.ts
index dab2a76..402e9fb 100644
--- a/sample/app.update.ts
+++ b/sample/app.update.ts
@@ -1,13 +1,14 @@
-import { Telegraf } from 'telegraf';
-import { Help, InjectBot, On, Start, Update } from '../lib/decorators';
-import { Context } from '../lib/interfaces';
+import { SceneContext, Telegraf } from 'telegraf';
+import { Command, Help, InjectBot, On, Start, Update } from '../lib';
import { EchoService } from './echo.service';
+import { HELLO_SCENE_ID } from './app.constants';
+import { Context } from './interfaces/context.interface';
@Update()
export class AppUpdate {
constructor(
@InjectBot()
- private readonly bot: Telegraf,
+ private readonly bot: Telegraf,
private readonly echoService: EchoService,
) {}
@@ -22,6 +23,11 @@ export class AppUpdate {
await ctx.reply('Send me any text');
}
+ @Command('scene')
+ async onSceneCommand(ctx: Context): Promise {
+ await ctx.scene.enter(HELLO_SCENE_ID);
+ }
+
@On('message')
async onMessage(ctx: Context): Promise {
console.log('New message received');
diff --git a/sample/interfaces/context.interface.ts b/sample/interfaces/context.interface.ts
new file mode 100644
index 0000000..fcefe97
--- /dev/null
+++ b/sample/interfaces/context.interface.ts
@@ -0,0 +1,4 @@
+import { SceneContext } from 'telegraf';
+
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface Context extends SceneContext {}
diff --git a/sample/scenes/hello.scene.ts b/sample/scenes/hello.scene.ts
new file mode 100644
index 0000000..beab49a
--- /dev/null
+++ b/sample/scenes/hello.scene.ts
@@ -0,0 +1,29 @@
+import { HELLO_SCENE_ID } from '../app.constants';
+import { Context } from '../interfaces/context.interface';
+import { Scene, SceneEnter, SceneLeave, Command } from '../../lib';
+
+@Scene(HELLO_SCENE_ID)
+export class HelloScene {
+ @SceneEnter()
+ async onSceneEnter(ctx: Context): Promise {
+ console.log('Enter to scene');
+ await ctx.reply('Welcome on scene ✋');
+ }
+
+ @SceneLeave()
+ async onSceneLeave(): Promise {
+ console.log('Leave from scene');
+ await ctx.reply('Bye Bye 👋');
+ }
+
+ @Command('hello')
+ async onHelloCommand(ctx: Context): Promise {
+ console.log('Use say hello');
+ await ctx.reply('Hi');
+ }
+
+ @Command('leave')
+ async onLeaveCommand(ctx: Context): Promise {
+ await ctx.scene.leave();
+ }
+}
From 306f239603ef2964aeae6dc653a24d518116239c Mon Sep 17 00:00:00 2001
From: Arthur
Date: Tue, 29 Dec 2020 22:48:19 +0300
Subject: [PATCH 25/33] reafctor(): remove unused code & add exports
---
lib/helpers/create-update-decorator.helper.ts | 2 +-
lib/helpers/index.ts | 1 +
lib/index.ts | 2 ++
lib/interfaces/index.ts | 1 +
lib/telegraf.constants.ts | 1 -
lib/telegraf.providers.ts | 2 +-
lib/telegraf.types.ts | 3 ---
7 files changed, 6 insertions(+), 6 deletions(-)
create mode 100644 lib/helpers/index.ts
diff --git a/lib/helpers/create-update-decorator.helper.ts b/lib/helpers/create-update-decorator.helper.ts
index 3db5787..887a552 100644
--- a/lib/helpers/create-update-decorator.helper.ts
+++ b/lib/helpers/create-update-decorator.helper.ts
@@ -1,7 +1,7 @@
import { SetMetadata } from '@nestjs/common';
import { UpdateMethodArgs, UpdateMethods } from '../telegraf.types';
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
-import { ListenerMetadata } from '../interfaces/listener-metadata.interface';
+import { ListenerMetadata } from '../interfaces';
export function createUpdateDecorator(
method: Method,
diff --git a/lib/helpers/index.ts b/lib/helpers/index.ts
new file mode 100644
index 0000000..4a414bd
--- /dev/null
+++ b/lib/helpers/index.ts
@@ -0,0 +1 @@
+export * from './create-update-decorator.helper';
diff --git a/lib/index.ts b/lib/index.ts
index a27fc83..da17d36 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -1,3 +1,5 @@
export * from './decorators';
export * from './interfaces';
+export * from './helpers';
export * from './telegraf.module';
+export * from './telegraf.types';
diff --git a/lib/interfaces/index.ts b/lib/interfaces/index.ts
index 23e7d9f..ef12fd5 100644
--- a/lib/interfaces/index.ts
+++ b/lib/interfaces/index.ts
@@ -1 +1,2 @@
export * from './telegraf-options.interface';
+export * from './listener-metadata.interface';
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index e7ce73e..adb1268 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -1,4 +1,3 @@
-export const STAGE_MIDDLEWARE = 'StageMiddleware';
export const TELEGRAF_MODULE_OPTIONS = 'TELEGRAF_MODULE_OPTIONS';
export const UPDATE_METADATA = 'UPDATE_METADATA';
diff --git a/lib/telegraf.providers.ts b/lib/telegraf.providers.ts
index b7ac54a..7c708c4 100644
--- a/lib/telegraf.providers.ts
+++ b/lib/telegraf.providers.ts
@@ -1,5 +1,5 @@
import { Provider } from '@nestjs/common';
-import { session, Telegraf } from 'telegraf';
+import { Telegraf } from 'telegraf';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
import { TelegrafModuleOptions } from './interfaces';
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index fbb6737..6f2d6bb 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -16,9 +16,6 @@ export type UpdateMethodArgs = Filter<
Parameters[T]>,
Middleware
>;
-// type Test0 = Filter<[['foo', 'bar', 'booz'], ...Middleware[]], Middleware>;
-// type Test1 = UpdateMethodArgs<'on'>;
-// type Test2 = Parameters['on']>;
export type TelegrafOption = ConstructorParameters[1];
export type TelegrafLaunchOption = Parameters[0];
From 3e585859d0789949b8c827cddd472eb02509d4a7 Mon Sep 17 00:00:00 2001
From: Arthur
Date: Wed, 30 Dec 2020 01:49:09 +0300
Subject: [PATCH 26/33] feat(): add middleware support & refactor
---
lib/decorators/listeners/action.decorator.ts | 4 +--
lib/decorators/listeners/cashtag.decorator.ts | 4 +--
lib/decorators/listeners/command.decorator.ts | 4 +--
lib/decorators/listeners/email.decorator.ts | 4 +--
.../listeners/game-query.decorator.ts | 4 +--
lib/decorators/listeners/hashtag.decorator.ts | 4 +--
lib/decorators/listeners/hears.decorator.ts | 4 +--
lib/decorators/listeners/help.decorator.ts | 4 +--
.../listeners/inline-query.decorator.ts | 4 +--
lib/decorators/listeners/mention.decorator.ts | 4 +--
lib/decorators/listeners/on.decorator.ts | 4 +--
lib/decorators/listeners/phone.decorator.ts | 4 +--
.../listeners/settings.decorator.ts | 4 +--
lib/decorators/listeners/start.decorator.ts | 4 +--
.../listeners/text-link.decorator.ts | 4 +--
.../listeners/text-mention.decorator.ts | 4 +--
lib/decorators/listeners/url.decorator.ts | 4 +--
lib/decorators/listeners/use.decorator.ts | 4 +--
lib/decorators/scene/scene-enter.decorator.ts | 7 ++---
lib/decorators/scene/scene-leave.decorator.ts | 7 ++---
lib/enums/scene-event-type.enum.ts | 4 ---
.../telegraf-scene.explorer.ts | 15 +++++------
.../telegraf-update.explorer.ts | 2 +-
.../create-scene-listener-decorator.helper.ts | 18 +++++++++++++
...reate-update-listener-decorator.helper.ts} | 9 ++++---
lib/helpers/index.ts | 3 ++-
lib/interfaces/listener-metadata.interface.ts | 4 +--
lib/interfaces/telegraf-options.interface.ts | 4 ++-
lib/telegraf.constants.ts | 1 -
lib/telegraf.module.ts | 4 +--
lib/telegraf.providers.ts | 3 ++-
lib/telegraf.types.ts | 26 ++++++++++++-------
sample/app.module.ts | 2 ++
sample/middleware/session.middleware.ts | 3 +++
sample/scenes/hello.scene.ts | 2 +-
35 files changed, 105 insertions(+), 81 deletions(-)
delete mode 100644 lib/enums/scene-event-type.enum.ts
rename lib/{ => explorers}/telegraf-scene.explorer.ts (90%)
rename lib/{ => explorers}/telegraf-update.explorer.ts (96%)
create mode 100644 lib/helpers/create-scene-listener-decorator.helper.ts
rename lib/helpers/{create-update-decorator.helper.ts => create-update-listener-decorator.helper.ts} (51%)
create mode 100644 sample/middleware/session.middleware.ts
diff --git a/lib/decorators/listeners/action.decorator.ts b/lib/decorators/listeners/action.decorator.ts
index 6a4c2ac..4b14901 100644
--- a/lib/decorators/listeners/action.decorator.ts
+++ b/lib/decorators/listeners/action.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling callback_data actions with regular expressions.
*
* @see https://telegraf.js.org/#/?id=action
*/
-export const Action = createUpdateDecorator('action');
+export const Action = createUpdateListenerDecorator('action');
diff --git a/lib/decorators/listeners/cashtag.decorator.ts b/lib/decorators/listeners/cashtag.decorator.ts
index ab48729..c3e37e9 100644
--- a/lib/decorators/listeners/cashtag.decorator.ts
+++ b/lib/decorators/listeners/cashtag.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Cashtag handling.
*
* @see https://telegraf.js.org/#/?id=cashtag
*/
-export const Cashtag = createUpdateDecorator('cashtag');
+export const Cashtag = createUpdateListenerDecorator('cashtag');
diff --git a/lib/decorators/listeners/command.decorator.ts b/lib/decorators/listeners/command.decorator.ts
index ec6e958..0e7806e 100644
--- a/lib/decorators/listeners/command.decorator.ts
+++ b/lib/decorators/listeners/command.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Command handling.
*
* @see https://telegraf.js.org/#/?id=command
*/
-export const Command = createUpdateDecorator('command');
+export const Command = createUpdateListenerDecorator('command');
diff --git a/lib/decorators/listeners/email.decorator.ts b/lib/decorators/listeners/email.decorator.ts
index 2364d71..e9bb1a6 100644
--- a/lib/decorators/listeners/email.decorator.ts
+++ b/lib/decorators/listeners/email.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling messages with email entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-email
*/
-export const Email = createUpdateDecorator('email');
+export const Email = createUpdateListenerDecorator('email');
diff --git a/lib/decorators/listeners/game-query.decorator.ts b/lib/decorators/listeners/game-query.decorator.ts
index 3b8c227..347f998 100644
--- a/lib/decorators/listeners/game-query.decorator.ts
+++ b/lib/decorators/listeners/game-query.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling callback_data actions with game query.
*
* @see https://telegraf.js.org/#/?id=inlinequery
*/
-export const GameQuery = createUpdateDecorator('gameQuery');
+export const GameQuery = createUpdateListenerDecorator('gameQuery');
diff --git a/lib/decorators/listeners/hashtag.decorator.ts b/lib/decorators/listeners/hashtag.decorator.ts
index 3c7514a..86e9e13 100644
--- a/lib/decorators/listeners/hashtag.decorator.ts
+++ b/lib/decorators/listeners/hashtag.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Hashtag handling.
*
* @see https://telegraf.js.org/#/?id=hashtag
*/
-export const Hashtag = createUpdateDecorator('hashtag');
+export const Hashtag = createUpdateListenerDecorator('hashtag');
diff --git a/lib/decorators/listeners/hears.decorator.ts b/lib/decorators/listeners/hears.decorator.ts
index b8f19a9..79d71af 100644
--- a/lib/decorators/listeners/hears.decorator.ts
+++ b/lib/decorators/listeners/hears.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling text messages.
*
* @see https://telegraf.js.org/#/?id=hears
*/
-export const Hears = createUpdateDecorator('hears');
+export const Hears = createUpdateListenerDecorator('hears');
diff --git a/lib/decorators/listeners/help.decorator.ts b/lib/decorators/listeners/help.decorator.ts
index 599d646..36ac9e4 100644
--- a/lib/decorators/listeners/help.decorator.ts
+++ b/lib/decorators/listeners/help.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Handler for /help command.
*
* @see https://telegraf.js.org/#/?id=help
*/
-export const Help = createUpdateDecorator('help');
+export const Help = createUpdateListenerDecorator('help');
diff --git a/lib/decorators/listeners/inline-query.decorator.ts b/lib/decorators/listeners/inline-query.decorator.ts
index abbdd39..722a348 100644
--- a/lib/decorators/listeners/inline-query.decorator.ts
+++ b/lib/decorators/listeners/inline-query.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling inline_query actions with regular expressions.
*
* @see https://telegraf.js.org/#/?id=inlinequery
*/
-export const InlineQuery = createUpdateDecorator('inlineQuery');
+export const InlineQuery = createUpdateListenerDecorator('inlineQuery');
diff --git a/lib/decorators/listeners/mention.decorator.ts b/lib/decorators/listeners/mention.decorator.ts
index d6be512..e4341a0 100644
--- a/lib/decorators/listeners/mention.decorator.ts
+++ b/lib/decorators/listeners/mention.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Mention handling.
*
* @see https://telegraf.js.org/#/?id=mention
*/
-export const Mention = createUpdateDecorator('mention');
+export const Mention = createUpdateListenerDecorator('mention');
diff --git a/lib/decorators/listeners/on.decorator.ts b/lib/decorators/listeners/on.decorator.ts
index a6f717c..9f3c0fd 100644
--- a/lib/decorators/listeners/on.decorator.ts
+++ b/lib/decorators/listeners/on.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for provided update type.
*
* @see https://telegraf.js.org/#/?id=on
*/
-export const On = createUpdateDecorator('on');
+export const On = createUpdateListenerDecorator('on');
diff --git a/lib/decorators/listeners/phone.decorator.ts b/lib/decorators/listeners/phone.decorator.ts
index 8feb92f..0f68380 100644
--- a/lib/decorators/listeners/phone.decorator.ts
+++ b/lib/decorators/listeners/phone.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Phone number handling.
*
* @see https://telegraf.js.org/#/?id=phone
*/
-export const Phone = createUpdateDecorator('phone');
+export const Phone = createUpdateListenerDecorator('phone');
diff --git a/lib/decorators/listeners/settings.decorator.ts b/lib/decorators/listeners/settings.decorator.ts
index 8f705f9..6cca7c7 100644
--- a/lib/decorators/listeners/settings.decorator.ts
+++ b/lib/decorators/listeners/settings.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Handler for /settings command.
*
* @see https://telegraf.js.org/#/?id=settings
*/
-export const Settings = createUpdateDecorator('settings');
+export const Settings = createUpdateListenerDecorator('settings');
diff --git a/lib/decorators/listeners/start.decorator.ts b/lib/decorators/listeners/start.decorator.ts
index 6a084f0..48bdc5b 100644
--- a/lib/decorators/listeners/start.decorator.ts
+++ b/lib/decorators/listeners/start.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Handler for /start command.
*
* @see https://telegraf.js.org/#/?id=start
*/
-export const Start = createUpdateDecorator('start');
+export const Start = createUpdateListenerDecorator('start');
diff --git a/lib/decorators/listeners/text-link.decorator.ts b/lib/decorators/listeners/text-link.decorator.ts
index 0e91ad7..c62439a 100644
--- a/lib/decorators/listeners/text-link.decorator.ts
+++ b/lib/decorators/listeners/text-link.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling messages with text_link entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TextLink = createUpdateDecorator('textLink');
+export const TextLink = createUpdateListenerDecorator('textLink');
diff --git a/lib/decorators/listeners/text-mention.decorator.ts b/lib/decorators/listeners/text-mention.decorator.ts
index ebd30e3..895a458 100644
--- a/lib/decorators/listeners/text-mention.decorator.ts
+++ b/lib/decorators/listeners/text-mention.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling messages with text_mention entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
-export const TextMention = createUpdateDecorator('textMention');
+export const TextMention = createUpdateListenerDecorator('textMention');
diff --git a/lib/decorators/listeners/url.decorator.ts b/lib/decorators/listeners/url.decorator.ts
index 36653fe..843aa41 100644
--- a/lib/decorators/listeners/url.decorator.ts
+++ b/lib/decorators/listeners/url.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers middleware for handling messages with url entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-url
*/
-export const Url = createUpdateDecorator('url');
+export const Url = createUpdateListenerDecorator('url');
diff --git a/lib/decorators/listeners/use.decorator.ts b/lib/decorators/listeners/use.decorator.ts
index a0b1ec4..ba83af5 100644
--- a/lib/decorators/listeners/use.decorator.ts
+++ b/lib/decorators/listeners/use.decorator.ts
@@ -1,8 +1,8 @@
-import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
+import { createUpdateListenerDecorator } from '../../helpers';
/**
* Registers a middleware.
*
* @see https://telegraf.js.org/#/?id=use
*/
-export const Use = createUpdateDecorator('use');
+export const Use = createUpdateListenerDecorator('use');
diff --git a/lib/decorators/scene/scene-enter.decorator.ts b/lib/decorators/scene/scene-enter.decorator.ts
index 7307e48..914b2d7 100644
--- a/lib/decorators/scene/scene-enter.decorator.ts
+++ b/lib/decorators/scene/scene-enter.decorator.ts
@@ -1,6 +1,3 @@
-import { SetMetadata } from '@nestjs/common';
-import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
-import { SceneEventType } from '../../enums/scene-event-type.enum';
+import { createSceneListenerDecorator } from '../../helpers';
-export const SceneEnter = (): MethodDecorator =>
- SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Enter);
+export const SceneEnter = createSceneListenerDecorator('enter');
diff --git a/lib/decorators/scene/scene-leave.decorator.ts b/lib/decorators/scene/scene-leave.decorator.ts
index 09eb509..19b970e 100644
--- a/lib/decorators/scene/scene-leave.decorator.ts
+++ b/lib/decorators/scene/scene-leave.decorator.ts
@@ -1,6 +1,3 @@
-import { SetMetadata } from '@nestjs/common';
-import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
-import { SceneEventType } from '../../enums/scene-event-type.enum';
+import { createSceneListenerDecorator } from '../../helpers';
-export const SceneLeave = (): MethodDecorator =>
- SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Leave);
+export const SceneLeave = createSceneListenerDecorator('leave');
diff --git a/lib/enums/scene-event-type.enum.ts b/lib/enums/scene-event-type.enum.ts
deleted file mode 100644
index ebd37d2..0000000
--- a/lib/enums/scene-event-type.enum.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export enum SceneEventType {
- Enter = 'enter',
- Leave = 'leave',
-}
diff --git a/lib/telegraf-scene.explorer.ts b/lib/explorers/telegraf-scene.explorer.ts
similarity index 90%
rename from lib/telegraf-scene.explorer.ts
rename to lib/explorers/telegraf-scene.explorer.ts
index 74baad9..dbf36c6 100644
--- a/lib/telegraf-scene.explorer.ts
+++ b/lib/explorers/telegraf-scene.explorer.ts
@@ -3,17 +3,21 @@ import { DiscoveryService } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { BaseScene as Scene, Stage, Telegraf } from 'telegraf';
-import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
+import { TelegrafMetadataAccessor } from '../telegraf.metadata-accessor';
@Injectable()
export class TelegrafSceneExplorer implements OnModuleInit {
+ private readonly stage = new Stage();
+
constructor(
@Inject(Telegraf)
private readonly telegraf: Telegraf,
private readonly discoveryService: DiscoveryService,
private readonly metadataAccessor: TelegrafMetadataAccessor,
private readonly metadataScanner: MetadataScanner,
- ) {}
+ ) {
+ this.telegraf.use(this.stage.middleware());
+ }
onModuleInit(): void {
this.explore();
@@ -21,7 +25,6 @@ export class TelegrafSceneExplorer implements OnModuleInit {
private explore(): void {
const sceneClasses = this.filterSceneClasses();
- const stage = new Stage();
sceneClasses.forEach((wrapper) => {
const { instance } = wrapper;
@@ -30,7 +33,7 @@ export class TelegrafSceneExplorer implements OnModuleInit {
instance.constructor,
);
const scene = new Scene(sceneId);
- stage.register(scene);
+ this.stage.register(scene);
const prototype = Object.getPrototypeOf(instance);
this.metadataScanner.scanFromPrototype(
@@ -39,11 +42,7 @@ export class TelegrafSceneExplorer implements OnModuleInit {
(methodKey: string) =>
this.registerIfListener(scene, instance, methodKey),
);
-
- stage.register(scene);
});
-
- this.telegraf.use(stage.middleware());
}
private filterSceneClasses(): InstanceWrapper[] {
diff --git a/lib/telegraf-update.explorer.ts b/lib/explorers/telegraf-update.explorer.ts
similarity index 96%
rename from lib/telegraf-update.explorer.ts
rename to lib/explorers/telegraf-update.explorer.ts
index 4e4640c..eac2625 100644
--- a/lib/telegraf-update.explorer.ts
+++ b/lib/explorers/telegraf-update.explorer.ts
@@ -3,7 +3,7 @@ import { DiscoveryService } from '@nestjs/core';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { Telegraf } from 'telegraf';
-import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
+import { TelegrafMetadataAccessor } from '../telegraf.metadata-accessor';
@Injectable()
export class TelegrafUpdateExplorer implements OnModuleInit {
diff --git a/lib/helpers/create-scene-listener-decorator.helper.ts b/lib/helpers/create-scene-listener-decorator.helper.ts
new file mode 100644
index 0000000..c997ffc
--- /dev/null
+++ b/lib/helpers/create-scene-listener-decorator.helper.ts
@@ -0,0 +1,18 @@
+import { SetMetadata } from '@nestjs/common';
+import { BaseScene as Scene } from 'telegraf';
+import { ComposerMethodArgs, SceneMethods } from '../telegraf.types';
+import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
+import { ListenerMetadata } from '../interfaces';
+
+export function createSceneListenerDecorator(
+ method: Method,
+) {
+ return (
+ ...args: ComposerMethodArgs, Method>
+ ): MethodDecorator => {
+ return SetMetadata(UPDATE_LISTENER_METADATA, {
+ method,
+ args,
+ } as ListenerMetadata);
+ };
+}
diff --git a/lib/helpers/create-update-decorator.helper.ts b/lib/helpers/create-update-listener-decorator.helper.ts
similarity index 51%
rename from lib/helpers/create-update-decorator.helper.ts
rename to lib/helpers/create-update-listener-decorator.helper.ts
index 887a552..6c28eb2 100644
--- a/lib/helpers/create-update-decorator.helper.ts
+++ b/lib/helpers/create-update-listener-decorator.helper.ts
@@ -1,12 +1,15 @@
import { SetMetadata } from '@nestjs/common';
-import { UpdateMethodArgs, UpdateMethods } from '../telegraf.types';
+import { Composer } from 'telegraf';
+import { ComposerMethodArgs, UpdateMethods } from '../telegraf.types';
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
import { ListenerMetadata } from '../interfaces';
-export function createUpdateDecorator(
+export function createUpdateListenerDecorator(
method: Method,
) {
- return (...args: UpdateMethodArgs): MethodDecorator => {
+ return (
+ ...args: ComposerMethodArgs, Method>
+ ): MethodDecorator => {
return SetMetadata(UPDATE_LISTENER_METADATA, {
method,
args,
diff --git a/lib/helpers/index.ts b/lib/helpers/index.ts
index 4a414bd..20b6077 100644
--- a/lib/helpers/index.ts
+++ b/lib/helpers/index.ts
@@ -1 +1,2 @@
-export * from './create-update-decorator.helper';
+export * from './create-update-listener-decorator.helper';
+export * from './create-scene-listener-decorator.helper';
diff --git a/lib/interfaces/listener-metadata.interface.ts b/lib/interfaces/listener-metadata.interface.ts
index b4f7f5c..9dc4925 100644
--- a/lib/interfaces/listener-metadata.interface.ts
+++ b/lib/interfaces/listener-metadata.interface.ts
@@ -1,6 +1,4 @@
-import { UpdateMethods } from '../telegraf.types';
-
export interface ListenerMetadata {
- method: UpdateMethods;
+ method: string;
args: unknown[];
}
diff --git a/lib/interfaces/telegraf-options.interface.ts b/lib/interfaces/telegraf-options.interface.ts
index 9f7dc6d..417d5bf 100644
--- a/lib/interfaces/telegraf-options.interface.ts
+++ b/lib/interfaces/telegraf-options.interface.ts
@@ -1,10 +1,12 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
+import { Middleware, Context } from 'telegraf';
import { TelegrafLaunchOption, TelegrafOption } from '../telegraf.types';
-export interface TelegrafModuleOptions {
+export interface TelegrafModuleOptions {
token: string;
options?: TelegrafOption;
launchOptions?: TelegrafLaunchOption;
+ middlewares?: Middleware[];
}
export interface TelegrafOptionsFactory {
diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts
index adb1268..1790594 100644
--- a/lib/telegraf.constants.ts
+++ b/lib/telegraf.constants.ts
@@ -4,4 +4,3 @@ export const UPDATE_METADATA = 'UPDATE_METADATA';
export const UPDATE_LISTENER_METADATA = 'UPDATE_LISTENER_METADATA';
export const SCENE_METADATA = 'SCENE_METADATA';
-export const SCENE_LISTENER_METADATA = 'SCENE_LISTENER_METADATA';
diff --git a/lib/telegraf.module.ts b/lib/telegraf.module.ts
index f40ca9e..4e9f958 100644
--- a/lib/telegraf.module.ts
+++ b/lib/telegraf.module.ts
@@ -15,8 +15,8 @@ import {
} from './interfaces';
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
import { TelegrafMetadataAccessor } from './telegraf.metadata-accessor';
-import { TelegrafUpdateExplorer } from './telegraf-update.explorer';
-import { TelegrafSceneExplorer } from './telegraf-scene.explorer';
+import { TelegrafUpdateExplorer } from './explorers/telegraf-update.explorer';
+import { TelegrafSceneExplorer } from './explorers/telegraf-scene.explorer';
import { createProviders, TelegrafProvider } from './telegraf.providers';
@Module({
diff --git a/lib/telegraf.providers.ts b/lib/telegraf.providers.ts
index 7c708c4..399efe7 100644
--- a/lib/telegraf.providers.ts
+++ b/lib/telegraf.providers.ts
@@ -5,11 +5,12 @@ import { TelegrafModuleOptions } from './interfaces';
export const TelegrafProvider = {
provide: Telegraf,
- inject: [TELEGRAF_MODULE_OPTIONS],
useFactory: (options: TelegrafModuleOptions) => {
const telegraf = new Telegraf(options.token, options.options);
+ telegraf.use(...options.middlewares);
return telegraf;
},
+ inject: [TELEGRAF_MODULE_OPTIONS],
};
export function createProviders(options: TelegrafModuleOptions): Provider[] {
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index 6f2d6bb..c319853 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -1,4 +1,4 @@
-import { Composer, Middleware, Telegraf } from 'telegraf';
+import { Composer, Middleware, BaseScene, Telegraf } from 'telegraf';
export type Filter = T extends []
? []
@@ -8,14 +8,22 @@ export type Filter = T extends []
: [Head, ...Filter]
: [];
-export type UpdateMethods = Exclude<
- keyof Composer,
- 'middleware' | 'guard' | 'filter' | 'drop'
->;
-export type UpdateMethodArgs = Filter<
- Parameters[T]>,
- Middleware
->;
+export type OnlyFunctionPropertyNames = {
+ [K in keyof T]: T[K] extends (...args: any) => any ? K : never;
+}[keyof T];
+
+// export type FilterComposerMethods = Exclude<
+// T,
+// 'middleware' | 'guard' | 'filter' | 'drop'
+// >;
+
+export type ComposerMethodArgs<
+ T extends Composer,
+ U extends OnlyFunctionPropertyNames = OnlyFunctionPropertyNames
+> = Filter, Middleware>;
+
+export type UpdateMethods = OnlyFunctionPropertyNames>;
+export type SceneMethods = OnlyFunctionPropertyNames>;
export type TelegrafOption = ConstructorParameters[1];
export type TelegrafLaunchOption = Parameters[0];
diff --git a/sample/app.module.ts b/sample/app.module.ts
index 8d4f95d..2d177de 100644
--- a/sample/app.module.ts
+++ b/sample/app.module.ts
@@ -3,11 +3,13 @@ import { TelegrafModule } from '../lib';
import { EchoService } from './echo.service';
import { AppUpdate } from './app.update';
import { HelloScene } from './scenes/hello.scene';
+import { sessionMiddleware } from './middleware/session.middleware';
@Module({
imports: [
TelegrafModule.forRoot({
token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8', // Don't steal >:(
+ middlewares: [sessionMiddleware],
}),
],
providers: [EchoService, AppUpdate, HelloScene],
diff --git a/sample/middleware/session.middleware.ts b/sample/middleware/session.middleware.ts
new file mode 100644
index 0000000..c203f15
--- /dev/null
+++ b/sample/middleware/session.middleware.ts
@@ -0,0 +1,3 @@
+import { session } from 'telegraf';
+
+export const sessionMiddleware = session();
diff --git a/sample/scenes/hello.scene.ts b/sample/scenes/hello.scene.ts
index beab49a..f84a6f4 100644
--- a/sample/scenes/hello.scene.ts
+++ b/sample/scenes/hello.scene.ts
@@ -11,7 +11,7 @@ export class HelloScene {
}
@SceneLeave()
- async onSceneLeave(): Promise {
+ async onSceneLeave(ctx: Context): Promise {
console.log('Leave from scene');
await ctx.reply('Bye Bye 👋');
}
From 7c8bb7b7e9d7a9f32e8c59d06f776904fc7fd02e Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Sat, 2 Jan 2021 13:49:15 +0300
Subject: [PATCH 27/33] chore(deps): update dependency eslint to v7.17.0 (#187)
Co-authored-by: Renovate Bot
---
package-lock.json | 16 ++++++++--------
package.json | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index aeba571..54659a1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,7 +5,7 @@
"requires": true,
"packages": {
"": {
- "version": "1.3.0",
+ "version": "1.3.1",
"license": "MIT",
"dependencies": {
"telegraf": "3.38.0"
@@ -15,7 +15,7 @@
"@nestjs/core": "7.6.5",
"@typescript-eslint/eslint-plugin": "4.11.1",
"@typescript-eslint/parser": "4.11.1",
- "eslint": "7.16.0",
+ "eslint": "7.17.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-import": "2.22.1",
"husky": "4.3.6",
@@ -936,9 +936,9 @@
}
},
"node_modules/eslint": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.16.0.tgz",
- "integrity": "sha512-iVWPS785RuDA4dWuhhgXTNrGxHHK3a8HLSMBgbbU59ruJDubUraXN8N5rn7kb8tG6sjg74eE0RA3YWT51eusEw==",
+ "version": "7.17.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.17.0.tgz",
+ "integrity": "sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ==",
"dev": true,
"dependencies": {
"@babel/code-frame": "^7.0.0",
@@ -4363,9 +4363,9 @@
"dev": true
},
"eslint": {
- "version": "7.16.0",
- "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.16.0.tgz",
- "integrity": "sha512-iVWPS785RuDA4dWuhhgXTNrGxHHK3a8HLSMBgbbU59ruJDubUraXN8N5rn7kb8tG6sjg74eE0RA3YWT51eusEw==",
+ "version": "7.17.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.17.0.tgz",
+ "integrity": "sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
diff --git a/package.json b/package.json
index abaa52c..a8609ce 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
"@nestjs/core": "7.6.5",
"@typescript-eslint/eslint-plugin": "4.11.1",
"@typescript-eslint/parser": "4.11.1",
- "eslint": "7.16.0",
+ "eslint": "7.17.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-import": "2.22.1",
"husky": "4.3.6",
From f56526b9f32873207b0587368995dc053ec00719 Mon Sep 17 00:00:00 2001
From: Arthur
Date: Sat, 2 Jan 2021 15:23:30 +0300
Subject: [PATCH 28/33] feat(): use last telegraf release
---
lib/explorers/telegraf-scene.explorer.ts | 6 +++---
lib/explorers/telegraf-update.explorer.ts | 2 +-
lib/telegraf.metadata-accessor.ts | 2 +-
lib/telegraf.types.ts | 7 +------
package.json | 2 +-
sample/interfaces/context.interface.ts | 4 ++--
6 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/lib/explorers/telegraf-scene.explorer.ts b/lib/explorers/telegraf-scene.explorer.ts
index dbf36c6..2ab2c49 100644
--- a/lib/explorers/telegraf-scene.explorer.ts
+++ b/lib/explorers/telegraf-scene.explorer.ts
@@ -7,11 +7,11 @@ import { TelegrafMetadataAccessor } from '../telegraf.metadata-accessor';
@Injectable()
export class TelegrafSceneExplorer implements OnModuleInit {
- private readonly stage = new Stage();
+ private readonly stage = new Stage([]);
constructor(
@Inject(Telegraf)
- private readonly telegraf: Telegraf,
+ private readonly telegraf: Telegraf,
private readonly discoveryService: DiscoveryService,
private readonly metadataAccessor: TelegrafMetadataAccessor,
private readonly metadataScanner: MetadataScanner,
@@ -55,7 +55,7 @@ export class TelegrafSceneExplorer implements OnModuleInit {
}
private registerIfListener(
- scene: Scene,
+ scene: Scene,
instance: Record,
methodKey: string,
): void {
diff --git a/lib/explorers/telegraf-update.explorer.ts b/lib/explorers/telegraf-update.explorer.ts
index eac2625..a848806 100644
--- a/lib/explorers/telegraf-update.explorer.ts
+++ b/lib/explorers/telegraf-update.explorer.ts
@@ -9,7 +9,7 @@ import { TelegrafMetadataAccessor } from '../telegraf.metadata-accessor';
export class TelegrafUpdateExplorer implements OnModuleInit {
constructor(
@Inject(Telegraf)
- private readonly telegraf: Telegraf,
+ private readonly telegraf: Telegraf,
private readonly discoveryService: DiscoveryService,
private readonly metadataAccessor: TelegrafMetadataAccessor,
private readonly metadataScanner: MetadataScanner,
diff --git a/lib/telegraf.metadata-accessor.ts b/lib/telegraf.metadata-accessor.ts
index 19e58b5..5c4394d 100644
--- a/lib/telegraf.metadata-accessor.ts
+++ b/lib/telegraf.metadata-accessor.ts
@@ -5,7 +5,7 @@ import {
UPDATE_LISTENER_METADATA,
UPDATE_METADATA,
} from './telegraf.constants';
-import { ListenerMetadata } from './interfaces/listener-metadata.interface';
+import { ListenerMetadata } from './interfaces';
@Injectable()
export class TelegrafMetadataAccessor {
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index c319853..84019a5 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -12,11 +12,6 @@ export type OnlyFunctionPropertyNames = {
[K in keyof T]: T[K] extends (...args: any) => any ? K : never;
}[keyof T];
-// export type FilterComposerMethods = Exclude<
-// T,
-// 'middleware' | 'guard' | 'filter' | 'drop'
-// >;
-
export type ComposerMethodArgs<
T extends Composer,
U extends OnlyFunctionPropertyNames = OnlyFunctionPropertyNames
@@ -26,4 +21,4 @@ export type UpdateMethods = OnlyFunctionPropertyNames>;
export type SceneMethods = OnlyFunctionPropertyNames>;
export type TelegrafOption = ConstructorParameters[1];
-export type TelegrafLaunchOption = Parameters[0];
+export type TelegrafLaunchOption = Parameters['launch']>[0];
diff --git a/package.json b/package.json
index d842c0e..8932e6a 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
"sample-app": "ts-node --transpile-only -r tsconfig-paths/register sample/main.ts"
},
"dependencies": {
- "telegraf": "https://github.com/telegraf/telegraf.git#develop"
+ "telegraf": "^3.38.0"
},
"devDependencies": {
"@nestjs/common": "7.6.1",
diff --git a/sample/interfaces/context.interface.ts b/sample/interfaces/context.interface.ts
index fcefe97..58f20ef 100644
--- a/sample/interfaces/context.interface.ts
+++ b/sample/interfaces/context.interface.ts
@@ -1,4 +1,4 @@
-import { SceneContext } from 'telegraf';
+import { SceneContextMessageUpdate } from 'telegraf/typings/stage';
// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface Context extends SceneContext {}
+export interface Context extends SceneContextMessageUpdate {}
From 13fe9b03c60c77fe0df2d94eac4c170833d04726 Mon Sep 17 00:00:00 2001
From: Arthur
Date: Sat, 2 Jan 2021 15:23:59 +0300
Subject: [PATCH 29/33] chore(): add lock files to gitignore
---
.gitignore | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitignore b/.gitignore
index f9a2902..8a8a4fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
+# lock
+package-lock.json
+yarn.lock
+
# dependencies
/node_modules
From f88e34d489e4efbe42df1832919bd0203051f2c3 Mon Sep 17 00:00:00 2001
From: Morb0
Date: Sat, 2 Jan 2021 15:47:17 +0300
Subject: [PATCH 30/33] fix(boot): update config interface
---
lib/interfaces/telegraf-options.interface.ts | 13 ++++++++++---
lib/telegraf.types.ts | 5 +----
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/lib/interfaces/telegraf-options.interface.ts b/lib/interfaces/telegraf-options.interface.ts
index 417d5bf..09ffb2c 100644
--- a/lib/interfaces/telegraf-options.interface.ts
+++ b/lib/interfaces/telegraf-options.interface.ts
@@ -1,11 +1,18 @@
import { ModuleMetadata, Type } from '@nestjs/common/interfaces';
import { Middleware, Context } from 'telegraf';
-import { TelegrafLaunchOption, TelegrafOption } from '../telegraf.types';
+import {
+ LaunchPollingOptions,
+ LaunchWebhookOptions,
+ TelegrafOptions,
+} from 'telegraf/typings/telegraf';
export interface TelegrafModuleOptions {
token: string;
- options?: TelegrafOption;
- launchOptions?: TelegrafLaunchOption;
+ options?: TelegrafOptions;
+ launchOptions?: {
+ polling?: LaunchPollingOptions;
+ webhook?: LaunchWebhookOptions;
+ };
middlewares?: Middleware[];
}
diff --git a/lib/telegraf.types.ts b/lib/telegraf.types.ts
index 84019a5..4a6dc63 100644
--- a/lib/telegraf.types.ts
+++ b/lib/telegraf.types.ts
@@ -1,4 +1,4 @@
-import { Composer, Middleware, BaseScene, Telegraf } from 'telegraf';
+import { BaseScene, Composer, Middleware } from 'telegraf';
export type Filter = T extends []
? []
@@ -19,6 +19,3 @@ export type ComposerMethodArgs<
export type UpdateMethods = OnlyFunctionPropertyNames>;
export type SceneMethods = OnlyFunctionPropertyNames>;
-
-export type TelegrafOption = ConstructorParameters[1];
-export type TelegrafLaunchOption = Parameters['launch']>[0];
From 147e0c997b935c51774651dde9216a8dbbacda18 Mon Sep 17 00:00:00 2001
From: Alexander Bukhalo
Date: Sat, 2 Jan 2021 16:19:26 +0300
Subject: [PATCH 31/33] chore(deps): update lockfile on v2
---
package-lock.json | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 54659a1..7490ee2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "nestjs-telegraf",
- "version": "1.3.1",
+ "version": "2.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "version": "1.3.1",
+ "version": "2.0.0",
"license": "MIT",
"dependencies": {
- "telegraf": "3.38.0"
+ "telegraf": "^3.38.0"
},
"devDependencies": {
"@nestjs/common": "7.6.5",
From 2df4ddfee4e20b4ba67c8b8d4e1a8ee6b452650b Mon Sep 17 00:00:00 2001
From: Alexander Bukhalo
Date: Sat, 2 Jan 2021 16:34:27 +0300
Subject: [PATCH 32/33] fix(): revert back typescript configuration
---
index.d.ts | 1 +
index.js | 6 ++++++
index.ts | 1 +
tsconfig.json | 4 ++--
4 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 index.d.ts
create mode 100644 index.js
create mode 100644 index.ts
diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index 0000000..5703fb5
--- /dev/null
+++ b/index.d.ts
@@ -0,0 +1 @@
+export * from './dist';
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..9f5e27a
--- /dev/null
+++ b/index.js
@@ -0,0 +1,6 @@
+"use strict";
+function __export(m) {
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
+}
+exports.__esModule = true;
+__export(require("./dist"));
diff --git a/index.ts b/index.ts
new file mode 100644
index 0000000..5703fb5
--- /dev/null
+++ b/index.ts
@@ -0,0 +1 @@
+export * from './dist';
diff --git a/tsconfig.json b/tsconfig.json
index 921d963..bb13608 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,10 +9,10 @@
"experimentalDecorators": true,
"target": "es6",
"sourceMap": false,
- "baseUrl": "./",
"outDir": "./dist",
+ "rootDir": "./lib",
"skipLibCheck": true
},
- "include": ["lib/**/*", "sample/**/*"],
+ "include": ["lib/**/*", "../index.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
From 63fe457b584d6e106f1af9d8de349abff4f7c07f Mon Sep 17 00:00:00 2001
From: Alexander Bukhalo
Date: Sat, 2 Jan 2021 16:37:59 +0300
Subject: [PATCH 33/33] fix(): module work restored
---
lib/helpers/create-update-listener-decorator.helper.ts | 2 +-
lib/telegraf.providers.ts | 4 +++-
sample/app.update.ts | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/helpers/create-update-listener-decorator.helper.ts b/lib/helpers/create-update-listener-decorator.helper.ts
index 6c28eb2..a27f85b 100644
--- a/lib/helpers/create-update-listener-decorator.helper.ts
+++ b/lib/helpers/create-update-listener-decorator.helper.ts
@@ -5,7 +5,7 @@ import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
import { ListenerMetadata } from '../interfaces';
export function createUpdateListenerDecorator(
- method: Method,
+ method: unknown,
) {
return (
...args: ComposerMethodArgs, Method>
diff --git a/lib/telegraf.providers.ts b/lib/telegraf.providers.ts
index 399efe7..b13de54 100644
--- a/lib/telegraf.providers.ts
+++ b/lib/telegraf.providers.ts
@@ -7,7 +7,9 @@ export const TelegrafProvider = {
provide: Telegraf,
useFactory: (options: TelegrafModuleOptions) => {
const telegraf = new Telegraf(options.token, options.options);
- telegraf.use(...options.middlewares);
+ if (options.middlewares?.length > 0) {
+ telegraf.use(...options.middlewares);
+ }
return telegraf;
},
inject: [TELEGRAF_MODULE_OPTIONS],
diff --git a/sample/app.update.ts b/sample/app.update.ts
index 402e9fb..f3c5022 100644
--- a/sample/app.update.ts
+++ b/sample/app.update.ts
@@ -1,4 +1,4 @@
-import { SceneContext, Telegraf } from 'telegraf';
+import { Telegraf } from 'telegraf';
import { Command, Help, InjectBot, On, Start, Update } from '../lib';
import { EchoService } from './echo.service';
import { HELLO_SCENE_ID } from './app.constants';
@@ -8,7 +8,7 @@ import { Context } from './interfaces/context.interface';
export class AppUpdate {
constructor(
@InjectBot()
- private readonly bot: Telegraf,
+ private readonly bot: Telegraf, // TODO: fix any
private readonly echoService: EchoService,
) {}