@botonic/core 0.56.0-alpha.0 → 0.57.0-rslib-esm.1

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 (175) hide show
  1. package/lib/constants.js +8 -0
  2. package/lib/constants.js.map +1 -0
  3. package/lib/{esm/core-bot.d.ts → core-bot.d.ts} +3 -3
  4. package/lib/{cjs/core-bot.js → core-bot.js} +87 -50
  5. package/lib/core-bot.js.map +1 -0
  6. package/lib/debug/index.d.ts +1 -0
  7. package/lib/debug/index.js +6 -0
  8. package/lib/debug/index.js.map +1 -0
  9. package/lib/{cjs/debug → debug}/inspector.d.ts +1 -1
  10. package/lib/{cjs/debug → debug}/inspector.js +27 -21
  11. package/lib/debug/inspector.js.map +1 -0
  12. package/lib/{cjs/handoff.d.ts → handoff.d.ts} +1 -1
  13. package/lib/{esm/handoff.js → handoff.js} +82 -53
  14. package/lib/handoff.js.map +1 -0
  15. package/lib/{esm/hubtype-service.d.ts → hubtype-service.d.ts} +3 -3
  16. package/lib/{cjs/hubtype-service.js → hubtype-service.js} +100 -64
  17. package/lib/hubtype-service.js.map +1 -0
  18. package/lib/index.d.ts +9 -0
  19. package/lib/index.js +22 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/{esm/models → models}/ai-agents.d.ts +1 -8
  22. package/lib/models/ai-agents.js +30 -0
  23. package/lib/models/ai-agents.js.map +1 -0
  24. package/lib/models/bot-config.js +10 -0
  25. package/lib/models/bot-config.js.map +1 -0
  26. package/lib/{esm/models → models}/hubtype-analytics.d.ts +1 -1
  27. package/lib/{esm/models → models}/hubtype-analytics.js +10 -10
  28. package/lib/models/hubtype-analytics.js.map +1 -0
  29. package/lib/models/index.d.ts +4 -0
  30. package/lib/models/index.js +12 -0
  31. package/lib/models/index.js.map +1 -0
  32. package/lib/{esm/models → models}/legacy-types.js +24 -24
  33. package/lib/models/legacy-types.js.map +1 -0
  34. package/lib/{cjs/plugins.d.ts → plugins.d.ts} +1 -1
  35. package/lib/{esm/plugins.js → plugins.js} +7 -8
  36. package/lib/plugins.js.map +1 -0
  37. package/lib/pusher-utils.js +23 -0
  38. package/lib/pusher-utils.js.map +1 -0
  39. package/lib/routing/index.d.ts +2 -0
  40. package/lib/routing/index.js +8 -0
  41. package/lib/routing/index.js.map +1 -0
  42. package/lib/{cjs/routing → routing}/router-utils.d.ts +1 -1
  43. package/lib/{cjs/routing → routing}/router-utils.js +37 -30
  44. package/lib/routing/router-utils.js.map +1 -0
  45. package/lib/{cjs/routing → routing}/router.d.ts +2 -2
  46. package/lib/routing/router.js +333 -0
  47. package/lib/routing/router.js.map +1 -0
  48. package/lib/{esm/testing → testing}/index.d.ts +1 -1
  49. package/lib/testing/index.js +162 -0
  50. package/lib/testing/index.js.map +1 -0
  51. package/lib/{cjs/utils → utils}/bot-config.d.ts +1 -1
  52. package/lib/{esm/utils → utils}/bot-config.js +57 -28
  53. package/lib/utils/bot-config.js.map +1 -0
  54. package/lib/{cjs/utils → utils}/check-providers.d.ts +1 -1
  55. package/lib/utils/check-providers.js +31 -0
  56. package/lib/utils/check-providers.js.map +1 -0
  57. package/lib/utils/functional.js +69 -0
  58. package/lib/utils/functional.js.map +1 -0
  59. package/lib/utils/index.d.ts +3 -0
  60. package/lib/utils/index.js +10 -0
  61. package/lib/utils/index.js.map +1 -0
  62. package/package.json +14 -12
  63. package/src/hubtype-service.ts +4 -2
  64. package/src/models/ai-agents.ts +0 -9
  65. package/lib/cjs/constants.js +0 -8
  66. package/lib/cjs/constants.js.map +0 -1
  67. package/lib/cjs/core-bot.d.ts +0 -43
  68. package/lib/cjs/core-bot.js.map +0 -1
  69. package/lib/cjs/debug/index.d.ts +0 -1
  70. package/lib/cjs/debug/index.js +0 -5
  71. package/lib/cjs/debug/index.js.map +0 -1
  72. package/lib/cjs/debug/inspector.js.map +0 -1
  73. package/lib/cjs/handoff.js +0 -238
  74. package/lib/cjs/handoff.js.map +0 -1
  75. package/lib/cjs/hubtype-service.d.ts +0 -58
  76. package/lib/cjs/hubtype-service.js.map +0 -1
  77. package/lib/cjs/index.d.ts +0 -9
  78. package/lib/cjs/index.js +0 -13
  79. package/lib/cjs/index.js.map +0 -1
  80. package/lib/cjs/models/ai-agents.d.ts +0 -147
  81. package/lib/cjs/models/ai-agents.js +0 -31
  82. package/lib/cjs/models/ai-agents.js.map +0 -1
  83. package/lib/cjs/models/bot-config.js +0 -10
  84. package/lib/cjs/models/bot-config.js.map +0 -1
  85. package/lib/cjs/models/hubtype-analytics.d.ts +0 -210
  86. package/lib/cjs/models/hubtype-analytics.js +0 -38
  87. package/lib/cjs/models/hubtype-analytics.js.map +0 -1
  88. package/lib/cjs/models/index.d.ts +0 -4
  89. package/lib/cjs/models/index.js +0 -8
  90. package/lib/cjs/models/index.js.map +0 -1
  91. package/lib/cjs/models/legacy-types.js +0 -84
  92. package/lib/cjs/models/legacy-types.js.map +0 -1
  93. package/lib/cjs/plugins.js +0 -24
  94. package/lib/cjs/plugins.js.map +0 -1
  95. package/lib/cjs/pusher-utils.js +0 -18
  96. package/lib/cjs/pusher-utils.js.map +0 -1
  97. package/lib/cjs/routing/index.d.ts +0 -2
  98. package/lib/cjs/routing/index.js +0 -6
  99. package/lib/cjs/routing/index.js.map +0 -1
  100. package/lib/cjs/routing/router-utils.js.map +0 -1
  101. package/lib/cjs/routing/router.js +0 -330
  102. package/lib/cjs/routing/router.js.map +0 -1
  103. package/lib/cjs/testing/index.d.ts +0 -91
  104. package/lib/cjs/testing/index.js +0 -196
  105. package/lib/cjs/testing/index.js.map +0 -1
  106. package/lib/cjs/utils/bot-config.js +0 -94
  107. package/lib/cjs/utils/bot-config.js.map +0 -1
  108. package/lib/cjs/utils/check-providers.js +0 -34
  109. package/lib/cjs/utils/check-providers.js.map +0 -1
  110. package/lib/cjs/utils/functional.js +0 -88
  111. package/lib/cjs/utils/functional.js.map +0 -1
  112. package/lib/cjs/utils/index.d.ts +0 -3
  113. package/lib/cjs/utils/index.js +0 -7
  114. package/lib/cjs/utils/index.js.map +0 -1
  115. package/lib/esm/constants.d.ts +0 -4
  116. package/lib/esm/constants.js +0 -8
  117. package/lib/esm/constants.js.map +0 -1
  118. package/lib/esm/core-bot.js +0 -205
  119. package/lib/esm/core-bot.js.map +0 -1
  120. package/lib/esm/debug/index.d.ts +0 -1
  121. package/lib/esm/debug/index.js +0 -5
  122. package/lib/esm/debug/index.js.map +0 -1
  123. package/lib/esm/debug/inspector.d.ts +0 -24
  124. package/lib/esm/debug/inspector.js +0 -70
  125. package/lib/esm/debug/inspector.js.map +0 -1
  126. package/lib/esm/handoff.d.ts +0 -110
  127. package/lib/esm/handoff.js.map +0 -1
  128. package/lib/esm/hubtype-service.js +0 -205
  129. package/lib/esm/hubtype-service.js.map +0 -1
  130. package/lib/esm/index.d.ts +0 -9
  131. package/lib/esm/index.js +0 -13
  132. package/lib/esm/index.js.map +0 -1
  133. package/lib/esm/models/ai-agents.js +0 -31
  134. package/lib/esm/models/ai-agents.js.map +0 -1
  135. package/lib/esm/models/bot-config.d.ts +0 -24
  136. package/lib/esm/models/bot-config.js +0 -10
  137. package/lib/esm/models/bot-config.js.map +0 -1
  138. package/lib/esm/models/hubtype-analytics.js.map +0 -1
  139. package/lib/esm/models/index.d.ts +0 -4
  140. package/lib/esm/models/index.js +0 -8
  141. package/lib/esm/models/index.js.map +0 -1
  142. package/lib/esm/models/legacy-types.d.ts +0 -332
  143. package/lib/esm/models/legacy-types.js.map +0 -1
  144. package/lib/esm/plugins.d.ts +0 -9
  145. package/lib/esm/plugins.js.map +0 -1
  146. package/lib/esm/pusher-utils.d.ts +0 -7
  147. package/lib/esm/pusher-utils.js +0 -18
  148. package/lib/esm/pusher-utils.js.map +0 -1
  149. package/lib/esm/routing/index.d.ts +0 -2
  150. package/lib/esm/routing/index.js +0 -6
  151. package/lib/esm/routing/index.js.map +0 -1
  152. package/lib/esm/routing/router-utils.d.ts +0 -11
  153. package/lib/esm/routing/router-utils.js +0 -96
  154. package/lib/esm/routing/router-utils.js.map +0 -1
  155. package/lib/esm/routing/router.d.ts +0 -54
  156. package/lib/esm/routing/router.js +0 -330
  157. package/lib/esm/routing/router.js.map +0 -1
  158. package/lib/esm/testing/index.js +0 -196
  159. package/lib/esm/testing/index.js.map +0 -1
  160. package/lib/esm/utils/bot-config.d.ts +0 -4
  161. package/lib/esm/utils/bot-config.js.map +0 -1
  162. package/lib/esm/utils/check-providers.d.ts +0 -8
  163. package/lib/esm/utils/check-providers.js +0 -34
  164. package/lib/esm/utils/check-providers.js.map +0 -1
  165. package/lib/esm/utils/functional.d.ts +0 -10
  166. package/lib/esm/utils/functional.js +0 -88
  167. package/lib/esm/utils/functional.js.map +0 -1
  168. package/lib/esm/utils/index.d.ts +0 -3
  169. package/lib/esm/utils/index.js +0 -7
  170. package/lib/esm/utils/index.js.map +0 -1
  171. /package/lib/{cjs/constants.d.ts → constants.d.ts} +0 -0
  172. /package/lib/{cjs/models → models}/bot-config.d.ts +0 -0
  173. /package/lib/{cjs/models → models}/legacy-types.d.ts +0 -0
  174. /package/lib/{cjs/pusher-utils.d.ts → pusher-utils.d.ts} +0 -0
  175. /package/lib/{cjs/utils → utils}/functional.d.ts +0 -0
