@aakash58/chatbot 1.1.20 → 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,72 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Injectable({
|
|
4
|
+
providedIn: 'root',
|
|
5
|
+
})
|
|
6
|
+
export class CryptoHelperService {
|
|
7
|
+
private encoder = new TextEncoder();
|
|
8
|
+
private decoder = new TextDecoder();
|
|
9
|
+
private secretKey = ''; // Will be set by AuthService
|
|
10
|
+
|
|
11
|
+
setSecretKey(key: string) {
|
|
12
|
+
this.secretKey = key;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private async getKey() {
|
|
16
|
+
const salt = this.encoder.encode('fixed_salt'); // Keep constant
|
|
17
|
+
const baseKey = await crypto.subtle.importKey(
|
|
18
|
+
'raw',
|
|
19
|
+
this.encoder.encode(this.secretKey),
|
|
20
|
+
'PBKDF2',
|
|
21
|
+
false,
|
|
22
|
+
['deriveKey'],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return crypto.subtle.deriveKey(
|
|
26
|
+
{
|
|
27
|
+
name: 'PBKDF2',
|
|
28
|
+
salt,
|
|
29
|
+
iterations: 100000,
|
|
30
|
+
hash: 'SHA-256',
|
|
31
|
+
},
|
|
32
|
+
baseKey,
|
|
33
|
+
{ name: 'AES-GCM', length: 256 },
|
|
34
|
+
false,
|
|
35
|
+
['encrypt', 'decrypt'],
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async encrypt(value: string): Promise<string | null> {
|
|
40
|
+
if (!value) return null;
|
|
41
|
+
|
|
42
|
+
const key = await this.getKey();
|
|
43
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
44
|
+
|
|
45
|
+
const encrypted = await crypto.subtle.encrypt(
|
|
46
|
+
{ name: 'AES-GCM', iv },
|
|
47
|
+
key,
|
|
48
|
+
this.encoder.encode(value),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const merged = new Uint8Array(iv.length + encrypted.byteLength);
|
|
52
|
+
merged.set(iv, 0);
|
|
53
|
+
merged.set(new Uint8Array(encrypted), iv.length);
|
|
54
|
+
|
|
55
|
+
return btoa(String.fromCharCode(...merged));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async decrypt(value: string): Promise<string | null> {
|
|
59
|
+
if (!value) return null;
|
|
60
|
+
|
|
61
|
+
const raw = Uint8Array.from(atob(value), (c) => c.charCodeAt(0));
|
|
62
|
+
|
|
63
|
+
const iv = raw.slice(0, 12);
|
|
64
|
+
const data = raw.slice(12);
|
|
65
|
+
|
|
66
|
+
const key = await this.getKey();
|
|
67
|
+
|
|
68
|
+
const decrypted = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, data);
|
|
69
|
+
|
|
70
|
+
return this.decoder.decode(decrypted);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Injectable, NgZone } from '@angular/core';
|
|
2
|
+
import { HttpClient, HttpEventType, HttpHeaders } from '@angular/common/http';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { StorageService } from '../auth/storage.service';
|
|
5
|
+
import { ChatStreamResponse } from '../../app/chat/model/chat-stream-response.model';
|
|
6
|
+
import logger from '../utils/logger.service';
|
|
7
|
+
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root',
|
|
10
|
+
})
|
|
11
|
+
export class HttpStreamService {
|
|
12
|
+
constructor(
|
|
13
|
+
private ngZone: NgZone,
|
|
14
|
+
private tokenStorage: StorageService,
|
|
15
|
+
private http: HttpClient,
|
|
16
|
+
) {}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a POST-based HTTP streaming connection using fetch()
|
|
20
|
+
*/
|
|
21
|
+
createHttpStream(
|
|
22
|
+
url: string,
|
|
23
|
+
body: any,
|
|
24
|
+
headers?: Record<string, string>,
|
|
25
|
+
): Observable<ChatStreamResponse> {
|
|
26
|
+
return new Observable<ChatStreamResponse>((observer) => {
|
|
27
|
+
// Note: Authorization header is added automatically by AuthInterceptor
|
|
28
|
+
let requestHeaders = new HttpHeaders({
|
|
29
|
+
'content-type': 'application/json',
|
|
30
|
+
accept: 'text/event-stream',
|
|
31
|
+
'cache-control': 'no-cache',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (headers) {
|
|
35
|
+
Object.keys(headers).forEach((key) => {
|
|
36
|
+
requestHeaders = requestHeaders.set(key, headers[key]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const req = this.http.request('POST', url, {
|
|
41
|
+
body,
|
|
42
|
+
headers: requestHeaders,
|
|
43
|
+
reportProgress: true,
|
|
44
|
+
observe: 'events',
|
|
45
|
+
responseType: 'text',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let lastLoaded = 0;
|
|
49
|
+
|
|
50
|
+
const sub = req.subscribe({
|
|
51
|
+
next: (event) => {
|
|
52
|
+
if (event.type === HttpEventType.DownloadProgress) {
|
|
53
|
+
// Process the new chunk of data
|
|
54
|
+
const fullText = (event as any).partialText;
|
|
55
|
+
if (!fullText) return;
|
|
56
|
+
|
|
57
|
+
const newText = fullText.slice(lastLoaded);
|
|
58
|
+
lastLoaded = fullText.length;
|
|
59
|
+
|
|
60
|
+
const lines = newText.split('\n');
|
|
61
|
+
|
|
62
|
+
for (const line of lines) {
|
|
63
|
+
if (line.trim() === '') continue;
|
|
64
|
+
|
|
65
|
+
if (line.startsWith('data: ')) {
|
|
66
|
+
const dataStr = line.substring(6).trim();
|
|
67
|
+
|
|
68
|
+
if (dataStr === '[DONE]') {
|
|
69
|
+
this.ngZone.run(() => observer.complete());
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const parsed = JSON.parse(dataStr);
|
|
75
|
+
this.ngZone.run(() =>
|
|
76
|
+
observer.next({
|
|
77
|
+
content: parsed.content ?? parsed.message ?? '',
|
|
78
|
+
type: parsed.type ?? 'chunk',
|
|
79
|
+
id: parsed.response_id ?? '',
|
|
80
|
+
created_at: parsed.created_at ?? '',
|
|
81
|
+
sources: parsed.sources ?? [],
|
|
82
|
+
error: parsed.error,
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
logger.warn('Failed to parse SSE data:', dataStr, e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else if (event.type === HttpEventType.Response) {
|
|
91
|
+
this.ngZone.run(() => observer.complete());
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
error: (err) => {
|
|
95
|
+
this.ngZone.run(() => observer.error(err));
|
|
96
|
+
},
|
|
97
|
+
complete: () => {
|
|
98
|
+
this.ngZone.run(() => observer.complete());
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return () => sub.unsubscribe();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { Observable, delay, retry, map, catchError, of } from 'rxjs';
|
|
4
|
+
import { CoreConfigService } from '../services/core-config.service';
|
|
5
|
+
import { StorageService } from '../auth/storage.service';
|
|
6
|
+
import logger from '../utils/logger.service';
|
|
7
|
+
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root',
|
|
10
|
+
})
|
|
11
|
+
export class HttpService {
|
|
12
|
+
// @BlockUI() blockUI!: NgBlockUI;
|
|
13
|
+
|
|
14
|
+
get apiUrl(): string {
|
|
15
|
+
return this.coreConfig.apiUrl;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
private http: HttpClient,
|
|
20
|
+
private tokenStorage: StorageService,
|
|
21
|
+
private coreConfig: CoreConfigService,
|
|
22
|
+
) {
|
|
23
|
+
logger.log('HttpService: Initialized');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get(
|
|
27
|
+
url: string,
|
|
28
|
+
param?: object,
|
|
29
|
+
nestedParam = false,
|
|
30
|
+
showLoader = false,
|
|
31
|
+
refresh = true,
|
|
32
|
+
headers?: HttpHeaders,
|
|
33
|
+
): Observable<any> {
|
|
34
|
+
// if (showLoader && !this.blockUI.isActive) {
|
|
35
|
+
|
|
36
|
+
// this.blockUI.start();
|
|
37
|
+
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
let params = {};
|
|
41
|
+
|
|
42
|
+
if (nestedParam) {
|
|
43
|
+
this.buildHttpParams(params, param, '');
|
|
44
|
+
} else {
|
|
45
|
+
params = param as HttpParams;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return this.http
|
|
49
|
+
.get(`${this.apiUrl}${url}`, {
|
|
50
|
+
params: params,
|
|
51
|
+
// withCredentials: true,
|
|
52
|
+
headers,
|
|
53
|
+
})
|
|
54
|
+
.pipe(
|
|
55
|
+
delay(100),
|
|
56
|
+
|
|
57
|
+
retry(0),
|
|
58
|
+
|
|
59
|
+
map((response) => this.returnResponse(response, showLoader)),
|
|
60
|
+
|
|
61
|
+
catchError((error) => {
|
|
62
|
+
// if (this.blockUI.isActive) {
|
|
63
|
+
|
|
64
|
+
// this.blockUI.stop();
|
|
65
|
+
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
return of(error);
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private buildHttpParams(params: any, data: any, currentPath: string) {
|
|
74
|
+
Object.keys(data).forEach((key) => {
|
|
75
|
+
if (data[key] instanceof Object && !(data[key] instanceof Array)) {
|
|
76
|
+
this.buildHttpParams(params, data[key], `${currentPath}${key}.`);
|
|
77
|
+
} else {
|
|
78
|
+
params[`${currentPath}${key}`] = data[key];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
post(url: string, param?: object, showLoader = false, headers?: HttpHeaders): Observable<any> {
|
|
84
|
+
// if (showLoader && !this.blockUI.isActive) {
|
|
85
|
+
// this.blockUI.start();
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
return this.http.post(`${this.apiUrl}${url}`, param as HttpParams, { headers }).pipe(
|
|
89
|
+
delay(100),
|
|
90
|
+
retry(0),
|
|
91
|
+
map((response: any) => this.returnResponse(response, showLoader)),
|
|
92
|
+
catchError((error) => {
|
|
93
|
+
// if (this.blockUI.isActive) {
|
|
94
|
+
// this.blockUI.stop();
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
return of(error);
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
patch(url: string, param?: object, showLoader = false, headers?: HttpHeaders): Observable<any> {
|
|
103
|
+
// if (showLoader && !this.blockUI.isActive) {
|
|
104
|
+
// this.blockUI.start();
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
return this.http.patch(`${this.apiUrl}${url}`, param as HttpParams, { headers }).pipe(
|
|
108
|
+
delay(100),
|
|
109
|
+
retry(0),
|
|
110
|
+
map((response: any) => this.returnResponse(response, showLoader)),
|
|
111
|
+
catchError((error) => {
|
|
112
|
+
// if (this.blockUI.isActive) {
|
|
113
|
+
// this.blockUI.stop();
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
return of(error);
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
delete(url: string, param?: object, showLoader = false, headers?: HttpHeaders): Observable<any> {
|
|
122
|
+
// if (showLoader && !this.blockUI.isActive) {
|
|
123
|
+
// this.blockUI.start();
|
|
124
|
+
// }
|
|
125
|
+
let params = {};
|
|
126
|
+
params = param as HttpParams;
|
|
127
|
+
|
|
128
|
+
return this.http.delete(`${this.apiUrl}${url}`, { body: param, headers }).pipe(
|
|
129
|
+
delay(100),
|
|
130
|
+
retry(0),
|
|
131
|
+
map((response: any) => this.returnResponse(response, showLoader)),
|
|
132
|
+
catchError((error) => {
|
|
133
|
+
// if (this.blockUI.isActive) {
|
|
134
|
+
// this.blockUI.stop();
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
return of(error);
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private returnResponse(value: any, showLoader: boolean = true): any {
|
|
143
|
+
// if (showLoader && this.blockUI.isActive) {
|
|
144
|
+
// this.blockUI.reset();
|
|
145
|
+
// }
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HttpErrorResponse,
|
|
3
|
+
HttpEvent,
|
|
4
|
+
HttpHandler,
|
|
5
|
+
HttpInterceptor,
|
|
6
|
+
HttpRequest,
|
|
7
|
+
} from '@angular/common/http';
|
|
8
|
+
import { Injectable } from '@angular/core';
|
|
9
|
+
import { BehaviorSubject, catchError, filter, Observable, switchMap, take, throwError } from 'rxjs';
|
|
10
|
+
import { AuthService } from '../auth/auth.service';
|
|
11
|
+
import { StorageService } from '../auth/storage.service';
|
|
12
|
+
import { Injector } from '@angular/core';
|
|
13
|
+
import logger from '../utils/logger.service';
|
|
14
|
+
|
|
15
|
+
@Injectable({
|
|
16
|
+
providedIn: 'root',
|
|
17
|
+
})
|
|
18
|
+
export class AuthInterceptor implements HttpInterceptor {
|
|
19
|
+
private isRefreshing = false;
|
|
20
|
+
private clearingAuth = false; // Prevent multiple clearAuth calls
|
|
21
|
+
private refreshTokenSubject: BehaviorSubject<any> = new BehaviorSubject<any>(null);
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
private tokenStorage: StorageService,
|
|
25
|
+
private injector: Injector,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
29
|
+
const authReq = this.getRequestWithHeaders(req);
|
|
30
|
+
|
|
31
|
+
return next.handle(authReq).pipe(
|
|
32
|
+
catchError((error) => {
|
|
33
|
+
// Handle 401 Unauthorized errors
|
|
34
|
+
if (
|
|
35
|
+
error instanceof HttpErrorResponse &&
|
|
36
|
+
error.status === 401 &&
|
|
37
|
+
!authReq.url.includes('auth/login') && // Don't retry login
|
|
38
|
+
!authReq.url.includes('auth/federated/login') && // Don't retry federated login
|
|
39
|
+
!authReq.url.includes('auth/logout') && // Don't retry logout
|
|
40
|
+
!authReq.url.includes('auth/refresh') // Don't retry refresh itself
|
|
41
|
+
) {
|
|
42
|
+
logger.error('[AuthInterceptor] 401 Unauthorized:', {
|
|
43
|
+
url: authReq.url,
|
|
44
|
+
userId: this.tokenStorage.get('user_id'),
|
|
45
|
+
});
|
|
46
|
+
return this.handle401Error(authReq, next);
|
|
47
|
+
}
|
|
48
|
+
return throwError(() => error);
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private handle401Error(request: HttpRequest<any>, next: HttpHandler) {
|
|
54
|
+
// If already clearing, don't retry
|
|
55
|
+
if (this.clearingAuth) {
|
|
56
|
+
logger.log('[AuthInterceptor] Already clearing auth, rejecting request');
|
|
57
|
+
return throwError(() => new Error('Authentication cleared'));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!this.isRefreshing) {
|
|
61
|
+
this.isRefreshing = true;
|
|
62
|
+
this.refreshTokenSubject.next(null);
|
|
63
|
+
|
|
64
|
+
const authService = this.injector.get(AuthService);
|
|
65
|
+
return authService.refreshToken().pipe(
|
|
66
|
+
switchMap((token: any) => {
|
|
67
|
+
this.isRefreshing = false;
|
|
68
|
+
this.refreshTokenSubject.next(token.access_token);
|
|
69
|
+
// Retry the original request with the new token
|
|
70
|
+
return next.handle(this.getRequestWithHeaders(request));
|
|
71
|
+
}),
|
|
72
|
+
catchError((err) => {
|
|
73
|
+
this.isRefreshing = false;
|
|
74
|
+
// Refresh failed - logout user (only once)
|
|
75
|
+
if (!this.clearingAuth) {
|
|
76
|
+
this.clearingAuth = true;
|
|
77
|
+
const authService = this.injector.get(AuthService);
|
|
78
|
+
authService.clearAuth();
|
|
79
|
+
this.clearingAuth = false;
|
|
80
|
+
}
|
|
81
|
+
return throwError(() => err);
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
// Wait while getting new token
|
|
86
|
+
return this.refreshTokenSubject.pipe(
|
|
87
|
+
filter((token) => token != null),
|
|
88
|
+
take(1),
|
|
89
|
+
switchMap((jwt) => {
|
|
90
|
+
// Rewrite with new token and retry
|
|
91
|
+
return next.handle(this.getRequestWithHeaders(request));
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
getRequestWithHeaders(req: HttpRequest<any>): HttpRequest<any> {
|
|
98
|
+
// Skip adding token for login/refresh/logout endpoints
|
|
99
|
+
if (
|
|
100
|
+
req.url.includes('auth/login') ||
|
|
101
|
+
req.url.includes('auth/federated/login') ||
|
|
102
|
+
req.url.includes('auth/refresh') ||
|
|
103
|
+
req.url.includes('auth/logout')
|
|
104
|
+
) {
|
|
105
|
+
return req;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let headers = req.headers;
|
|
109
|
+
// Get fresh token from new storage service
|
|
110
|
+
const token = this.tokenStorage.get('access_token') ?? '';
|
|
111
|
+
|
|
112
|
+
if (token != '') {
|
|
113
|
+
headers = headers.set('authorization', `Bearer ${token}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return req.clone({ headers });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
|
+
import { Injectable, Injector } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { AuthService } from '../auth/auth.service';
|
|
5
|
+
import { LicenseService } from '../services/license.service';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class LicenseInterceptor implements HttpInterceptor {
|
|
9
|
+
constructor(private injector: Injector) {}
|
|
10
|
+
|
|
11
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
12
|
+
const authService = this.injector.get(AuthService);
|
|
13
|
+
const licenseService = this.injector.get(LicenseService);
|
|
14
|
+
|
|
15
|
+
// Skip if this is a login/auth request (AccountService handles it explicitly)
|
|
16
|
+
if (
|
|
17
|
+
req.url.includes('auth/login') ||
|
|
18
|
+
req.url.includes('auth/federated/login') ||
|
|
19
|
+
req.url.includes('auth/refresh') ||
|
|
20
|
+
req.url.includes('auth/logout')
|
|
21
|
+
) {
|
|
22
|
+
return next.handle(req);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Determine if this is an internal API request
|
|
26
|
+
const apiUrl = authService.apiUrl;
|
|
27
|
+
|
|
28
|
+
const isInternalApi =
|
|
29
|
+
(apiUrl && req.url.startsWith(apiUrl)) ||
|
|
30
|
+
(!req.url.startsWith('http') && !req.url.startsWith('assets/'));
|
|
31
|
+
|
|
32
|
+
if (!isInternalApi) {
|
|
33
|
+
return next.handle(req);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Resolve License Key for Authenticated Request
|
|
37
|
+
const context = authService.getLicensingContext();
|
|
38
|
+
// Post-login, context.tenantId should be company_id
|
|
39
|
+
const licenseKey = licenseService.resolveLicenseKey(context, '');
|
|
40
|
+
|
|
41
|
+
if (licenseKey) {
|
|
42
|
+
const clonedReq = req.clone({
|
|
43
|
+
headers: req.headers.set('x-license-key', licenseKey),
|
|
44
|
+
});
|
|
45
|
+
return next.handle(clonedReq);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return next.handle(req);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { environment } from '../environments/environment.prod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for Doohbot API integration
|
|
6
|
+
*/
|
|
7
|
+
export interface DoohbotApiConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Backend API endpoint URL
|
|
10
|
+
* Example: 'https://api.example.com/chat'
|
|
11
|
+
*/
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Optional API key for authentication
|
|
16
|
+
*/
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Request timeout in milliseconds
|
|
21
|
+
* @default 30000 (30 seconds)
|
|
22
|
+
*/
|
|
23
|
+
timeout?: number; // no need
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enable API mode (true) or use local intent matching (false)
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
enableApi?: boolean; // no need
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Include message history in API requests
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
includeHistory?: boolean; // no need
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Maximum number of history messages to include in requests
|
|
39
|
+
* @default 10
|
|
40
|
+
*/
|
|
41
|
+
maxHistoryMessages?: number; // no need
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Custom headers to include in API requests
|
|
45
|
+
*/
|
|
46
|
+
customHeaders?: Record<string, string>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Enable retry on failure
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
enableRetry?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Number of retry attempts
|
|
56
|
+
* @default 2
|
|
57
|
+
*/
|
|
58
|
+
retryAttempts?: number;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Delay between retries in milliseconds
|
|
62
|
+
* @default 1000
|
|
63
|
+
*/
|
|
64
|
+
retryDelay?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Injection token for providing Doohbot API configuration
|
|
69
|
+
*/
|
|
70
|
+
export const DOOHBOT_API_CONFIG = new InjectionToken<DoohbotApiConfig>('DOOHBOT_API_CONFIG', {
|
|
71
|
+
providedIn: 'root',
|
|
72
|
+
factory: () => ({
|
|
73
|
+
apiUrl: '',
|
|
74
|
+
timeout: 30000,
|
|
75
|
+
enableApi: false,
|
|
76
|
+
includeHistory: false,
|
|
77
|
+
maxHistoryMessages: 10,
|
|
78
|
+
enableRetry: true,
|
|
79
|
+
retryAttempts: 2,
|
|
80
|
+
retryDelay: 1000,
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PromptMode } from '../types/prompt-mode.type';
|
|
2
|
+
import { Message } from './message';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Request payload for chat API
|
|
6
|
+
*/
|
|
7
|
+
export interface ChatApiRequest {
|
|
8
|
+
/**
|
|
9
|
+
* User's message text
|
|
10
|
+
*/
|
|
11
|
+
message: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Prompt mode
|
|
15
|
+
*/
|
|
16
|
+
prompt_mode?: PromptMode;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Optional message history for context
|
|
20
|
+
*/
|
|
21
|
+
history?: Message[];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Optional metadata
|
|
25
|
+
*/
|
|
26
|
+
metadata?: Record<string, any>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Timestamp of the request
|
|
30
|
+
*/
|
|
31
|
+
timestamp?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Response from chat API
|
|
36
|
+
*/
|
|
37
|
+
export interface ChatApiResponse {
|
|
38
|
+
/**
|
|
39
|
+
* Bot's reply message
|
|
40
|
+
*/
|
|
41
|
+
reply: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Optional confidence score (0-1)
|
|
45
|
+
*/
|
|
46
|
+
confidence?: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether to show suggestion chips
|
|
50
|
+
*/
|
|
51
|
+
showSuggestions?: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional suggested responses
|
|
55
|
+
*/
|
|
56
|
+
suggestions?: string[];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Optional metadata from the API
|
|
60
|
+
*/
|
|
61
|
+
metadata?: Record<string, any>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Optional message ID from the backend
|
|
65
|
+
*/
|
|
66
|
+
messageId?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Error response from chat API
|
|
71
|
+
*/
|
|
72
|
+
export interface ChatApiError {
|
|
73
|
+
/**
|
|
74
|
+
* Error message
|
|
75
|
+
*/
|
|
76
|
+
message: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Error code
|
|
80
|
+
*/
|
|
81
|
+
code?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* HTTP status code
|
|
85
|
+
*/
|
|
86
|
+
statusCode?: number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Additional error details
|
|
90
|
+
*/
|
|
91
|
+
details?: any;
|
|
92
|
+
}
|