chz-telegram-bot 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/builtin/helpAction.js +3 -6
  2. package/dist/dtos/chatHistoryMessage.js +1 -5
  3. package/dist/dtos/chatInfo.js +1 -5
  4. package/dist/dtos/commandTriggerCheckResult.js +1 -5
  5. package/dist/dtos/cooldownInfo.js +1 -5
  6. package/dist/dtos/incomingMessage.js +21 -25
  7. package/dist/dtos/incomingQuery.js +1 -5
  8. package/dist/dtos/messageInfo.js +1 -5
  9. package/dist/dtos/propertyProviderSets.js +1 -2
  10. package/dist/dtos/replyInfo.js +1 -5
  11. package/dist/dtos/responses/delay.js +3 -7
  12. package/dist/dtos/responses/imageMessage.js +3 -7
  13. package/dist/dtos/responses/inlineQueryResponse.js +3 -7
  14. package/dist/dtos/responses/reaction.js +3 -7
  15. package/dist/dtos/responses/textMessage.js +3 -7
  16. package/dist/dtos/responses/unpin.js +3 -7
  17. package/dist/dtos/responses/videoMessage.js +3 -7
  18. package/dist/dtos/userInfo.js +1 -5
  19. package/dist/entities/actions/commandAction.js +32 -39
  20. package/dist/entities/actions/inlineQueryAction.js +4 -8
  21. package/dist/entities/actions/replyCaptureAction.js +10 -14
  22. package/dist/entities/actions/scheduledAction.js +16 -23
  23. package/dist/entities/botInstance.js +13 -17
  24. package/dist/entities/cachedStateFactory.js +1 -5
  25. package/dist/entities/context/baseContext.d.ts +1 -1
  26. package/dist/entities/context/baseContext.d.ts.map +1 -1
  27. package/dist/entities/context/baseContext.js +1 -5
  28. package/dist/entities/context/chatContext.js +13 -17
  29. package/dist/entities/context/inlineQueryContext.js +4 -8
  30. package/dist/entities/context/messageContext.js +15 -19
  31. package/dist/entities/context/replyContext.js +15 -19
  32. package/dist/entities/states/actionStateBase.js +1 -5
  33. package/dist/entities/taskRecord.js +1 -5
  34. package/dist/eslint.config.d.ts +3 -0
  35. package/dist/eslint.config.d.ts.map +1 -0
  36. package/dist/eslint.config.js +51 -0
  37. package/dist/helpers/builders/commandActionBuilder.js +15 -20
  38. package/dist/helpers/builders/inlineQueryActionBuilder.js +5 -9
  39. package/dist/helpers/builders/scheduledActionBuilder.js +10 -15
  40. package/dist/helpers/mapUtils.js +2 -6
  41. package/dist/helpers/noop.js +1 -5
  42. package/dist/helpers/objectFromEntries.js +1 -5
  43. package/dist/helpers/timeConvertions.js +3 -8
  44. package/dist/helpers/toArray.js +1 -4
  45. package/dist/helpers/traceFactory.js +1 -4
  46. package/dist/index.d.ts +3 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +20 -41
  49. package/dist/main.js +5 -8
  50. package/dist/services/actionProcessingService.js +15 -19
  51. package/dist/services/actionProcessors/baseProcessor.js +1 -5
  52. package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
  53. package/dist/services/actionProcessors/commandActionProcessor.js +35 -38
  54. package/dist/services/actionProcessors/inlineQueryActionProcessor.js +7 -11
  55. package/dist/services/actionProcessors/scheduledActionProcessor.js +12 -19
  56. package/dist/services/jsonFileStorage.js +15 -19
  57. package/dist/services/jsonLogger.js +1 -5
  58. package/dist/services/nodeTimeoutScheduler.js +9 -13
  59. package/dist/services/responseProcessingQueue.js +3 -7
  60. package/dist/services/telegramApi.js +5 -9
  61. package/dist/types/action.js +1 -2
  62. package/dist/types/actionState.js +1 -2
  63. package/dist/types/cachedValueAccessor.js +1 -2
  64. package/dist/types/capture.js +1 -2
  65. package/dist/types/commandCondition.js +1 -2
  66. package/dist/types/commandTrigger.js +1 -2
  67. package/dist/types/externalAliases.js +1 -2
  68. package/dist/types/handlers.js +1 -2
  69. package/dist/types/inputFile.js +1 -2
  70. package/dist/types/logger.js +1 -2
  71. package/dist/types/messageSendingOptions.js +1 -2
  72. package/dist/types/messageTypes.js +17 -20
  73. package/dist/types/propertyProvider.js +1 -2
  74. package/dist/types/response.js +1 -4
  75. package/dist/types/scheduler.js +1 -2
  76. package/dist/types/storage.js +1 -2
  77. package/dist/types/timeValues.js +1 -2
  78. package/dist/types/trace.js +1 -2
  79. package/entities/botInstance.ts +1 -1
  80. package/entities/context/messageContext.ts +3 -3
  81. package/entities/context/replyContext.ts +3 -3
  82. package/{eslint.config.js → eslint.config.ts} +8 -5
  83. package/index.ts +3 -0
  84. package/package.json +2 -1
  85. package/services/actionProcessors/commandActionProcessor.ts +5 -6
  86. package/services/jsonFileStorage.ts +1 -1
  87. package/services/nodeTimeoutScheduler.ts +2 -2
  88. package/tsconfig.json +2 -2
  89. package/bun.lock +0 -301
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonFileStorage = void 0;
4
- const fs_1 = require("fs");
5
- const promises_1 = require("fs/promises");
6
- const async_sema_1 = require("async-sema");
7
- const mapUtils_1 = require("../helpers/mapUtils");
1
+ import { existsSync, mkdirSync } from 'fs';
2
+ import { readFile, writeFile } from 'fs/promises';
3
+ import { Sema as Semaphore } from 'async-sema';
4
+ import { getOrSetIfNotExists } from '../helpers/mapUtils';
8
5
  function buildPath(storagePath, botName, actionKey) {
9
6
  return `${storagePath}/${botName}/${actionKey.replaceAll(':', '/')}.json`;
10
7
  }
