@servicetitan/titan-chatbot-api 7.1.2 → 9.0.0

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 (178) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts +1 -0
  3. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts.map +1 -1
  4. package/dist/api-client/__mocks__/chatbot-api-client.mock.js +22 -47
  5. package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -1
  6. package/dist/api-client/base/chatbot-api-client.d.ts +7 -0
  7. package/dist/api-client/base/chatbot-api-client.d.ts.map +1 -1
  8. package/dist/api-client/base/chatbot-api-client.js +3 -4
  9. package/dist/api-client/base/chatbot-api-client.js.map +1 -1
  10. package/dist/api-client/index.d.ts +2 -2
  11. package/dist/api-client/index.d.ts.map +1 -1
  12. package/dist/api-client/index.js +12 -7
  13. package/dist/api-client/index.js.map +1 -1
  14. package/dist/api-client/models/__mocks__/models.mock.js +154 -124
  15. package/dist/api-client/models/__mocks__/models.mock.js.map +1 -1
  16. package/dist/api-client/models/index.d.ts +2 -1
  17. package/dist/api-client/models/index.d.ts.map +1 -1
  18. package/dist/api-client/models/index.js +8 -7
  19. package/dist/api-client/models/index.js.map +1 -1
  20. package/dist/api-client/titan-chat/__tests__/chatbot-api-client-stream.test.d.ts +2 -0
  21. package/dist/api-client/titan-chat/__tests__/chatbot-api-client-stream.test.d.ts.map +1 -0
  22. package/dist/api-client/titan-chat/__tests__/chatbot-api-client-stream.test.js +240 -0
  23. package/dist/api-client/titan-chat/__tests__/chatbot-api-client-stream.test.js.map +1 -0
  24. package/dist/api-client/titan-chat/__tests__/native-client.test.js +6 -6
  25. package/dist/api-client/titan-chat/__tests__/native-client.test.js.map +1 -1
  26. package/dist/api-client/titan-chat/chatbot-api-client.d.ts +11 -0
  27. package/dist/api-client/titan-chat/chatbot-api-client.d.ts.map +1 -1
  28. package/dist/api-client/titan-chat/chatbot-api-client.js +69 -35
  29. package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -1
  30. package/dist/api-client/titan-chat/index.d.ts +2 -1
  31. package/dist/api-client/titan-chat/index.d.ts.map +1 -1
  32. package/dist/api-client/titan-chat/index.js +1 -0
  33. package/dist/api-client/titan-chat/index.js.map +1 -1
  34. package/dist/api-client/titan-chat/native-client.js +359 -812
  35. package/dist/api-client/titan-chat/native-client.js.map +1 -1
  36. package/dist/api-client/utils/__tests__/model-utils.test.js +454 -191
  37. package/dist/api-client/utils/__tests__/model-utils.test.js.map +1 -1
  38. package/dist/api-client/utils/model-utils.d.ts.map +1 -1
  39. package/dist/api-client/utils/model-utils.js +28 -25
  40. package/dist/api-client/utils/model-utils.js.map +1 -1
  41. package/dist/hooks/use-customization-chatbot.js +2 -1
  42. package/dist/hooks/use-customization-chatbot.js.map +1 -1
  43. package/dist/index.d.ts +3 -2
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +7 -5
  46. package/dist/index.js.map +1 -1
  47. package/dist/models/__tests__/chatbot-customizations.test.d.ts +2 -0
  48. package/dist/models/__tests__/chatbot-customizations.test.d.ts.map +1 -0
  49. package/dist/models/__tests__/chatbot-customizations.test.js +36 -0
  50. package/dist/models/__tests__/chatbot-customizations.test.js.map +1 -0
  51. package/dist/models/chatbot-customizations.d.ts +17 -0
  52. package/dist/models/chatbot-customizations.d.ts.map +1 -1
  53. package/dist/models/chatbot-customizations.js +7 -1
  54. package/dist/models/chatbot-customizations.js.map +1 -1
  55. package/dist/models/index.js +1 -0
  56. package/dist/models/index.js.map +1 -1
  57. package/dist/stores/__tests__/chatbot-ui-backend.store.observability.test.d.ts +2 -0
  58. package/dist/stores/__tests__/chatbot-ui-backend.store.observability.test.d.ts.map +1 -0
  59. package/dist/stores/__tests__/chatbot-ui-backend.store.observability.test.js +107 -0
  60. package/dist/stores/__tests__/chatbot-ui-backend.store.observability.test.js.map +1 -0
  61. package/dist/stores/__tests__/chatbot-ui-backend.store.streaming.test.d.ts +2 -0
  62. package/dist/stores/__tests__/chatbot-ui-backend.store.streaming.test.d.ts.map +1 -0
  63. package/dist/stores/__tests__/chatbot-ui-backend.store.streaming.test.js +312 -0
  64. package/dist/stores/__tests__/chatbot-ui-backend.store.streaming.test.js.map +1 -0
  65. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js +267 -172
  66. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js.map +1 -1
  67. package/dist/stores/__tests__/chatbot-ui.store.test.js +61 -64
  68. package/dist/stores/__tests__/chatbot-ui.store.test.js.map +1 -1
  69. package/dist/stores/__tests__/filter.store.test.js +243 -116
  70. package/dist/stores/__tests__/filter.store.test.js.map +1 -1
  71. package/dist/stores/__tests__/initialize.store.test.js +9 -8
  72. package/dist/stores/__tests__/initialize.store.test.js.map +1 -1
  73. package/dist/stores/__tests__/message-feedback-guardrail.store.test.js +8 -7
  74. package/dist/stores/__tests__/message-feedback-guardrail.store.test.js.map +1 -1
  75. package/dist/stores/__tests__/message-feedback.store.test.js +34 -27
  76. package/dist/stores/__tests__/message-feedback.store.test.js.map +1 -1
  77. package/dist/stores/__tests__/session-feedback.store.test.js +9 -8
  78. package/dist/stores/__tests__/session-feedback.store.test.js.map +1 -1
  79. package/dist/stores/chatbot-ui-backend.store.d.ts +26 -2
  80. package/dist/stores/chatbot-ui-backend.store.d.ts.map +1 -1
  81. package/dist/stores/chatbot-ui-backend.store.js +295 -239
  82. package/dist/stores/chatbot-ui-backend.store.js.map +1 -1
  83. package/dist/stores/chatbot-ui.store.js +73 -46
  84. package/dist/stores/chatbot-ui.store.js.map +1 -1
  85. package/dist/stores/filter.store.js +298 -378
  86. package/dist/stores/filter.store.js.map +1 -1
  87. package/dist/stores/index.d.ts +5 -3
  88. package/dist/stores/index.d.ts.map +1 -1
  89. package/dist/stores/index.js +3 -2
  90. package/dist/stores/index.js.map +1 -1
  91. package/dist/stores/initialize.store.js +55 -51
  92. package/dist/stores/initialize.store.js.map +1 -1
  93. package/dist/stores/message-feedback-base.store.js +2 -1
  94. package/dist/stores/message-feedback-base.store.js.map +1 -1
  95. package/dist/stores/message-feedback-guardrail.store.js +50 -47
  96. package/dist/stores/message-feedback-guardrail.store.js.map +1 -1
  97. package/dist/stores/message-feedback.store.js +84 -89
  98. package/dist/stores/message-feedback.store.js.map +1 -1
  99. package/dist/stores/session-feedback.store.js +46 -39
  100. package/dist/stores/session-feedback.store.js.map +1 -1
  101. package/dist/streaming/__tests__/agent-stream.test.d.ts +2 -0
  102. package/dist/streaming/__tests__/agent-stream.test.d.ts.map +1 -0
  103. package/dist/streaming/__tests__/agent-stream.test.js +92 -0
  104. package/dist/streaming/__tests__/agent-stream.test.js.map +1 -0
  105. package/dist/streaming/agent-stream.d.ts +83 -0
  106. package/dist/streaming/agent-stream.d.ts.map +1 -0
  107. package/dist/streaming/agent-stream.js +28 -0
  108. package/dist/streaming/agent-stream.js.map +1 -0
  109. package/dist/streaming/index.d.ts +3 -0
  110. package/dist/streaming/index.d.ts.map +1 -0
  111. package/dist/streaming/index.js +4 -0
  112. package/dist/streaming/index.js.map +1 -0
  113. package/dist/streaming/run-agent-stream.d.ts +23 -0
  114. package/dist/streaming/run-agent-stream.d.ts.map +1 -0
  115. package/dist/streaming/run-agent-stream.js +83 -0
  116. package/dist/streaming/run-agent-stream.js.map +1 -0
  117. package/dist/utils/__tests__/axios-utils.test.js +8 -7
  118. package/dist/utils/__tests__/axios-utils.test.js.map +1 -1
  119. package/dist/utils/axios-utils.js +9 -7
  120. package/dist/utils/axios-utils.js.map +1 -1
  121. package/dist/utils/test-utils.js +5 -5
  122. package/dist/utils/test-utils.js.map +1 -1
  123. package/package.json +6 -3
  124. package/src/api-client/__mocks__/chatbot-api-client.mock.ts +1 -0
  125. package/src/api-client/base/chatbot-api-client.ts +11 -0
  126. package/src/api-client/index.ts +2 -7
  127. package/src/api-client/models/index.ts +15 -13
  128. package/src/api-client/titan-chat/__tests__/chatbot-api-client-stream.test.ts +208 -0
  129. package/src/api-client/titan-chat/chatbot-api-client.ts +46 -0
  130. package/src/api-client/titan-chat/index.ts +2 -1
  131. package/src/api-client/utils/model-utils.ts +4 -8
  132. package/src/index.ts +7 -2
  133. package/src/models/__tests__/chatbot-customizations.test.ts +26 -0
  134. package/src/models/chatbot-customizations.ts +20 -0
  135. package/src/stores/__tests__/chatbot-ui-backend.store.observability.test.ts +105 -0
  136. package/src/stores/__tests__/chatbot-ui-backend.store.streaming.test.ts +261 -0
  137. package/src/stores/chatbot-ui-backend.store.ts +179 -4
  138. package/src/stores/index.ts +5 -12
  139. package/src/streaming/__tests__/agent-stream.test.ts +80 -0
  140. package/src/streaming/agent-stream.ts +103 -0
  141. package/src/streaming/index.ts +2 -0
  142. package/src/streaming/run-agent-stream.ts +109 -0
  143. package/tsconfig.tsbuildinfo +1 -1
  144. package/dist/api-client/help-center/__tests__/converter-from-models.test.d.ts +0 -2
  145. package/dist/api-client/help-center/__tests__/converter-from-models.test.d.ts.map +0 -1
  146. package/dist/api-client/help-center/__tests__/converter-from-models.test.js +0 -34
  147. package/dist/api-client/help-center/__tests__/converter-from-models.test.js.map +0 -1
  148. package/dist/api-client/help-center/__tests__/converter-to-models.test.d.ts +0 -2
  149. package/dist/api-client/help-center/__tests__/converter-to-models.test.d.ts.map +0 -1
  150. package/dist/api-client/help-center/__tests__/converter-to-models.test.js +0 -82
  151. package/dist/api-client/help-center/__tests__/converter-to-models.test.js.map +0 -1
  152. package/dist/api-client/help-center/chatbot-api-client.d.ts +0 -32
  153. package/dist/api-client/help-center/chatbot-api-client.d.ts.map +0 -1
  154. package/dist/api-client/help-center/chatbot-api-client.js +0 -102
  155. package/dist/api-client/help-center/chatbot-api-client.js.map +0 -1
  156. package/dist/api-client/help-center/converter-from-models.d.ts +0 -13
  157. package/dist/api-client/help-center/converter-from-models.d.ts.map +0 -1
  158. package/dist/api-client/help-center/converter-from-models.js +0 -114
  159. package/dist/api-client/help-center/converter-from-models.js.map +0 -1
  160. package/dist/api-client/help-center/converter-to-models.d.ts +0 -13
  161. package/dist/api-client/help-center/converter-to-models.d.ts.map +0 -1
  162. package/dist/api-client/help-center/converter-to-models.js +0 -98
  163. package/dist/api-client/help-center/converter-to-models.js.map +0 -1
  164. package/dist/api-client/help-center/index.d.ts +0 -2
  165. package/dist/api-client/help-center/index.d.ts.map +0 -1
  166. package/dist/api-client/help-center/index.js +0 -2
  167. package/dist/api-client/help-center/index.js.map +0 -1
  168. package/dist/api-client/help-center/native-client.d.ts +0 -1268
  169. package/dist/api-client/help-center/native-client.d.ts.map +0 -1
  170. package/dist/api-client/help-center/native-client.js +0 -6242
  171. package/dist/api-client/help-center/native-client.js.map +0 -1
  172. package/src/api-client/help-center/__tests__/converter-from-models.test.ts +0 -41
  173. package/src/api-client/help-center/__tests__/converter-to-models.test.ts +0 -89
  174. package/src/api-client/help-center/chatbot-api-client.ts +0 -122
  175. package/src/api-client/help-center/converter-from-models.ts +0 -133
  176. package/src/api-client/help-center/converter-to-models.ts +0 -127
  177. package/src/api-client/help-center/index.ts +0 -1
  178. package/src/api-client/help-center/native-client.ts +0 -5727
