@aakash58/chatbot 1.1.19 → 1.1.21
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.
- package/.editorconfig +17 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +41 -0
- package/.vscode/settings.json +14 -0
- package/.vscode/tasks.json +60 -0
- package/README.md +298 -22
- package/angular.json +132 -0
- package/docs/PUBLISHING_GUIDE.md +104 -0
- package/package.json +75 -29
- package/projects/app-doohbot/public/assets/const/app-const.json +15 -0
- package/projects/app-doohbot/public/assets/const/doohclick_license.json +6 -0
- package/projects/app-doohbot/public/favicon.ico +0 -0
- package/projects/app-doohbot/src/app/app.config.ts +13 -0
- package/projects/app-doohbot/src/app/app.html +31 -0
- package/projects/app-doohbot/src/app/app.routes.ts +3 -0
- package/projects/app-doohbot/src/app/app.scss +279 -0
- package/projects/app-doohbot/src/app/app.spec.ts +23 -0
- package/projects/app-doohbot/src/app/app.ts +72 -0
- package/projects/app-doohbot/src/index.html +15 -0
- package/projects/app-doohbot/src/main.ts +6 -0
- package/projects/app-doohbot/src/styles.scss +15 -0
- package/projects/app-doohbot/tsconfig.app.json +15 -0
- package/projects/app-doohbot/tsconfig.spec.json +14 -0
- package/projects/doohbot/README.md +64 -0
- package/projects/doohbot/docs/README.md +140 -0
- package/projects/doohbot/ng-package.json +10 -0
- package/projects/doohbot/package.json +16 -0
- package/projects/doohbot/src/lib/app/chat/chat-ui-state.service.ts +194 -0
- package/projects/doohbot/src/lib/app/chat/chat.service.ts +547 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.html +27 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.scss +115 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.ts +35 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.html +3 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.scss +20 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.ts +12 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.html +34 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.scss +78 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.ts +52 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.html +77 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.scss +346 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.ts +188 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.html +146 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.scss +187 -0
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.ts +256 -0
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.html +17 -0
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.scss +59 -0
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.ts +28 -0
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.html +138 -0
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.scss +436 -0
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.ts +106 -0
- package/projects/doohbot/src/lib/app/chat/model/chat-history.model.ts +57 -0
- package/projects/doohbot/src/lib/app/chat/model/chat-request.model.ts +17 -0
- package/projects/doohbot/src/lib/app/chat/model/chat-response.model.ts +9 -0
- package/projects/doohbot/src/lib/app/chat/model/chat-session.model.ts +14 -0
- package/{lib/app/chat/model/chat-stream-message.model.d.ts → projects/doohbot/src/lib/app/chat/model/chat-stream-message.model.ts} +6 -5
- package/projects/doohbot/src/lib/app/chat/model/chat-stream-response.model.ts +12 -0
- package/projects/doohbot/src/lib/app/chat/services/chat-api.service.ts +82 -0
- package/projects/doohbot/src/lib/app/chat/services/chat-audio.service.ts +44 -0
- package/projects/doohbot/src/lib/app/chat/services/chat-history.service.ts +303 -0
- package/projects/doohbot/src/lib/app/login/login-form.component.html +80 -0
- package/projects/doohbot/src/lib/app/login/login-form.component.scss +189 -0
- package/projects/doohbot/src/lib/app/login/login-form.component.ts +45 -0
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.html +81 -0
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.scss +179 -0
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.ts +217 -0
- package/projects/doohbot/src/lib/app/personalization/personalization.service.ts +197 -0
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.html +111 -0
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.scss +218 -0
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.ts +121 -0
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.html +46 -0
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.scss +138 -0
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.ts +28 -0
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/color-picker-dialog.component.ts +92 -0
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.html +198 -0
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.scss +107 -0
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.ts +103 -0
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.html +46 -0
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.scss +131 -0
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.ts +23 -0
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.html +33 -0
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.scss +61 -0
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.ts +20 -0
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.html +30 -0
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.scss +59 -0
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.ts +12 -0
- package/projects/doohbot/src/lib/constant/doohbot-constant.ts +40 -0
- package/projects/doohbot/src/lib/constant/html-entities.ts +8 -0
- package/projects/doohbot/src/lib/constant/utf8.ts +9 -0
- package/projects/doohbot/src/lib/core/app-const.ts +63 -0
- package/projects/doohbot/src/lib/core/auth/account-api.service.ts +53 -0
- package/projects/doohbot/src/lib/core/auth/auth.service.ts +478 -0
- package/projects/doohbot/src/lib/core/auth/models/auth-result.model.ts +4 -0
- package/projects/doohbot/src/lib/core/auth/models/federated-login-request.model.ts +5 -0
- package/projects/doohbot/src/lib/core/auth/models/login-request.model.ts +6 -0
- package/projects/doohbot/src/lib/core/auth/storage.service.ts +113 -0
- package/projects/doohbot/src/lib/core/directives/draggable/draggable-dialog.directive.ts +123 -0
- package/projects/doohbot/src/lib/core/directives/draggable/draggable-dialog.module.ts +9 -0
- package/projects/doohbot/src/lib/core/directives/fullscreen/fullscreen.directive.ts +58 -0
- package/projects/doohbot/src/lib/core/directives/fullscreen/fullscreen.module.ts +9 -0
- package/projects/doohbot/src/lib/core/directives/popout/popout.directive.ts +169 -0
- package/projects/doohbot/src/lib/core/directives/popout/popout.module.ts +9 -0
- package/projects/doohbot/src/lib/core/directives/resizable/resizable-dialog.directive.ts +197 -0
- package/projects/doohbot/src/lib/core/directives/resizable/resizable-dialog.module.ts +9 -0
- package/projects/doohbot/src/lib/core/enums/api-request-state.enum.ts +9 -0
- package/projects/doohbot/src/lib/core/environments/environment.prod.ts +14 -0
- package/projects/doohbot/src/lib/core/environments/environment.ts +14 -0
- package/projects/doohbot/src/lib/core/helpers/crypto-helper.service.ts +72 -0
- package/projects/doohbot/src/lib/core/http/http-stream.service.ts +105 -0
- package/projects/doohbot/src/lib/core/http/http.service.ts +148 -0
- package/projects/doohbot/src/lib/core/interceptors/auth.interceptor.ts +118 -0
- package/projects/doohbot/src/lib/core/interceptors/license.interceptor.ts +50 -0
- package/projects/doohbot/src/lib/core/models/api-config.model.ts +82 -0
- package/projects/doohbot/src/lib/core/models/api-request.model.ts +92 -0
- package/projects/doohbot/src/lib/core/models/api-response.model.ts +13 -0
- package/projects/doohbot/src/lib/core/models/doohbot-config.model.ts +109 -0
- package/{lib/core/models/license.model.d.ts → projects/doohbot/src/lib/core/models/license.model.ts} +27 -23
- package/projects/doohbot/src/lib/core/models/message.ts +18 -0
- package/projects/doohbot/src/lib/core/models/theme-config.model.ts +48 -0
- package/projects/doohbot/src/lib/core/services/core-config.service.ts +53 -0
- package/projects/doohbot/src/lib/core/services/doohbot-api.service.ts +207 -0
- package/projects/doohbot/src/lib/core/services/license.service.ts +171 -0
- package/projects/doohbot/src/lib/core/services/markdown.service.ts +73 -0
- package/projects/doohbot/src/lib/core/services/theme.service.ts +305 -0
- package/{lib/core/types/auth-mode.type.d.ts → projects/doohbot/src/lib/core/types/auth-mode.type.ts} +4 -4
- package/{lib/core/types/auth-status.type.d.ts → projects/doohbot/src/lib/core/types/auth-status.type.ts} +5 -4
- package/{lib/core/types/chat-stream.type.d.ts → projects/doohbot/src/lib/core/types/chat-stream.type.ts} +4 -4
- package/{lib/core/types/message-role.type.d.ts → projects/doohbot/src/lib/core/types/message-role.type.ts} +4 -4
- package/{lib/core/types/prompt-mode.type.d.ts → projects/doohbot/src/lib/core/types/prompt-mode.type.ts} +5 -4
- package/{lib/core/types/snackbar-error.type.d.ts → projects/doohbot/src/lib/core/types/snackbar-error.type.ts} +5 -4
- package/{lib/core/types/tenant-resolution-strategy.type.d.ts → projects/doohbot/src/lib/core/types/tenant-resolution-strategy.type.ts} +4 -4
- package/projects/doohbot/src/lib/core/utils/error-handler.util.ts +31 -0
- package/projects/doohbot/src/lib/core/utils/logger.service.ts +45 -0
- package/projects/doohbot/src/lib/doohbot-input.ts +19 -0
- package/projects/doohbot/src/lib/doohbot.component.html +34 -0
- package/projects/doohbot/src/lib/doohbot.component.scss +17 -0
- package/projects/doohbot/src/lib/doohbot.component.spec.ts +31 -0
- package/projects/doohbot/src/lib/doohbot.component.ts +545 -0
- package/projects/doohbot/src/lib/elements.ts +25 -0
- package/projects/doohbot/src/lib/predefined_messages.ts +14 -0
- package/projects/doohbot/src/lib/shared/chips/chips.component.html +9 -0
- package/projects/doohbot/src/lib/shared/chips/chips.component.scss +29 -0
- package/projects/doohbot/src/lib/shared/chips/chips.component.spec.ts +22 -0
- package/projects/doohbot/src/lib/shared/chips/chips.component.ts +20 -0
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.html +29 -0
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.scss +100 -0
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.ts +42 -0
- package/projects/doohbot/src/lib/shared/dialog/dialog.service.ts +62 -0
- package/projects/doohbot/src/lib/shared/dialog/dialog.utils.ts +102 -0
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.html +30 -0
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.scss +53 -0
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.spec.ts +22 -0
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.ts +35 -0
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.html +16 -0
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.scss +45 -0
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.ts +46 -0
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.html +5 -0
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.scss +0 -0
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.spec.ts +22 -0
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.ts +20 -0
- package/projects/doohbot/src/lib/shared/pipes/simple-markdown.pipe.ts +19 -0
- package/projects/doohbot/src/lib/shared/popout/popout.html +1 -0
- package/projects/doohbot/src/lib/shared/popout/popout.scss +0 -0
- package/projects/doohbot/src/lib/shared/popout/popout.spec.ts +23 -0
- package/projects/doohbot/src/lib/shared/popout/popout.ts +11 -0
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.html +7 -0
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.scss +125 -0
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.spec.ts +21 -0
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.ts +44 -0
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.service.ts +54 -0
- package/{lib/shared/snackbar/snackbar.utils.d.ts → projects/doohbot/src/lib/shared/snackbar/snackbar.utils.ts} +49 -33
- package/projects/doohbot/src/lib/styles/_theme.scss +132 -0
- package/projects/doohbot/src/lib/styles/material-override.scss +302 -0
- package/projects/doohbot/src/lib/styles/utility.scss +588 -0
- package/projects/doohbot/src/public-api.ts +42 -0
- package/projects/doohbot/tsconfig.lib.json +15 -0
- package/projects/doohbot/tsconfig.lib.prod.json +11 -0
- package/projects/doohbot/tsconfig.spec.json +10 -0
- package/proxy.conf.json +8 -0
- package/publish.config.js +25 -0
- package/scripts/publishing/index.ts +67 -0
- package/scripts/publishing/pipeline/01-clean.ts +11 -0
- package/scripts/publishing/pipeline/02-validate-pre.ts +8 -0
- package/scripts/publishing/pipeline/03-build.ts +7 -0
- package/scripts/publishing/pipeline/04-validate-post.ts +8 -0
- package/scripts/publishing/pipeline/05-prepare-package.ts +29 -0
- package/scripts/publishing/pipeline/06-version.ts +23 -0
- package/scripts/publishing/pipeline/07-publish.ts +14 -0
- package/scripts/publishing/pipeline/08-cleanup.ts +5 -0
- package/scripts/publishing/types.ts +36 -0
- package/scripts/publishing/utils/command.ts +15 -0
- package/scripts/publishing/utils/config.ts +17 -0
- package/scripts/validate.ts +166 -0
- package/tsconfig.json +45 -0
- package/tsconfig.scripts.json +15 -0
- package/esm2022/aakash58-chatbot.mjs +0 -5
- package/esm2022/lib/app/chat/chat-ui-state.service.mjs +0 -170
- package/esm2022/lib/app/chat/chat.service.mjs +0 -445
- package/esm2022/lib/app/chat/components/chat-button/chat-button.component.mjs +0 -50
- package/esm2022/lib/app/chat/components/chat-footer/chat-footer.component.mjs +0 -12
- package/esm2022/lib/app/chat/components/chat-header/chat-header.component.mjs +0 -66
- package/esm2022/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.mjs +0 -186
- package/esm2022/lib/app/chat/components/chat-window/chat-window.component.mjs +0 -312
- package/esm2022/lib/app/chat/components/message-input/message-input.component.mjs +0 -36
- package/esm2022/lib/app/chat/components/message-list/message-list.component.mjs +0 -115
- package/esm2022/lib/app/chat/model/chat-history.model.mjs +0 -2
- package/esm2022/lib/app/chat/model/chat-request.model.mjs +0 -2
- package/esm2022/lib/app/chat/model/chat-response.model.mjs +0 -2
- package/esm2022/lib/app/chat/model/chat-session.model.mjs +0 -2
- package/esm2022/lib/app/chat/model/chat-stream-message.model.mjs +0 -2
- package/esm2022/lib/app/chat/model/chat-stream-response.model.mjs +0 -2
- package/esm2022/lib/app/chat/services/chat-api.service.mjs +0 -61
- package/esm2022/lib/app/chat/services/chat-audio.service.mjs +0 -50
- package/esm2022/lib/app/chat/services/chat-history.service.mjs +0 -252
- package/esm2022/lib/app/login/login-form.component.mjs +0 -46
- package/esm2022/lib/app/personalization/personalization-dialog.component.mjs +0 -194
- package/esm2022/lib/app/personalization/personalization.service.mjs +0 -149
- package/esm2022/lib/app/personalization/sections/account/account-section.component.mjs +0 -122
- package/esm2022/lib/app/personalization/sections/preferences/color-picker-dialog.component.mjs +0 -86
- package/esm2022/lib/app/personalization/sections/preferences/preferences-section.component.mjs +0 -115
- package/esm2022/lib/app/personalization/sections/profile/profile-section.component.mjs +0 -29
- package/esm2022/lib/app/personalization/sections/settings/setting-section.component.mjs +0 -30
- package/esm2022/lib/app/personalization/sections/terms/terms-section.component.mjs +0 -12
- package/esm2022/lib/constant/doohbot-constant.mjs +0 -28
- package/esm2022/lib/constant/html-entities.mjs +0 -9
- package/esm2022/lib/constant/utf8.mjs +0 -10
- package/esm2022/lib/core/app-const.mjs +0 -61
- package/esm2022/lib/core/auth/account-api.service.mjs +0 -40
- package/esm2022/lib/core/auth/auth.service.mjs +0 -391
- package/esm2022/lib/core/auth/models/auth-result.model.mjs +0 -3
- package/esm2022/lib/core/auth/models/federated-login-request.model.mjs +0 -6
- package/esm2022/lib/core/auth/models/login-request.model.mjs +0 -6
- package/esm2022/lib/core/auth/storage.service.mjs +0 -110
- package/esm2022/lib/core/directives/draggable/draggable-dialog.directive.mjs +0 -112
- package/esm2022/lib/core/directives/fullscreen/fullscreen.directive.mjs +0 -55
- package/esm2022/lib/core/directives/resizable/resizable-dialog.directive.mjs +0 -179
- package/esm2022/lib/core/environments/environment.mjs +0 -15
- package/esm2022/lib/core/environments/environment.prod.mjs +0 -15
- package/esm2022/lib/core/helpers/crypto-helper.service.mjs +0 -52
- package/esm2022/lib/core/http/http-stream.service.mjs +0 -97
- package/esm2022/lib/core/http/http.service.mjs +0 -103
- package/esm2022/lib/core/interceptors/auth.interceptor.mjs +0 -96
- package/esm2022/lib/core/interceptors/license.interceptor.mjs +0 -44
- package/esm2022/lib/core/models/api-config.model.mjs +0 -18
- package/esm2022/lib/core/models/api-request.model.mjs +0 -2
- package/esm2022/lib/core/models/api-response.model.mjs +0 -8
- package/esm2022/lib/core/models/doohbot-config.model.mjs +0 -18
- package/esm2022/lib/core/models/license.model.mjs +0 -2
- package/esm2022/lib/core/models/message.mjs +0 -2
- package/esm2022/lib/core/models/theme-config.model.mjs +0 -2
- package/esm2022/lib/core/services/core-config.service.mjs +0 -52
- package/esm2022/lib/core/services/license.service.mjs +0 -145
- package/esm2022/lib/core/services/markdown.service.mjs +0 -64
- package/esm2022/lib/core/services/theme.service.mjs +0 -248
- package/esm2022/lib/core/types/auth-mode.type.mjs +0 -2
- package/esm2022/lib/core/types/auth-status.type.mjs +0 -5
- package/esm2022/lib/core/types/chat-stream.type.mjs +0 -2
- package/esm2022/lib/core/types/message-role.type.mjs +0 -2
- package/esm2022/lib/core/types/prompt-mode.type.mjs +0 -5
- package/esm2022/lib/core/types/snackbar-error.type.mjs +0 -5
- package/esm2022/lib/core/types/tenant-resolution-strategy.type.mjs +0 -2
- package/esm2022/lib/core/utils/logger.service.mjs +0 -42
- package/esm2022/lib/doohbot-input.mjs +0 -20
- package/esm2022/lib/doohbot.component.mjs +0 -444
- package/esm2022/lib/predefined_messages.mjs +0 -15
- package/esm2022/lib/shared/chips/chips.component.mjs +0 -28
- package/esm2022/lib/shared/dialog/dialog.component.mjs +0 -36
- package/esm2022/lib/shared/dialog/dialog.service.mjs +0 -64
- package/esm2022/lib/shared/dialog/dialog.utils.mjs +0 -85
- package/esm2022/lib/shared/dropdown-menu/dropdown-menu.component.mjs +0 -29
- package/esm2022/lib/shared/input-dialog/input-dialog.component.mjs +0 -38
- package/esm2022/lib/shared/menu-item/menu-item.component.mjs +0 -24
- package/esm2022/lib/shared/pipes/simple-markdown.pipe.mjs +0 -27
- package/esm2022/lib/shared/snackbar/snackbar.component.mjs +0 -43
- package/esm2022/lib/shared/snackbar/snackbar.service.mjs +0 -46
- package/esm2022/lib/shared/snackbar/snackbar.utils.mjs +0 -43
- package/esm2022/public-api.mjs +0 -37
- package/fesm2022/aakash58-chatbot.mjs +0 -5193
- package/fesm2022/aakash58-chatbot.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/app/chat/chat-ui-state.service.d.ts +0 -96
- package/lib/app/chat/chat.service.d.ts +0 -88
- package/lib/app/chat/components/chat-button/chat-button.component.d.ts +0 -16
- package/lib/app/chat/components/chat-footer/chat-footer.component.d.ts +0 -5
- package/lib/app/chat/components/chat-header/chat-header.component.d.ts +0 -24
- package/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.d.ts +0 -49
- package/lib/app/chat/components/chat-window/chat-window.component.d.ts +0 -107
- package/lib/app/chat/components/message-input/message-input.component.d.ts +0 -12
- package/lib/app/chat/components/message-list/message-list.component.d.ts +0 -40
- package/lib/app/chat/model/chat-history.model.d.ts +0 -51
- package/lib/app/chat/model/chat-request.model.d.ts +0 -10
- package/lib/app/chat/model/chat-response.model.d.ts +0 -9
- package/lib/app/chat/model/chat-session.model.d.ts +0 -12
- package/lib/app/chat/model/chat-stream-response.model.d.ts +0 -10
- package/lib/app/chat/services/chat-api.service.d.ts +0 -30
- package/lib/app/chat/services/chat-audio.service.d.ts +0 -19
- package/lib/app/chat/services/chat-history.service.d.ts +0 -53
- package/lib/app/login/login-form.component.d.ts +0 -20
- package/lib/app/personalization/personalization-dialog.component.d.ts +0 -53
- package/lib/app/personalization/personalization.service.d.ts +0 -66
- package/lib/app/personalization/sections/account/account-section.component.d.ts +0 -30
- package/lib/app/personalization/sections/preferences/color-picker-dialog.component.d.ts +0 -17
- package/lib/app/personalization/sections/preferences/preferences-section.component.d.ts +0 -27
- package/lib/app/personalization/sections/profile/profile-section.component.d.ts +0 -17
- package/lib/app/personalization/sections/settings/setting-section.component.d.ts +0 -10
- package/lib/app/personalization/sections/terms/terms-section.component.d.ts +0 -5
- package/lib/constant/doohbot-constant.d.ts +0 -12
- package/lib/constant/html-entities.d.ts +0 -8
- package/lib/constant/utf8.d.ts +0 -9
- package/lib/core/app-const.d.ts +0 -11
- package/lib/core/auth/account-api.service.d.ts +0 -20
- package/lib/core/auth/auth.service.d.ts +0 -90
- package/lib/core/auth/models/auth-result.model.d.ts +0 -4
- package/lib/core/auth/models/federated-login-request.model.d.ts +0 -5
- package/lib/core/auth/models/login-request.model.d.ts +0 -6
- package/lib/core/auth/storage.service.d.ts +0 -21
- package/lib/core/directives/draggable/draggable-dialog.directive.d.ts +0 -23
- package/lib/core/directives/fullscreen/fullscreen.directive.d.ts +0 -14
- package/lib/core/directives/resizable/resizable-dialog.directive.d.ts +0 -30
- package/lib/core/environments/environment.d.ts +0 -7
- package/lib/core/environments/environment.prod.d.ts +0 -7
- package/lib/core/helpers/crypto-helper.service.d.ts +0 -12
- package/lib/core/http/http-stream.service.d.ts +0 -18
- package/lib/core/http/http.service.d.ts +0 -20
- package/lib/core/interceptors/auth.interceptor.d.ts +0 -18
- package/lib/core/interceptors/license.interceptor.d.ts +0 -11
- package/lib/core/models/api-config.model.d.ts +0 -58
- package/lib/core/models/api-request.model.d.ts +0 -77
- package/lib/core/models/api-response.model.d.ts +0 -6
- package/lib/core/models/doohbot-config.model.d.ts +0 -81
- package/lib/core/models/message.d.ts +0 -16
- package/lib/core/models/theme-config.model.d.ts +0 -28
- package/lib/core/services/core-config.service.d.ts +0 -23
- package/lib/core/services/license.service.d.ts +0 -33
- package/lib/core/services/markdown.service.d.ts +0 -8
- package/lib/core/services/theme.service.d.ts +0 -40
- package/lib/core/utils/logger.service.d.ts +0 -11
- package/lib/doohbot-input.d.ts +0 -19
- package/lib/doohbot.component.d.ts +0 -108
- package/lib/predefined_messages.d.ts +0 -2
- package/lib/shared/chips/chips.component.d.ts +0 -10
- package/lib/shared/dialog/dialog.component.d.ts +0 -19
- package/lib/shared/dialog/dialog.service.d.ts +0 -29
- package/lib/shared/dialog/dialog.utils.d.ts +0 -41
- package/lib/shared/dropdown-menu/dropdown-menu.component.d.ts +0 -11
- package/lib/shared/input-dialog/input-dialog.component.d.ts +0 -20
- package/lib/shared/menu-item/menu-item.component.d.ts +0 -9
- package/lib/shared/pipes/simple-markdown.pipe.d.ts +0 -10
- package/lib/shared/snackbar/snackbar.component.d.ts +0 -14
- package/lib/shared/snackbar/snackbar.service.d.ts +0 -19
- package/public-api.d.ts +0 -11
- /package/{src → projects/doohbot/src}/assets/bot.mp3 +0 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import {
|
|
2
|
+
APP_INITIALIZER,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
computed,
|
|
6
|
+
effect,
|
|
7
|
+
ElementRef,
|
|
8
|
+
inject,
|
|
9
|
+
Input,
|
|
10
|
+
OnDestroy,
|
|
11
|
+
OnInit,
|
|
12
|
+
Renderer2,
|
|
13
|
+
signal,
|
|
14
|
+
SimpleChanges,
|
|
15
|
+
ViewChild,
|
|
16
|
+
ViewEncapsulation,
|
|
17
|
+
} from '@angular/core';
|
|
18
|
+
import { DoohbotConst } from './constant/doohbot-constant';
|
|
19
|
+
import { LoginRequest } from './core/auth/models/login-request.model';
|
|
20
|
+
import { FederatedLoginRequest } from './core/auth/models/federated-login-request.model';
|
|
21
|
+
import { AuthService } from './core/auth/auth.service';
|
|
22
|
+
import logger from './core/utils/logger.service';
|
|
23
|
+
import { ThemeService } from './core/services/theme.service';
|
|
24
|
+
import { PredefinedMessages, SuggestedMessages } from './predefined_messages';
|
|
25
|
+
import { DoohbotInput } from './doohbot-input';
|
|
26
|
+
import { DoohbotApiConfig } from './core/models/api-config.model';
|
|
27
|
+
import { DoohbotThemeConfig } from './core/models/theme-config.model';
|
|
28
|
+
import { ChatButtonComponent } from './app/chat/components/chat-button/chat-button.component';
|
|
29
|
+
import { ChatWindowComponent } from './app/chat/components/chat-window/chat-window.component';
|
|
30
|
+
import { FullscreenDirective } from './core/directives/fullscreen/fullscreen.directive';
|
|
31
|
+
import { ChatHistoryService } from './app/chat/services/chat-history.service';
|
|
32
|
+
import { ChatUIStateService } from './app/chat/chat-ui-state.service';
|
|
33
|
+
import { ChatSession } from './app/chat/model/chat-session.model';
|
|
34
|
+
import { AuthStatus } from './core/types/auth-status.type';
|
|
35
|
+
import { ChatService } from './app/chat/chat.service';
|
|
36
|
+
import { DialogService } from './shared/dialog/dialog.service';
|
|
37
|
+
import { DialogUtils } from './shared/dialog/dialog.utils';
|
|
38
|
+
import { SnackbarService } from './shared/snackbar/snackbar.service';
|
|
39
|
+
import { PersonalizationService } from './app/personalization/personalization.service';
|
|
40
|
+
import { LicenseService } from './core/services/license.service';
|
|
41
|
+
import { AppConst } from './core/app-const';
|
|
42
|
+
import { LicenseInterceptor } from './core/interceptors/license.interceptor';
|
|
43
|
+
import { AuthInterceptor } from './core/interceptors/auth.interceptor';
|
|
44
|
+
import { CommonModule } from '@angular/common';
|
|
45
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
46
|
+
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
|
47
|
+
|
|
48
|
+
@Component({
|
|
49
|
+
selector: 'app-doohbot',
|
|
50
|
+
standalone: true,
|
|
51
|
+
imports: [CommonModule, ChatButtonComponent, ChatWindowComponent, FullscreenDirective],
|
|
52
|
+
templateUrl: './doohbot.component.html',
|
|
53
|
+
styleUrls: ['./doohbot.component.scss'],
|
|
54
|
+
encapsulation: ViewEncapsulation.None,
|
|
55
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
56
|
+
})
|
|
57
|
+
export class Doohbot extends DoohbotInput implements OnInit, OnDestroy {
|
|
58
|
+
//! ======================= INPUTS ==========================
|
|
59
|
+
|
|
60
|
+
@Input() config: DoohbotInput = new DoohbotInput();
|
|
61
|
+
@Input() override buttonStyle?: 'fab' | 'sidebar' | 'sidebar-top' | 'sidebar-bottom' = 'fab';
|
|
62
|
+
@Input() enableDrag: boolean = false;
|
|
63
|
+
@Input() enableResize: boolean = false;
|
|
64
|
+
@Input() apiConfig?: DoohbotApiConfig;
|
|
65
|
+
@Input() themeConfig: DoohbotThemeConfig | undefined;
|
|
66
|
+
|
|
67
|
+
//! ==================== SERVICES ======================
|
|
68
|
+
|
|
69
|
+
private chatHistory = inject(ChatHistoryService);
|
|
70
|
+
private uiState = inject(ChatUIStateService);
|
|
71
|
+
private themeService = inject(ThemeService);
|
|
72
|
+
private authService = inject(AuthService);
|
|
73
|
+
private chatService = inject(ChatService);
|
|
74
|
+
private dialogService = inject(DialogService);
|
|
75
|
+
private snackbarService = inject(SnackbarService);
|
|
76
|
+
private personalization = inject(PersonalizationService);
|
|
77
|
+
private licenseService = inject(LicenseService);
|
|
78
|
+
|
|
79
|
+
//! ========================= EXPOSED STATE FROM SERVICES ============================
|
|
80
|
+
|
|
81
|
+
// UI State signals
|
|
82
|
+
public isChatOpen = this.uiState.isChatOpen;
|
|
83
|
+
public isHistorySidebarOpen = this.uiState.isHistorySidebarOpen;
|
|
84
|
+
public isFullScreen = this.uiState.isFullScreen;
|
|
85
|
+
public unreadCount = this.uiState.unreadCount;
|
|
86
|
+
|
|
87
|
+
// Chat State signals
|
|
88
|
+
public messages = this.chatService.messages;
|
|
89
|
+
public isBotTyping = this.chatService.isBotTyping;
|
|
90
|
+
public isStreaming = this.chatService.isStreaming;
|
|
91
|
+
public messageError = computed(() => this.chatService.apiError()?.message || null);
|
|
92
|
+
public showSuggestionChips = this.chatService.showSuggestionChips;
|
|
93
|
+
public chatSessions = this.chatHistory.sessions;
|
|
94
|
+
public hasMoreHistory = this.chatHistory.hasMore;
|
|
95
|
+
public isLoadingMore = this.chatHistory.isLoadingMore;
|
|
96
|
+
public isLoadingSessions = this.chatHistory.isLoading;
|
|
97
|
+
public processingSessionId = this.chatHistory.processingSessionId;
|
|
98
|
+
|
|
99
|
+
// Auth State signals
|
|
100
|
+
// public isAuthenticated = this.chatFacade.isAuthenticated;
|
|
101
|
+
|
|
102
|
+
public isLoggingIn = this.authService.isLoggingIn;
|
|
103
|
+
public authError = this.authService.authError;
|
|
104
|
+
public authSuccess = this.authService.authSuccess;
|
|
105
|
+
|
|
106
|
+
// Personalization
|
|
107
|
+
public activeButtonStyle = computed(() => this.personalization.settings().appearance.buttonStyle);
|
|
108
|
+
|
|
109
|
+
//! ======================= COMPONENT-SPECIFIC STATE =====================
|
|
110
|
+
|
|
111
|
+
public userName = 'User';
|
|
112
|
+
public predefinedMessages: string[] = PredefinedMessages;
|
|
113
|
+
public suggestedMessages: string[] = SuggestedMessages;
|
|
114
|
+
|
|
115
|
+
public maxMessageLength = 1000;
|
|
116
|
+
|
|
117
|
+
// Constants
|
|
118
|
+
readonly DoohbotConst = DoohbotConst;
|
|
119
|
+
|
|
120
|
+
// Context cleanup
|
|
121
|
+
private contextCleanup?: () => void;
|
|
122
|
+
|
|
123
|
+
// Reactive state
|
|
124
|
+
public authStatus = signal<AuthStatus>(this.authService.authStatus);
|
|
125
|
+
public isAuthenticated = signal<boolean>(this.authStatus() === 'authenticated');
|
|
126
|
+
|
|
127
|
+
//! ========================= VIEW CHILDREN ======================
|
|
128
|
+
|
|
129
|
+
@ViewChild(ChatWindowComponent, { read: ElementRef }) chatWindowRef!: ElementRef;
|
|
130
|
+
@ViewChild(FullscreenDirective) fullscreenDirective!: FullscreenDirective;
|
|
131
|
+
|
|
132
|
+
//! ======================= CONSTRUCTOR ========================
|
|
133
|
+
|
|
134
|
+
constructor(
|
|
135
|
+
private elementRef: ElementRef,
|
|
136
|
+
private renderer: Renderer2,
|
|
137
|
+
) {
|
|
138
|
+
super();
|
|
139
|
+
|
|
140
|
+
// Setup messages signal ref for UI state service
|
|
141
|
+
this.uiState.setMessagesSignal(this.chatService.messages);
|
|
142
|
+
|
|
143
|
+
// Theme management effect
|
|
144
|
+
effect(() => {
|
|
145
|
+
const activeTheme = this.themeService.activeTheme();
|
|
146
|
+
const host = this.elementRef.nativeElement;
|
|
147
|
+
this.renderer.removeClass(host, 'light-theme');
|
|
148
|
+
this.renderer.removeClass(host, 'dark-theme');
|
|
149
|
+
this.renderer.addClass(host, activeTheme);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//! ====================== LIFECYCLE HOOKS =====================
|
|
154
|
+
// Corrected structural integrity.
|
|
155
|
+
|
|
156
|
+
async ngOnInit() {
|
|
157
|
+
logger.log('Initializing Doohbot component...');
|
|
158
|
+
|
|
159
|
+
// Load license registry from file and wait for it to complete
|
|
160
|
+
if (this.config.licenseFilePath) {
|
|
161
|
+
await this.licenseService.loadLicenseFile(this.config.licenseFilePath);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Run validation once on startup
|
|
165
|
+
this.authService.validateStoredToken().subscribe();
|
|
166
|
+
|
|
167
|
+
// React to auth status changes
|
|
168
|
+
this.authService.authStatus$.subscribe((status) => {
|
|
169
|
+
const wasAuthenticated = this.isAuthenticated();
|
|
170
|
+
this.authStatus.set(status);
|
|
171
|
+
this.isAuthenticated.set(status === 'authenticated');
|
|
172
|
+
|
|
173
|
+
if (status === 'authenticated' && !wasAuthenticated) {
|
|
174
|
+
this.initializeUI();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Handle initial state
|
|
179
|
+
if (this.isAuthenticated()) {
|
|
180
|
+
this.initializeUI();
|
|
181
|
+
} else {
|
|
182
|
+
//! STRICT VALIDATION: Only attempt federated login if we have the necessary configuration
|
|
183
|
+
const hasAuthToken = !!this.config.authToken;
|
|
184
|
+
|
|
185
|
+
// STRICT VALIDATION: We need both Token AND Valid License Context to proceed
|
|
186
|
+
if (this.canAttemptFederatedLogin()) {
|
|
187
|
+
logger.log('Attempting federated login...');
|
|
188
|
+
await this.onFederatedLogin();
|
|
189
|
+
// If federated login failed, the login screen will be shown automatically
|
|
190
|
+
// via the auth status subscription above
|
|
191
|
+
} else {
|
|
192
|
+
logger.info(
|
|
193
|
+
'Insufficient config for federated login (Need Token + TenancyName/LicenseKey). Waiting for user login.',
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private canAttemptFederatedLogin(): boolean {
|
|
200
|
+
const hasAuthToken = !!this.config.authToken;
|
|
201
|
+
|
|
202
|
+
const hasDirectLicenseKey = !!this.config.licenseKey;
|
|
203
|
+
const hasTenantLicenseLookup = !!this.config.tenancyName && !!this.config.licenseFilePath;
|
|
204
|
+
|
|
205
|
+
const hasValidLicenseContext = hasDirectLicenseKey || hasTenantLicenseLookup;
|
|
206
|
+
|
|
207
|
+
return hasAuthToken && hasValidLicenseContext;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private initializeUI() {
|
|
211
|
+
// Apply theme
|
|
212
|
+
if (this.themeConfig) {
|
|
213
|
+
this.themeService.setThemeConfig(this.themeConfig, this.elementRef.nativeElement);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Set user metadata
|
|
217
|
+
this.userAvatarUrl();
|
|
218
|
+
this.updateUserName();
|
|
219
|
+
|
|
220
|
+
// Start new session
|
|
221
|
+
this.chatService.startNewSession();
|
|
222
|
+
|
|
223
|
+
// Subscribe to context changes if not already
|
|
224
|
+
if (!this.contextCleanup) {
|
|
225
|
+
this.uiState.resetLastRead();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
230
|
+
// Handle user context changes
|
|
231
|
+
if (changes['userContext']) {
|
|
232
|
+
// this.chatFacade.handleUserContextChange(this.userContext);
|
|
233
|
+
this.updateUserName();
|
|
234
|
+
|
|
235
|
+
// Reset UI state and re-authenticate
|
|
236
|
+
this.uiState.closeChat();
|
|
237
|
+
this.uiState.closeHistorySidebar();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Handle config changes
|
|
241
|
+
if (changes['config']) {
|
|
242
|
+
this.authService.updateConfig(this.config);
|
|
243
|
+
this.userAvatarUrl();
|
|
244
|
+
this.updateUserName();
|
|
245
|
+
|
|
246
|
+
if (this.config.licenseKey) {
|
|
247
|
+
this.authService.setLicenseKey(this.config.licenseKey);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (this.config.buttonStyle || this.buttonStyle) {
|
|
251
|
+
this.personalization.setDeveloperDefaults({
|
|
252
|
+
buttonStyle: this.buttonStyle || this.config.buttonStyle,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Handle dynamic config updates for authentication
|
|
257
|
+
if (!this.isAuthenticated()) {
|
|
258
|
+
const token = this.config.authToken;
|
|
259
|
+
// Validate Config before attempting
|
|
260
|
+
if (token && this.canAttemptFederatedLogin()) {
|
|
261
|
+
this.onFederatedLogin(token);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (changes['buttonStyle'] && this.buttonStyle) {
|
|
267
|
+
this.personalization.setDeveloperDefaults({ buttonStyle: this.buttonStyle });
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (changes['themeConfig']) {
|
|
271
|
+
if (this.themeConfig) {
|
|
272
|
+
this.themeService.setThemeConfig(this.themeConfig, this.elementRef.nativeElement);
|
|
273
|
+
}
|
|
274
|
+
if (this.themeConfig?.primaryColor) {
|
|
275
|
+
this.personalization.setDeveloperDefaults({ primaryColor: this.themeConfig.primaryColor });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Handle Color Inputs
|
|
280
|
+
if (changes['config'] && (this.config.primaryColor || this.config.accentColor)) {
|
|
281
|
+
const defaults: any = {};
|
|
282
|
+
if (this.config.primaryColor) defaults.primaryColor = this.config.primaryColor;
|
|
283
|
+
if (this.config.accentColor) defaults.primaryColor = this.config.accentColor;
|
|
284
|
+
|
|
285
|
+
this.personalization.setDeveloperDefaults(defaults);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
//! ====================== AUTHENTICATION ==================
|
|
290
|
+
// Logic moved to ChatFacadeService.initialize()
|
|
291
|
+
|
|
292
|
+
onNormalLogin(credentials: LoginRequest): void {
|
|
293
|
+
// Use Tenancy Name from Config Input
|
|
294
|
+
let tenancy = this.config.tenancyName;
|
|
295
|
+
|
|
296
|
+
//! fallback: Try to resolve from global utility (Auto-detect)
|
|
297
|
+
// if (!tenancy) {
|
|
298
|
+
// tenancy = window.AppPreBootstrap?.resolveTenancyName(window.AppConsts?.appBaseUrl);
|
|
299
|
+
// }
|
|
300
|
+
|
|
301
|
+
// Resolve key from whatever tenancy we found
|
|
302
|
+
let autoKey = this.licenseService.resolveTenantLicenseKey(tenancy || undefined);
|
|
303
|
+
|
|
304
|
+
// Inject for strict validation
|
|
305
|
+
if (autoKey) {
|
|
306
|
+
credentials.license = autoKey;
|
|
307
|
+
// Also set it in service usage context for this session
|
|
308
|
+
this.authService.setLicenseKey(autoKey);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.authService.login(credentials, false);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async onFederatedLogin(token?: string): Promise<void> {
|
|
315
|
+
// Resolve Key from tenancy name
|
|
316
|
+
let autoKey = this.licenseService.resolveTenantLicenseKey();
|
|
317
|
+
|
|
318
|
+
// Fallback to Config Input
|
|
319
|
+
if (!autoKey) {
|
|
320
|
+
autoKey = this.config.licenseKey || '';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (autoKey) {
|
|
324
|
+
this.authService.setLicenseKey(autoKey);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const request: Partial<FederatedLoginRequest> = {
|
|
328
|
+
accessToken: token,
|
|
329
|
+
rememberMe: this.config.rememberMe,
|
|
330
|
+
license: autoKey,
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// Await the federated login result
|
|
334
|
+
const success = await this.authService.federatedLogin(request);
|
|
335
|
+
|
|
336
|
+
if (!success) {
|
|
337
|
+
logger.info('Federated login failed. User can proceed with normal login.');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
performLogout(): void {
|
|
342
|
+
DialogUtils.confirmLogout(this.dialogService).subscribe((confirmed) => {
|
|
343
|
+
if (confirmed) {
|
|
344
|
+
// Invalidate history cache before logout
|
|
345
|
+
this.chatHistory.invalidateCache();
|
|
346
|
+
this.authService.logout();
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
//! ====================== CHAT OPERATIONS =====================
|
|
352
|
+
|
|
353
|
+
toggleChat(): void {
|
|
354
|
+
this.uiState.toggleChat();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async sendMessage(text: string): Promise<void> {
|
|
358
|
+
await this.chatService.sendMessage(text, this.maxMessageLength);
|
|
359
|
+
// Invalidate cache after sending message
|
|
360
|
+
this.chatHistory.invalidateCache();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
onStopRequest(): void {
|
|
364
|
+
logger.log('Stopping chat request...');
|
|
365
|
+
this.chatService.cancelRequest();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
clearChat(): void {
|
|
369
|
+
const userId = this.authService.getUserId() || '';
|
|
370
|
+
// this.chatService.cancelRequest();
|
|
371
|
+
this.chatService.clearMessages();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
clearMessageError(): void {
|
|
375
|
+
this.chatService.apiError.set(null);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
//! ===================== SESSION MANAGEMENT =======================
|
|
379
|
+
|
|
380
|
+
toggleHistorySidebar(): void {
|
|
381
|
+
const isNowOpen = !this.uiState.isHistorySidebarOpen();
|
|
382
|
+
if (isNowOpen) {
|
|
383
|
+
// Only load if not already cached
|
|
384
|
+
this.loadUserSessions();
|
|
385
|
+
}
|
|
386
|
+
this.uiState.toggleHistorySidebar();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
loadChatSession(session: ChatSession): void {
|
|
390
|
+
logger.log(`Session selected: ${session.id}. continuing session...`);
|
|
391
|
+
this.chatService.continueSession(session.id);
|
|
392
|
+
this.uiState.closeHistorySidebar();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
deleteSession(sessionId: string): void {
|
|
396
|
+
logger.log(`Deleting session: ${sessionId}`);
|
|
397
|
+
const userId = this.authService.getUserId() || '';
|
|
398
|
+
this.chatHistory.deleteSession(sessionId, userId.toString()).subscribe(() => {
|
|
399
|
+
// Invalidate cache after deletion
|
|
400
|
+
this.chatHistory.invalidateCache();
|
|
401
|
+
|
|
402
|
+
// If deleted session is currently active, start a new one
|
|
403
|
+
const activeSession = this.chatService.getActiveSession();
|
|
404
|
+
if (activeSession?.id === sessionId) {
|
|
405
|
+
logger.log('Active session was deleted, starting a new one.');
|
|
406
|
+
this.chatService.startNewSession();
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
//! deleteAllSessions
|
|
412
|
+
|
|
413
|
+
deleteAllSessions(): void {
|
|
414
|
+
logger.log('Deleting all chat sessions');
|
|
415
|
+
const userId = this.authService.getUserId() || '';
|
|
416
|
+
this.chatHistory.deleteAllHistory(userId.toString()).subscribe({
|
|
417
|
+
next: () => {
|
|
418
|
+
this.chatService.clearMessages();
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
renameSession(event: { sessionId: string; newTitle: string }): void {
|
|
424
|
+
logger.log(`Renaming session ${event.sessionId} to ${event.newTitle}`);
|
|
425
|
+
const userId = this.authService.getUserId() || '';
|
|
426
|
+
this.chatHistory
|
|
427
|
+
.updateSessionTitle(event.sessionId, event.newTitle, userId.toString())
|
|
428
|
+
.subscribe((success) => {
|
|
429
|
+
if (success) {
|
|
430
|
+
// If updated session is currently active, update its title in ChatService
|
|
431
|
+
const activeSession = this.chatService.getActiveSession();
|
|
432
|
+
if (activeSession?.id === event.sessionId) {
|
|
433
|
+
activeSession.title = event.newTitle;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private loadUserSessions(): void {
|
|
440
|
+
const userId = this.authService.getUserId() || '';
|
|
441
|
+
logger.log(`Initiating loadUserSessions for user: ${userId}`);
|
|
442
|
+
this.chatHistory.loadSessions(userId.toString());
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Load more sessions for infinite scroll
|
|
447
|
+
*/
|
|
448
|
+
loadMoreHistory(): void {
|
|
449
|
+
const userId = this.authService.getUserId() || '';
|
|
450
|
+
logger.log(`Loading more sessions for user: ${userId}`);
|
|
451
|
+
this.chatHistory.loadMoreSessions(userId.toString());
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Manually refresh history
|
|
456
|
+
*/
|
|
457
|
+
refreshHistory(): void {
|
|
458
|
+
const userId = this.authService.getUserId() || '';
|
|
459
|
+
logger.log(`Refreshing sessions for user: ${userId}`);
|
|
460
|
+
this.chatHistory.invalidateCache();
|
|
461
|
+
this.chatHistory.loadSessions(userId.toString(), true); // force refresh
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
//! ======================== FULLSCREEN =====================
|
|
465
|
+
|
|
466
|
+
toggleFullScreen(): void {
|
|
467
|
+
if (this.fullscreenDirective) {
|
|
468
|
+
this.fullscreenDirective.toggle();
|
|
469
|
+
const isFullscreen = this.fullscreenDirective.getFullscreenState();
|
|
470
|
+
this.uiState.setFullscreen(isFullscreen);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
//! ================== UTILITY METHODS =======================
|
|
475
|
+
|
|
476
|
+
trackByMessageId(index: number, item: any): string {
|
|
477
|
+
return item.id || index.toString();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Resolve and update the username from all available sources
|
|
482
|
+
*/
|
|
483
|
+
private updateUserName(): void {
|
|
484
|
+
if (!this.isAuthenticated()) {
|
|
485
|
+
this.userName = '';
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
const loggedInName = this.authService.getLoggedInUserName();
|
|
490
|
+
// const contextName = this.userContext?.userName;
|
|
491
|
+
const configName = this.config.username;
|
|
492
|
+
|
|
493
|
+
if (configName) {
|
|
494
|
+
this.userName = configName;
|
|
495
|
+
} else if (loggedInName) {
|
|
496
|
+
this.userName = loggedInName;
|
|
497
|
+
} else {
|
|
498
|
+
this.userName = 'User';
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
logger.log('Resolved userName:', this.userName);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
userAvatarUrl(): string {
|
|
505
|
+
return DoohbotConst.userAvatar;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
ngOnDestroy() {
|
|
509
|
+
// Clean up subscriptions
|
|
510
|
+
if (this.contextCleanup) {
|
|
511
|
+
this.contextCleanup();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
this.chatService.cancelRequest();
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
//! ================== INITIALIZATION =======================
|
|
519
|
+
|
|
520
|
+
export function initializeApp() {
|
|
521
|
+
const appConst = inject(AppConst);
|
|
522
|
+
return appConst.load(); // Returns a Promise
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
bootstrapApplication(Doohbot, {
|
|
526
|
+
providers: [
|
|
527
|
+
provideHttpClient(withInterceptorsFromDi()),
|
|
528
|
+
AppConst,
|
|
529
|
+
{
|
|
530
|
+
provide: APP_INITIALIZER,
|
|
531
|
+
useFactory: initializeApp,
|
|
532
|
+
multi: true,
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
provide: HTTP_INTERCEPTORS,
|
|
536
|
+
useClass: AuthInterceptor,
|
|
537
|
+
multi: true,
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
provide: HTTP_INTERCEPTORS,
|
|
541
|
+
useClass: LicenseInterceptor,
|
|
542
|
+
multi: true,
|
|
543
|
+
},
|
|
544
|
+
],
|
|
545
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NgModule, Injector } from '@angular/core';
|
|
2
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
3
|
+
import { createCustomElement } from '@angular/elements';
|
|
4
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
5
|
+
import { platformBrowser } from '@angular/platform-browser';
|
|
6
|
+
import { Doohbot } from './doohbot.component';
|
|
7
|
+
|
|
8
|
+
@NgModule({
|
|
9
|
+
imports: [BrowserModule, MatIconModule],
|
|
10
|
+
declarations: [],
|
|
11
|
+
})
|
|
12
|
+
export class ElementModule {
|
|
13
|
+
constructor(injector: Injector) {
|
|
14
|
+
const doohbotElement = createCustomElement(Doohbot, { injector });
|
|
15
|
+
|
|
16
|
+
// Check if already defined to avoid errors
|
|
17
|
+
if (!customElements.get('app-doohbot')) {
|
|
18
|
+
customElements.define('app-doohbot', doohbotElement);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
platformBrowser()
|
|
24
|
+
.bootstrapModule(ElementModule)
|
|
25
|
+
.catch((err) => console.error(err));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const PredefinedMessages = [
|
|
2
|
+
'How do I create a new DOOH proposal in Doohclick?',
|
|
3
|
+
'Can the buyer see internal notes I add in Doohclick?',
|
|
4
|
+
// 'What happens after a buyer approves a proposal?',
|
|
5
|
+
// 'Why would an SR hide the pipeline value in a proposal?',
|
|
6
|
+
// 'Are additional services like ad formatting included in the base campaign cost?',
|
|
7
|
+
'How to create a proposal?',
|
|
8
|
+
];
|
|
9
|
+
export const SuggestedMessages = [
|
|
10
|
+
'Hi! How can I help?',
|
|
11
|
+
'Check your activity?',
|
|
12
|
+
'Need account help?',
|
|
13
|
+
'Quick tips to start.',
|
|
14
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.predefined-chips {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
gap: 8px;
|
|
5
|
+
padding: 10px;
|
|
6
|
+
font: var(--font-family);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.chip {
|
|
10
|
+
background-color: rgba(var(--primary-color), 0.2);
|
|
11
|
+
border: 1px solid var(--primary-color);
|
|
12
|
+
border-radius: 16px;
|
|
13
|
+
padding: 6px 12px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
font-size: 0.9rem;
|
|
16
|
+
font: var(--font-family);
|
|
17
|
+
transition: background-color 0.3s ease;
|
|
18
|
+
color: var(--text-color);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.chip:hover {
|
|
22
|
+
background-color: var(--primary-color);
|
|
23
|
+
color: var(--white);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.chip.active {
|
|
27
|
+
background-color: var(--primary-color);
|
|
28
|
+
color: var(--white);
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { Chips } from './chips.component';
|
|
4
|
+
|
|
5
|
+
describe('Chips', () => {
|
|
6
|
+
let component: Chips;
|
|
7
|
+
let fixture: ComponentFixture<Chips>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [Chips],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(Chips);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'app-chips',
|
|
6
|
+
standalone: true,
|
|
7
|
+
imports: [CommonModule],
|
|
8
|
+
templateUrl: './chips.component.html',
|
|
9
|
+
styleUrls: ['./chips.component.scss'],
|
|
10
|
+
})
|
|
11
|
+
export class Chips {
|
|
12
|
+
@Input() messages: string[] = []; // messages array
|
|
13
|
+
@Input() disabled = false;
|
|
14
|
+
@Output() chipClick = new EventEmitter<string>(); // emit clicked chip
|
|
15
|
+
|
|
16
|
+
onChipClick(msg: string) {
|
|
17
|
+
if (this.disabled) return;
|
|
18
|
+
this.chipClick.emit(msg);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<div class="dialog-container">
|
|
2
|
+
<div class="dialog-header">
|
|
3
|
+
<mat-icon class="dialog-icon" [class.warn-icon]="data.confirmButtonColor === 'warn'">
|
|
4
|
+
{{ data.icon }}
|
|
5
|
+
</mat-icon>
|
|
6
|
+
<h2 mat-dialog-title>{{ data.title }}</h2>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<mat-dialog-content>
|
|
10
|
+
<p class="dialog-message">{{ data.message }}</p>
|
|
11
|
+
</mat-dialog-content>
|
|
12
|
+
|
|
13
|
+
<mat-dialog-actions align="end">
|
|
14
|
+
<button mat-button class="cancel-btn" (click)="onCancel()" type="button">
|
|
15
|
+
{{ data.cancelText }}
|
|
16
|
+
</button>
|
|
17
|
+
<button
|
|
18
|
+
mat-raised-button
|
|
19
|
+
class="confirm-btn"
|
|
20
|
+
[class.warn-btn]="data.confirmButtonColor === 'warn'"
|
|
21
|
+
[class.primary-btn]="data.confirmButtonColor === 'primary'"
|
|
22
|
+
[class.accent-btn]="data.confirmButtonColor === 'accent'"
|
|
23
|
+
(click)="onConfirm()"
|
|
24
|
+
type="button"
|
|
25
|
+
>
|
|
26
|
+
{{ data.confirmText }}
|
|
27
|
+
</button>
|
|
28
|
+
</mat-dialog-actions>
|
|
29
|
+
</div>
|