@@ -4,7 +4,6 @@ export declare enum OutputMessageType {
4
4
  TextWithButtons = "textWithButtons",
5
5
  BotExecutor = "botExecutor",
6
6
  Carousel = "carousel",
7
- RequestContactInfo = "requestContactInfo",
8
7
  Exit = "exit"
9
8
  }
10
9
  export interface BaseMessage<T extends string = OutputMessageType> {
@@ -53,16 +52,10 @@ export interface CarouselMessage extends BaseMessage {
53
52
  elements: CarouselElement[];
54
53
  };
55
54
  }
56
- export interface RequestContactInfoMessage extends BaseMessage {
57
- type: OutputMessageType.RequestContactInfo;
58
- content: {
59
- text: string;
60
- };
61
- }
62
55
  export interface ExitMessage extends BaseMessage {
63
56
  type: OutputMessageType.Exit;
64
57
  }
65
- export type OutputMessage<Extra extends BaseMessage<string> = never> = TextMessage | TextWithButtonsMessage | BotExecutorMessage | CarouselMessage | RequestContactInfoMessage | ExitMessage | Extra;
58
+ export type OutputMessage<Extra extends BaseMessage<string> = never> = TextMessage | TextWithButtonsMessage | BotExecutorMessage | CarouselMessage | ExitMessage | Extra;
66
59
  export type AgenticOutputMessage<Extra extends BaseMessage<string> = never> = Exclude<OutputMessage<Extra>, ExitMessage>;