@@ -1 +1 @@
1
- {"version":3,"file":"model-utils.test.js","sourceRoot":"","sources":["../../../../src/api-client/utils/__tests__/model-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACjD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAChC,IAAI,CAAC,qDAAqD,EAAE,GAAG,EAAE;YAC7D,MAAM,aAAa,GAAG,WAAW,CAAC,iBAAiB,EAAE,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AAM,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACjD,MAAM,CAAC,MAAO,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,CAAC,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/api-client/utils/__tests__/model-utils.test.ts"],"sourcesContent":["import { expect } from '@jest/globals';\nimport { Models, ModelsMocks } from '../..';\nimport { createSelectionsModel } from '../model-utils';\n\ndescribe('[model-utils] createSelectionsModel', () => {\n afterEach(() => {\n jest.clearAllMocks();\n });\n\n describe('with no selections', () => {\n test('should return undefined when no selections are made', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = [frontendModel.options];\n const selected = new Map<string, string[]>();\n\n const result = createSelectionsModel(filters, selected);\n\n expect(result).toBeUndefined();\n });\n\n test('should return undefined when selected map is empty', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = [frontendModel.options];\n const selected = new Map<string, string[]>();\n\n const result = createSelectionsModel(filters, selected);\n\n expect(result).toBeUndefined();\n });\n\n test('should handle empty selection arrays', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = [frontendModel.options];\n const selected = new Map<string, string[]>([\n ['Sources', []],\n ['ContentTypes', []],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n\n expect(result).toBeUndefined();\n });\n });\n\n describe('with flat filter structure (leaf filters only)', () => {\n test('top level, single filter, single value', () => {\n const flatModel = ModelsMocks.mockFrontendModelFlat();\n const flatFilters = flatModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([['ContentTypes', ['kbReleaseNotes']]]);\n\n const result = createSelectionsModel(flatFilters, selected);\n expect(result).toEqual({\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n },\n });\n });\n\n test('top level, single filter, multiple values', () => {\n const flatModel = ModelsMocks.mockFrontendModelFlat();\n const flatFilters = flatModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['ContentTypes', ['kbReleaseNotes', 'kbFaq', 'kbHowTo']],\n ]);\n\n const result = createSelectionsModel(flatFilters, selected);\n expect(result).toEqual({\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'kbFaq', 'kbHowTo'],\n },\n },\n });\n });\n\n test('top level, multiple filter, multiple values', () => {\n const flatModel = ModelsMocks.mockFrontendModelFlat();\n const flatFilters = flatModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['ContentTypes', ['kbReleaseNotes', 'kbFaq']],\n ['ProductAreas', ['Marketing']],\n ]);\n\n const result = createSelectionsModel(flatFilters, selected);\n expect(result).toEqual({\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'kbFaq'],\n },\n ProductAreas: {\n values: ['Marketing'],\n },\n },\n });\n });\n\n test('non-existing filter', () => {\n const flatModel = ModelsMocks.mockFrontendModelFlat();\n const flatFilters = flatModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['ContentTypes', ['kbReleaseNotes', 'nonExistentOption']],\n ]);\n\n const result = createSelectionsModel(flatFilters, selected);\n expect(result).toEqual({\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n },\n });\n });\n\n test('no valid filters', () => {\n const flatModel = ModelsMocks.mockFrontendModelFlat();\n const flatFilters = flatModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['ContentTypes', ['nonExistent1', 'nonExistent2']],\n ]);\n\n const result = createSelectionsModel(flatFilters, selected);\n expect(result).toBeUndefined();\n });\n });\n\n describe('with mixed filter structure', () => {\n test('top level, single filter, single value', () => {\n const frontendModel = ModelsMocks.mockFrontendModelMixed();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([['Sources', ['Jarvis']]]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['Jarvis'],\n },\n },\n });\n });\n\n test('top level, multiple filters, single value', () => {\n const frontendModel = ModelsMocks.mockFrontendModelMixed();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([['Sources', ['KnowledgeBase', 'Jarvis']]]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase', 'Jarvis'],\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values', () => {\n const frontendModel = ModelsMocks.mockFrontendModelMixed();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase', 'Jarvis']],\n ['ContentTypes', ['kbReleaseNotes']],\n ['ProductAreas', ['Marketing']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase', 'Jarvis'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n ProductAreas: {\n values: ['Marketing'],\n },\n },\n },\n },\n },\n },\n });\n });\n });\n\n describe('with nested filter structure', () => {\n test('top level, single filter, single value', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([['Sources', ['KnowledgeBase']]]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase'],\n },\n },\n });\n });\n\n test('all levels, multiple filters, single value', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase']],\n ['ContentTypes', ['kbReleaseNotes']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n },\n },\n },\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values (with shared sub option)', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase', 'Jarvis']],\n ['ContentTypes', ['kbReleaseNotes']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase', 'Jarvis'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n },\n },\n Jarvis: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes'],\n },\n },\n },\n },\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values (with mixed sub options)', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase', 'Jarvis']],\n ['ContentTypes', ['kbReleaseNotes', 'kbFaq', 'xxx']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase', 'Jarvis'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'kbFaq'],\n },\n },\n },\n Jarvis: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'xxx'],\n },\n },\n },\n },\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase']],\n ['ProductAreas', ['Marketing', 'Marketing Pro']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ProductAreas: {\n values: ['Marketing', 'Marketing Pro'],\n },\n },\n },\n },\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values (more values)', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase']],\n ['ContentTypes', ['kbReleaseNotes', 'kbHowTo']],\n ['ProductAreas', ['Marketing']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'kbHowTo'],\n },\n ProductAreas: {\n values: ['Marketing'],\n },\n },\n },\n },\n },\n },\n });\n });\n\n test('all levels, multiple filters, multiple values (more values2)', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase', 'Jarvis']],\n ['ContentTypes', ['kbReleaseNotes', 'yyy', 'kbHowTo']],\n ['ProductAreas', ['Marketing', 'Marketing Pro']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n expect(result).toEqual({\n subOptions: {\n Sources: {\n values: ['KnowledgeBase', 'Jarvis'],\n subOptions: {\n KnowledgeBase: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'kbHowTo'],\n },\n ProductAreas: {\n values: ['Marketing', 'Marketing Pro'],\n },\n },\n },\n Jarvis: {\n subOptions: {\n ContentTypes: {\n values: ['kbReleaseNotes', 'yyy'],\n },\n },\n },\n },\n },\n },\n });\n });\n });\n\n describe('edge cases', () => {\n test('should ignore non-Group type filters', () => {\n const customFilters: Models.IOption[] = [\n new Models.Option({\n key: 'NotAGroup',\n displayName: 'Not A Group',\n type: Models.OptionType.Selectable,\n subOptions: [\n new Models.Option({\n key: 'option1',\n displayName: 'Option 1',\n type: Models.OptionType.Selectable,\n }),\n ],\n }),\n ];\n const selected = new Map<string, string[]>([['NotAGroup', ['option1']]]);\n\n const result = createSelectionsModel(customFilters, selected);\n\n expect(result).toBeUndefined();\n });\n\n test('should handle filters with no subOptions', () => {\n const customFilters: Models.IOption[] = [\n new Models.Option({\n key: 'EmptyFilter',\n displayName: 'Empty Filter',\n type: Models.OptionType.Group,\n subOptions: [],\n }),\n ];\n const selected = new Map<string, string[]>([['EmptyFilter', ['anything']]]);\n\n const result = createSelectionsModel(customFilters, selected);\n\n expect(result).toBeUndefined();\n });\n\n test('should create proper Selections model structure', () => {\n const frontendModel = ModelsMocks.mockFrontendModel();\n const filters = frontendModel.options.subOptions ?? [];\n const selected = new Map<string, string[]>([\n ['Sources', ['KnowledgeBase']],\n ['ContentTypes', ['kbReleaseNotes']],\n ]);\n\n const result = createSelectionsModel(filters, selected);\n\n expect(result).toBeInstanceOf(Models.Selections);\n expect(result!.subOptions).toBeDefined();\n expect(typeof result?.subOptions).toBe('object');\n });\n });\n});\n"],"names":["expect","Models","ModelsMocks","createSelectionsModel","describe","afterEach","jest","clearAllMocks","test","frontendModel","mockFrontendModel","filters","options","selected","Map","result","toBeUndefined","flatModel","mockFrontendModelFlat","flatFilters","subOptions","toEqual","ContentTypes","values","ProductAreas","mockFrontendModelMixed","Sources","KnowledgeBase","Jarvis","customFilters","Option","key","displayName","type","OptionType","Selectable","Group","toBeInstanceOf","Selections","toBeDefined","toBe"],"mappings":"AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,MAAM,EAAEC,WAAW,QAAQ,QAAQ;AAC5C,SAASC,qBAAqB,QAAQ,iBAAiB;AAEvDC,SAAS,uCAAuC;IAC5CC,UAAU;QACNC,KAAKC,aAAa;IACtB;IAEAH,SAAS,sBAAsB;QAC3BI,KAAK,uDAAuD;YACxD,MAAMC,gBAAgBP,YAAYQ,iBAAiB;YACnD,MAAMC,UAAU;g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CvC,OAAO,QAAOe,mBAAAA,6BAAAA,OAAQK,UAAU,GAAEoB,IAAI,CAAC;QAC3C;IACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../../src/api-client/utils/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAE5E;AAED,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAChC,MAAM,CAAC,UAAU,GAAG,SAAS,CA6E/B"}
1
+ {"version":3,"file":"model-utils.d.ts","sourceRoot":"","sources":["../../../src/api-client/utils/model-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAE5B,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAE5E;AAED,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAChC,MAAM,CAAC,UAAU,GAAG,SAAS,CAyE/B"}
@@ -3,48 +3,51 @@ export function createNewSessionModel(data) {
3
3
  return new Models.Session(data);
4
4
  }
5
5
  export function createSelectionsModel(filters, selected) {
6
- const process = (filters) => {
6
+ const process = (filters)=>{
7
7
  let result;
8
- const ensureResult = () => {
9
- if (!result) {
10
- result = new Models.Selections({
11
- subOptions: {},
12
- });
13
- }
8
+ const ensureResult = ()=>{
9
+ result !== null && result !== void 0 ? result : result = new Models.Selections({
10
+ subOptions: {}
11
+ });
14
12
  return result.subOptions;
15
13
  };
16
- const filterList = filters.filter(x => { var _a; return x.type === Models.OptionType.Group && Boolean((_a = x.subOptions) === null || _a === void 0 ? void 0 : _a.length); });
17
- for (const filter of filterList) {
18
- const selectedLeafOptions = filter.subOptions.filter(x => {
19
- var _a;
20
- return x.type === Models.OptionType.Selectable &&
21
- ((_a = selected.get(filter.key)) === null || _a === void 0 ? void 0 : _a.includes(x.key));
14
+ const filterList = filters.filter((x)=>{
15
+ var _x_subOptions;
16
+ return x.type === Models.OptionType.Group && Boolean((_x_subOptions = x.subOptions) === null || _x_subOptions === void 0 ? void 0 : _x_subOptions.length);
17
+ });
18
+ for (const filter of filterList){
19
+ const selectedLeafOptions = filter.subOptions.filter((x)=>{
20
+ var _selected_get;
21
+ return x.type === Models.OptionType.Selectable && ((_selected_get = selected.get(filter.key)) === null || _selected_get === void 0 ? void 0 : _selected_get.includes(x.key));
22
22
  });
23
23
  let values;
24
24
  if (selectedLeafOptions.length) {
25
25
  // Leaf filter: just collect selected values
26
- values = selectedLeafOptions === null || selectedLeafOptions === void 0 ? void 0 : selectedLeafOptions.map(o => o.key).filter(o => { var _a; return (_a = selected.get(filter.key)) === null || _a === void 0 ? void 0 : _a.includes(o); });
26
+ values = selectedLeafOptions === null || selectedLeafOptions === void 0 ? void 0 : selectedLeafOptions.map((o)=>o.key).filter((o)=>{
27
+ var _selected_get;
28
+ return (_selected_get = selected.get(filter.key)) === null || _selected_get === void 0 ? void 0 : _selected_get.includes(o);
29
+ });
27
30
  if (values === null || values === void 0 ? void 0 : values.length) {
28
31
  const subOptions = ensureResult();
29
- subOptions[filter.key] = new Models.Selections({ values });
32
+ subOptions[filter.key] = new Models.Selections({
33
+ values
34
+ });
30
35
  }
31
36
  }
32
37
  if (!selectedLeafOptions.length) {
33
38
  continue;
34
39
  }
35
40
  // Non-leaf filter: add selected options as selectables and process sub-filters
36
- const selectedNonLeafOptions = filter.subOptions.filter(x => {
37
- var _a, _b;
38
- return x.type === Models.OptionType.Selectable &&
39
- ((_a = selected.get(filter.key)) === null || _a === void 0 ? void 0 : _a.includes(x.key)) &&
40
- Boolean((_b = x.subOptions) === null || _b === void 0 ? void 0 : _b.length);
41
+ const selectedNonLeafOptions = filter.subOptions.filter((x)=>{
42
+ var _selected_get, _x_subOptions;
43
+ return x.type === Models.OptionType.Selectable && ((_selected_get = selected.get(filter.key)) === null || _selected_get === void 0 ? void 0 : _selected_get.includes(x.key)) && Boolean((_x_subOptions = x.subOptions) === null || _x_subOptions === void 0 ? void 0 : _x_subOptions.length);
41
44
  });
42
45
  if (!selectedNonLeafOptions.length) {
43
46
  continue;
44
47
  }
45
48
  // We have some sub-filters to process: collect their results
46
49
  const subFilterResults = new Map();
47
- for (const nonLeafOption of selectedNonLeafOptions) {
50
+ for (const nonLeafOption of selectedNonLeafOptions){
48
51
  const subFilters = nonLeafOption.subOptions;
49
52
  const resultSubFilters = process(subFilters);
50
53
  if (!resultSubFilters) {
@@ -55,15 +58,14 @@ export function createSelectionsModel(filters, selected) {
55
58
  // If any sub-filters selected, ensure result and add them to the current subOptions
56
59
  if (subFilterResults.size) {
57
60
  const subOptions = ensureResult();
58
- for (const [key, value] of subFilterResults) {
61
+ for (const [key, value] of subFilterResults){
62
+ var _subFilterSelection, _subOptions;
59
63
  let subFilterSelection = subOptions[filter.key];
60
64
  if (!subFilterSelection) {
61
65
  subFilterSelection = new Models.Selections({});
62
66
  subOptions[filter.key] = subFilterSelection;
63
67
  }
64
- if (!subFilterSelection.subOptions) {
65
- subFilterSelection.subOptions = {};
66
- }
68
+ (_subOptions = (_subFilterSelection = subFilterSelection).subOptions) !== null && _subOptions !== void 0 ? _subOptions : _subFilterSelection.subOptions = {};
67
69
  subFilterSelection.subOptions[key] = value;
68
70
  }
69
71
  }
@@ -72,4 +74,5 @@ export function createSelectionsModel(filters, selected) {
72
74
  };
73
75
  return process(filters);
74
76
  }
77
+
75
78
  //# sourceMappingURL=model-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-utils.js","sourceRoot":"","sources":["../../../src/api-client/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AI,CAAC,gBAAgB,EAAE,CAAC;oBACpB,SAAS;gBACb,CAAC;gBACD,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,GAAI,EAAE,gBAAgB,CAAC,CAAC;YAC/D,CAAC;YAED,oFAAoF;YACpF,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC;gBACxB,MAAM,UAAU,GAAG,YAAY,EAAE,CAAC;gBAClC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,gBAAgB,EAAE,CAAC;oBAC1C,IAAI,kBAAkB,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBAChD,IAAI,CAAC,kBAAkB,EAAE,CAAC;wBACtB,kBAAkB,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;wBAC/C,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC;oBAChD,CAAC;oBACD,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAAC;wBACjC,kBAAkB,CAAC,UAAU,GAAG,EAAE,CAAC;oBACvC,CAAC;oBACD,kBAAkB,CAAC,UAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBAChD,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;IACF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC"}
1
+ {"version":3,"sources":["../../../src/api-client/utils/model-utils.ts"],"sourcesContent":["import { Models } from '..';\n\nexport function createNewSessionModel(data?: Models.ISession): Models.Session {\n return new Models.Session(data);\n}\n\nexport function createSelectionsModel(\n filters: Models.IOption[],\n selected: Map<string, string[]>\n): Models.Selections | undefined {\n const process = (filters: Models.IOption[]): Models.Selections | undefined => {\n let result: Models.Selections | undefined;\n const ensureResult = () => {\n result ??= new Models.Selections({\n subOptions: {},\n });\n return result.subOptions!;\n };\n\n const filterList = filters.filter(\n x => x.type === Models.OptionType.Group && Boolean(x.subOptions?.length)\n );\n for (const filter of filterList) {\n const selectedLeafOptions = filter.subOptions!.filter(\n x =>\n x.type === Models.OptionType.Selectable &&\n selected.get(filter.key)?.includes(x.key!)\n );\n let values: string[] | undefined;\n if (selectedLeafOptions.length) {\n // Leaf filter: just collect selected values\n values = selectedLeafOptions\n ?.map(o => o.key)\n .filter(o => selected.get(filter.key)?.includes(o));\n if (values?.length) {\n const subOptions = ensureResult();\n subOptions[filter.key] = new Models.Selections({ values });\n }\n }\n if (!selectedLeafOptions.length) {\n continue;\n }\n\n // Non-leaf filter: add selected options as selectables and process sub-filters\n const selectedNonLeafOptions = filter.subOptions!.filter(\n x =>\n x.type === Models.OptionType.Selectable &&\n selected.get(filter.key)?.includes(x.key!) &&\n Boolean(x.subOptions?.length)\n );\n if (!selectedNonLeafOptions.length) {\n continue;\n }\n\n // We have some sub-filters to process: collect their results\n const subFilterResults = new Map<string, Models.Selections>();\n for (const nonLeafOption of selectedNonLeafOptions) {\n const subFilters = nonLeafOption.subOptions!;\n const resultSubFilters = process(subFilters);\n if (!resultSubFilters) {\n continue;\n }\n subFilterResults.set(nonLeafOption.key!, resultSubFilters);\n }\n\n // If any sub-filters selected, ensure result and add them to the current subOptions\n if (subFilterResults.size) {\n const subOptions = ensureResult();\n for (const [key, value] of subFilterResults) {\n let subFilterSelection = subOptions[filter.key];\n if (!subFilterSelection) {\n subFilterSelection = new Models.Selections({});\n subOptions[filter.key] = subFilterSelection;\n }\n subFilterSelection.subOptions ??= {};\n subFilterSelection.subOptions![key] = value;\n }\n }\n }\n return result;\n };\n return process(filters);\n}\n"],"names":["Models","createNewSessionModel","data","Session","createSelectionsModel","filters","selected","process","result","ensureResult","Selections","subOptions","filterList","filter","x","type","OptionType","Group","Boolean","length","selectedLeafOptions","Selectable","get","key","includes","values","map","o","selectedNonLeafOptions","subFilterResults","Map","nonLeafOption","subFilters","resultSubFilters","set","size","value","subFilterSelection"],"mappings":"AAAA,SAASA,MAAM,QAAQ,KA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8 @@
1
1
  import { useDependencies } from '@servicetitan/react-ioc';
2
2
  import { CHATBOT_UI_STORE_TOKEN } from '../stores';
3
- export const useCustomizationChatbot = () => {
3
+ export const useCustomizationChatbot = ()=>{
4
4
  const [chatbotUiStore] = useDependencies(CHATBOT_UI_STORE_TOKEN);
5
5
  return chatbotUiStore.customizations;
6
6
  };
7
+
7
8
  //# sourceMappingURL=use-customization-chatbot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-customization-chatbot.js","sourceRoot":"","sources":["../../src/hooks/use-customization-chatbot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACxC,MAAM,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAC;IACjE,OAAO,cAAc,CAAC,cAAc,CAAC;AACzC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/hooks/use-customization-chatbot.tsx"],"sourcesContent":["import { useDependencies } from '@servicetitan/react-ioc';\nimport { CHATBOT_UI_STORE_TOKEN } from '../stores';\n\nexport const useCustomizationChatbot = () => {\n const [chatbotUiStore] = useDependencies(CHATBOT_UI_STORE_TOKEN);\n return chatbotUiStore.customizations;\n};\n"],"names":["useDependencies","CHATBOT_UI_STORE_TOKEN","useCustomizationChatbot","chatbotUiStore","customizations"],"mappings":"AAAA,SAASA,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,sBAAsB,QAAQ,YAAY;AAEnD,OAAO,MAAMC,0BAA0B;IACnC,MAAM,CAACC,eAAe,GAAGH,gBAAgBC;IACzC,OAAOE,eAAeC,cAAc;AACxC,EAAE"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from './api-client';
2
2
  export * from './stores';
3
- export * from './models';
3
+ export * from './streaming';
4
+ export type * from './models';
5
+ export { isChatbotStreamingEnabled, DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS, } from './models/chatbot-customizations';
4
6
  export * from './hooks/use-customization-chatbot';
5
- export * as NativeClientHC from './api-client/help-center/native-client';
6
7
  export * as NativeClientTC from './api-client/titan-chat/native-client';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mCAAmC,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,wCAAwC,CAAC;AACzE,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,mBAAmB,UAAU,CAAC;AAE9B,OAAO,EACH,yBAAyB,EACzB,uCAAuC,GAC1C,MAAM,iCAAiC,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
- /* eslint-disable no-restricted-imports */
2
- export * from './api-client';
1
+ /* eslint-disable no-restricted-imports */ export * from './api-client';
3
2
  export * from './stores';
4
- export * from './models';
3
+ export * from './streaming';
4
+ // Runtime helpers from models (the `export type *` above is type-only).
5
+ export { isChatbotStreamingEnabled, DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS } from './models/chatbot-customizations';
5
6
  export * from './hooks/use-customization-chatbot';
6
- export * as NativeClientHC from './api-client/help-center/native-client';
7
- export * as NativeClientTC from './api-client/titan-chat/native-client';
7
+ import * as _NativeClientTC from './api-client/titan-chat/native-client';
8
+ export { _NativeClientTC as NativeClientTC };
9
+
8
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mCAAmC,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,wCAAwC,CAAC;AACzE,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable no-restricted-imports */\nexport * from './api-client';\nexport * from './stores';\nexport * from './streaming';\nexport type * from './models';\n// Runtime helpers from models (the `export type *` above is type-only).\nexport {\n isChatbotStreamingEnabled,\n DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS,\n} from './models/chatbot-customizations';\nexport * from './hooks/use-customization-chatbot';\nexport * as NativeClientTC from './api-client/titan-chat/native-client';\n"],"names":["isChatbotStreamingEnabled","DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS","NativeClientTC"],"mappings":"AAAA,wCAAwC,GACxC,cAAc,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,cAAc;AAE5B,wEAAwE;AACxE,SACIA,yBAAyB,EACzBC,uCAAuC,QACpC,kCAAkC;AACzC,cAAc,oCAAoC;AAClD,iCAAgC,wCAAwC;AAAxE,SAAO,mBAAKC,cAAc,GAA8C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chatbot-customizations.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatbot-customizations.test.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/chatbot-customizations.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from '@jest/globals';
2
+ import { isChatbotStreamingEnabled } from '../chatbot-customizations';
3
+ describe('ChatbotCustomizations streaming setting', ()=>{
4
+ test('streaming is disabled when customizations are undefined', ()=>{
5
+ expect(isChatbotStreamingEnabled(undefined)).toBe(false);
6
+ });
7
+ test('streaming is disabled when the streaming setting is absent', ()=>{
8
+ const c = {
9
+ feedback: {
10
+ title: 'x'
11
+ }
12
+ };
13
+ expect(isChatbotStreamingEnabled(c)).toBe(false);
14
+ });
15
+ test('streaming is disabled when explicitly false', ()=>{
16
+ const c = {
17
+ streaming: {
18
+ enabled: false
19
+ }
20
+ };
21
+ expect(isChatbotStreamingEnabled(c)).toBe(false);
22
+ });
23
+ test('streaming is enabled only when explicitly true', ()=>{
24
+ var _c_streaming;
25
+ const c = {
26
+ streaming: {
27
+ enabled: true,
28
+ inactivityTimeoutMs: 16000
29
+ }
30
+ };
31
+ expect(isChatbotStreamingEnabled(c)).toBe(true);
32
+ expect((_c_streaming = c.streaming) === null || _c_streaming === void 0 ? void 0 : _c_streaming.inactivityTimeoutMs).toBe(16000);
33
+ });
34
+ });
35
+
36
+ //# sourceMappingURL=chatbot-customizations.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/models/__tests__/chatbot-customizations.test.ts"],"sourcesContent":["import { describe, expect, test } from '@jest/globals';\nimport { ChatbotCustomizations, isChatbotStreamingEnabled } from '../chatbot-customizations';\n\ndescribe('ChatbotCustomizations streaming setting', () => {\n test('streaming is disabled when customizations are undefined', () => {\n expect(isChatbotStreamingEnabled(undefined)).toBe(false);\n });\n\n test('streaming is disabled when the streaming setting is absent', () => {\n const c: ChatbotCustomizations = { feedback: { title: 'x' } };\n expect(isChatbotStreamingEnabled(c)).toBe(false);\n });\n\n test('streaming is disabled when explicitly false', () => {\n const c: ChatbotCustomizations = { streaming: { enabled: false } };\n expect(isChatbotStreamingEnabled(c)).toBe(false);\n });\n\n test('streaming is enabled only when explicitly true', () => {\n const c: ChatbotCustomizations = {\n streaming: { enabled: true, inactivityTimeoutMs: 16_000 },\n };\n expect(isChatbotStreamingEnabled(c)).toBe(true);\n expect(c.streaming?.inactivityTimeoutMs).toBe(16_000);\n });\n});\n"],"names":["describe","expect","test","isChatbotStreamingEnabled","undefined","toBe","c","feedback","title","streaming","enabled","inactivityTimeoutMs"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,gBAAgB;AACvD,SAAgCC,yBAAyB,QAAQ,4BAA4B;AAE7FH,SAAS,2CAA2C;IAChDE,KAAK,2DAA2D;QAC5DD,OAAOE,0BAA0BC,YAAYC,IAAI,CAAC;IACtD;IAEAH,KAAK,8DAA8D;QAC/D,MAAMI,IAA2B;YAAEC,UAAU;gBAAEC,OAAO;YAAI;QAAE;QAC5DP,OAAOE,0BAA0BG,IAAID,IAAI,CAAC;IAC9C;IAEAH,KAAK,+CAA+C;QAChD,MAAMI,IAA2B;YAAEG,WAAW;gBAAEC,SAAS;YAAM;QAAE;QACjET,OAAOE,0BAA0BG,IAAID,IAAI,CAAC;IAC9C;IAEAH,KAAK,kDAAkD;YAK5CI;QAJP,MAAMA,IAA2B;YAC7BG,WAAW;gBAAEC,SAAS;gBAAMC,qBAAqB;YAAO;QAC5D;QACAV,OAAOE,0BAA0BG,IAAID,IAAI,CAAC;QAC1CJ,QAAOK,eAAAA,EAAEG,SAAS,cAAXH,mCAAAA,aAAaK,mBAAmB,EAAEN,IAAI,CAAC;IAClD;AACJ"}
@@ -7,6 +7,19 @@ import { ChatCustomizations, ChatError } from '@servicetitan/titan-chat-ui-commo
7
7
  */
8
8
  export type FilterDefaultSelectionFn = (filterKey: string, optionKey: string) => boolean;
9
9
  export type ChatbotCustomizations = ChatCustomizations & Partial<{
10
+ /**
11
+ * Agent-progress SSE streaming. Disabled by default; when disabled (or when the streaming
12
+ * endpoint is unreachable at connect time) the widget falls back to the non-streaming path.
13
+ */
14
+ streaming?: {
15
+ /** Opt in to the SSE streaming send-path. Defaults to false. */
16
+ enabled?: boolean;
17
+ /**
18
+ * Inactivity threshold (ms) before the "Still working on it…" keepalive is shown.
19
+ * Defaults to 16000 (matching the legacy hard timeout).
20
+ */
21
+ inactivityTimeoutMs?: number;
22
+ };
10
23
  timeouts?: {
11
24
  chatbotRequestTimeoutMs?: number;
12
25
  };
@@ -28,4 +41,8 @@ export type ChatbotCustomizations = ChatCustomizations & Partial<{
28
41
  isDefaultSelected?: FilterDefaultSelectionFn;
29
42
  };
30
43
  }>;
44
+ /** Default inactivity threshold before the keepalive message is shown (ms). */
45
+ export declare const DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS = 16000;
46
+ /** Whether the SSE streaming send-path is enabled. Defaults to off. */
47
+ export declare const isChatbotStreamingEnabled: (customizations?: ChatbotCustomizations) => boolean;
31
48
  //# sourceMappingURL=chatbot-customizations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot-customizations.d.ts","sourceRoot":"","sources":["../../src/models/chatbot-customizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;AAEzF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAClD,OAAO,CAAC;IACJ,QAAQ,CAAC,EAAE;QACP,uBAAuB,CAAC,EAAE,MAAM,CAAC;KACpC,CAAC;IACF,KAAK,CAAC,EAAE;QACJ,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACjD,CAAC;IACF,QAAQ,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAChC,uBAAuB,CAAC,EAAE,OAAO,CAAC;KACrC,CAAC;IACF,OAAO,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;QAC5B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;KAChD,CAAC;CACL,CAAC,CAAC"}
1
+ {"version":3,"file":"chatbot-customizations.d.ts","sourceRoot":"","sources":["../../src/models/chatbot-customizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;AAEzF,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAClD,OAAO,CAAC;IACJ;;;OAGG;IACH,SAAS,CAAC,EAAE;QACR,gEAAgE;QAChE,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB;;;WAGG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;IACF,QAAQ,CAAC,EAAE;QACP,uBAAuB,CAAC,EAAE,MAAM,CAAC;KACpC,CAAC;IACF,KAAK,CAAC,EAAE;QACJ,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACjD,CAAC;IACF,QAAQ,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;QAChC,uBAAuB,CAAC,EAAE,OAAO,CAAC;KACrC,CAAC;IACF,OAAO,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;QAC5B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;KAChD,CAAC;CACL,CAAC,CAAC;AAEP,+EAA+E;AAC/E,eAAO,MAAM,uCAAuC,QAAS,CAAC;AAE9D,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,GAAI,iBAAiB,qBAAqB,KAAG,OACpC,CAAC"}
@@ -1,2 +1,8 @@
1
- export {};
1
+ /** Default inactivity threshold before the keepalive message is shown (ms). */ export const DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS = 16000;
2
+ /** Whether the SSE streaming send-path is enabled. Defaults to off. */ export const isChatbotStreamingEnabled = (customizations)=>{
3
+ var _ref;
4
+ var _customizations_streaming;
5
+ return (_ref = customizations === null || customizations === void 0 ? void 0 : (_customizations_streaming = customizations.streaming) === null || _customizations_streaming === void 0 ? void 0 : _customizations_streaming.enabled) !== null && _ref !== void 0 ? _ref : false;
6
+ };
7
+
2
8
  //# sourceMappingURL=chatbot-customizations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatbot-customizations.js","sourceRoot":"","sources":["../../src/models/chatbot-customizations.ts"],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../../src/models/chatbot-customizations.ts"],"sourcesContent":["import { ChatCustomizations, ChatError } from '@servicetitan/titan-chat-ui-common';\n\n/**\n * Customization function to determine if a filter option should be selected by default.\n * @param filterKey - The key of the filter (e.g., 'Sources', 'ContentTypes', 'ProductAreas')\n * @param optionKey - The key of the option within the filter\n * @returns true if the option should be selected by default, false otherwise\n */\nexport type FilterDefaultSelectionFn = (filterKey: string, optionKey: string) => boolean;\n\nexport type ChatbotCustomizations = ChatCustomizations &\n Partial<{\n /**\n * Agent-progress SSE streaming. Disabled by default; when disabled (or when the streaming\n * endpoint is unreachable at connect time) the widget falls back to the non-streaming path.\n */\n streaming?: {\n /** Opt in to the SSE streaming send-path. Defaults to false. */\n enabled?: boolean;\n /**\n * Inactivity threshold (ms) before the \"Still working on it…\" keepalive is shown.\n * Defaults to 16000 (matching the legacy hard timeout).\n */\n inactivityTimeoutMs?: number;\n };\n timeouts?: {\n chatbotRequestTimeoutMs?: number;\n };\n error?: {\n recover: (error?: ChatError) => Promise<void>;\n };\n feedback?: {\n title?: string;\n showGuardrailFeedback?: boolean;\n isCommentAlwaysRequired?: boolean;\n };\n filters?: {\n enabled?: boolean;\n position?: 'top' | 'bottom';\n /**\n * Function to determine if a filter option should be selected by default.\n * Called for each filter option during initialization.\n */\n isDefaultSelected?: FilterDefaultSelectionFn;\n };\n }>;\n\n/** Default inactivity threshold before the keepalive message is shown (ms). */\nexport const DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS = 16_000;\n\n/** Whether the SSE streaming send-path is enabled. Defaults to off. */\nexport const isChatbotStreamingEnabled = (customizations?: ChatbotCustomizations): boolean =>\n customizations?.streaming?.enabled ?? false;\n"],"names":["DEFAULT_STREAMING_INACTIVITY_TIMEOUT_MS","isChatbotStreamingEnabled","customizations","streaming","enabled"],"mappings":"AA+CA,6EAA6E,GAC7E,OAAO,MAAMA,0CAA0C,MAAO;AAE9D,qEAAqE,GACrE,OAAO,MAAMC,4BAA4B,CAACC;;QACtCA;mBAAAA,2BAAAA,sCAAAA,4BAAAA,eAAgBC,SAAS,cAAzBD,gDAAAA,0BAA2BE,OAAO,uCAAI;EAAM"}
@@ -1,2 +1,3 @@
1
1
  export * from './chatbot-customizations';
2
+
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"sources":["../../src/models/index.ts"],"sourcesContent":["export * from './chatbot-customizations';\n"],"names":[],"mappings":"AAAA,cAAc,2BAA2B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chatbot-ui-backend.store.observability.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatbot-ui-backend.store.observability.test.d.ts","sourceRoot":"","sources":["../../../src/stores/__tests__/chatbot-ui-backend.store.observability.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,107 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ import { expect } from '@jest/globals';
15
+ import { Log } from '@servicetitan/log-service';
16
+ import { CHATBOT_API_CLIENT, ModelsMocks } from '../../api-client';
17
+ import { ChatbotApiClientMock } from '../../api-client/__mocks__/chatbot-api-client.mock';
18
+ import { initTestContainer } from '../../utils/test-utils';
19
+ import { ChatbotUiBackendStore } from '../chatbot-ui-backend.store';
20
+ import { CHATBOT_UI_STORE_TOKEN, ChatbotUiStore } from '../chatbot-ui.store';
21
+ const initContainer = initTestContainer(ChatbotUiBackendStore, (container)=>{
22
+ container.bind(Log).to(class {
23
+ constructor(){
24
+ _define_property(this, "error", jest.fn());
25
+ _define_property(this, "info", jest.fn());
26
+ _define_property(this, "warning", jest.fn());
27
+ }
28
+ }).inSingletonScope();
29
+ container.bind(CHATBOT_API_CLIENT).toConstantValue(new ChatbotApiClientMock());
30
+ container.bind(CHATBOT_UI_STORE_TOKEN).to(ChatbotUiStore).inSingletonScope();
31
+ });
32
+ describe('[ChatbotUiBackendStore] streaming observability', ()=>{
33
+ let container;
34
+ let store;
35
+ let chatbotApi;
36
+ let chatUiStore;
37
+ let log;
38
+ const runListener = async (listener, args)=>new Promise((resolve, reject)=>listener.apply(store, [
39
+ resolve,
40
+ reject,
41
+ ...args
42
+ ]));
43
+ const sendStreamed = async ()=>{
44
+ chatUiStore.setCustomizationContext({
45
+ streaming: {
46
+ enabled: true
47
+ }
48
+ });
49
+ await chatUiStore.sendMessageText('q');
50
+ const message = chatUiStore.messages.at(-1);
51
+ await runListener(store.handleMessageSend, [
52
+ message
53
+ ]);
54
+ };
55
+ const codesLogged = ()=>log.info.mock.calls.map((c)=>c[0].code);
56
+ beforeEach(()=>{
57
+ container = initContainer();
58
+ store = container.get(ChatbotUiBackendStore);
59
+ chatbotApi = container.get(CHATBOT_API_CLIENT);
60
+ chatUiStore = container.get(CHATBOT_UI_STORE_TOKEN);
61
+ log = container.get(Log);
62
+ chatbotApi.getOptions.mockResolvedValue(ModelsMocks.mockFrontendModel());
63
+ chatbotApi.postSession.mockResolvedValue(ModelsMocks.mockSession());
64
+ });
65
+ test('logs the connection lifecycle (connected → completed)', async ()=>{
66
+ chatbotApi.streamMessage.mockImplementation((_m, h)=>{
67
+ var _h_onConnected, _h_onCompleted;
68
+ (_h_onConnected = h.onConnected) === null || _h_onConnected === void 0 ? void 0 : _h_onConnected.call(h);
69
+ (_h_onCompleted = h.onCompleted) === null || _h_onCompleted === void 0 ? void 0 : _h_onCompleted.call(h);
70
+ return ModelsMocks.mockBotMessage({
71
+ answer: 'done'
72
+ });
73
+ });
74
+ await sendStreamed();
75
+ const codes = codesLogged();
76
+ expect(codes).toContain('TitanChatbot_Streaming_connected');
77
+ expect(codes).toContain('TitanChatbot_Streaming_completed');
78
+ });
79
+ test('logs disconnected and timed_out lifecycle phases', async ()=>{
80
+ chatbotApi.streamMessage.mockImplementation((_m, h)=>{
81
+ var _h_onConnected, _h_onDisconnected, _h_onTimeout;
82
+ (_h_onConnected = h.onConnected) === null || _h_onConnected === void 0 ? void 0 : _h_onConnected.call(h);
83
+ (_h_onDisconnected = h.onDisconnected) === null || _h_onDisconnected === void 0 ? void 0 : _h_onDisconnected.call(h);
84
+ (_h_onTimeout = h.onTimeout) === null || _h_onTimeout === void 0 ? void 0 : _h_onTimeout.call(h);
85
+ return ModelsMocks.mockBotMessage({
86
+ answer: 'done'
87
+ });
88
+ });
89
+ await sendStreamed();
90
+ const codes = codesLogged();
91
+ expect(codes).toContain('TitanChatbot_Streaming_disconnected');
92
+ expect(codes).toContain('TitanChatbot_Streaming_timed_out');
93
+ });
94
+ test('tracks fallback separately and does not log a completed streaming run', async ()=>{
95
+ chatbotApi.streamMessage.mockRejectedValue(new Error('unreachable'));
96
+ chatbotApi.postMessage.mockResolvedValue(ModelsMocks.mockBotMessage({
97
+ answer: 'fallback'
98
+ }));
99
+ await sendStreamed();
100
+ expect(store.streamingFallbackCount).toBe(1);
101
+ const codes = codesLogged();
102
+ expect(codes).toContain('TitanChatbot_Streaming_fallback');
103
+ expect(codes).not.toContain('TitanChatbot_Streaming_completed');
104
+ });
105
+ });
106
+
107
+ //# sourceMappingURL=chatbot-ui-backend.store.observability.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/stores/__tests__/chatbot-ui-backend.store.observability.test.ts"],"sourcesContent":["import { expect } from '@jest/globals';\nimport { ILog, Log, LogError, LogInfo, LogWarning } from '@servicetitan/log-service';\nimport { Container } from '@servicetitan/react-ioc';\nimport { ChatMessageModelText, ChatUiEventListener } from '@servicetitan/titan-chat-ui-common';\nimport { CHATBOT_API_CLIENT, IChatbotApiClient, Models, ModelsMocks } from '../../api-client';\nimport { ChatbotApiClientMock } from '../../api-client/__mocks__/chatbot-api-client.mock';\nimport { AgentStreamHandlers } from '../../streaming';\nimport { initTestContainer } from '../../utils/test-utils';\nimport { ChatbotUiBackendStore } from '../chatbot-ui-backend.store';\nimport { CHATBOT_UI_STORE_TOKEN, ChatbotUiStore } from '../chatbot-ui.store';\n\nconst initContainer = initTestContainer(ChatbotUiBackendStore, container => {\n container\n .bind<ILog>(Log)\n .to(\n class implements ILog {\n error: (entry: LogError) => void = jest.fn();\n info: (entry: LogInfo) => void = jest.fn();\n warning: (entry: LogWarning) => void = jest.fn();\n }\n )\n .inSingletonScope();\n container\n .bind<IChatbotApiClient>(CHATBOT_API_CLIENT)\n .toConstantValue(new ChatbotApiClientMock());\n container.bind(CHATBOT_UI_STORE_TOKEN).to(ChatbotUiStore).inSingletonScope();\n});\n\ndescribe('[ChatbotUiBackendStore] streaming observability', () => {\n let container: Container;\n let store: ChatbotUiBackendStore;\n let chatbotApi: ChatbotApiClientMock;\n let chatUiStore: ChatbotUiStore;\n let log: ILog;\n\n const runListener = async (listener: ChatUiEventListener, args: unknown[]) =>\n new Promise<void>((resolve, reject) => listener.apply(store, [resolve, reject, ...args]));\n\n const sendStreamed = async () => {\n chatUiStore.setCustomizationContext({ streaming: { enabled: true } });\n await chatUiStore.sendMessageText('q');\n const message = chatUiStore.messages.at(-1)! as ChatMessageModelText;\n await runListener(store.handleMessageSend, [message]);\n };\n\n const codesLogged = () =>\n (log.info as jest.Mock).mock.calls.map(c => (c[0] as { code: string }).code);\n\n beforeEach(() => {\n container = initContainer();\n store = container.get(ChatbotUiBackendStore);\n chatbotApi = container.get<IChatbotApiClient>(CHATBOT_API_CLIENT) as ChatbotApiClientMock;\n chatUiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);\n log = container.get<ILog>(Log);\n chatbotApi.getOptions.mockResolvedValue(ModelsMocks.mockFrontendModel());\n chatbotApi.postSession.mockResolvedValue(ModelsMocks.mockSession());\n });\n\n test('logs the connection lifecycle (connected → completed)', async () => {\n chatbotApi.streamMessage.mockImplementation(\n (_m: Models.IUserMessage, h: AgentStreamHandlers) => {\n h.onConnected?.();\n h.onCompleted?.();\n return ModelsMocks.mockBotMessage({ answer: 'done' });\n }\n );\n\n await sendStreamed();\n\n const codes = codesLogged();\n expect(codes).toContain('TitanChatbot_Streaming_connected');\n expect(codes).toContain('TitanChatbot_Streaming_completed');\n });\n\n test('logs disconnected and timed_out lifecycle phases', async () => {\n chatbotApi.streamMessage.mockImplementation(\n (_m: Models.IUserMessage, h: AgentStreamHandlers) => {\n h.onConnected?.();\n h.onDisconnected?.();\n h.onTimeout?.();\n return ModelsMocks.mockBotMessage({ answer: 'done' });\n }\n );\n\n await sendStreamed();\n\n const codes = codesLogged();\n expect(codes).toContain('TitanChatbot_Streaming_disconnected');\n expect(codes).toContain('TitanChatbot_Streaming_timed_out');\n });\n\n test('tracks fallback separately and does not log a completed streaming run', async () => {\n chatbotApi.streamMessage.mockRejectedValue(new Error('unreachable'));\n chatbotApi.postMessage.mockResolvedValue(\n ModelsMocks.mockBotMessage({ answer: 'fallback' })\n );\n\n await sendStreamed();\n\n expect(store.streamingFallbackCount).toBe(1);\n const codes = codesLogged();\n expect(codes).toContain('TitanChatbot_Streaming_fallback');\n expect(codes).not.toContain('TitanChatbot_Streaming_completed');\n });\n});\n"],"names":["expect","Log","CHATBOT_API_CLIENT","ModelsMocks","ChatbotApiClientMock","initTestContainer","ChatbotUiBackendStore","CHATBOT_UI_STORE_TOKEN","ChatbotUiStore","initContainer","container","bind","to","error","jest","fn","info","warning","inSingletonScope","toConstantValue","describe","store","chatbotApi","chatUiStore","log","runListener","listener","args","Promise","resolve","reject","apply","sendStreamed","setCustomizationContext","streaming","enabled","sendMessageText","message","messages","at","handleMessageSend","codesLogged","mock","calls","map","c","code","beforeEach","get","getOptions","mockResolvedValue","mockFrontendModel","postSession","mockSession","test","streamMessage","mockImplementation","_m","h","onConnected","onCompleted","mockBotMessage","answer","codes","toContain","onDisconnected","onTimeout","mockRejectedValue","Error","postMessage","streamingFallbackCount","toBe","not"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAAeC,GAAG,QAAuC,4BAA4B;AAGrF,SAASC,kBAAkB,EAA6BC,WAAW,QAAQ,mBAAmB;AAC9F,SAASC,oBAAoB,QAAQ,qDAAqD;AAE1F,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qBAAqB,QAAQ,8BAA8B;AACpE,SAASC,sBAAsB,EAAEC,cAAc,QAAQ,sBAAsB;AAE7E,MAAMC,gBAAgBJ,kBAAkBC,uBAAuBI,CAAAA;IAC3DA,UACKC,IAAI,CAAOV,KACXW,EAAE,CACC;;YACIC,uBAAAA,SAAmCC,KAAKC,EAAE;YAC1CC,uBAAAA,QAAiCF,KAAKC,EAAE;YACxCE,uBAAAA,WAAuCH,KAAKC,EAAE;;IAClD,GAEHG,gBAAgB;IACrBR,UACKC,IAAI,CAAoBT,oBACxBiB,eAAe,CAAC,IAAIf;IACzBM,UAAUC,IAAI,CAACJ,wBAAwBK,EAAE,CAACJ,gBAAgBU,gBAAgB;AAC9E;AAEAE,SAAS,mDAAmD;IACxD,IAAIV;IACJ,IAAIW;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IA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ACrDhC,WAAWiC,aAAa,CAACC,kBAAkB,CACvC,CAACC,IAAyBC;gBACtBA,gBACAA,mBACAA;aAFAA,iBAAAA,EAAEC,WAAW,cAAbD,qCAAAA,oBAAAA;aACAA,oBAAAA,EAAEO,cAAc,cAAhBP,wCAAAA,uBAAAA;aACAA,eAAAA,EAAEQ,SAAS,cAAXR,mCAAAA,kBAAAA;YACA,OAAOvD,YAAY0D,cAAc,CAAC;gBAAEC,QAAQ;YAAO;QACvD;QAGJ,MAAM9B;QAEN,MAAM+B,QAAQtB;QACdzC,OAAO+D,OAAOC,SAAS,CAAC;QACxBhE,OAAO+D,OAAOC,SAAS,CAAC;IAC5B;IAEAV,KAAK,yEAAyE;QAC1EhC,WAAWiC,aAAa,CAACY,iBAAiB,CAAC,IAAIC,MAAM;QACrD9C,WAAW+C,WAAW,CAACnB,iBAAiB,CACpC/C,YAAY0D,cAAc,CAAC;YAAEC,QAAQ;QAAW;QAGpD,MAAM9B;QAENhC,OAAOqB,MAAMiD,sBAAsB,EAAEC,IAAI,CAAC;QAC1C,MAAMR,QAAQtB;QACdzC,OAAO+D,OAAOC,SAAS,CAAC;QACxBhE,OAAO+D,OAAOS,GAAG,CAACR,SAAS,CAAC;IAChC;AACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chatbot-ui-backend.store.streaming.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatbot-ui-backend.store.streaming.test.d.ts","sourceRoot":"","sources":["../../../src/stores/__tests__/chatbot-ui-backend.store.streaming.test.ts"],"names":[],"mappings":""}