11
- class JsonFileStorage {
8
+ export class JsonFileStorage {
12
9
  filePaths = new Map();
13
10
  locks = new Map();
14
11
  cache;
@@ -18,13 +15,13 @@ class JsonFileStorage {
18
15
  this.cache = new Map();
19
16
  this.botName = botName;
20
17
  this.storagePath = path ?? 'storage';
21
- if (!(0, fs_1.existsSync)(`${this.storagePath}/${this.botName}/`)) {
22
- (0, fs_1.mkdirSync)(`${this.storagePath}/${this.botName}/`, {
18
+ if (!existsSync(`${this.storagePath}/${this.botName}/`)) {
19
+ mkdirSync(`${this.storagePath}/${this.botName}/`, {
23
20
  recursive: true
24
21
  });
25
22
  }
26
23
  for (const action of actions) {
27
- this.locks.set(action.key, new async_sema_1.Sema(1));
24
+ this.locks.set(action.key, new Semaphore(1));
28
25
  this.filePaths.set(action.key, buildPath(this.storagePath, this.botName, action.key));
29
26
  }
30
27
  }
@@ -32,12 +29,12 @@ class JsonFileStorage {
32
29
  for (const [stringKey, value] of Object.entries(data)) {
33
30
  if (value)
34
31
  continue;
35
- data[parseInt(stringKey)] = action.stateConstructor();
32
+ data[Number.parseInt(stringKey)] = action.stateConstructor();
36
33
  }
37
34
  return true;
38
35
  }
39
36
  async lock(key, action) {
40
- const lock = (0, mapUtils_1.getOrSetIfNotExists)(this.locks, key, new async_sema_1.Sema(1));
37
+ const lock = getOrSetIfNotExists(this.locks, key, new Semaphore(1));
41
38
  await lock.acquire();
42
39
  try {
43
40
  return await action();
@@ -50,8 +47,8 @@ class JsonFileStorage {
50
47
  return this.cache.get(key);
51
48
  }
52
49
  async loadFromFile(key) {
53
- const targetPath = (0, mapUtils_1.getOrSetIfNotExists)(this.filePaths, key, buildPath(this.storagePath, this.botName, key));
54
- const fileContent = await (0, promises_1.readFile)(targetPath, {
50
+ const targetPath = getOrSetIfNotExists(this.filePaths, key, buildPath(this.storagePath, this.botName, key));
51
+ const fileContent = await readFile(targetPath, {
55
52
  encoding: 'utf-8',
56
53
  flag: 'a+'
57
54
  });
@@ -63,8 +60,8 @@ class JsonFileStorage {
63
60
  }
64
61
  async updateCacheAndSaveToFile(data, key) {
65
62
  this.cache.set(key, data);
66
- const targetPath = (0, mapUtils_1.getOrSetIfNotExists)(this.filePaths, key, buildPath(this.storagePath, this.botName, key));
67
- await (0, promises_1.writeFile)(targetPath, JSON.stringify(data), { flag: 'w+' });
63
+ const targetPath = getOrSetIfNotExists(this.filePaths, key, buildPath(this.storagePath, this.botName, key));
64
+ await writeFile(targetPath, JSON.stringify(data), { flag: 'w+' });
68
65
  }
69
66
  async load(key) {
70
67
  return (this.tryGetFromCache(key) ??
@@ -74,7 +71,7 @@ class JsonFileStorage {
74
71
  }
75
72
  async saveMetadata(actions) {
76
73
  const targetPath = `${this.storagePath}/${this.botName}/Metadata-${this.botName}.json`;
77
- await (0, promises_1.writeFile)(targetPath, JSON.stringify(actions), {
74
+ await writeFile(targetPath, JSON.stringify(actions), {
78
75
  flag: 'w+'
79
76
  });
80
77
  }
@@ -110,4 +107,3 @@ class JsonFileStorage {
110
107
  });
111
108
  }
112
109
  }
113
- exports.JsonFileStorage = JsonFileStorage;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JsonLogger = void 0;
4
- class JsonLogger {
1
+ export class JsonLogger {
5
2
  serializeError(error) {
6
3
  if (error instanceof Error) {
7
4
  const plainObject = {
@@ -67,4 +64,3 @@ class JsonLogger {
67
64
  console.error(`{"botName":"${botName}","traceId":"${traceId}","chatName":"${chatName}","error":${this.serializeError(errorObj)}${dataString}}`);
68
65
  }
69
66
  }
70
- exports.JsonLogger = JsonLogger;
@@ -1,35 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeTimeoutScheduler = void 0;
4
- const taskRecord_1 = require("../entities/taskRecord");
5
- const traceFactory_1 = require("../helpers/traceFactory");
6
- class NodeTimeoutScheduler {
1
+ import { TaskRecord } from '../entities/taskRecord';
2
+ import { createTrace } from '../helpers/traceFactory';
3
+ export class NodeTimeoutScheduler {
7
4
  logger;
8
5
  activeTasks = [];
9
6
  constructor(logger) {
10
7
  this.logger = logger;
11
8
  }
12
9
  stopAll() {
13
- this.activeTasks.forEach((task) => {
10
+ for (const task of this.activeTasks) {
14
11
  clearInterval(task.taskId);
15
- });
12
+ }
16
13
  }
17
14
  createTask(name, action, interval, executeRightAway, ownerName) {
18
15
  const taskId = setInterval(action, interval);
19
- const task = new taskRecord_1.TaskRecord(name, taskId, interval);
16
+ const task = new TaskRecord(name, taskId, interval);
20
17
  if (executeRightAway) {
21
18
  setImmediate(action);
22
19
  }
23
- this.logger.logWithTraceId(ownerName, (0, traceFactory_1.createTrace)(this, ownerName, name), 'System', `Created task ${name}, that will run every ${interval}ms.`);
20
+ this.logger.logWithTraceId(ownerName, createTrace(this, ownerName, name), 'System', `Created task ${name}, that will run every ${interval}ms.`);
24
21
  this.activeTasks.push(task);
25
22
  }
26
23
  createOnetimeTask(name, action, delay, ownerName) {
27
24
  const actionWrapper = () => {
28
- this.logger.logWithTraceId(ownerName, (0, traceFactory_1.createTrace)(this, ownerName, name), 'System', `Executing delayed oneshot ${name}`);
25
+ this.logger.logWithTraceId(ownerName, createTrace(this, ownerName, name), 'System', `Executing delayed oneshot ${name}`);
29
26
  action();
30
27
  };
31
28
  setTimeout(actionWrapper, delay);
32
- this.logger.logWithTraceId(ownerName, (0, traceFactory_1.createTrace)(this, ownerName, name), 'System', `Created oneshot task ${name}, that will run in ${delay}ms.`);
29
+ this.logger.logWithTraceId(ownerName, createTrace(this, ownerName, name), 'System', `Created oneshot task ${name}, that will run in ${delay}ms.`);
33
30
  }
34
31
  }
35
- exports.NodeTimeoutScheduler = NodeTimeoutScheduler;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseProcessingQueue = void 0;
4
- const async_sema_1 = require("async-sema");
1
+ import { RateLimit } from 'async-sema';
5
2
  function notEmpty(arr) {
6
3
  return arr.length > 0;
7
4
  }
8
5
  const TELEGRAM_RATELIMIT_DELAY = 35;
9
- class ResponseProcessingQueue {
10
- rateLimiter = (0, async_sema_1.RateLimit)(1, { timeUnit: TELEGRAM_RATELIMIT_DELAY });
6
+ export class ResponseProcessingQueue {
7
+ rateLimiter = RateLimit(1, { timeUnit: TELEGRAM_RATELIMIT_DELAY });
11
8
  items = [];
12
9
  isFlushing = false;
13
10
  enqueue(item) {
@@ -38,4 +35,3 @@ class ResponseProcessingQueue {
38
35
  this.isFlushing = false;
39
36
  }
40
37
  }
41
- exports.ResponseProcessingQueue = ResponseProcessingQueue;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TelegramApiService = exports.TELEGRAM_ERROR_QUOTE_INVALID = void 0;
4
- const responseProcessingQueue_1 = require("./responseProcessingQueue");
5
- exports.TELEGRAM_ERROR_QUOTE_INVALID = 'QUOTE_TEXT_INVALID';
6
- class TelegramApiService {
7
- queue = new responseProcessingQueue_1.ResponseProcessingQueue();
1
+ import { ResponseProcessingQueue } from './responseProcessingQueue';
2
+ export const TELEGRAM_ERROR_QUOTE_INVALID = 'QUOTE_TEXT_INVALID';
3
+ export class TelegramApiService {
4
+ queue = new ResponseProcessingQueue();
8
5
  telegram;
9
6
  storage;
10
7
  logger;
@@ -35,7 +32,7 @@ class TelegramApiService {
35
32
  catch (error) {
36
33
  if ('message' in error) {
37
34
  const telegramResponse = error;
38
- if (telegramResponse.message.includes(exports.TELEGRAM_ERROR_QUOTE_INVALID)) {
35
+ if (telegramResponse.message.includes(TELEGRAM_ERROR_QUOTE_INVALID)) {
39
36
  scopedLogger.logWithTraceId('Quote error recieved, retrying without quote');
40
37
  try {
41
38
  await this.processResponse(response, true);
@@ -134,4 +131,3 @@ class TelegramApiService {
134
131
  }
135
132
  }
136
133
  }
137
- exports.TelegramApiService = TelegramApiService;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageType = exports.INTERNAL_MESSAGE_TYPE_PREFIX = void 0;
4
- exports.INTERNAL_MESSAGE_TYPE_PREFIX = `__msg:`;
5
- exports.MessageType = {
6
- Any: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Any`,
7
- Text: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Text`,
8
- Sticker: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Sticker`,
9
- Animation: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Animation`,
10
- Document: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Document`,
11
- Voice: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Voice`,
12
- Audio: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Audio`,
13
- LeftChatMember: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}LeftChatMember`,
14
- NewChatMember: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}NewChatMember`,
15
- Poll: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Poll`,
16
- Location: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Location`,
17
- Photo: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Photo`,
18
- Forward: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Forward`,
19
- Video: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Video`,
20
- Unknown: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Unknown`
1
+ export const INTERNAL_MESSAGE_TYPE_PREFIX = `__msg:`;
2
+ export const MessageType = {
3
+ Any: `${INTERNAL_MESSAGE_TYPE_PREFIX}Any`,
4
+ Text: `${INTERNAL_MESSAGE_TYPE_PREFIX}Text`,
5
+ Sticker: `${INTERNAL_MESSAGE_TYPE_PREFIX}Sticker`,
6
+ Animation: `${INTERNAL_MESSAGE_TYPE_PREFIX}Animation`,
7
+ Document: `${INTERNAL_MESSAGE_TYPE_PREFIX}Document`,
8
+ Voice: `${INTERNAL_MESSAGE_TYPE_PREFIX}Voice`,
9
+ Audio: `${INTERNAL_MESSAGE_TYPE_PREFIX}Audio`,
10
+ LeftChatMember: `${INTERNAL_MESSAGE_TYPE_PREFIX}LeftChatMember`,
11
+ NewChatMember: `${INTERNAL_MESSAGE_TYPE_PREFIX}NewChatMember`,
12
+ Poll: `${INTERNAL_MESSAGE_TYPE_PREFIX}Poll`,
13
+ Location: `${INTERNAL_MESSAGE_TYPE_PREFIX}Location`,
14
+ Photo: `${INTERNAL_MESSAGE_TYPE_PREFIX}Photo`,
15
+ Forward: `${INTERNAL_MESSAGE_TYPE_PREFIX}Forward`,
16
+ Video: `${INTERNAL_MESSAGE_TYPE_PREFIX}Video`,
17
+ Unknown: `${INTERNAL_MESSAGE_TYPE_PREFIX}Unknown`
21
18
  };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotResponseTypes = void 0;
4
- exports.BotResponseTypes = {
1
+ export const BotResponseTypes = {
5
2
  unpin: 'unpin',
6
3
  text: 'text',
7
4
  image: 'image',
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -93,6 +93,6 @@ export class BotInstance {
93
93
 
94
94
  this.scheduler.stopAll();
95
95
  await this.storage.close();
96
- await this.actionProcessingService.stop();
96
+ this.actionProcessingService.stop();
97
97
  }
98
98
  }
@@ -43,9 +43,9 @@ export class MessageContextInternal<
43
43
  private getQuotePart(quote: boolean | string) {
44
44
  if (typeof quote != 'boolean') return quote;
45
45
 
46
- return this.matchResults.length != 0
47
- ? this.matchResults[0][1]
48
- : this.messageInfo.text;
46
+ return this.matchResults.length == 0
47
+ ? this.messageInfo.text
48
+ : this.matchResults[0][1];
49
49
  }
50
50
 
51
51
  private replyWithText(
@@ -45,9 +45,9 @@ export class ReplyContextInternal<
45
45
  private getQuotePart(quote: boolean | string) {
46
46
  if (typeof quote != 'boolean') return quote;
47
47
 
48
- return this.matchResults.length != 0
49
- ? this.matchResults[0][1]
50
- : this.messageInfo.text;
48
+ return this.matchResults.length == 0
49
+ ? this.messageInfo.text
50
+ : this.matchResults[0][1];
51
51
  }
52
52
 
53
53
  private replyWithText(
@@ -3,18 +3,22 @@ import tseslint from 'typescript-eslint';
3
3
  import parser from '@typescript-eslint/parser';
4
4
 
5
5
  export default tseslint.config(
6
+ {
7
+ ignores: ['dist/**']
8
+ },
6
9
  eslint.configs.recommended,
7
10
  tseslint.configs.strictTypeChecked,
8
11
  {
9
12
  languageOptions: {
10
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11
13
  parser,
12
14
  parserOptions: {
13
15
  project: './tsconfig.json',
14
- tsconfigRootDir: import.meta.dirname,
15
- sourceType: 'module'
16
+ tsconfigRootDir: __dirname,
17
+ sourceType: 'module',
18
+ projectService: true
16
19
  }
17
20
  },
21
+ plugins: { '@typescript-eslint': tseslint.plugin },
18
22
  rules: {
19
23
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
20
24
  '@typescript-eslint/no-unused-vars': [
@@ -48,7 +52,6 @@ export default tseslint.config(
48
52
  ignoreStatic: true
49
53
  }
50
54
  ]
51
- },
52
- ignores: ['dist/*']
55
+ }
53
56
  }
54
57
  );
package/index.ts CHANGED
@@ -8,6 +8,9 @@ export * from './types/messageTypes';
8
8
  export * from './helpers/timeConvertions';
9
9
  export * from './types/action';
10
10
  export * from './types/externalAliases';
11
+ export * from './types/storage';
12
+ export * from './types/logger';
13
+ export * from './types/scheduler';
11
14
  export { CommandAction } from './entities/actions/commandAction';
12
15
  export { InlineQueryAction } from './entities/actions/inlineQueryAction';
13
16
  export { ReplyCaptureAction } from './entities/actions/replyCaptureAction';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "type": "git",
15
15
  "url": "https://github.com/AlexSolari/botFramework.git"
16
16
  },
17
- "version": "0.5.1",
17
+ "version": "0.5.2",
18
18
  "type": "module",
19
19
  "dependencies": {
20
20
  "async-sema": "^3.1.1",
@@ -27,6 +27,7 @@
27
27
  "@eslint/js": "^9.29.0",
28
28
  "@types/node": "^22.5.5",
29
29
  "eslint": "^9.29.0",
30
+ "jiti": "^2.6.1",
30
31
  "typescript": "^5.9.0-beta",
31
32
  "typescript-eslint": "^8.34.1"
32
33
  },
@@ -48,9 +48,8 @@ export class CommandActionProcessor extends BaseActionProcessor {
48
48
  if (msgType == MessageType.Text) {
49
49
  this.commands[msgType] = commands.filter(
50
50
  (cmd) =>
51
- cmd.triggers.find((x) => typeof x != 'string') !=
52
- undefined ||
53
- cmd.triggers.find(
51
+ cmd.triggers.some((x) => typeof x != 'string') ||
52
+ cmd.triggers.some(
54
53
  (x) =>
55
54
  typeof x == 'string' &&
56
55
  !x.startsWith(INTERNAL_MESSAGE_TYPE_PREFIX)
@@ -161,9 +160,9 @@ export class CommandActionProcessor extends BaseActionProcessor {
161
160
 
162
161
  const commandsToCheck = new Set(this.commands[msg.type]);
163
162
  if (msg.type != MessageType.Text && msg.text != '') {
164
- this.commands[MessageType.Text].forEach((x) =>
165
- commandsToCheck.add(x)
166
- );
163
+ for (const command of this.commands[MessageType.Text]) {
164
+ commandsToCheck.add(command);
165
+ }
167
166
  }
168
167
 
169
168
  for (const commandAction of commandsToCheck) {
@@ -48,7 +48,7 @@ export class JsonFileStorage implements IStorageClient {
48
48
  for (const [stringKey, value] of Object.entries(data)) {
49
49
  if (value) continue;
50
50
 
51
- data[parseInt(stringKey)] = action.stateConstructor();
51
+ data[Number.parseInt(stringKey)] = action.stateConstructor();
52
52
  }
53
53
 
54
54
  return true;
@@ -13,9 +13,9 @@ export class NodeTimeoutScheduler implements IScheduler {
13
13
  }
14
14
 
15
15
  stopAll() {
16
- this.activeTasks.forEach((task) => {
16
+ for (const task of this.activeTasks) {
17
17
  clearInterval(task.taskId);
18
- });
18
+ }
19
19
  }
20
20
 
21
21
  createTask(
package/tsconfig.json CHANGED
@@ -31,9 +31,9 @@
31
31
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
32
32
 
33
33
  /* Modules */
34
- "module": "commonjs" /* Specify what module code is generated. */,
34
+ "module": "esnext" /* Specify what module code is generated. */,
35
35
  // "rootDir": "./", /* Specify the root folder within your source files. */
36
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
36
+ "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
37
37
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
38
38
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
39
39
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */