chz-telegram-bot 0.7.12 → 0.7.13

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 (35) hide show
  1. package/dist/dtos/propertyProviderSets.d.ts +1 -0
  2. package/dist/dtos/propertyProviderSets.d.ts.map +1 -1
  3. package/dist/entities/actions/commandAction.d.ts +1 -1
  4. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  5. package/dist/entities/actions/commandAction.js +7 -7
  6. package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
  7. package/dist/entities/actions/inlineQueryAction.js +5 -5
  8. package/dist/entities/actions/replyCaptureAction.js +4 -4
  9. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  10. package/dist/entities/actions/scheduledAction.js +8 -8
  11. package/dist/entities/context/baseContext.d.ts +7 -4
  12. package/dist/entities/context/baseContext.d.ts.map +1 -1
  13. package/dist/entities/context/baseContext.js +5 -5
  14. package/dist/entities/context/chatContext.d.ts.map +1 -1
  15. package/dist/entities/context/chatContext.js +5 -5
  16. package/dist/entities/context/messageContext.js +4 -4
  17. package/dist/entities/context/replyContext.js +4 -4
  18. package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -1
  19. package/dist/helpers/builders/commandActionBuilder.js +3 -2
  20. package/dist/services/actionProcessors/baseProcessor.js +1 -1
  21. package/package.json +1 -1
  22. package/src/dtos/propertyProviderSets.ts +1 -0
  23. package/src/entities/actions/commandAction.ts +20 -15
  24. package/src/entities/actions/inlineQueryAction.ts +11 -8
  25. package/src/entities/actions/replyCaptureAction.ts +4 -4
  26. package/src/entities/actions/scheduledAction.ts +22 -16
  27. package/src/entities/context/baseContext.ts +12 -8
  28. package/src/entities/context/chatContext.ts +14 -7
  29. package/src/entities/context/messageContext.ts +4 -4
  30. package/src/entities/context/replyContext.ts +4 -4
  31. package/src/helpers/builders/commandActionBuilder.ts +3 -2
  32. package/src/services/actionProcessors/baseProcessor.ts +1 -1
  33. package/tests/entities/actions/inlineQueryAction.test.ts +12 -6
  34. package/tests/entities/actions/replyCaptureAction.test.ts +12 -6
  35. package/tests/entities/context/chatContext.test.ts +4 -2
@@ -7,6 +7,7 @@ export type CommandActionProviders = {
7
7
  chatsBlacklistProvider: CommandActionPropertyProvider<number[]>;
8
8
  chatsWhitelistProvider: CommandActionPropertyProvider<number[]>;
9
9
  usersWhitelistProvider: CommandActionPropertyProvider<number[]>;
10
+ maxAllowedSimultaniousExecutions: number;
10
11
  };