67
60
  export interface ToolExecution {
68
61
  toolName: string;
@@ -0,0 +1,30 @@
1
+ var ai_agents_OutputMessageType = /*#__PURE__*/ function(OutputMessageType) {
2
+ OutputMessageType["Text"] = "text";
3
+ OutputMessageType["TextWithButtons"] = "textWithButtons";
4
+ OutputMessageType["BotExecutor"] = "botExecutor";
5
+ OutputMessageType["Carousel"] = "carousel";
6
+ OutputMessageType["Exit"] = "exit";
7
+ return OutputMessageType;
8
+ }({});
9
+ var ai_agents_VerbosityLevel = /*#__PURE__*/ function(VerbosityLevel) {
10
+ VerbosityLevel["Low"] = "low";
11
+ VerbosityLevel["Medium"] = "medium";
12
+ VerbosityLevel["High"] = "high";
13
+ return VerbosityLevel;
14
+ }({});
15
+ var ai_agents_ReasoningEffort = /*#__PURE__*/ function(ReasoningEffort) {
16
+ ReasoningEffort["None"] = "none";
17
+ ReasoningEffort["Low"] = "low";
18
+ ReasoningEffort["Medium"] = "medium";
19
+ ReasoningEffort["High"] = "high";
20
+ return ReasoningEffort;
21
+ }({});
22
+ var ai_agents_AiAgentType = /*#__PURE__*/ function(AiAgentType) {
23
+ AiAgentType["Specialist"] = "specialist";
24
+ AiAgentType["Router"] = "router";
25
+ return AiAgentType;
26
+ }({});
27
+
28
+ export { ai_agents_AiAgentType as AiAgentType, ai_agents_OutputMessageType as OutputMessageType, ai_agents_ReasoningEffort as ReasoningEffort, ai_agents_VerbosityLevel as VerbosityLevel };
29
+
30
+ //# sourceMappingURL=ai-agents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models/ai-agents.js","sources":["../../src/models/ai-agents.ts"],"sourcesContent":["import type { z } from 'zod'\n\nexport enum OutputMessageType {\n Text = 'text',\n TextWithButtons = 'textWithButtons',\n BotExecutor = 'botExecutor',\n Carousel = 'carousel',\n Exit = 'exit',\n}\n\nexport interface BaseMessage<T extends string = OutputMessageType> {\n type: T\n}\n\nexport interface Button {\n text: string\n payload?: string\n url?: string\n target?: string\n}\nexport interface ButtonWithPayload {\n text: string\n payload: string\n}\n\nexport interface TextMessage extends BaseMessage {\n type: OutputMessageType.Text\n content: {\n text: string\n }\n}\n\nexport interface TextWithButtonsMessage extends BaseMessage {\n type: OutputMessageType.TextWithButtons\n content: {\n text: string\n buttons: Button[]\n }\n}\n\nexport interface BotExecutorMessage extends BaseMessage {\n type: OutputMessageType.BotExecutor\n content: {\n text: string\n buttons: ButtonWithPayload[]\n }\n}\n\ninterface CarouselElement {\n title: string\n subtitle: string\n image: string\n button: Button\n}\n\nexport interface CarouselMessage extends BaseMessage {\n type: OutputMessageType.Carousel\n content: {\n text?: string\n elements: CarouselElement[]\n }\n}\n\nexport interface ExitMessage extends BaseMessage {\n type: OutputMessageType.Exit\n}\n\nexport type OutputMessage<Extra extends BaseMessage<string> = never> =\n | TextMessage\n | TextWithButtonsMessage\n | BotExecutorMessage\n | CarouselMessage\n | ExitMessage\n | Extra\n\nexport type AgenticOutputMessage<Extra extends BaseMessage<string> = never> =\n Exclude<OutputMessage<Extra>, ExitMessage>\n\nexport interface ToolExecution {\n toolName: string\n toolArguments: Record<string, any>\n toolResults?: string\n knowledgebaseSourcesIds?: string[]\n knowledgebaseChunksIds?: string[]\n}\n\nexport interface AvailableSpecialist {\n name: string\n description: string\n}\n\nexport interface RunResult<Extra extends BaseMessage<string> = never> {\n messages: AgenticOutputMessage<Extra>[]\n toolsExecuted: ToolExecution[]\n memoryLength: number\n exit: boolean\n error: boolean\n inputGuardrailsTriggered: string[]\n outputGuardrailsTriggered: string[]\n startingAgentName: string\n lastAgentName: string\n availableSpecialists: AvailableSpecialist[]\n isTransferredToSpecialist: boolean\n}\n\nexport type InferenceResponse<Extra extends BaseMessage<string> = never> =\n RunResult<Extra>\n\nexport interface GuardrailRule {\n name: string\n description: string\n}\nexport enum VerbosityLevel {\n Low = 'low',\n Medium = 'medium',\n High = 'high',\n}\n\nexport enum ReasoningEffort {\n None = 'none',\n Low = 'low',\n Medium = 'medium',\n High = 'high',\n}\n\nexport interface HubtypeAssistantMessage {\n role: 'assistant'\n content: string\n}\n\nexport interface HubtypeUserMessage {\n role: 'user'\n content: string\n}\n\nexport enum AiAgentType {\n Specialist = 'specialist',\n Router = 'router',\n}\n\nexport type AiAgentArgs = AiAgentSpecialistArgs | AIAgentRouterArgs\n\nexport type AiAgentBaseArgs = {\n type: AiAgentType\n name: string\n instructions: string\n model: string\n verbosity: VerbosityLevel\n reasoningEffort?: ReasoningEffort\n disableForceRetrieveKnowledge?: boolean // If true, the agent will not force the retrieve knowledge tool to be used.\n inputGuardrailRules?: GuardrailRule[]\n previousHubtypeMessages?: HubtypeAssistantMessage[]\n outputMessagesSchemas?: z.ZodObject<any>[]\n forceToolNameOverride?: string\n}\n\nexport interface AiAgentSpecialistArgs extends AiAgentBaseArgs {\n type: AiAgentType.Specialist\n activeTools: { name: string }[]\n sourceIds: string[]\n}\n\ninterface AIAgentRoute extends AiAgentSpecialistArgs {\n description: string\n}\n\nexport interface AIAgentRouterArgs extends AiAgentBaseArgs {\n type: AiAgentType.Router\n specialists: AIAgentRoute[]\n}\n"],"names":["OutputMessageType","VerbosityLevel","ReasoningEffort","AiAgentType"],"mappings":"AAEO,IAAKA,2BAAiBA,0BAAjBA;;;;;;WAAAA;MAMX;AAwGM,IAAKC,wBAAcA,0BAAdA;;;;WAAAA;MAIX;AAEM,IAAKC,yBAAeA,0BAAfA;;;;;WAAAA;MAKX;AAYM,IAAKC,qBAAWA,0BAAXA;;;WAAAA;MAGX"}
@@ -0,0 +1,10 @@
1
+ var bot_config_VariableType = /*#__PURE__*/ function(VariableType) {
2
+ VariableType["String"] = "string";
3
+ VariableType["Number"] = "number";
4
+ VariableType["Boolean"] = "boolean";
5
+ return VariableType;
6
+ }({});
7
+
8
+ export { bot_config_VariableType as VariableType };
9
+
10
+ //# sourceMappingURL=bot-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models/bot-config.js","sources":["../../src/models/bot-config.ts"],"sourcesContent":["import type { core } from 'zod'\n\n// This types are used in the bot-config.ts file to load the bot config when deploy a bot.\nexport interface BotConfigJSON {\n tools: ToolConfigJSON[]\n payloads: string[]\n webviews: WebviewConfigJSON[]\n variables?: VariableConfigJSON[]\n}\n\nexport interface ToolConfigJSON {\n name: string\n schema?: core.JSONSchema.JSONSchema\n description: string\n}\n\nexport interface WebviewConfigJSON {\n name: string\n}\n\nexport enum VariableType {\n String = 'string',\n Number = 'number',\n Boolean = 'boolean',\n}\n\nexport interface VariableConfigJSON {\n key_path: string\n type: VariableType\n}\n"],"names":["VariableType"],"mappings":"AAoBO,IAAKA,uBAAYA,0BAAZA;;;;WAAAA;MAIX"}
@@ -1,4 +1,4 @@
1
- import type { AvailableSpecialist, ToolExecution } from './ai-agents';
1
+ import type { AvailableSpecialist, ToolExecution } from './ai-agents.js';
2
2
  export declare const EVENT_FORMAT_VERSION = 5;
3
3
  export declare enum EventAction {
4
4
  AiAgent = "ai_agent",
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebviewEndFailType = exports.EventAction = exports.EVENT_FORMAT_VERSION = void 0;
4
- exports.EVENT_FORMAT_VERSION = 5;
5
- var EventAction;
6
- (function (EventAction) {
1
+ const EVENT_FORMAT_VERSION = 5;
2
+ var hubtype_analytics_EventAction = /*#__PURE__*/ function(EventAction) {
7
3
  EventAction["AiAgent"] = "ai_agent";
8
4
  EventAction["FeedbackCase"] = "feedback_case";
9
5
  EventAction["FeedbackMessage"] = "feedback_message";
@@ -28,11 +24,15 @@ var EventAction;
28
24
  EventAction["RedirectFlow"] = "redirect_flow";
29
25
  EventAction["CaptureUserInput"] = "capture_user_input";
30
26
  EventAction["AiAgentRouter"] = "ai_agent_router";
31
- })(EventAction || (exports.EventAction = EventAction = {}));
32
- var WebviewEndFailType;
33
- (function (WebviewEndFailType) {
27
+ return EventAction;
28
+ }({});
29
+ var hubtype_analytics_WebviewEndFailType = /*#__PURE__*/ function(WebviewEndFailType) {
34
30
  WebviewEndFailType["CanceledByUser"] = "canceled_by_user";
35
31
  WebviewEndFailType["ApiError"] = "api_error";
36
32
  WebviewEndFailType["NeedsEscalation"] = "needs_escalation";
37
- })(WebviewEndFailType || (exports.WebviewEndFailType = WebviewEndFailType = {}));
33
+ return WebviewEndFailType;
34
+ }({});
35
+
36
+ export { EVENT_FORMAT_VERSION, hubtype_analytics_EventAction as EventAction, hubtype_analytics_WebviewEndFailType as WebviewEndFailType };
37
+
38
38
  //# sourceMappingURL=hubtype-analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models/hubtype-analytics.js","sources":["../../src/models/hubtype-analytics.ts"],"sourcesContent":["import type { AvailableSpecialist, ToolExecution } from './ai-agents'\n\nexport const EVENT_FORMAT_VERSION = 5\n\nexport enum EventAction {\n AiAgent = 'ai_agent',\n FeedbackCase = 'feedback_case',\n FeedbackMessage = 'feedback_message',\n FeedbackConversation = 'feedback_conversation',\n FeedbackWebview = 'feedback_webview',\n FlowNode = 'flow_node',\n ConditionalCountry = 'conditional_country',\n ConditionalQueueStatus = 'conditional_queue_status',\n ConditionalCustom = 'conditional_custom',\n ConditionalChannel = 'conditional_channel',\n BotAction = 'bot_action',\n WebviewActionTriggered = 'webview_action_triggered',\n HandoffOption = 'handoff_option',\n HandoffSuccess = 'handoff_success',\n HandoffFail = 'handoff_fail',\n Keyword = 'nlu_keyword',\n IntentSmart = 'nlu_intent_smart',\n Fallback = 'fallback',\n WebviewStep = 'webview_step',\n WebviewEnd = 'webview_end',\n Custom = 'custom',\n RedirectFlow = 'redirect_flow',\n CaptureUserInput = 'capture_user_input',\n AiAgentRouter = 'ai_agent_router',\n}\n\nexport interface HtBaseEventProps {\n action: EventAction\n}\n\nexport interface HtBaseEventAllFlowProps extends HtBaseEventProps {\n flowThreadId: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n flowNodeIsMeaningful: boolean\n}\n\nexport interface EventFeedback extends HtBaseEventProps {\n action:\n | EventAction.FeedbackCase\n | EventAction.FeedbackConversation\n | EventAction.FeedbackMessage\n | EventAction.FeedbackWebview\n feedbackTargetId: string\n feedbackGroupId: string\n possibleOptions: string[]\n possibleValues?: number[]\n option: string\n value?: number\n comment?: string\n}\n\nexport interface EventFlow extends HtBaseEventProps {\n action: EventAction.FlowNode\n flowThreadId: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n flowNodeIsMeaningful?: boolean\n}\n\nexport interface EventBotAction extends HtBaseEventAllFlowProps {\n action: EventAction.BotAction\n payload: string\n}\n\nexport interface EventConditionalCountry extends HtBaseEventAllFlowProps {\n action: EventAction.ConditionalCountry\n country: string\n}\n\nexport interface EventConditionalQueueStatus extends HtBaseEventAllFlowProps {\n action: EventAction.ConditionalQueueStatus\n queueId: string\n queueName: string\n isQueueOpen: boolean\n isAvailableAgent: boolean\n}\n\nexport interface EventConditionalCustom extends HtBaseEventAllFlowProps {\n action: EventAction.ConditionalCustom\n conditionalVariable: string\n variableFormat: string\n operator: string\n}\n\nexport interface EventConditionalChannel extends HtBaseEventAllFlowProps {\n action: EventAction.ConditionalChannel\n channel: string\n}\n\nexport interface EventHandoff extends HtBaseEventProps {\n action: EventAction.HandoffSuccess | EventAction.HandoffFail\n flowThreadId?: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n queueId: string\n queueName: string\n caseId?: string\n isQueueOpen?: boolean\n isAvailableAgent?: boolean\n isThresholdReached?: boolean\n}\n\nexport interface EventHandoffOption extends HtBaseEventProps {\n action: EventAction.HandoffOption\n flowThreadId?: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n queueId?: string\n queueName?: string\n}\n\nexport interface EventKeyword extends HtBaseEventProps {\n action: EventAction.Keyword\n flowThreadId: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n nluKeywordName: string\n nluKeywordIsRegex?: boolean\n nluKeywordMessageId: string\n userInput: string\n}\n\nexport interface EventIntentSmart extends HtBaseEventProps {\n action: EventAction.IntentSmart\n flowThreadId: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n nluIntentSmartTitle: string\n nluIntentSmartNumUsed: number\n nluIntentSmartMessageId: string\n userInput: string\n}\n\nexport interface EventWebviewActionTriggered extends HtBaseEventAllFlowProps {\n action: EventAction.WebviewActionTriggered\n webviewTargetId: string\n webviewName: string\n webviewParams?: Record<string, string>\n}\n\nexport interface EventAiAgent extends HtBaseEventAllFlowProps {\n action: EventAction.AiAgent\n toolsExecuted: ToolExecution[]\n inputMessageId: string\n memoryLength: number\n inputGuardrailsTriggered: string[]\n outputGuardrailsTriggered: string[]\n exit: boolean\n error: boolean\n}\n\nexport interface EventAiAgentRouter extends HtBaseEventAllFlowProps {\n action: EventAction.AiAgentRouter\n inputMessageId: string\n memoryLength: number\n inputGuardrailsTriggered: string[]\n outputGuardrailsTriggered: string[]\n exit: boolean\n error: boolean\n startingAgentName: string\n lastAgentName: string\n availableSpecialists: AvailableSpecialist[]\n isTransferredToSpecialist: boolean\n}\n\nexport interface EventRedirectFlow extends HtBaseEventAllFlowProps {\n action: EventAction.RedirectFlow\n flowTargetId: string\n flowTargetName: string\n}\n\nexport interface EventCaptureUserInput extends HtBaseEventAllFlowProps {\n action: EventAction.CaptureUserInput\n fieldName: string\n userInput: string\n captureSuccess: boolean\n messageId: string\n}\n\nexport interface EventFallback extends HtBaseEventProps {\n action: EventAction.Fallback\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n userInput: string\n fallbackOut: number\n fallbackMessageId: string\n}\n\nexport interface EventWebviewStep extends HtBaseEventProps {\n action: EventAction.WebviewStep\n flowThreadId?: string\n webviewThreadId: string\n webviewName: string\n webviewStepName: string\n webviewStepNumber: number\n}\n\nexport interface EventWebviewEnd extends HtBaseEventProps {\n action: EventAction.WebviewEnd\n flowThreadId?: string\n webviewThreadId: string\n webviewName: string\n webviewStepName?: string\n webviewStepNumber?: number\n webviewEndFailType?: WebviewEndFailType\n webviewEndFailMessage?: string\n}\n\nexport enum WebviewEndFailType {\n CanceledByUser = 'canceled_by_user',\n ApiError = 'api_error',\n NeedsEscalation = 'needs_escalation',\n}\n\nexport interface EventCustom extends HtBaseEventProps {\n action: EventAction.Custom\n customFields?: Record<string, any>\n customSensitiveFields?: Record<string, any>\n}\n"],"names":["EVENT_FORMAT_VERSION","EventAction","WebviewEndFailType"],"mappings":"AAEO,MAAMA,oBAAoBA,GAAG,EAAC;AAE9B,IAAKC,6BAAWA,0BAAXA;;;;;;;;;;;;;;;;;;;;;;;;;WAAAA;MAyBX;AAuMM,IAAKC,oCAAkBA,0BAAlBA;;;;WAAAA;MAIX"}
@@ -0,0 +1,4 @@
1
+ export * from './ai-agents.js';
2
+ export * from './bot-config.js';
3
+ export * from './hubtype-analytics.js';
4
+ export * from './legacy-types.js';
@@ -0,0 +1,12 @@
1
+ export * from "./ai-agents.js";
2
+ export * from "./bot-config.js";
3
+ export * from "./hubtype-analytics.js";
4
+ export * from "./legacy-types.js";
5
+
6
+
7
+
8
+
9
+
10
+ export {};
11
+
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models/index.js","sources":["../../src/models/index.ts"],"sourcesContent":["export * from './ai-agents'\nexport * from './bot-config'\nexport * from './hubtype-analytics'\nexport * from './legacy-types'\n"],"names":[],"mappings":";;;;AAA2B;AACC;AACO;AACL"}
@@ -1,23 +1,19 @@
1
- "use strict";
2
1
  // TODO: This file contains all the legacy types we had in index.ts. After some refactors, we should be able to get rid of many of them.
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.BotonicAction = exports.CaseStatus = exports.NluType = exports.INPUT = exports.PROVIDER = exports.CASE_RESOLUTION = exports.CASE_STATUS = void 0;
5
- var CASE_STATUS;
6
- (function (CASE_STATUS) {
2
+ var legacy_types_CASE_STATUS = /*#__PURE__*/ function(CASE_STATUS) {
7
3
  CASE_STATUS["WAITING"] = "status_waiting";
8
4
  CASE_STATUS["ATTENDING"] = "status_attending";
9
5
  CASE_STATUS["IDLE"] = "status_idle";
10
6
  CASE_STATUS["RESOLVED"] = "status_resolved";
11
- })(CASE_STATUS || (exports.CASE_STATUS = CASE_STATUS = {}));
12
- var CASE_RESOLUTION;
13
- (function (CASE_RESOLUTION) {
7
+ return CASE_STATUS;
8
+ }({});
9
+ var legacy_types_CASE_RESOLUTION = /*#__PURE__*/ function(CASE_RESOLUTION) {
14
10
  CASE_RESOLUTION["OK"] = "result_ok";
15
11
  CASE_RESOLUTION["NOK"] = "result_nok";
16
12
  CASE_RESOLUTION["NOT_SOLVED"] = "result_not_solved";
17
13
  CASE_RESOLUTION["BANNED"] = "result_banned";
18
- })(CASE_RESOLUTION || (exports.CASE_RESOLUTION = CASE_RESOLUTION = {}));
19
- var PROVIDER;
20
- (function (PROVIDER) {
14
+ return CASE_RESOLUTION;
15
+ }({});
16
+ var legacy_types_PROVIDER = /*#__PURE__*/ function(PROVIDER) {
21
17
  PROVIDER["APPLE"] = "apple";
22
18
  PROVIDER["DEV"] = "dev";
23
19
  PROVIDER["FACEBOOK"] = "facebook";
@@ -30,9 +26,9 @@ var PROVIDER;
30
26
  PROVIDER["WEBCHAT"] = "webchat";
31
27
  PROVIDER["WECHAT"] = "wechat";
32
28
  PROVIDER["WHATSAPP"] = "whatsapp";
33
- })(PROVIDER || (exports.PROVIDER = PROVIDER = {}));
34
- var INPUT;
35
- (function (INPUT) {
29
+ return PROVIDER;
30
+ }({});
31
+ var legacy_types_INPUT = /*#__PURE__*/ function(INPUT) {
36
32
  INPUT["TEXT"] = "text";
37
33
  INPUT["POSTBACK"] = "postback";
38
34
  INPUT["AUDIO"] = "audio";
@@ -61,24 +57,28 @@ var INPUT;
61
57
  INPUT["EVENT_QUEUE_POSITION_CHANGED"] = "case_event_queue_position_changed";
62
58
  INPUT["EVENT_CASE_STATUS_CHANGED"] = "case_event_status_changed";
63
59
  INPUT["SYSTEM_DEBUG_TRACE"] = "system_debug_trace";
64
- })(INPUT || (exports.INPUT = INPUT = {}));
65
- var NluType;
66
- (function (NluType) {
60
+ return INPUT;
61
+ }({});
62
+ var legacy_types_NluType = /*#__PURE__*/ function(NluType) {
67
63
  NluType["Keyword"] = "keyword";
68
64
  NluType["SmartIntent"] = "smart-intent";
69
- })(NluType || (exports.NluType = NluType = {}));
70
- var CaseStatus;
71
- (function (CaseStatus) {
65
+ return NluType;
66
+ }({});
67
+ var legacy_types_CaseStatus = /*#__PURE__*/ function(CaseStatus) {
72
68
  CaseStatus["Waiting"] = "status_waiting";
73
69
  CaseStatus["Attending"] = "status_attending";
74
70
  CaseStatus["Idle"] = "status_idle";
75
71
  CaseStatus["Resolved"] = "status_resolved";
76
- })(CaseStatus || (exports.CaseStatus = CaseStatus = {}));
77
- var BotonicAction;
78
- (function (BotonicAction) {
72
+ return CaseStatus;
73
+ }({});
74
+ var legacy_types_BotonicAction = /*#__PURE__*/ function(BotonicAction) {
79
75
  BotonicAction["Redirect"] = "redirect_action";
80
76
  BotonicAction["CreateCase"] = "create_case";
81
77
  BotonicAction["DeleteUser"] = "delete_user";
82
78
  BotonicAction["DiscardCase"] = "discard_case";
83
- })(BotonicAction || (exports.BotonicAction = BotonicAction = {}));
79
+ return BotonicAction;
80
+ }({});
81
+
82
+ export { legacy_types_BotonicAction as BotonicAction, legacy_types_CASE_RESOLUTION as CASE_RESOLUTION, legacy_types_CASE_STATUS as CASE_STATUS, legacy_types_CaseStatus as CaseStatus, legacy_types_INPUT as INPUT, legacy_types_NluType as NluType, legacy_types_PROVIDER as PROVIDER };
83
+
84
84
  //# sourceMappingURL=legacy-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models/legacy-types.js","sources":["../../src/models/legacy-types.ts"],"sourcesContent":["// TODO: This file contains all the legacy types we had in index.ts. After some refactors, we should be able to get rid of many of them.\n\nexport enum CASE_STATUS {\n WAITING = 'status_waiting',\n ATTENDING = 'status_attending',\n IDLE = 'status_idle',\n RESOLVED = 'status_resolved',\n}\n\nexport type CaseStatusType =\n | CASE_STATUS.ATTENDING\n | CASE_STATUS.IDLE\n | CASE_STATUS.RESOLVED\n | CASE_STATUS.WAITING\n\nexport enum CASE_RESOLUTION {\n OK = 'result_ok',\n NOK = 'result_nok',\n NOT_SOLVED = 'result_not_solved',\n BANNED = 'result_banned',\n}\n\nexport type CaseResolution =\n | CASE_RESOLUTION.BANNED\n | CASE_RESOLUTION.NOK\n | CASE_RESOLUTION.NOT_SOLVED\n | CASE_RESOLUTION.OK\n\nexport enum PROVIDER {\n APPLE = 'apple',\n DEV = 'dev',\n FACEBOOK = 'facebook',\n GENERIC = 'generic',\n INSTAGRAM = 'instagram',\n INTERCOM = 'intercom',\n SMOOCH = 'smooch',\n TELEGRAM = 'telegram',\n TWITTER = 'twitter',\n WEBCHAT = 'webchat',\n WECHAT = 'wechat',\n WHATSAPP = 'whatsapp',\n}\n\nexport type ProviderType =\n | PROVIDER.DEV\n | PROVIDER.FACEBOOK\n | PROVIDER.GENERIC\n | PROVIDER.INSTAGRAM\n | PROVIDER.INTERCOM\n | PROVIDER.SMOOCH\n | PROVIDER.TELEGRAM\n | PROVIDER.TWITTER\n | PROVIDER.WEBCHAT\n | PROVIDER.WECHAT\n | PROVIDER.WHATSAPP\n\nexport enum INPUT {\n TEXT = 'text',\n POSTBACK = 'postback',\n AUDIO = 'audio',\n IMAGE = 'image',\n VIDEO = 'video',\n DOCUMENT = 'document',\n LOCATION = 'location',\n CONTACT = 'contact',\n BUTTON_MESSAGE = 'buttonmessage',\n CAROUSEL = 'carousel',\n CUSTOM = 'custom',\n WEBCHAT_SETTINGS = 'webchatsettings',\n WHATSAPP_TEMPLATE = 'whatsapptemplate',\n RAW = 'raw',\n CHAT_EVENT = 'chatevent',\n WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',\n WHATSAPP_CTA_URL_BUTTON = 'whatsapp-cta-url-button',\n WHATSAPP_REQUEST_CONTACT_INFO = 'whatsapp-request-contact-info',\n WHATSAPP_CATALOG = 'whatsapp-catalog',\n WHATSAPP_PRODUCT = 'whatsapp-product',\n WHATSAPP_PRODUCT_LIST = 'whatsapp-product-list',\n WHATSAPP_PRODUCT_CAROUSEL = 'whatsapp-product-carousel',\n WHATSAPP_MEDIA_CAROUSEL = 'whatsapp-media-carousel',\n WHATSAPP_ORDER = 'whatsapp_order',\n EVENT_AGENT_MESSAGE_CREATED = 'case_event_agent_message_created',\n EVENT_QUEUE_POSITION_CHANGED = 'case_event_queue_position_changed',\n EVENT_CASE_STATUS_CHANGED = 'case_event_status_changed',\n SYSTEM_DEBUG_TRACE = 'system_debug_trace',\n}\n\ninterface PluginConstructor<T> {\n new (arg: T): Plugin\n}\n\nexport interface PluginConfig<T> {\n id: string\n options?: T\n resolve: { default: PluginConstructor<T> }\n}\n\nexport type ResolvedPlugins = Record<string, Plugin>\n\nexport type InputType =\n | INPUT.AUDIO\n | INPUT.BUTTON_MESSAGE\n | INPUT.CAROUSEL\n | INPUT.CONTACT\n | INPUT.CUSTOM\n | INPUT.DOCUMENT\n | INPUT.IMAGE\n | INPUT.LOCATION\n | INPUT.POSTBACK\n | INPUT.TEXT\n | INPUT.VIDEO\n | INPUT.CHAT_EVENT\n | INPUT.WEBCHAT_SETTINGS\n | INPUT.WHATSAPP_TEMPLATE\n | INPUT.WHATSAPP_BUTTON_LIST\n | INPUT.WHATSAPP_CTA_URL_BUTTON\n | INPUT.WHATSAPP_REQUEST_CONTACT_INFO\n | INPUT.WHATSAPP_CATALOG\n | INPUT.WHATSAPP_PRODUCT\n | INPUT.WHATSAPP_PRODUCT_LIST\n | INPUT.WHATSAPP_PRODUCT_CAROUSEL\n | INPUT.WHATSAPP_MEDIA_CAROUSEL\n | INPUT.WHATSAPP_ORDER\n | INPUT.EVENT_AGENT_MESSAGE_CREATED\n | INPUT.EVENT_QUEUE_POSITION_CHANGED\n | INPUT.EVENT_CASE_STATUS_CHANGED\n\n/** Generated by Translation plugins: GoogleTranslation **/\nexport interface Translations {\n [languageCode: string]: string\n}\n\nexport enum NluType {\n Keyword = 'keyword',\n SmartIntent = 'smart-intent',\n}\n\nexport interface Input {\n text?: string\n src?: string\n data?: string\n path?: string\n payload?: string\n referral?: string\n type: InputType\n context?: {\n campaign?: Campaign\n campaigns_v2?: CampaignV2[]\n salesforce?: {\n access_token: string\n }\n }\n transcript?: string\n message_id: string\n bot_interaction_id: string\n catalog_id?: string\n product_items?: ProductItem[]\n nluResolution?: {\n type: NluType\n matchedValue: string\n payload?: string\n }\n origin?: string\n}\n\nexport interface CaseEventQueuePositionChangedInput {\n type: INPUT.EVENT_QUEUE_POSITION_CHANGED\n case_id: string\n prev_queue_position: number | null\n prev_queue_position_notified_at: string | null\n current_queue_position: number\n current_queue_position_notified_at: string\n total_queue_waiting_cases_number: number\n}\n\nexport enum CaseStatus {\n Waiting = 'status_waiting',\n Attending = 'status_attending',\n Idle = 'status_idle',\n Resolved = 'status_resolved',\n}\n\nexport interface CaseEventStatusChangedInput {\n type: INPUT.EVENT_CASE_STATUS_CHANGED\n case_id: string\n prev_status: CaseStatus | null\n next_status: CaseStatus\n}\n\nexport interface CaseEventAgentMessageCreatedInput {\n type: INPUT.EVENT_AGENT_MESSAGE_CREATED\n agent_id?: string\n agent_name?: string\n message?: {\n type: string\n data: string\n }\n}\n\ninterface ProductItem {\n product_retailer_id: string\n quantity: number\n item_price: number\n currency: string\n}\n\nexport interface Campaign {\n id: string\n name: string\n status: string\n start_date: string\n end_date: string\n bot_path: string\n template_name: string\n}\n\nexport interface CampaignV2 {\n id: string\n name: string\n agent_context?: string\n end_date?: string\n}\n\nexport interface ContactInfo {\n name: string\n type: string\n value: string\n description?: string\n}\n\nexport interface SessionUser<TExtraData = any> {\n id: string\n // login\n username?: string\n // person name\n name?: string\n // whatsapp, telegram,...\n provider: ProviderType\n // The provider's user id\n extra_data?: TExtraData\n contact_info?: ContactInfo[]\n imp_id?: string\n provider_id?: string\n locale: string\n country: string\n system_locale: string\n system_locale_updated?: boolean\n}\n\nexport interface HubtypeCaseContactReason {\n id: string\n name: string\n project_id: string\n}\n\nexport interface SessionBot {\n id: string\n name?: string\n}\n\nexport interface Session<TExtraData = any> {\n bot: SessionBot\n __retries: number\n _access_token: string\n _hubtype_api: string\n is_first_interaction: boolean\n is_test_integration: boolean\n last_session?: any\n organization_id: string\n organization: string\n user: SessionUser<TExtraData>\n // after handoff\n _botonic_action?: BotonicActionType\n _hubtype_case_resolution?: CaseResolution\n _hubtype_case_id?: string\n _hubtype_case_typification?: string\n _hubtype_case_contact_reasons?: HubtypeCaseContactReason[]\n _shadowing?: boolean\n external?: any\n zendesk_ticket_id?: string\n flow_thread_id?: string\n __campaign?: {\n id: string\n path: string\n active: boolean\n }\n capture_user_input?: {\n node_id: string\n }\n}\n\nexport type InputMatcher = (input: Input) => boolean\nexport type ParamsMatcher =\n | { [key: string]: string }\n | ((params: { [key: string]: string }) => boolean)\nexport type SessionMatcher<TExtraData = any> = (\n session: Session<TExtraData>\n) => boolean\nexport type RequestMatcher<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (request: BotContext<TPlugins, TExtraData>) => boolean\nexport type StringMatcher = RegExp | string | ((data: string) => boolean)\n\nexport type RouteMatcher =\n | InputMatcher\n | ParamsMatcher\n | RequestMatcher\n | SessionMatcher\n | StringMatcher\n\nexport interface Route<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n action?: any\n childRoutes?: Route[]\n lastRoutePath?: string\n ignoreRetry?: boolean\n path: RoutePath\n redirect?: string\n retry?: number\n\n // matchers\n input?: InputMatcher\n params?: ParamsMatcher\n payload?: StringMatcher\n request?: RequestMatcher<TPlugins, TExtraData>\n session?: SessionMatcher<TExtraData>\n text?: StringMatcher\n data?: StringMatcher\n type?: StringMatcher\n}\n\nexport type Routes<R = Route> = R[] | ((request: BotContext) => R[])\n\nexport interface BotRequest<TExtraData = any> {\n input: Input\n lastRoutePath: RoutePath\n session: Session<TExtraData>\n settings: BotSettings\n secrets: BotSecrets\n}\n\nexport interface BotSettings {\n HUBTYPE_API_URL: string\n STATIC_URL: string\n LITELLM_API_URL: string\n AZURE_OPENAI_API_BASE: string\n AZURE_OPENAI_API_VERSION: string\n LANGUAGE_DETECTION_ENABLED?: boolean\n CUSTOM_SHORT_URL_HOST: string | null\n custom: Record<string, any>\n}\n\nexport interface BotSecrets {\n HUBTYPE_ACCESS_TOKEN: string\n LITELLM_API_KEY: string\n AZURE_OPENAI_API_KEY: string\n custom: Record<string, any>\n}\n\nexport interface BotContext<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> extends BotRequest<TExtraData> {\n getUserCountry: () => string\n getUserLocale: () => string\n getSystemLocale: () => string\n setUserCountry: (country: string) => void\n setUserLocale: (locale: string) => void\n setSystemLocale: (locale: string) => void\n defaultDelay: number\n defaultTyping: number\n params: Record<string, string>\n plugins: TPlugins\n}\n\n/** The response of the bot for the triggered actions, which can be\n * the one matched by the routes, the default action and the retry actions.\n * See Response at @botonic/react's index.d.ts for the React type\n * */\nexport interface BotResponse extends BotRequest {\n response: any\n}\n\nexport type PluginPreRequest<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = BotContext<TPlugins, TExtraData>\n\nexport type PluginPostRequest<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = BotContext<TPlugins, TExtraData> & {\n response: string | null\n}\n\nexport interface Plugin {\n post?(request: PluginPostRequest): void | Promise<void>\n pre?(request: PluginPreRequest): void | Promise<void>\n}\n\nexport interface Params {\n [key: string]: any\n}\n\nexport type Nullable<T> = T | null\n\nexport type Action = Nullable<() => any>\nexport type RoutePath = Nullable<string>\n\nexport interface ProcessInputResult {\n action: Action\n emptyAction: Action\n fallbackAction: Action\n lastRoutePath: RoutePath\n params: Params\n}\n\nexport type MatchedValue = boolean | RegExpExecArray | null\n\nexport type RoutingState = {\n currentRoute: Nullable<Route>\n matchedRoute: Nullable<Route>\n params: Params\n isFlowBroken: boolean\n}\n\nexport interface RouteParams {\n route: Nullable<Route>\n params: Params\n}\nexport interface PathParams {\n path: RoutePath\n params: Params\n}\n\nexport type MatchingProp =\n | 'text'\n | 'payload'\n | 'type'\n | 'input'\n | 'session'\n | 'request'\n\nexport type Matcher = string | RegExp | ((args) => boolean)\n\nexport type BotonicActionType =\n | `${BotonicAction.CreateCase}${BotonicActionSeparator}${string}`\n | `${BotonicAction.Redirect}${BotonicActionSeparator}${string}`\n | `${BotonicAction.DiscardCase}${BotonicActionSeparator}${string}`\n | `${BotonicAction.DiscardCase}`\n | `${BotonicAction.DeleteUser}`\n\ntype BotonicActionSeparator = ':'\n\nexport enum BotonicAction {\n Redirect = 'redirect_action',\n CreateCase = 'create_case',\n DeleteUser = 'delete_user',\n DiscardCase = 'discard_case',\n}\n"],"names":["CASE_STATUS","CASE_RESOLUTION","PROVIDER","INPUT","NluType","CaseStatus","BotonicAction"],"mappings":"AAAA,wIAAwI;AAEjI,IAAKA,wBAAWA,0BAAXA;;;;;WAAAA;MAKX;AAQM,IAAKC,4BAAeA,0BAAfA;;;;;WAAAA;MAKX;AAQM,IAAKC,qBAAQA,0BAARA;;;;;;;;;;;;;WAAAA;MAaX;AAeM,IAAKC,kBAAKA,0BAALA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAAA;MA6BX;AA+CM,IAAKC,oBAAOA,0BAAPA;;;WAAAA;MAGX;AAwCM,IAAKC,uBAAUA,0BAAVA;;;;;WAAAA;MAKX;AAqRM,IAAKC,0BAAaA,0BAAbA;;;;;WAAAA;MAKX"}
@@ -1,4 +1,4 @@
1
- import type { BotContext } from './models';
1
+ import type { BotContext } from './models/index.js';
2
2
  interface RunPluginArgs {
3
3
  botContext: BotContext;
4
4
  mode: PluginMode;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runPlugins = runPlugins;
4
- async function runPlugins({ botContext, mode, response = null, }) {
1
+ async function runPlugins({ botContext, mode, response = null }) {
5
2
  const plugins = botContext.plugins;
6
- for (const key in plugins) {
3
+ for(const key in plugins){
7
4
  const plugin = plugins[key];
8
5
  try {
9
6
  if (mode === 'pre' && typeof plugin.pre === 'function') {
@@ -12,13 +9,15 @@ async function runPlugins({ botContext, mode, response = null, }) {
12
9
  if (mode === 'post' && typeof plugin.post === 'function') {
13
10
  await plugin.post({
14
11
  ...botContext,
15
- response,
12
+ response
16
13
  });
17
14
  }
18
- }
19
- catch (e) {
15
+ } catch (e) {
20
16
  console.log(e);
21
17
  }
22
18
  }
23
19
  }
20
+
21
+ export { runPlugins };
22
+
24
23
  //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sources":["../src/plugins.ts"],"sourcesContent":["import type { BotContext, Plugin } from './models'\n\ninterface RunPluginArgs {\n botContext: BotContext\n mode: PluginMode\n response?: string | null\n}\n\ntype PluginMode = 'pre' | 'post'\n\nexport async function runPlugins({\n botContext,\n mode,\n response = null,\n}: RunPluginArgs): Promise<void> {\n const plugins = botContext.plugins\n for (const key in plugins) {\n const plugin: Plugin = plugins[key]\n try {\n if (mode === 'pre' && typeof plugin.pre === 'function') {\n await plugin.pre(botContext)\n }\n if (mode === 'post' && typeof plugin.post === 'function') {\n await plugin.post({\n ...botContext,\n response,\n })\n }\n } catch (e) {\n console.log(e)\n }\n }\n}\n"],"names":["runPlugins","botContext","mode","response","plugins","key","plugin","e","console"],"mappings":"AAUO,eAAeA,UAAUA,CAAC,EAC/BC,UAAU,EACVC,IAAI,EACJC,WAAW,IAAI,EACD;IACd,MAAMC,UAAUH,WAAW,OAAO;IAClC,IAAK,MAAMI,OAAOD,QAAS;QACzB,MAAME,SAAiBF,OAAO,CAACC,IAAI;QACnC,IAAI;YACF,IAAIH,SAAS,SAAS,OAAOI,OAAO,GAAG,KAAK,YAAY;gBACtD,MAAMA,OAAO,GAAG,CAACL;YACnB;YACA,IAAIC,SAAS,UAAU,OAAOI,OAAO,IAAI,KAAK,YAAY;gBACxD,MAAMA,OAAO,IAAI,CAAC;oBAChB,GAAGL,UAAU;oBACbE;gBACF;YACF;QACF,EAAE,OAAOI,GAAG;YACVC,QAAQ,GAAG,CAACD;QACd;IACF;AACF"}
@@ -0,0 +1,23 @@
1
+ import { inflate } from "pako";
2
+
3
+
4
+
5
+ /**
6
+ *
7
+ * @param compressedData a string representing gzipped data previously encoded to base64 for very large contents
8
+ * @returns a string representing the information of a very large content
9
+ * Ref: https://stackoverflow.com/questions/4875020/javascript-decompress-inflate-unzip-ungzip-strings (check jsfiddle proposal)
10
+ */ function decompressData(compressedData) {
11
+ const strData = atob(compressedData) // Decode base64 (convert ascii to binary)
12
+ ;
13
+ const charData = strData.split('').map((x)=>x.charCodeAt(0)) // Convert binary string to character-number array
14
+ ;
15
+ const binData = new Uint8Array(charData) // Turn number array into byte-array
16
+ ;
17
+ const data = inflate(binData);
18
+ return new TextDecoder('utf-8').decode(data);
19
+ }
20
+
21
+ export { decompressData };
22
+
23
+ //# sourceMappingURL=pusher-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pusher-utils.js","sources":["../src/pusher-utils.ts"],"sourcesContent":["import { inflate } from 'pako'\n\n/**\n *\n * @param compressedData a string representing gzipped data previously encoded to base64 for very large contents\n * @returns a string representing the information of a very large content\n * Ref: https://stackoverflow.com/questions/4875020/javascript-decompress-inflate-unzip-ungzip-strings (check jsfiddle proposal)\n */\nexport function decompressData(compressedData: string): string {\n const strData = atob(compressedData) // Decode base64 (convert ascii to binary)\n const charData = strData.split('').map(x => x.charCodeAt(0)) // Convert binary string to character-number array\n const binData = new Uint8Array(charData) // Turn number array into byte-array\n const data = inflate(binData)\n return new TextDecoder('utf-8').decode(data)\n}\n"],"names":["inflate","decompressData","compressedData","strData","atob","charData","x","binData","Uint8Array","data","TextDecoder"],"mappings":";;;AAA8B;AAE9B;;;;;CAKC,GACM,SAASC,cAAcA,CAACC,cAAsB;IACnD,MAAMC,UAAUC,KAAKF,gBAAgB,0CAA0C;;IAC/E,MAAMG,WAAWF,QAAQ,KAAK,CAAC,IAAI,GAAG,CAACG,CAAAA,IAAKA,EAAE,UAAU,CAAC,IAAI,kDAAkD;;IAC/G,MAAMC,UAAU,IAAIC,WAAWH,UAAU,oCAAoC;;IAC7E,MAAMI,OAAOT,OAAOA,CAACO;IACrB,OAAO,IAAIG,YAAY,SAAS,MAAM,CAACD;AACzC"}
@@ -0,0 +1,2 @@
1
+ export * from './router.js';
2
+ export * from './router-utils.js';
@@ -0,0 +1,8 @@
1
+ export * from "./router.js";
2
+ export * from "./router-utils.js";
3
+
4
+
5
+
6
+ export {};
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing/index.js","sources":["../../src/routing/index.ts"],"sourcesContent":["export * from './router'\nexport * from './router-utils'\n"],"names":[],"mappings":";;AAAwB;AACM"}
@@ -1,4 +1,4 @@
1
- import type { Action, BotContext, Input, Params, PathParams, Route, Routes } from '../models';
1
+ import type { Action, BotContext, Input, Params, PathParams, Route, Routes } from '../models/index.js';
2
2
  export declare class NoMatchingRouteError extends Error {
3
3
  input: Input;
4
4
  constructor(input: Input);
@@ -1,47 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoMatchingRouteError = void 0;
4
- exports.isPathPayload = isPathPayload;
5
- exports.getPathParamsFromPathPayload = getPathParamsFromPathPayload;
6
- exports.pathParamsToParams = pathParamsToParams;
7
- exports.getEmptyAction = getEmptyAction;
8
- exports.getNotFoundAction = getNotFoundAction;
9
- exports.getComputedRoutes = getComputedRoutes;
10
- const constants_1 = require("../constants");
1
+ import { EMPTY_ACTION_PATH, NOT_FOUND_PATH, PATH_PAYLOAD_IDENTIFIER, PATH_PAYLOAD_REGEXP } from "../constants.js";
2
+
3
+
4
+ function _define_property(obj, key, value) {
5
+ if (key in obj) {
6
+ Object.defineProperty(obj, key, {
7
+ value: value,
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true
11
+ });
12
+ } else obj[key] = value;
13
+ return obj;
14
+ }
15
+
11
16
  class NoMatchingRouteError extends Error {
12
- constructor(input) {
13
- super(`No route found for input '${JSON.stringify(input)}' and no ${constants_1.NOT_FOUND_PATH} route defined`);
17
+ constructor(input){
18
+ super(`No route found for input '${JSON.stringify(input)}' and no ${NOT_FOUND_PATH} route defined`), _define_property(this, "input", void 0);
14
19
  this.input = input;
15
20
  }
16
21
  }
17
- exports.NoMatchingRouteError = NoMatchingRouteError;
18
- function isPathPayload(payload) {
22
+ function router_utils_isPathPayload(payload) {
19
23
  if (!payload) {
20
24
  return false;
21
25
  }
22
- const isPathPayload = constants_1.PATH_PAYLOAD_REGEXP.exec(payload);
26
+ const isPathPayload = PATH_PAYLOAD_REGEXP.exec(payload);
23
27
  return Boolean(isPathPayload);
24
28
  }
25
29
  function getPathParamsFromPathPayload(payload) {
26
30
  const defaultPathParams = {
27
31
  path: null,
28
- params: {},
32
+ params: {}
29
33
  };
30
34
  if (!payload) {
31
35
  return defaultPathParams;
32
36
  }
33
- if (!isPathPayload(payload)) {
37
+ if (!router_utils_isPathPayload(payload)) {
34
38
  return defaultPathParams;
35
39
  }
36
40
  try {
37
- const pathWithParams = payload.split(constants_1.PATH_PAYLOAD_IDENTIFIER)[1];
41
+ const pathWithParams = payload.split(PATH_PAYLOAD_IDENTIFIER)[1];
38
42
  if (!pathWithParams) {
39
- throw `${constants_1.PATH_PAYLOAD_IDENTIFIER} is empty`;
43
+ throw `${PATH_PAYLOAD_IDENTIFIER} is empty`;
40
44
  }
41
45
  const [path, params] = pathWithParams.split('?');
42
- return { path: path ?? null, params: pathParamsToParams(params) };
43
- }
44
- catch (e) {
46
+ return {
47
+ path: path ?? null,
48
+ params: pathParamsToParams(params)
49
+ };
50
+ } catch (e) {
45
51
  console.error('Error getting path and params from input.payload:', e);
46
52
  return defaultPathParams;
47
53
  }
@@ -53,12 +59,11 @@ function pathParamsToParams(pathParams) {
53
59
  try {
54
60
  const params = {};
55
61
  const searchParams = new URLSearchParams(pathParams);
56
- for (const [key, value] of searchParams) {
62
+ for (const [key, value] of searchParams){
57
63
  params[key] = value;
58
64
  }
59
65
  return params;
60
- }
61
- catch (_e) {
66
+ } catch (_e) {
62
67
  return {};
63
68
  }
64
69
  }
@@ -66,14 +71,14 @@ function getEmptyAction(childRoutes) {
66
71
  if (!childRoutes) {
67
72
  return null;
68
73
  }
69
- const emptyActionRoute = childRoutes.find(r => r.path === constants_1.EMPTY_ACTION_PATH);
74
+ const emptyActionRoute = childRoutes.find((r)=>r.path === EMPTY_ACTION_PATH);
70
75
  if (!emptyActionRoute) {
71
76
  return null;
72
77
  }
73
78
  return emptyActionRoute.action;
74
79
  }
75
80
  function getNotFoundAction(input, routes) {
76
- const notFoundActionRoute = routes.find(r => r.path === constants_1.NOT_FOUND_PATH);
81
+ const notFoundActionRoute = routes.find((r)=>r.path === NOT_FOUND_PATH);
77
82
  if (!notFoundActionRoute) {
78
83
  throw new NoMatchingRouteError(input);
79
84
  }
@@ -83,14 +88,16 @@ async function getComputedRoutes(routes, botContext) {
83
88
  if (routes instanceof Function) {
84
89
  return await getComputedRoutes(await routes(botContext), botContext);
85
90
  }
86
- for (const [key, route] of Object.entries(routes)) {
91
+ for (const [key, route] of Object.entries(routes)){
87
92
  if (route.childRoutes && route.childRoutes instanceof Function) {
88
93
  routes[key].childRoutes = await getComputedRoutes(await route.childRoutes(botContext), botContext);
89
- }
90
- else {
94
+ } else {
91
95
  routes[key] = route;
92
96
  }
93
97
  }
94
98
  return routes;
95
99
  }
100
+
101
+ export { NoMatchingRouteError, getComputedRoutes, getEmptyAction, getNotFoundAction, getPathParamsFromPathPayload, pathParamsToParams, router_utils_isPathPayload as isPathPayload };
102
+
96
103
  //# sourceMappingURL=router-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing/router-utils.js","sources":["../../src/routing/router-utils.ts"],"sourcesContent":["import {\n EMPTY_ACTION_PATH,\n NOT_FOUND_PATH,\n PATH_PAYLOAD_IDENTIFIER,\n PATH_PAYLOAD_REGEXP,\n} from '../constants'\nimport type {\n Action,\n BotContext,\n Input,\n Params,\n PathParams,\n Route,\n Routes,\n} from '../models'\n\nexport class NoMatchingRouteError extends Error {\n input: Input\n constructor(input: Input) {\n super(\n `No route found for input '${JSON.stringify(\n input\n )}' and no ${NOT_FOUND_PATH} route defined`\n )\n this.input = input\n }\n}\n\nexport function isPathPayload(payload?: string): boolean {\n if (!payload) {\n return false\n }\n const isPathPayload = PATH_PAYLOAD_REGEXP.exec(payload)\n return Boolean(isPathPayload)\n}\n\nexport function getPathParamsFromPathPayload(payload?: string): PathParams {\n const defaultPathParams = {\n path: null,\n params: {},\n }\n if (!payload) {\n return defaultPathParams\n }\n if (!isPathPayload(payload)) {\n return defaultPathParams\n }\n try {\n const pathWithParams = payload.split(PATH_PAYLOAD_IDENTIFIER)[1]\n if (!pathWithParams) {\n throw `${PATH_PAYLOAD_IDENTIFIER} is empty`\n }\n const [path, params] = pathWithParams.split('?')\n return { path: path ?? null, params: pathParamsToParams(params) }\n } catch (e) {\n console.error('Error getting path and params from input.payload:', e)\n return defaultPathParams\n }\n}\n\nexport function pathParamsToParams(pathParams?: string): Params {\n if (!pathParams) {\n return {}\n }\n try {\n const params = {}\n const searchParams = new URLSearchParams(pathParams)\n for (const [key, value] of searchParams) {\n params[key] = value\n }\n return params\n } catch (_e) {\n return {}\n }\n}\n\nexport function getEmptyAction(childRoutes?: Route[]): Action {\n if (!childRoutes) {\n return null\n }\n const emptyActionRoute = childRoutes.find(r => r.path === EMPTY_ACTION_PATH)\n if (!emptyActionRoute) {\n return null\n }\n return emptyActionRoute.action\n}\n\nexport function getNotFoundAction(input: Input, routes: Route[]): Action {\n const notFoundActionRoute = routes.find(r => r.path === NOT_FOUND_PATH)\n if (!notFoundActionRoute) {\n throw new NoMatchingRouteError(input)\n }\n return notFoundActionRoute.action\n}\n\nexport async function getComputedRoutes(\n routes: Routes,\n botContext: BotContext\n): Promise<Route[]> {\n if (routes instanceof Function) {\n return await getComputedRoutes(await routes(botContext), botContext)\n }\n for (const [key, route] of Object.entries(routes) as any) {\n if (route.childRoutes && route.childRoutes instanceof Function) {\n routes[key].childRoutes = await getComputedRoutes(\n await route.childRoutes(botContext),\n botContext\n )\n } else {\n routes[key] = route\n }\n }\n return routes\n}\n"],"names":["EMPTY_ACTION_PATH","NOT_FOUND_PATH","PATH_PAYLOAD_IDENTIFIER","PATH_PAYLOAD_REGEXP","NoMatchingRouteError","Error","input","JSON","isPathPayload","payload","Boolean","getPathParamsFromPathPayload","defaultPathParams","pathWithParams","path","params","pathParamsToParams","e","console","pathParams","searchParams","URLSearchParams","key","value","_e","getEmptyAction","childRoutes","emptyActionRoute","r","getNotFoundAction","routes","notFoundActionRoute","getComputedRoutes","botContext","Function","route","Object"],"mappings":";;;;;;;;;;;;;;AAKqB;AAWd,MAAMI,oBAAoBA,SAASC;IAExC,YAAYC,KAAY,CAAE;QACxB,KAAK,CACH,CAAC,0BAA0B,EAAEC,KAAK,SAAS,CACzCD,OACA,SAAS,EAAEL,cAAcA,CAAC,cAAc,CAAC,GAL/C;QAOE,IAAI,CAAC,KAAK,GAAGK;IACf;AACF;AAEO,SAASE,0BAAaA,CAACC,OAAgB;IAC5C,IAAI,CAACA,SAAS;QACZ,OAAO;IACT;IACA,MAAMD,gBAAgBL,wBAAwB,CAACM;IAC/C,OAAOC,QAAQF;AACjB;AAEO,SAASG,4BAA4BA,CAACF,OAAgB;IAC3D,MAAMG,oBAAoB;QACxB,MAAM;QACN,QAAQ,CAAC;IACX;IACA,IAAI,CAACH,SAAS;QACZ,OAAOG;IACT;IACA,IAAI,CAACJ,0BAAaA,CAACC,UAAU;QAC3B,OAAOG;IACT;IACA,IAAI;QACF,MAAMC,iBAAiBJ,QAAQ,KAAK,CAACP,uBAAuBA,CAAC,CAAC,EAAE;QAChE,IAAI,CAACW,gBAAgB;YACnB,MAAM,GAAGX,uBAAuBA,CAAC,SAAS,CAAC;QAC7C;QACA,MAAM,CAACY,MAAMC,OAAO,GAAGF,eAAe,KAAK,CAAC;QAC5C,OAAO;YAAE,MAAMC,QAAQ;YAAM,QAAQE,kBAAkBA,CAACD;QAAQ;IAClE,EAAE,OAAOE,GAAG;QACVC,QAAQ,KAAK,CAAC,qDAAqDD;QACnE,OAAOL;IACT;AACF;AAEO,SAASI,kBAAkBA,CAACG,UAAmB;IACpD,IAAI,CAACA,YAAY;QACf,OAAO,CAAC;IACV;IACA,IAAI;QACF,MAAMJ,SAAS,CAAC;QAChB,MAAMK,eAAe,IAAIC,gBAAgBF;QACzC,KAAK,MAAM,CAACG,KAAKC,MAAM,IAAIH,aAAc;YACvCL,MAAM,CAACO,IAAI,GAAGC;QAChB;QACA,OAAOR;IACT,EAAE,OAAOS,IAAI;QACX,OAAO,CAAC;IACV;AACF;AAEO,SAASC,cAAcA,CAACC,WAAqB;IAClD,IAAI,CAACA,aAAa;QAChB,OAAO;IACT;IACA,MAAMC,mBAAmBD,YAAY,IAAI,CAACE,CAAAA,IAAKA,EAAE,IAAI,KAAK5B,iBAAiBA;IAC3E,IAAI,CAAC2B,kBAAkB;QACrB,OAAO;IACT;IACA,OAAOA,iBAAiB,MAAM;AAChC;AAEO,SAASE,iBAAiBA,CAACvB,KAAY,EAAEwB,MAAe;IAC7D,MAAMC,sBAAsBD,OAAO,IAAI,CAACF,CAAAA,IAAKA,EAAE,IAAI,KAAK3B,cAAcA;IACtE,IAAI,CAAC8B,qBAAqB;QACxB,MAAM,IAAI3B,oBAAoBA,CAACE;IACjC;IACA,OAAOyB,oBAAoB,MAAM;AACnC;AAEO,eAAeC,iBAAiBA,CACrCF,MAAc,EACdG,UAAsB;IAEtB,IAAIH,kBAAkBI,UAAU;QAC9B,OAAO,MAAMF,iBAAiBA,CAAC,MAAMF,OAAOG,aAAaA;IAC3D;IACA,KAAK,MAAM,CAACX,KAAKa,MAAM,IAAIC,OAAO,OAAO,CAACN,QAAgB;QACxD,IAAIK,MAAM,WAAW,IAAIA,MAAM,WAAW,YAAYD,UAAU;YAC9DJ,MAAM,CAACR,IAAI,CAAC,WAAW,GAAG,MAAMU,iBAAiBA,CAC/C,MAAMG,MAAM,WAAW,CAACF,aACxBA;QAEJ,OAAO;YACLH,MAAM,CAACR,IAAI,GAAGa;QAChB;IACF;IACA,OAAOL;AACT"}
@@ -1,5 +1,5 @@
1
- import { RouteInspector } from '../debug/inspector';
2
- import type { Input, MatchedValue, Matcher, MatchingProp, Nullable, ProcessInputResult, Route, RouteParams, RoutePath, RoutingState, Session } from '../models';
1
+ import { RouteInspector } from '../debug/inspector.js';
2
+ import type { Input, MatchedValue, Matcher, MatchingProp, Nullable, ProcessInputResult, Route, RouteParams, RoutePath, RoutingState, Session } from '../models/index.js';
3
3
  export declare class Router {
4
4
  routes: Route[];
5
5
  routeInspector: RouteInspector;