11
12
  export type ScheduledActionProviders = {
12
13
  timeinHoursProvider: ScheduledActionPropertyProvider<HoursOfDay>;
@@ -1 +1 @@
1
- {"version":3,"file":"propertyProviderSets.d.ts","sourceRoot":"","sources":["../../src/dtos/propertyProviderSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACH,6BAA6B,EAC7B,+BAA+B,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACjC,gBAAgB,EAAE,6BAA6B,CAAC,YAAY,CAAC,CAAC;IAC9D,gBAAgB,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACzD,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC,mBAAmB,EAAE,+BAA+B,CAAC,UAAU,CAAC,CAAC;IACjE,gBAAgB,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;IAC3D,sBAAsB,EAAE,+BAA+B,CAAC,MAAM,EAAE,CAAC,CAAC;CACrE,CAAC"}
1
+ {"version":3,"file":"propertyProviderSets.d.ts","sourceRoot":"","sources":["../../src/dtos/propertyProviderSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACH,6BAA6B,EAC7B,+BAA+B,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACjC,gBAAgB,EAAE,6BAA6B,CAAC,YAAY,CAAC,CAAC;IAC9D,gBAAgB,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACzD,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,sBAAsB,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,gCAAgC,EAAE,MAAM,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC,mBAAmB,EAAE,+BAA+B,CAAC,UAAU,CAAC,CAAC;IACjE,gBAAgB,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;IAC3D,sBAAsB,EAAE,+BAA+B,CAAC,MAAM,EAAE,CAAC,CAAC;CACrE,CAAC"}
@@ -23,7 +23,7 @@ export declare class CommandAction<TActionState extends IActionState> implements
23
23
  readonly stateConstructor: () => TActionState;
24
24
  readonly readmeFactory: (botName: string) => string;
25
25
  private lastCustomCooldown;
26
- constructor(trigger: CommandTrigger | CommandTrigger[], handler: CommandHandler<TActionState>, name: string, providers: CommandActionProviders, maxAllowedSimultaniousExecutions: number, condition: CommandCondition<TActionState>, stateConstructor: () => TActionState, readmeFactory: (botName: string) => string);
26
+ constructor(trigger: CommandTrigger | CommandTrigger[], handler: CommandHandler<TActionState>, name: string, providers: CommandActionProviders, condition: CommandCondition<TActionState>, stateConstructor: () => TActionState, readmeFactory: (botName: string) => string);
27
27
  exec(ctx: MessageContextInternal<TActionState>): Promise<BotResponse[]>;
28
28
  private checkIfShouldBeExecuted;
29
29
  private checkTrigger;
@@ -1 +1 @@
1
- {"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAO/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,qBAAa,aAAa,CACtB,YAAY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8C;IACnF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyC;IAC1E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IACF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IACF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IAEF,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,mBAAmB,yBAAgC;IAC5D,QAAQ,CAAC,gCAAgC,EAAE,MAAM,CAAC;IAElD,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAEpC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,C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C,uBAAuB;IA6D/B,OAAO,CAAC,YAAY;CAuCvB"}
@@ -25,7 +25,7 @@ export class CommandAction {
25
25
  stateConstructor;
26
26
  readmeFactory;
27
27
  lastCustomCooldown;
28
- constructor(trigger, handler, name, providers, maxAllowedSimultaniousExecutions, condition, stateConstructor, readmeFactory) {
28
+ constructor(trigger, handler, name, providers, condition, stateConstructor, readmeFactory) {
29
29
  this.triggers = toArray(trigger);
30
30
  this.name = name;
31
31
  this.cooldownInfoProvider = providers.cooldownProvider;
@@ -38,7 +38,7 @@ export class CommandAction {
38
38
  this.stateConstructor = stateConstructor;
39
39
  this.readmeFactory = readmeFactory;
40
40
  this.maxAllowedSimultaniousExecutions =
41
- maxAllowedSimultaniousExecutions;
41
+ providers.maxAllowedSimultaniousExecutions;
42
42
  this.key = `command:${this.name.replace('.', '-')}`;
43
43
  }
44
44
  async exec(ctx) {
@@ -57,17 +57,17 @@ export class CommandAction {
57
57
  const cooldownMessage = this.cooldownInfoProvider(ctx).message;
58
58
  return cooldownMessage
59
59
  ? [
60
- new TextMessage(cooldownMessage, ctx.chatInfo, ctx.traceId, this, new ReplyInfo(ctx.messageInfo.id))
60
+ new TextMessage(cooldownMessage, ctx.chatInfo, ctx.observability.traceId, this, new ReplyInfo(ctx.messageInfo.id))
61
61
  ]
62
62
  : Noop.NoResponse;
63
63
  }
64
64
  return Noop.NoResponse;
65
65
  }
66
- ctx.eventEmitter.emit(BotEventType.commandActionExecuting, {
66
+ ctx.observability.eventEmitter.emit(BotEventType.commandActionExecuting, {
67
67
  action: this,
68
68
  ctx,
69
69
  state,
70
- traceId: ctx.traceId
70
+ traceId: ctx.observability.traceId
71
71
  });
72
72
  ctx.matchResults = matchResults;
73
73
  await this.handler(ctx, state);
@@ -79,11 +79,11 @@ export class CommandAction {
79
79
  state.lastExecutedDate = moment().valueOf();
80
80
  }
81
81
  await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
82
- ctx.eventEmitter.emit(BotEventType.commandActionExecuted, {
82
+ ctx.observability.eventEmitter.emit(BotEventType.commandActionExecuted, {
83
83
  action: this,
84
84
  ctx,
85
85
  state,
86
- traceId: ctx.traceId
86
+ traceId: ctx.observability.traceId
87
87
  });
88
88
  return ctx.responses;
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAI5E,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACjE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,4BAA4B,CAAC,OAAO,CAAC,EACrD,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,0BAA0B;CAkD7C"}
1
+ {"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAI5E,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACjE,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,4BAA4B,CAAC,OAAO,CAAC,EACrD,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,0BAA0B;CAqD7C"}
@@ -36,19 +36,19 @@ export class InlineQueryAction {
36
36
  if (matchResults.length == 0)
37
37
  return Noop.NoResponse;
38
38
  ctx.matchResults = matchResults;
39
- ctx.eventEmitter.emit(BotEventType.inlineActionExecuting, {
39
+ ctx.observability.eventEmitter.emit(BotEventType.inlineActionExecuting, {
40
40
  action: this,
41
41
  ctx,
42
- traceId: ctx.traceId
42
+ traceId: ctx.observability.traceId
43
43
  });
44
44
  await this.handler(ctx);
45
- ctx.eventEmitter.emit(BotEventType.inlineActionExecuted, {
45
+ ctx.observability.eventEmitter.emit(BotEventType.inlineActionExecuted, {
46
46
  action: this,
47
47
  ctx,
48
- traceId: ctx.traceId
48
+ traceId: ctx.observability.traceId
49
49
  });
50
50
  return [
51
- new InlineQueryResponse(ctx.queryResults, ctx.queryId, ctx.traceId, ctx.action)
51
+ new InlineQueryResponse(ctx.queryResults, ctx.queryId, ctx.observability.traceId, ctx.action)
52
52
  ];
53
53
  }
54
54
  }
@@ -22,17 +22,17 @@ export class ReplyCaptureAction {
22
22
  .reduce((acc, curr) => acc.mergeWith(curr), CommandTriggerCheckResult.DoNotTrigger('Other'));
23
23
  if (!shouldExecute)
24
24
  return Noop.NoResponse;
25
- ctx.eventEmitter.emit(BotEventType.replyActionExecuting, {
25
+ ctx.observability.eventEmitter.emit(BotEventType.replyActionExecuting, {
26
26
  action: this,
27
27
  ctx,
28
- traceId: ctx.traceId
28
+ traceId: ctx.observability.traceId
29
29
  });
30
30
  ctx.matchResults = matchResults;
31
31
  await this.handler(ctx);
32
- ctx.eventEmitter.emit(BotEventType.replyActionExecuted, {
32
+ ctx.observability.eventEmitter.emit(BotEventType.replyActionExecuted, {
33
33
  action: this,
34
34
  ctx,
35
- traceId: ctx.traceId
35
+ traceId: ctx.observability.traceId
36
36
  });
37
37
  return ctx.responses;
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,qBAAa,eAAe,CACxB,YAAY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAgC;IAErD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA8C;IAClF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2C;IAC1E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IAEF,QAAQ,CAAC,WAAW,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AmB,CAA8C;IAClF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2C;IAC1E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IAEF,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG7C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACvC,SAAS,EAAE,wBAAwB,EACnC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAclC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,YAAY,CAAC;YAmDnC,cAAc;IA6D5B,OAAO,CAAC,uBAAuB;CAgBlC"}
@@ -33,20 +33,20 @@ export class ScheduledAction {
33
33
  const isAllowedToTrigger = this.checkIfShouldBeExecuted(state, ctx);
34
34
  if (!isAllowedToTrigger)
35
35
  return Noop.NoResponse;
36
- ctx.eventEmitter.emit(BotEventType.scheduledActionExecuting, {
36
+ ctx.observability.eventEmitter.emit(BotEventType.scheduledActionExecuting, {
37
37
  action: this,
38
38
  ctx,
39
39
  state,
40
- traceId: ctx.traceId
40
+ traceId: ctx.observability.traceId
41
41
  });
42
42
  await this.handler(ctx, (key) => this.getCachedValue(key, ctx), state);
43
43
  state.lastExecutedDate = moment().valueOf();
44
44
  await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
45
- ctx.eventEmitter.emit(BotEventType.scheduledActionExecuted, {
45
+ ctx.observability.eventEmitter.emit(BotEventType.scheduledActionExecuted, {
46
46
  action: this,
47
47
  ctx,
48
48
  state,
49
- traceId: ctx.traceId
49
+ traceId: ctx.observability.traceId
50
50
  });
51
51
  return ctx.responses;
52
52
  }
@@ -59,11 +59,11 @@ export class ScheduledAction {
59
59
  if (this.cachedState.has(key)) {
60
60
  return this.cachedState.get(key);
61
61
  }
62
- ctx.eventEmitter.emit(BotEventType.scheduledActionCacheValueCreating, {
62
+ ctx.observability.eventEmitter.emit(BotEventType.scheduledActionCacheValueCreating, {
63
63
  action: this,
64
64
  ctx,
65
65
  key,
66
- traceId: ctx.traceId
66
+ traceId: ctx.observability.traceId
67
67
  });
68
68
  const value = await cachedItemFactory.getValue();
69
69
  this.cachedState.set(key, value);
@@ -71,11 +71,11 @@ export class ScheduledAction {
71
71
  return value;
72
72
  }
73
73
  finally {
74
- ctx.eventEmitter.emit(BotEventType.scheduledActionCacheValueReturned, {
74
+ ctx.observability.eventEmitter.emit(BotEventType.scheduledActionCacheValueReturned, {
75
75
  action: this,
76
76
  ctx,
77
77
  key,
78
- traceId: ctx.traceId
78
+ traceId: ctx.observability.traceId
79
79
  });
80
80
  semaphore.release();
81
81
  }
@@ -7,7 +7,7 @@ import { BotResponse, IReplyResponse } from '../../types/response';
7
7
  import { IScheduler } from '../../types/scheduler';
8
8
  import { IStorageClient } from '../../types/storage';
9
9
  import { TraceId } from '../../types/trace';
10
- export type BaseContextPropertiesToOmit = 'action' | 'isInitialized' | 'storage' | 'scheduler' | 'eventEmitter' | 'responses' | 'traceId';
10
+ export type BaseContextPropertiesToOmit = 'action' | 'isInitialized' | 'storage' | 'scheduler' | 'responses';
11
11
  export declare abstract class BaseContextInternal<TAction extends IAction> {
12
12
  readonly responses: BotResponse[];
13
13
  readonly action: TAction;
@@ -15,13 +15,16 @@ export declare abstract class BaseContextInternal<TAction extends IAction> {
15
15
  readonly storage: IStorageClient;
16
16
  /** Scheduler instance for the bot executing this action */
17
17
  readonly scheduler: IScheduler;
18
- readonly eventEmitter: TypedEventEmitter;
19
- /** Trace id of a action execution. */
20
- readonly traceId: TraceId;
21
18
  /** Name of a bot that executes this action. */
22
19
  readonly botName: string;
23
20
  /** Chat information. */
24
21
  readonly chatInfo: ChatInfo;
22
+ readonly observability: {
23
+ /** Event emitter for emitting events related to action execution. */
24
+ eventEmitter: TypedEventEmitter;
25
+ /** Trace id of a action execution. */
26
+ traceId: TraceId;
27
+ };
25
28
  get actionKey(): import("../..").ActionKey;
26
29
  constructor(storage: IStorageClient, scheduler: IScheduler, eventEmitter: TypedEventEmitter, action: TAction, chatInfo: ChatInfo, traceId: TraceId, botName: string);
27
30
  protected createCaptureController(response: IReplyResponse): ICaptureController;
@@ -1 +1 @@
1
- {"version":3,"file":"baseContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/baseContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,MAAM,MAAM,2BAA2B,GACjC,QAAQ,GACR,eAAe,GACf,SAAS,GACT,WAAW,GACX,cAAc,GACd,WAAW,GACX,SAAS,CAAC;AAEhB,8BAAsB,mBAAmB,CAAC,OAAO,SAAS,OAAO;IAC7D,QAAQ,CAAC,SAAS,EAAE,WAAW,EAAE,CAAM;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,2DAA2D;IAC3D,Q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AAC,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC;CAI9D"}
@@ -5,24 +5,24 @@ export class BaseContextInternal {
5
5
  storage;
6
6
  /** Scheduler instance for the bot executing this action */
7
7
  scheduler;
8
- eventEmitter;
9
- /** Trace id of a action execution. */
10
- traceId;
11
8
  /** Name of a bot that executes this action. */
12
9
  botName;
13
10
  /** Chat information. */
14
11
  chatInfo;
12
+ observability;
15
13
  get actionKey() {
16
14
  return this.action.key;
17
15
  }
18
16
  constructor(storage, scheduler, eventEmitter, action, chatInfo, traceId, botName) {
19
17
  this.storage = storage;
20
18
  this.scheduler = scheduler;
21
- this.eventEmitter = eventEmitter;
22
19
  this.botName = botName;
23
20
  this.action = action;
24
21
  this.chatInfo = chatInfo;
25
- this.traceId = traceId;
22
+ this.observability = {
23
+ eventEmitter,
24
+ traceId
25
+ };
26
26
  }
27
27
  createCaptureController(response) {
28
28
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,WAAW,CACnB,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,IAC9E,IAAI,CACJ,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,EAC1C,2BAA2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AAQ,mBAAmB,CAAC,OAAO,CAAC;IAClC;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAexD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;QAerD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;MAcvD;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAU3B"}
@@ -20,7 +20,7 @@ export class ChatContextInternal extends BaseContextInternal {
20
20
  * @param options Message sending option.
21
21
  */
22
22
  text: (text, options) => {
23
- const response = new TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
23
+ const response = new TextMessage(text, this.chatInfo, this.observability.traceId, this.action, undefined, options);
24
24
  this.responses.push(response);
25
25
  return this.createCaptureController(response);
26
26
  },
@@ -31,7 +31,7 @@ export class ChatContextInternal extends BaseContextInternal {
31
31
  * @param options Message sending option.
32
32
  */
33
33
  image: (name, options) => {
34
- const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
34
+ const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action, undefined, options);
35
35
  this.responses.push(response);
36
36
  return this.createCaptureController(response);
37
37
  },
@@ -42,7 +42,7 @@ export class ChatContextInternal extends BaseContextInternal {
42
42
  * @param options Message sending option.
43
43
  */
44
44
  video: (name, options) => {
45
- const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
45
+ const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action, undefined, options);
46
46
  this.responses.push(response);
47
47
  return this.createCaptureController(response);
48
48
  }
@@ -53,13 +53,13 @@ export class ChatContextInternal extends BaseContextInternal {
53
53
  * @param messageId Message id.
54
54
  */
55
55
  unpinMessage(messageId) {
56
- this.responses.push(new UnpinResponse(messageId, this.chatInfo, this.traceId, this.action));
56
+ this.responses.push(new UnpinResponse(messageId, this.chatInfo, this.observability.traceId, this.action));
57
57
  }
58
58
  /**
59
59
  * Delays next responses by specified amount of time.
60
60
  * @param delay Delay in milliseconds.
61
61
  */
62
62
  wait(delay) {
63
- this.responses.push(new DelayResponse(delay, this.chatInfo, this.traceId, this.action));
63
+ this.responses.push(new DelayResponse(delay, this.chatInfo, this.observability.traceId, this.action));
64
64
  }
65
65
  }
@@ -39,19 +39,19 @@ export class MessageContextInternal extends ChatContextInternal {
39
39
  }
40
40
  replyWithText(text, quote, options) {
41
41
  const quotedPart = this.getQuotePart(quote);
42
- const response = new TextMessage(text, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
42
+ const response = new TextMessage(text, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
43
43
  this.responses.push(response);
44
44
  return this.createCaptureController(response);
45
45
  }
46
46
  replyWithImage(name, quote, options) {
47
47
  const quotedPart = this.getQuotePart(quote);
48
- const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
48
+ const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
49
49
  this.responses.push(response);
50
50
  return this.createCaptureController(response);
51
51
  }
52
52
  replyWithVideo(name, quote, options) {
53
53
  const quotedPart = this.getQuotePart(quote);
54
- const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
54
+ const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
55
55
  this.responses.push(response);
56
56
  return this.createCaptureController(response);
57
57
  }
@@ -120,7 +120,7 @@ export class MessageContextInternal extends ChatContextInternal {
120
120
  * @param emoji Telegram emoji to react with.
121
121
  */
122
122
  withReaction: (emoji) => {
123
- this.responses.push(new Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
123
+ this.responses.push(new Reaction(this.observability.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
124
124
  }
125
125
  };
126
126
  }
@@ -35,19 +35,19 @@ export class ReplyContextInternal extends BaseContextInternal {
35
35
  }
36
36
  replyWithText(text, quote, options) {
37
37
  const quotedPart = this.getQuotePart(quote);
38
- const response = new TextMessage(text, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
38
+ const response = new TextMessage(text, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
39
39
  this.responses.push(response);
40
40
  return this.createCaptureController(response);
41
41
  }
42
42
  replyWithImage(name, quote, options) {
43
43
  const quotedPart = this.getQuotePart(quote);
44
- const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
44
+ const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
45
45
  this.responses.push(response);
46
46
  return this.createCaptureController(response);
47
47
  }
48
48
  replyWithVideo(name, quote, options) {
49
49
  const quotedPart = this.getQuotePart(quote);
50
- const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
50
+ const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
51
51
  this.responses.push(response);
52
52
  return this.createCaptureController(response);
53
53
  }
@@ -127,7 +127,7 @@ export class ReplyContextInternal extends BaseContextInternal {
127
127
  * @param emoji Telegram emoji to react with.
128
128
  */
129
129
  withReaction: (emoji) => {
130
- this.responses.push(new Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
130
+ this.responses.push(new Reaction(this.observability.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
131
131
  }
132
132
  };
133
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"commandActionBuilder.d.ts","sourceRoot":"","sources":["../../../src/helpers/builders/commandActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;GAEG;AACH,qBAAa,6BAA6B,CAAC,YAAY,SAAS,YAAY;IACxE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAyC;IAExD,OAAO,CAAC,cAAc,CAAsD;IAC5E,OAAO,CAAC,wBAAwB,CACS;IACzC,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,oBAAoB,CACf;IAEb,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IACtD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BAAa,oBAAqB,SAAQ,6BAA6B,CAAC,eAAe,CAAC;IACpF;;OAEG;gBACS,IAAI,EAAE,MAAM;CAG3B"}
@@ -129,8 +129,9 @@ export class CommandActionBuilderWithState {
129
129
  isActiveProvider: this.activeProvider,
130
130
  chatsBlacklistProvider: this.blacklistProvider,
131
131
  chatsWhitelistProvider: this.whitelistProvider,
132
- usersWhitelistProvider: this.allowedUsersProvider
133
- }, this.maxAllowedSimultaniousExecutions, this.condition, this.stateConstructor, this.readmeFactory);
132
+ usersWhitelistProvider: this.allowedUsersProvider,
133
+ maxAllowedSimultaniousExecutions: this.maxAllowedSimultaniousExecutions
134
+ }, this.condition, this.stateConstructor, this.readmeFactory);
134
135
  }
135
136
  }
136
137
  /**
@@ -15,7 +15,7 @@ export class BaseActionProcessor {
15
15
  console.error(error);
16
16
  this.eventEmitter.emit(BotEventType.error, {
17
17
  error,
18
- traceId: ctx.traceId
18
+ traceId: ctx.observability.traceId
19
19
  });
20
20
  }
21
21
  initializeDependencies(api) {
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.7.12",
17
+ "version": "0.7.13",
18
18
  "type": "module",
19
19
  "dependencies": {
20
20
  "async-sema": "^3.1.1",
@@ -11,6 +11,7 @@ export type CommandActionProviders = {
11
11
  chatsBlacklistProvider: CommandActionPropertyProvider<number[]>;
12
12
  chatsWhitelistProvider: CommandActionPropertyProvider<number[]>;
13
13
  usersWhitelistProvider: CommandActionPropertyProvider<number[]>;
14
+ maxAllowedSimultaniousExecutions: number;
14
15
  };
15
16
 
16
17
  export type ScheduledActionProviders = {
@@ -55,7 +55,6 @@ export class CommandAction<
55
55
  handler: CommandHandler<TActionState>,
56
56
  name: string,
57
57
  providers: CommandActionProviders,
58
- maxAllowedSimultaniousExecutions: number,
59
58
  condition: CommandCondition<TActionState>,
60
59
  stateConstructor: () => TActionState,
61
60
  readmeFactory: (botName: string) => string
@@ -75,7 +74,7 @@ export class CommandAction<
75
74
  this.readmeFactory = readmeFactory;
76
75
 
77
76
  this.maxAllowedSimultaniousExecutions =
78
- maxAllowedSimultaniousExecutions;
77
+ providers.maxAllowedSimultaniousExecutions;
79
78
 
80
79
  this.key = `command:${this.name.replace('.', '-')}` as ActionKey;
81
80
  }
@@ -118,7 +117,7 @@ export class CommandAction<
118
117
  new TextMessage(
119
118
  cooldownMessage,
120
119
  ctx.chatInfo,
121
- ctx.traceId,
120
+ ctx.observability.traceId,
122
121
  this,
123
122
  new ReplyInfo(ctx.messageInfo.id)
124
123
  )
@@ -129,12 +128,15 @@ export class CommandAction<
129
128
  return Noop.NoResponse;
130
129
  }
131
130
 
132
- ctx.eventEmitter.emit(BotEventType.commandActionExecuting, {
133
- action: this,
134
- ctx,
135
- state,
136
- traceId: ctx.traceId
137
- });
131
+ ctx.observability.eventEmitter.emit(
132
+ BotEventType.commandActionExecuting,
133
+ {
134
+ action: this,
135
+ ctx,
136
+ state,
137
+ traceId: ctx.observability.traceId
138
+ }
139
+ );
138
140
  ctx.matchResults = matchResults;
139
141
 
140
142
  await this.handler(ctx, state);
@@ -155,12 +157,15 @@ export class CommandAction<
155
157
  state
156
158
  );
157
159
 
158
- ctx.eventEmitter.emit(BotEventType.commandActionExecuted, {
159
- action: this,
160
- ctx,
161
- state,
162
- traceId: ctx.traceId
163
- });
160
+ ctx.observability.eventEmitter.emit(
161
+ BotEventType.commandActionExecuted,
162
+ {
163
+ action: this,
164
+ ctx,
165
+ state,
166
+ traceId: ctx.observability.traceId
167
+ }
168
+ );
164
169
  return ctx.responses;
165
170
  } finally {
166
171
  lock?.release();
@@ -55,24 +55,27 @@ export class InlineQueryAction implements IAction {
55
55
 
56
56
  ctx.matchResults = matchResults;
57
57
 
58
- ctx.eventEmitter.emit(BotEventType.inlineActionExecuting, {
59
- action: this,
60
- ctx,
61
- traceId: ctx.traceId
62
- });
58
+ ctx.observability.eventEmitter.emit(
59
+ BotEventType.inlineActionExecuting,
60
+ {
61
+ action: this,
62
+ ctx,
63
+ traceId: ctx.observability.traceId
64
+ }
65
+ );
63
66
 
64
67
  await this.handler(ctx);
65
68
 
66
- ctx.eventEmitter.emit(BotEventType.inlineActionExecuted, {
69
+ ctx.observability.eventEmitter.emit(BotEventType.inlineActionExecuted, {
67
70
  action: this,
68
71
  ctx,
69
- traceId: ctx.traceId
72
+ traceId: ctx.observability.traceId
70
73
  });
71
74
  return [
72
75
  new InlineQueryResponse(
73
76
  ctx.queryResults,
74
77
  ctx.queryId,
75
- ctx.traceId,
78
+ ctx.observability.traceId,
76
79
  ctx.action
77
80
  )
78
81
  ];
@@ -46,19 +46,19 @@ export class ReplyCaptureAction<
46
46
 
47
47
  if (!shouldExecute) return Noop.NoResponse;
48
48
 
49
- ctx.eventEmitter.emit(BotEventType.replyActionExecuting, {
49
+ ctx.observability.eventEmitter.emit(BotEventType.replyActionExecuting, {
50
50
  action: this,
51
51
  ctx,
52
- traceId: ctx.traceId
52
+ traceId: ctx.observability.traceId
53
53
  });
54
54
  ctx.matchResults = matchResults;
55
55
 
56
56
  await this.handler(ctx);
57
57
 
58
- ctx.eventEmitter.emit(BotEventType.replyActionExecuted, {
58
+ ctx.observability.eventEmitter.emit(BotEventType.replyActionExecuted, {
59
59
  action: this,
60
60
  ctx,
61
- traceId: ctx.traceId
61
+ traceId: ctx.observability.traceId
62
62
  });
63
63
  return ctx.responses;
64
64
  }
@@ -66,12 +66,15 @@ export class ScheduledAction<
66
66
  const isAllowedToTrigger = this.checkIfShouldBeExecuted(state, ctx);
67
67
  if (!isAllowedToTrigger) return Noop.NoResponse;
68
68
 
69
- ctx.eventEmitter.emit(BotEventType.scheduledActionExecuting, {
70
- action: this,
71
- ctx,
72
- state,
73
- traceId: ctx.traceId
74
- });
69
+ ctx.observability.eventEmitter.emit(
70
+ BotEventType.scheduledActionExecuting,
71
+ {
72
+ action: this,
73
+ ctx,
74
+ state,
75
+ traceId: ctx.observability.traceId
76
+ }
77
+ );
75
78
 
76
79
  await this.handler(
77
80
  ctx,
@@ -87,12 +90,15 @@ export class ScheduledAction<
87
90
  state
88
91
  );
89
92
 
90
- ctx.eventEmitter.emit(BotEventType.scheduledActionExecuted, {
91
- action: this,
92
- ctx,
93
- state,
94
- traceId: ctx.traceId
95
- });
93
+ ctx.observability.eventEmitter.emit(
94
+ BotEventType.scheduledActionExecuted,
95
+ {
96
+ action: this,
97
+ ctx,
98
+ state,
99
+ traceId: ctx.observability.traceId
100
+ }
101
+ );
96
102
  return ctx.responses;
97
103
  }
98
104
 
@@ -120,13 +126,13 @@ export class ScheduledAction<
120
126
  return this.cachedState.get(key) as TResult;
121
127
  }
122
128
 
123
- ctx.eventEmitter.emit(
129
+ ctx.observability.eventEmitter.emit(
124
130
  BotEventType.scheduledActionCacheValueCreating,
125
131
  {
126
132
  action: this,
127
133
  ctx,
128
134
  key,
129
- traceId: ctx.traceId
135
+ traceId: ctx.observability.traceId
130
136
  }
131
137
  );
132
138
  const value = await cachedItemFactory.getValue();
@@ -144,13 +150,13 @@ export class ScheduledAction<
144
150
 
145
151
  return value as TResult;
146
152
  } finally {
147
- ctx.eventEmitter.emit(
153
+ ctx.observability.eventEmitter.emit(
148
154
  BotEventType.scheduledActionCacheValueReturned,
149
155
  {
150
156
  action: this,
151
157
  ctx,
152
158
  key,
153
- traceId: ctx.traceId
159
+ traceId: ctx.observability.traceId
154
160
  }
155
161
  );
156
162
  semaphore.release();
@@ -15,9 +15,7 @@ export type BaseContextPropertiesToOmit =
15
15
  | 'isInitialized'
16
16
  | 'storage'
17
17
  | 'scheduler'
18
- | 'eventEmitter'
19
- | 'responses'
20
- | 'traceId';
18
+ | 'responses';
21
19
 
22
20
  export abstract class BaseContextInternal<TAction extends IAction> {
23
21
  readonly responses: BotResponse[] = [];
@@ -26,14 +24,18 @@ export abstract class BaseContextInternal<TAction extends IAction> {
26
24
  readonly storage: IStorageClient;
27
25
  /** Scheduler instance for the bot executing this action */
28
26
  readonly scheduler: IScheduler;
29
- readonly eventEmitter: TypedEventEmitter;
30
- /** Trace id of a action execution. */
31
- readonly traceId: TraceId;
32
27
  /** Name of a bot that executes this action. */
33
28
  readonly botName: string;
34
29
  /** Chat information. */
35
30
  readonly chatInfo: ChatInfo;
36
31
 
32
+ readonly observability: {
33
+ /** Event emitter for emitting events related to action execution. */
34
+ eventEmitter: TypedEventEmitter;
35
+ /** Trace id of a action execution. */
36
+ traceId: TraceId;
37
+ };
38
+
37
39
  get actionKey() {
38
40
  return this.action.key;
39
41
  }
@@ -49,11 +51,13 @@ export abstract class BaseContextInternal<TAction extends IAction> {
49
51
  ) {
50
52
  this.storage = storage;
51
53
  this.scheduler = scheduler;
52
- this.eventEmitter = eventEmitter;
53
54
  this.botName = botName;
54
55
  this.action = action;
55
56
  this.chatInfo = chatInfo;
56
- this.traceId = traceId;
57
+ this.observability = {
58
+ eventEmitter,
59
+ traceId
60
+ };
57
61
  }
58
62
 
59
63
  protected createCaptureController(
@@ -19,7 +19,8 @@ import { ScheduledAction } from '../actions/scheduledAction';
19
19
 
20
20
  export type ChatContext<
21
21
  TActionState extends IActionState,
22
- TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>
22
+ TAction extends IActionWithState<TActionState> =
23
+ ScheduledAction<TActionState>
23
24
  > = Omit<
24
25
  ChatContextInternal<TActionState, TAction>,
25
26
  BaseContextPropertiesToOmit
@@ -30,7 +31,8 @@ export type ChatContext<
30
31
  */
31
32
  export class ChatContextInternal<
32
33
  TActionState extends IActionState,
33
- TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>
34
+ TAction extends IActionWithState<TActionState> =
35
+ ScheduledAction<TActionState>
34
36
  > extends BaseContextInternal<TAction> {
35
37
  /**
36
38
  * Collection of actions that send something to chat as a standalone message.
@@ -46,7 +48,7 @@ export class ChatContextInternal<
46
48
  const response = new TextMessage(
47
49
  text,
48
50
  this.chatInfo,
49
- this.traceId,
51
+ this.observability.traceId,
50
52
  this.action,
51
53
  undefined,
52
54
  options
@@ -67,7 +69,7 @@ export class ChatContextInternal<
67
69
  const response = new ImageMessage(
68
70
  { source: resolve(`./content/${name}.png`) },
69
71
  this.chatInfo,
70
- this.traceId,
72
+ this.observability.traceId,
71
73
  this.action,
72
74
  undefined,
73
75
  options
@@ -88,7 +90,7 @@ export class ChatContextInternal<
88
90
  const response = new VideoMessage(
89
91
  { source: resolve(`./content/${name}.mp4`) },
90
92
  this.chatInfo,
91
- this.traceId,
93
+ this.observability.traceId,
92
94
  this.action,
93
95
  undefined,
94
96
  options
@@ -110,7 +112,7 @@ export class ChatContextInternal<
110
112
  new UnpinResponse(
111
113
  messageId,
112
114
  this.chatInfo,
113
- this.traceId,
115
+ this.observability.traceId,
114
116
  this.action
115
117
  )
116
118
  );
@@ -122,7 +124,12 @@ export class ChatContextInternal<
122
124
  */
123
125
  wait(delay: Milliseconds) {
124
126
  this.responses.push(
125
- new DelayResponse(delay, this.chatInfo, this.traceId, this.action)
127
+ new DelayResponse(
128
+ delay,
129
+ this.chatInfo,
130
+ this.observability.traceId,
131
+ this.action
132
+ )
126
133
  );
127
134
  }
128
135
  }
@@ -97,7 +97,7 @@ export class MessageContextInternal<
97
97
  const response = new TextMessage(
98
98
  text,
99
99
  this.chatInfo,
100
- this.traceId,
100
+ this.observability.traceId,
101
101
  this.action,
102
102
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
103
103
  options
@@ -118,7 +118,7 @@ export class MessageContextInternal<
118
118
  const response = new ImageMessage(
119
119
  { source: resolve(`./content/${name}.png`) },
120
120
  this.chatInfo,
121
- this.traceId,
121
+ this.observability.traceId,
122
122
  this.action,
123
123
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
124
124
  options
@@ -139,7 +139,7 @@ export class MessageContextInternal<
139
139
  const response = new VideoMessage(
140
140
  { source: resolve(`./content/${name}.mp4`) },
141
141
  this.chatInfo,
142
- this.traceId,
142
+ this.observability.traceId,
143
143
  this.action,
144
144
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
145
145
  options
@@ -238,7 +238,7 @@ export class MessageContextInternal<
238
238
  withReaction: (emoji: TelegramEmoji) => {
239
239
  this.responses.push(
240
240
  new Reaction(
241
- this.traceId,
241
+ this.observability.traceId,
242
242
  this.chatInfo,
243
243
  this.messageInfo.id,
244
244
  emoji,
@@ -100,7 +100,7 @@ export class ReplyContextInternal<
100
100
  const response = new TextMessage(
101
101
  text,
102
102
  this.chatInfo,
103
- this.traceId,
103
+ this.observability.traceId,
104
104
  this.action,
105
105
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
106
106
  options
@@ -121,7 +121,7 @@ export class ReplyContextInternal<
121
121
  const response = new ImageMessage(
122
122
  { source: resolve(`./content/${name}.png`) },
123
123
  this.chatInfo,
124
- this.traceId,
124
+ this.observability.traceId,
125
125
  this.action,
126
126
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
127
127
  options
@@ -142,7 +142,7 @@ export class ReplyContextInternal<
142
142
  const response = new VideoMessage(
143
143
  { source: resolve(`./content/${name}.mp4`) },
144
144
  this.chatInfo,
145
- this.traceId,
145
+ this.observability.traceId,
146
146
  this.action,
147
147
  new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined),
148
148
  options
@@ -248,7 +248,7 @@ export class ReplyContextInternal<
248
248
  withReaction: (emoji: TelegramEmoji) => {
249
249
  this.responses.push(
250
250
  new Reaction(
251
- this.traceId,
251
+ this.observability.traceId,
252
252
  this.chatInfo,
253
253
  this.messageInfo.id,
254
254
  emoji,
@@ -182,9 +182,10 @@ export class CommandActionBuilderWithState<TActionState extends IActionState> {
182
182
  isActiveProvider: this.activeProvider,
183
183
  chatsBlacklistProvider: this.blacklistProvider,
184
184
  chatsWhitelistProvider: this.whitelistProvider,
185
- usersWhitelistProvider: this.allowedUsersProvider
185
+ usersWhitelistProvider: this.allowedUsersProvider,
186
+ maxAllowedSimultaniousExecutions:
187
+ this.maxAllowedSimultaniousExecutions
186
188
  },
187
- this.maxAllowedSimultaniousExecutions,
188
189
  this.condition,
189
190
  this.stateConstructor,
190
191
  this.readmeFactory
@@ -34,7 +34,7 @@ export abstract class BaseActionProcessor {
34
34
  console.error(error);
35
35
  this.eventEmitter.emit(BotEventType.error, {
36
36
  error,
37
- traceId: ctx.traceId
37
+ traceId: ctx.observability.traceId
38
38
  });
39
39
  }
40
40
 
@@ -243,9 +243,12 @@ describe('InlineQueryAction', () => {
243
243
  );
244
244
 
245
245
  const ctx = createMockInlineContext('test query');
246
- ctx.eventEmitter.on(BotEventType.inlineActionExecuting, () => {
247
- events.push('executing');
248
- });
246
+ ctx.observability.eventEmitter.on(
247
+ BotEventType.inlineActionExecuting,
248
+ () => {
249
+ events.push('executing');
250
+ }
251
+ );
249
252
 
250
253
  await action.exec(ctx);
251
254
 
@@ -266,9 +269,12 @@ describe('InlineQueryAction', () => {
266
269
  );
267
270
 
268
271
  const ctx = createMockInlineContext('test query');
269
- ctx.eventEmitter.on(BotEventType.inlineActionExecuted, () => {
270
- events.push('executed');
271
- });
272
+ ctx.observability.eventEmitter.on(
273
+ BotEventType.inlineActionExecuted,
274
+ () => {
275
+ events.push('executed');
276
+ }
277
+ );
272
278
 
273
279
  await action.exec(ctx);
274
280
 
@@ -342,9 +342,12 @@ describe('ReplyCaptureAction', () => {
342
342
  );
343
343
 
344
344
  const ctx = createMockReplyContext(123, 'yes');
345
- ctx.eventEmitter.on(BotEventType.replyActionExecuting, () => {
346
- events.push('executing');
347
- });
345
+ ctx.observability.eventEmitter.on(
346
+ BotEventType.replyActionExecuting,
347
+ () => {
348
+ events.push('executing');
349
+ }
350
+ );
348
351
 
349
352
  await action.exec(ctx);
350
353
 
@@ -366,9 +369,12 @@ describe('ReplyCaptureAction', () => {
366
369
  );
367
370
 
368
371
  const ctx = createMockReplyContext(123, 'yes');
369
- ctx.eventEmitter.on(BotEventType.replyActionExecuted, () => {
370
- events.push('executed');
371
- });
372
+ ctx.observability.eventEmitter.on(
373
+ BotEventType.replyActionExecuted,
374
+ () => {
375
+ events.push('executed');
376
+ }
377
+ );
372
378
 
373
379
  await action.exec(ctx);
374
380
 
@@ -90,7 +90,9 @@ describe('ChatContextInternal', () => {
90
90
  test('should set eventEmitter', () => {
91
91
  const ctx = createChatContext();
92
92
 
93
- expect(ctx.eventEmitter).toBeInstanceOf(TypedEventEmitter);
93
+ expect(ctx.observability.eventEmitter).toBeInstanceOf(
94
+ TypedEventEmitter
95
+ );
94
96
  });
95
97
 
96
98
  test('should have isInitialized as false by default', () => {
@@ -158,7 +160,7 @@ describe('ChatContextInternal', () => {
158
160
  ctx.send.text('Test');
159
161
 
160
162
  const response = ctx.responses[0] as TextMessage;
161
- expect(response.traceId).toBe(ctx.traceId);
163
+ expect(response.traceId).toBe(ctx.observability.traceId);
162
164
  });
163
165
 
164
166
  test('should set action on response', () => {