@aakash58/chatbot 1.1.21 → 1.1.24
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/README.md +22 -298
- package/esm2022/aakash58-chatbot.mjs +5 -0
- package/esm2022/lib/app/chat/chat-ui-state.service.mjs +170 -0
- package/esm2022/lib/app/chat/chat.service.mjs +445 -0
- package/esm2022/lib/app/chat/components/chat-button/chat-button.component.mjs +50 -0
- package/esm2022/lib/app/chat/components/chat-footer/chat-footer.component.mjs +12 -0
- package/esm2022/lib/app/chat/components/chat-header/chat-header.component.mjs +66 -0
- package/esm2022/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.mjs +186 -0
- package/esm2022/lib/app/chat/components/chat-window/chat-window.component.mjs +312 -0
- package/esm2022/lib/app/chat/components/message-input/message-input.component.mjs +36 -0
- package/esm2022/lib/app/chat/components/message-list/message-list.component.mjs +115 -0
- package/esm2022/lib/app/chat/model/chat-history.model.mjs +2 -0
- package/esm2022/lib/app/chat/model/chat-request.model.mjs +2 -0
- package/esm2022/lib/app/chat/model/chat-response.model.mjs +2 -0
- package/esm2022/lib/app/chat/model/chat-session.model.mjs +2 -0
- package/esm2022/lib/app/chat/model/chat-stream-message.model.mjs +2 -0
- package/esm2022/lib/app/chat/model/chat-stream-response.model.mjs +2 -0
- package/esm2022/lib/app/chat/services/chat-api.service.mjs +61 -0
- package/esm2022/lib/app/chat/services/chat-audio.service.mjs +50 -0
- package/esm2022/lib/app/chat/services/chat-history.service.mjs +252 -0
- package/esm2022/lib/app/login/login-form.component.mjs +46 -0
- package/esm2022/lib/app/personalization/personalization-dialog.component.mjs +194 -0
- package/esm2022/lib/app/personalization/personalization.service.mjs +149 -0
- package/esm2022/lib/app/personalization/sections/account/account-section.component.mjs +122 -0
- package/esm2022/lib/app/personalization/sections/preferences/color-picker-dialog.component.mjs +86 -0
- package/esm2022/lib/app/personalization/sections/preferences/preferences-section.component.mjs +115 -0
- package/esm2022/lib/app/personalization/sections/profile/profile-section.component.mjs +29 -0
- package/esm2022/lib/app/personalization/sections/settings/setting-section.component.mjs +30 -0
- package/esm2022/lib/app/personalization/sections/terms/terms-section.component.mjs +12 -0
- package/esm2022/lib/constant/doohbot-constant.mjs +28 -0
- package/esm2022/lib/constant/html-entities.mjs +9 -0
- package/esm2022/lib/constant/utf8.mjs +10 -0
- package/esm2022/lib/core/app-const.mjs +61 -0
- package/esm2022/lib/core/auth/account-api.service.mjs +40 -0
- package/esm2022/lib/core/auth/auth.service.mjs +391 -0
- package/esm2022/lib/core/auth/models/auth-result.model.mjs +3 -0
- package/esm2022/lib/core/auth/models/federated-login-request.model.mjs +6 -0
- package/esm2022/lib/core/auth/models/login-request.model.mjs +6 -0
- package/esm2022/lib/core/auth/storage.service.mjs +110 -0
- package/esm2022/lib/core/directives/draggable/draggable-dialog.directive.mjs +112 -0
- package/esm2022/lib/core/directives/fullscreen/fullscreen.directive.mjs +55 -0
- package/esm2022/lib/core/directives/resizable/resizable-dialog.directive.mjs +179 -0
- package/esm2022/lib/core/environments/environment.mjs +15 -0
- package/esm2022/lib/core/environments/environment.prod.mjs +15 -0
- package/esm2022/lib/core/helpers/crypto-helper.service.mjs +52 -0
- package/esm2022/lib/core/http/http-stream.service.mjs +97 -0
- package/esm2022/lib/core/http/http.service.mjs +103 -0
- package/esm2022/lib/core/interceptors/auth.interceptor.mjs +96 -0
- package/esm2022/lib/core/interceptors/license.interceptor.mjs +44 -0
- package/esm2022/lib/core/models/api-config.model.mjs +18 -0
- package/esm2022/lib/core/models/api-request.model.mjs +2 -0
- package/esm2022/lib/core/models/api-response.model.mjs +8 -0
- package/esm2022/lib/core/models/doohbot-config.model.mjs +18 -0
- package/esm2022/lib/core/models/license.model.mjs +2 -0
- package/esm2022/lib/core/models/message.mjs +2 -0
- package/esm2022/lib/core/models/theme-config.model.mjs +2 -0
- package/esm2022/lib/core/services/core-config.service.mjs +52 -0
- package/esm2022/lib/core/services/license.service.mjs +145 -0
- package/esm2022/lib/core/services/markdown.service.mjs +64 -0
- package/esm2022/lib/core/services/theme.service.mjs +248 -0
- package/esm2022/lib/core/types/auth-mode.type.mjs +2 -0
- package/esm2022/lib/core/types/auth-status.type.mjs +5 -0
- package/esm2022/lib/core/types/chat-stream.type.mjs +2 -0
- package/esm2022/lib/core/types/message-role.type.mjs +2 -0
- package/esm2022/lib/core/types/prompt-mode.type.mjs +5 -0
- package/esm2022/lib/core/types/snackbar-error.type.mjs +5 -0
- package/esm2022/lib/core/types/tenant-resolution-strategy.type.mjs +2 -0
- package/esm2022/lib/core/utils/logger.service.mjs +42 -0
- package/esm2022/lib/doohbot-input.mjs +20 -0
- package/esm2022/lib/doohbot.component.mjs +444 -0
- package/esm2022/lib/predefined_messages.mjs +15 -0
- package/esm2022/lib/shared/chips/chips.component.mjs +28 -0
- package/esm2022/lib/shared/dialog/dialog.component.mjs +36 -0
- package/esm2022/lib/shared/dialog/dialog.service.mjs +64 -0
- package/esm2022/lib/shared/dialog/dialog.utils.mjs +85 -0
- package/esm2022/lib/shared/dropdown-menu/dropdown-menu.component.mjs +29 -0
- package/esm2022/lib/shared/input-dialog/input-dialog.component.mjs +38 -0
- package/esm2022/lib/shared/menu-item/menu-item.component.mjs +24 -0
- package/esm2022/lib/shared/pipes/simple-markdown.pipe.mjs +27 -0
- package/esm2022/lib/shared/snackbar/snackbar.component.mjs +43 -0
- package/esm2022/lib/shared/snackbar/snackbar.service.mjs +46 -0
- package/esm2022/lib/shared/snackbar/snackbar.utils.mjs +43 -0
- package/esm2022/public-api.mjs +37 -0
- package/fesm2022/aakash58-chatbot.mjs +5193 -0
- package/fesm2022/aakash58-chatbot.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/app/chat/chat-ui-state.service.d.ts +96 -0
- package/lib/app/chat/chat.service.d.ts +88 -0
- package/lib/app/chat/components/chat-button/chat-button.component.d.ts +16 -0
- package/lib/app/chat/components/chat-footer/chat-footer.component.d.ts +5 -0
- package/lib/app/chat/components/chat-header/chat-header.component.d.ts +24 -0
- package/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.d.ts +49 -0
- package/lib/app/chat/components/chat-window/chat-window.component.d.ts +107 -0
- package/lib/app/chat/components/message-input/message-input.component.d.ts +12 -0
- package/lib/app/chat/components/message-list/message-list.component.d.ts +40 -0
- package/lib/app/chat/model/chat-history.model.d.ts +51 -0
- package/lib/app/chat/model/chat-request.model.d.ts +10 -0
- package/lib/app/chat/model/chat-response.model.d.ts +9 -0
- package/lib/app/chat/model/chat-session.model.d.ts +12 -0
- package/{projects/doohbot/src/lib/app/chat/model/chat-stream-message.model.ts → lib/app/chat/model/chat-stream-message.model.d.ts} +5 -6
- package/lib/app/chat/model/chat-stream-response.model.d.ts +10 -0
- package/lib/app/chat/services/chat-api.service.d.ts +30 -0
- package/lib/app/chat/services/chat-audio.service.d.ts +19 -0
- package/lib/app/chat/services/chat-history.service.d.ts +53 -0
- package/lib/app/login/login-form.component.d.ts +20 -0
- package/lib/app/personalization/personalization-dialog.component.d.ts +53 -0
- package/lib/app/personalization/personalization.service.d.ts +66 -0
- package/lib/app/personalization/sections/account/account-section.component.d.ts +30 -0
- package/lib/app/personalization/sections/preferences/color-picker-dialog.component.d.ts +17 -0
- package/lib/app/personalization/sections/preferences/preferences-section.component.d.ts +27 -0
- package/lib/app/personalization/sections/profile/profile-section.component.d.ts +17 -0
- package/lib/app/personalization/sections/settings/setting-section.component.d.ts +10 -0
- package/lib/app/personalization/sections/terms/terms-section.component.d.ts +5 -0
- package/lib/constant/doohbot-constant.d.ts +12 -0
- package/lib/constant/html-entities.d.ts +8 -0
- package/lib/constant/utf8.d.ts +9 -0
- package/lib/core/app-const.d.ts +11 -0
- package/lib/core/auth/account-api.service.d.ts +20 -0
- package/lib/core/auth/auth.service.d.ts +90 -0
- package/lib/core/auth/models/auth-result.model.d.ts +4 -0
- package/lib/core/auth/models/federated-login-request.model.d.ts +5 -0
- package/lib/core/auth/models/login-request.model.d.ts +6 -0
- package/lib/core/auth/storage.service.d.ts +21 -0
- package/lib/core/directives/draggable/draggable-dialog.directive.d.ts +23 -0
- package/lib/core/directives/fullscreen/fullscreen.directive.d.ts +14 -0
- package/lib/core/directives/resizable/resizable-dialog.directive.d.ts +30 -0
- package/lib/core/environments/environment.d.ts +7 -0
- package/lib/core/environments/environment.prod.d.ts +7 -0
- package/lib/core/helpers/crypto-helper.service.d.ts +12 -0
- package/lib/core/http/http-stream.service.d.ts +18 -0
- package/lib/core/http/http.service.d.ts +20 -0
- package/lib/core/interceptors/auth.interceptor.d.ts +18 -0
- package/lib/core/interceptors/license.interceptor.d.ts +11 -0
- package/lib/core/models/api-config.model.d.ts +58 -0
- package/lib/core/models/api-request.model.d.ts +77 -0
- package/lib/core/models/api-response.model.d.ts +6 -0
- package/lib/core/models/doohbot-config.model.d.ts +81 -0
- package/{projects/doohbot/src/lib/core/models/license.model.ts → lib/core/models/license.model.d.ts} +23 -27
- package/lib/core/models/message.d.ts +16 -0
- package/lib/core/models/theme-config.model.d.ts +28 -0
- package/lib/core/services/core-config.service.d.ts +23 -0
- package/lib/core/services/license.service.d.ts +33 -0
- package/lib/core/services/markdown.service.d.ts +8 -0
- package/lib/core/services/theme.service.d.ts +40 -0
- package/{projects/doohbot/src/lib/core/types/auth-mode.type.ts → lib/core/types/auth-mode.type.d.ts} +4 -4
- package/{projects/doohbot/src/lib/core/types/auth-status.type.ts → lib/core/types/auth-status.type.d.ts} +4 -5
- package/{projects/doohbot/src/lib/core/types/chat-stream.type.ts → lib/core/types/chat-stream.type.d.ts} +4 -4
- package/{projects/doohbot/src/lib/core/types/message-role.type.ts → lib/core/types/message-role.type.d.ts} +4 -4
- package/{projects/doohbot/src/lib/core/types/prompt-mode.type.ts → lib/core/types/prompt-mode.type.d.ts} +4 -5
- package/{projects/doohbot/src/lib/core/types/snackbar-error.type.ts → lib/core/types/snackbar-error.type.d.ts} +4 -5
- package/{projects/doohbot/src/lib/core/types/tenant-resolution-strategy.type.ts → lib/core/types/tenant-resolution-strategy.type.d.ts} +4 -4
- package/lib/core/utils/logger.service.d.ts +11 -0
- package/lib/doohbot-input.d.ts +19 -0
- package/lib/doohbot.component.d.ts +108 -0
- package/lib/predefined_messages.d.ts +2 -0
- package/lib/shared/chips/chips.component.d.ts +10 -0
- package/lib/shared/dialog/dialog.component.d.ts +19 -0
- package/lib/shared/dialog/dialog.service.d.ts +29 -0
- package/lib/shared/dialog/dialog.utils.d.ts +41 -0
- package/lib/shared/dropdown-menu/dropdown-menu.component.d.ts +11 -0
- package/lib/shared/input-dialog/input-dialog.component.d.ts +20 -0
- package/lib/shared/menu-item/menu-item.component.d.ts +9 -0
- package/lib/shared/pipes/simple-markdown.pipe.d.ts +10 -0
- package/lib/shared/snackbar/snackbar.component.d.ts +14 -0
- package/lib/shared/snackbar/snackbar.service.d.ts +19 -0
- package/{projects/doohbot/src/lib/shared/snackbar/snackbar.utils.ts → lib/shared/snackbar/snackbar.utils.d.ts} +33 -49
- package/package.json +29 -75
- package/public-api.d.ts +11 -0
- package/.editorconfig +0 -17
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -41
- package/.vscode/settings.json +0 -14
- package/.vscode/tasks.json +0 -60
- package/angular.json +0 -132
- package/docs/PUBLISHING_GUIDE.md +0 -104
- package/projects/app-doohbot/public/assets/const/app-const.json +0 -15
- package/projects/app-doohbot/public/assets/const/doohclick_license.json +0 -6
- package/projects/app-doohbot/public/favicon.ico +0 -0
- package/projects/app-doohbot/src/app/app.config.ts +0 -13
- package/projects/app-doohbot/src/app/app.html +0 -31
- package/projects/app-doohbot/src/app/app.routes.ts +0 -3
- package/projects/app-doohbot/src/app/app.scss +0 -279
- package/projects/app-doohbot/src/app/app.spec.ts +0 -23
- package/projects/app-doohbot/src/app/app.ts +0 -72
- package/projects/app-doohbot/src/index.html +0 -15
- package/projects/app-doohbot/src/main.ts +0 -6
- package/projects/app-doohbot/src/styles.scss +0 -15
- package/projects/app-doohbot/tsconfig.app.json +0 -15
- package/projects/app-doohbot/tsconfig.spec.json +0 -14
- package/projects/doohbot/README.md +0 -64
- package/projects/doohbot/docs/README.md +0 -140
- package/projects/doohbot/ng-package.json +0 -10
- package/projects/doohbot/package.json +0 -16
- package/projects/doohbot/src/lib/app/chat/chat-ui-state.service.ts +0 -194
- package/projects/doohbot/src/lib/app/chat/chat.service.ts +0 -547
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.html +0 -27
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.scss +0 -115
- package/projects/doohbot/src/lib/app/chat/components/chat-button/chat-button.component.ts +0 -35
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.html +0 -3
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.scss +0 -20
- package/projects/doohbot/src/lib/app/chat/components/chat-footer/chat-footer.component.ts +0 -12
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.html +0 -34
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.scss +0 -78
- package/projects/doohbot/src/lib/app/chat/components/chat-header/chat-header.component.ts +0 -52
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.html +0 -77
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.scss +0 -346
- package/projects/doohbot/src/lib/app/chat/components/chat-history-sidebar/chat-history-sidebar.component.ts +0 -188
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.html +0 -146
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.scss +0 -187
- package/projects/doohbot/src/lib/app/chat/components/chat-window/chat-window.component.ts +0 -256
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.html +0 -17
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.scss +0 -59
- package/projects/doohbot/src/lib/app/chat/components/message-input/message-input.component.ts +0 -28
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.html +0 -138
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.scss +0 -436
- package/projects/doohbot/src/lib/app/chat/components/message-list/message-list.component.ts +0 -106
- package/projects/doohbot/src/lib/app/chat/model/chat-history.model.ts +0 -57
- package/projects/doohbot/src/lib/app/chat/model/chat-request.model.ts +0 -17
- package/projects/doohbot/src/lib/app/chat/model/chat-response.model.ts +0 -9
- package/projects/doohbot/src/lib/app/chat/model/chat-session.model.ts +0 -14
- package/projects/doohbot/src/lib/app/chat/model/chat-stream-response.model.ts +0 -12
- package/projects/doohbot/src/lib/app/chat/services/chat-api.service.ts +0 -82
- package/projects/doohbot/src/lib/app/chat/services/chat-audio.service.ts +0 -44
- package/projects/doohbot/src/lib/app/chat/services/chat-history.service.ts +0 -303
- package/projects/doohbot/src/lib/app/login/login-form.component.html +0 -80
- package/projects/doohbot/src/lib/app/login/login-form.component.scss +0 -189
- package/projects/doohbot/src/lib/app/login/login-form.component.ts +0 -45
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.html +0 -81
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.scss +0 -179
- package/projects/doohbot/src/lib/app/personalization/personalization-dialog.component.ts +0 -217
- package/projects/doohbot/src/lib/app/personalization/personalization.service.ts +0 -197
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.html +0 -111
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.scss +0 -218
- package/projects/doohbot/src/lib/app/personalization/sections/account/account-section.component.ts +0 -121
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.html +0 -46
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.scss +0 -138
- package/projects/doohbot/src/lib/app/personalization/sections/instructions/instructions-section.component.ts +0 -28
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/color-picker-dialog.component.ts +0 -92
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.html +0 -198
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.scss +0 -107
- package/projects/doohbot/src/lib/app/personalization/sections/preferences/preferences-section.component.ts +0 -103
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.html +0 -46
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.scss +0 -131
- package/projects/doohbot/src/lib/app/personalization/sections/profile/profile-section.component.ts +0 -23
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.html +0 -33
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.scss +0 -61
- package/projects/doohbot/src/lib/app/personalization/sections/settings/setting-section.component.ts +0 -20
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.html +0 -30
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.scss +0 -59
- package/projects/doohbot/src/lib/app/personalization/sections/terms/terms-section.component.ts +0 -12
- package/projects/doohbot/src/lib/constant/doohbot-constant.ts +0 -40
- package/projects/doohbot/src/lib/constant/html-entities.ts +0 -8
- package/projects/doohbot/src/lib/constant/utf8.ts +0 -9
- package/projects/doohbot/src/lib/core/app-const.ts +0 -63
- package/projects/doohbot/src/lib/core/auth/account-api.service.ts +0 -53
- package/projects/doohbot/src/lib/core/auth/auth.service.ts +0 -478
- package/projects/doohbot/src/lib/core/auth/models/auth-result.model.ts +0 -4
- package/projects/doohbot/src/lib/core/auth/models/federated-login-request.model.ts +0 -5
- package/projects/doohbot/src/lib/core/auth/models/login-request.model.ts +0 -6
- package/projects/doohbot/src/lib/core/auth/storage.service.ts +0 -113
- package/projects/doohbot/src/lib/core/directives/draggable/draggable-dialog.directive.ts +0 -123
- package/projects/doohbot/src/lib/core/directives/draggable/draggable-dialog.module.ts +0 -9
- package/projects/doohbot/src/lib/core/directives/fullscreen/fullscreen.directive.ts +0 -58
- package/projects/doohbot/src/lib/core/directives/fullscreen/fullscreen.module.ts +0 -9
- package/projects/doohbot/src/lib/core/directives/popout/popout.directive.ts +0 -169
- package/projects/doohbot/src/lib/core/directives/popout/popout.module.ts +0 -9
- package/projects/doohbot/src/lib/core/directives/resizable/resizable-dialog.directive.ts +0 -197
- package/projects/doohbot/src/lib/core/directives/resizable/resizable-dialog.module.ts +0 -9
- package/projects/doohbot/src/lib/core/enums/api-request-state.enum.ts +0 -9
- package/projects/doohbot/src/lib/core/environments/environment.prod.ts +0 -14
- package/projects/doohbot/src/lib/core/environments/environment.ts +0 -14
- package/projects/doohbot/src/lib/core/helpers/crypto-helper.service.ts +0 -72
- package/projects/doohbot/src/lib/core/http/http-stream.service.ts +0 -105
- package/projects/doohbot/src/lib/core/http/http.service.ts +0 -148
- package/projects/doohbot/src/lib/core/interceptors/auth.interceptor.ts +0 -118
- package/projects/doohbot/src/lib/core/interceptors/license.interceptor.ts +0 -50
- package/projects/doohbot/src/lib/core/models/api-config.model.ts +0 -82
- package/projects/doohbot/src/lib/core/models/api-request.model.ts +0 -92
- package/projects/doohbot/src/lib/core/models/api-response.model.ts +0 -13
- package/projects/doohbot/src/lib/core/models/doohbot-config.model.ts +0 -109
- package/projects/doohbot/src/lib/core/models/message.ts +0 -18
- package/projects/doohbot/src/lib/core/models/theme-config.model.ts +0 -48
- package/projects/doohbot/src/lib/core/services/core-config.service.ts +0 -53
- package/projects/doohbot/src/lib/core/services/doohbot-api.service.ts +0 -207
- package/projects/doohbot/src/lib/core/services/license.service.ts +0 -171
- package/projects/doohbot/src/lib/core/services/markdown.service.ts +0 -73
- package/projects/doohbot/src/lib/core/services/theme.service.ts +0 -305
- package/projects/doohbot/src/lib/core/utils/error-handler.util.ts +0 -31
- package/projects/doohbot/src/lib/core/utils/logger.service.ts +0 -45
- package/projects/doohbot/src/lib/doohbot-input.ts +0 -19
- package/projects/doohbot/src/lib/doohbot.component.html +0 -34
- package/projects/doohbot/src/lib/doohbot.component.scss +0 -17
- package/projects/doohbot/src/lib/doohbot.component.spec.ts +0 -31
- package/projects/doohbot/src/lib/doohbot.component.ts +0 -545
- package/projects/doohbot/src/lib/elements.ts +0 -25
- package/projects/doohbot/src/lib/predefined_messages.ts +0 -14
- package/projects/doohbot/src/lib/shared/chips/chips.component.html +0 -9
- package/projects/doohbot/src/lib/shared/chips/chips.component.scss +0 -29
- package/projects/doohbot/src/lib/shared/chips/chips.component.spec.ts +0 -22
- package/projects/doohbot/src/lib/shared/chips/chips.component.ts +0 -20
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.html +0 -29
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.scss +0 -100
- package/projects/doohbot/src/lib/shared/dialog/dialog.component.ts +0 -42
- package/projects/doohbot/src/lib/shared/dialog/dialog.service.ts +0 -62
- package/projects/doohbot/src/lib/shared/dialog/dialog.utils.ts +0 -102
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.html +0 -30
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.scss +0 -53
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.spec.ts +0 -22
- package/projects/doohbot/src/lib/shared/dropdown-menu/dropdown-menu.component.ts +0 -35
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.html +0 -16
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.scss +0 -45
- package/projects/doohbot/src/lib/shared/input-dialog/input-dialog.component.ts +0 -46
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.html +0 -5
- 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 +0 -22
- package/projects/doohbot/src/lib/shared/menu-item/menu-item.component.ts +0 -20
- package/projects/doohbot/src/lib/shared/pipes/simple-markdown.pipe.ts +0 -19
- package/projects/doohbot/src/lib/shared/popout/popout.html +0 -1
- package/projects/doohbot/src/lib/shared/popout/popout.scss +0 -0
- package/projects/doohbot/src/lib/shared/popout/popout.spec.ts +0 -23
- package/projects/doohbot/src/lib/shared/popout/popout.ts +0 -11
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.html +0 -7
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.scss +0 -125
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.spec.ts +0 -21
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.component.ts +0 -44
- package/projects/doohbot/src/lib/shared/snackbar/snackbar.service.ts +0 -54
- package/projects/doohbot/src/lib/styles/_theme.scss +0 -132
- package/projects/doohbot/src/lib/styles/material-override.scss +0 -302
- package/projects/doohbot/src/lib/styles/utility.scss +0 -588
- package/projects/doohbot/src/public-api.ts +0 -42
- package/projects/doohbot/tsconfig.lib.json +0 -15
- package/projects/doohbot/tsconfig.lib.prod.json +0 -11
- package/projects/doohbot/tsconfig.spec.json +0 -10
- package/proxy.conf.json +0 -8
- package/publish.config.js +0 -25
- package/scripts/publishing/index.ts +0 -67
- package/scripts/publishing/pipeline/01-clean.ts +0 -11
- package/scripts/publishing/pipeline/02-validate-pre.ts +0 -8
- package/scripts/publishing/pipeline/03-build.ts +0 -7
- package/scripts/publishing/pipeline/04-validate-post.ts +0 -8
- package/scripts/publishing/pipeline/05-prepare-package.ts +0 -29
- package/scripts/publishing/pipeline/06-version.ts +0 -23
- package/scripts/publishing/pipeline/07-publish.ts +0 -14
- package/scripts/publishing/pipeline/08-cleanup.ts +0 -5
- package/scripts/publishing/types.ts +0 -36
- package/scripts/publishing/utils/command.ts +0 -15
- package/scripts/publishing/utils/config.ts +0 -17
- package/scripts/validate.ts +0 -166
- package/tsconfig.json +0 -45
- package/tsconfig.scripts.json +0 -15
- /package/{projects/doohbot/src → src}/assets/bot.mp3 +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { AuthMode } from '../types/auth-mode.type';
|
|
3
|
-
import { TenantResolutionStrategy } from '../types/tenant-resolution-strategy.type';
|
|
4
|
-
import { PromptMode } from '../types/prompt-mode.type';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Advanced configuration for DoohBot package
|
|
8
|
-
* Supports both simple and complex use cases
|
|
9
|
-
*/
|
|
10
|
-
export interface DoohbotAdvancedConfig {
|
|
11
|
-
/**
|
|
12
|
-
* Authentication mode
|
|
13
|
-
* - 'manual': You provide platformTenant, subTenant, agent manually
|
|
14
|
-
* - 'auto': Package reads from your auth service via resolver
|
|
15
|
-
* @default 'manual'
|
|
16
|
-
*/
|
|
17
|
-
authMode?: AuthMode;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Tenant resolution strategy
|
|
21
|
-
* - 'static': Use fixed values provided via inputs
|
|
22
|
-
* - 'dynamic': Automatically update when auth state changes
|
|
23
|
-
* - 'callback': Use custom resolver function
|
|
24
|
-
* @default 'static'
|
|
25
|
-
*/
|
|
26
|
-
tenantResolution?: TenantResolutionStrategy;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Auto-configure from localStorage key
|
|
30
|
-
* If provided, package will read auth data from localStorage
|
|
31
|
-
* Example: 'auth_user' or 'saas_session'
|
|
32
|
-
*/
|
|
33
|
-
autoConfigFromStorage?: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Enable multi-tenant mode
|
|
37
|
-
* Allows switching between different tenant contexts
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
enableMultiTenant?: boolean;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Persist chat history per tenant
|
|
44
|
-
* @default true
|
|
45
|
-
*/
|
|
46
|
-
persistChatPerTenant?: boolean;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Custom authentication header name
|
|
50
|
-
* @default 'Authorization'
|
|
51
|
-
*/
|
|
52
|
-
authHeaderName?: string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Custom authentication header format
|
|
56
|
-
* Use {token} as placeholder
|
|
57
|
-
* @default 'Bearer {token}'
|
|
58
|
-
*/
|
|
59
|
-
authHeaderFormat?: string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Enable role-based features
|
|
63
|
-
* Shows/hides features based on user permissions
|
|
64
|
-
* @default false
|
|
65
|
-
*/
|
|
66
|
-
enableRoleBasedFeatures?: boolean;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* User permissions (for role-based features)
|
|
70
|
-
*/
|
|
71
|
-
userPermissions?: string[];
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Callback when authentication fails
|
|
75
|
-
*/
|
|
76
|
-
onAuthFailure?: (error: any) => void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Enable debug mode (logs configuration and requests)
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
debugMode?: boolean;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Prompt mode for chat responses
|
|
86
|
-
* @default 'markdown'
|
|
87
|
-
*/
|
|
88
|
-
promptMode?: PromptMode;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Injection token for advanced configuration
|
|
93
|
-
*/
|
|
94
|
-
export const DOOHBOT_ADVANCED_CONFIG = new InjectionToken<DoohbotAdvancedConfig>(
|
|
95
|
-
'DOOHBOT_ADVANCED_CONFIG',
|
|
96
|
-
{
|
|
97
|
-
providedIn: 'root',
|
|
98
|
-
factory: () => ({
|
|
99
|
-
authMode: 'manual',
|
|
100
|
-
tenantResolution: 'static',
|
|
101
|
-
enableMultiTenant: false,
|
|
102
|
-
persistChatPerTenant: true,
|
|
103
|
-
authHeaderName: 'Authorization',
|
|
104
|
-
authHeaderFormat: 'Bearer {token}',
|
|
105
|
-
enableRoleBasedFeatures: false,
|
|
106
|
-
debugMode: false,
|
|
107
|
-
}),
|
|
108
|
-
},
|
|
109
|
-
);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { MessageRole } from '../types/message-role.type';
|
|
2
|
-
|
|
3
|
-
export interface Message {
|
|
4
|
-
id: string;
|
|
5
|
-
sender: MessageRole;
|
|
6
|
-
senderName?: string;
|
|
7
|
-
text: string; //! used for non-streaming
|
|
8
|
-
chunks?: string[]; //! used for streaming
|
|
9
|
-
timestamp?: Date;
|
|
10
|
-
showSuggestions?: boolean;
|
|
11
|
-
// Optional context fields for API integration
|
|
12
|
-
platformTenant?: string;
|
|
13
|
-
subTenant?: string;
|
|
14
|
-
agent?: string;
|
|
15
|
-
completed: boolean | true;
|
|
16
|
-
isHistory: boolean | true; //! Indicated the message is from history
|
|
17
|
-
copied?: boolean;
|
|
18
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// TODO
|
|
2
|
-
export interface DoohbotThemeConfig {
|
|
3
|
-
// Font
|
|
4
|
-
fontFamily?: string;
|
|
5
|
-
|
|
6
|
-
// Primary & Secondary
|
|
7
|
-
primaryColor?: string;
|
|
8
|
-
secondaryColor?: string;
|
|
9
|
-
|
|
10
|
-
// Backgrounds
|
|
11
|
-
backgroundColor?: string;
|
|
12
|
-
chatInputColor?: string;
|
|
13
|
-
|
|
14
|
-
// Text Colors
|
|
15
|
-
textAltColor?: string;
|
|
16
|
-
textColor?: string;
|
|
17
|
-
secondaryTextColor?: string;
|
|
18
|
-
hintTextColor?: string;
|
|
19
|
-
|
|
20
|
-
// Button Colors
|
|
21
|
-
buttonColor?: string;
|
|
22
|
-
|
|
23
|
-
// Message Colors
|
|
24
|
-
userMessageColor?: string;
|
|
25
|
-
botMessageColor?: string;
|
|
26
|
-
|
|
27
|
-
// Message Text Colors
|
|
28
|
-
userTextColor?: string;
|
|
29
|
-
botTextColor?: string;
|
|
30
|
-
|
|
31
|
-
// Borders
|
|
32
|
-
borderColor?: string;
|
|
33
|
-
borderShadowColor?: string;
|
|
34
|
-
borderTopColor?: string;
|
|
35
|
-
|
|
36
|
-
// Indicators
|
|
37
|
-
typingIndicatorColor?: string;
|
|
38
|
-
|
|
39
|
-
// Utility Colors
|
|
40
|
-
white?: string;
|
|
41
|
-
black?: string;
|
|
42
|
-
grey?: string;
|
|
43
|
-
red?: string;
|
|
44
|
-
yellow?: string;
|
|
45
|
-
orange?: string;
|
|
46
|
-
green?: string;
|
|
47
|
-
blue?: string;
|
|
48
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Injectable, signal, WritableSignal } from '@angular/core';
|
|
2
|
-
import { DoohbotInput } from '../../doohbot-input';
|
|
3
|
-
|
|
4
|
-
@Injectable({
|
|
5
|
-
providedIn: 'root',
|
|
6
|
-
})
|
|
7
|
-
export class CoreConfigService {
|
|
8
|
-
private configSignal: WritableSignal<DoohbotInput> = signal(new DoohbotInput());
|
|
9
|
-
public config$ = this.configSignal.asReadonly();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Updates the global library configuration
|
|
13
|
-
*/
|
|
14
|
-
updateConfig(config: DoohbotInput): void {
|
|
15
|
-
this.configSignal.set(config);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Dynamic getters for common config properties
|
|
20
|
-
*/
|
|
21
|
-
get apiUrl(): string {
|
|
22
|
-
const config = this.configSignal();
|
|
23
|
-
return `${config.apiBaseUrl}${config.apiSegment}`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get storageKey(): string {
|
|
27
|
-
return this.configSignal().storageKey || '';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get secretKey(): string {
|
|
31
|
-
return this.configSignal().secretKey || '';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get companyCode(): string {
|
|
35
|
-
return this.configSignal().companyCode || '';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get tenancyName(): string {
|
|
39
|
-
return this.configSignal().tenancyName || '';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get licenseKey(): string {
|
|
43
|
-
return this.configSignal().licenseKey || '';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get licenseFilePath(): string {
|
|
47
|
-
return this.configSignal().licenseFilePath || '';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get rememberMe(): boolean {
|
|
51
|
-
return this.configSignal().rememberMe !== undefined ? this.configSignal().rememberMe! : false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { Injectable, inject } from '@angular/core';
|
|
2
|
-
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
|
|
3
|
-
import { Observable, throwError, timer } from 'rxjs';
|
|
4
|
-
import { catchError, retry, timeout, map } from 'rxjs/operators';
|
|
5
|
-
import { DOOHBOT_API_CONFIG, DoohbotApiConfig } from '../models/api-config.model';
|
|
6
|
-
import { ChatApiRequest, ChatApiResponse, ChatApiError } from '../models/api-request.model';
|
|
7
|
-
import { Message } from '../models/message';
|
|
8
|
-
import { ErrorHandlerUtil } from '../utils/error-handler.util';
|
|
9
|
-
import logger from '../utils/logger.service';
|
|
10
|
-
import { SnackbarUtils } from '../../shared/snackbar/snackbar.utils';
|
|
11
|
-
import { StorageService } from './../auth/storage.service';
|
|
12
|
-
import { LicenseService } from './license.service';
|
|
13
|
-
import { AuthService } from '../auth/auth.service';
|
|
14
|
-
|
|
15
|
-
@Injectable({
|
|
16
|
-
providedIn: 'root',
|
|
17
|
-
})
|
|
18
|
-
export class ChatbotApiService {
|
|
19
|
-
private http = inject(HttpClient);
|
|
20
|
-
private config = inject(DOOHBOT_API_CONFIG);
|
|
21
|
-
private tokenStorage = inject(StorageService);
|
|
22
|
-
private licenseService = inject(LicenseService);
|
|
23
|
-
private authService = inject(AuthService);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Send a chat message to the API
|
|
27
|
-
* @param message User's message text
|
|
28
|
-
* @param history Optional message history for context
|
|
29
|
-
* @returns Observable of the API response
|
|
30
|
-
*/
|
|
31
|
-
sendMessage(message: string, history?: Message[]): Observable<ChatApiResponse> {
|
|
32
|
-
if (!this.config.apiUrl) {
|
|
33
|
-
return throwError(
|
|
34
|
-
() =>
|
|
35
|
-
({
|
|
36
|
-
message: 'API URL not configured',
|
|
37
|
-
code: 'CONFIG_ERROR',
|
|
38
|
-
}) as ChatApiError,
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Build request payload with tenant context
|
|
43
|
-
const request = this.buildRequest(message, history);
|
|
44
|
-
|
|
45
|
-
// Build headers
|
|
46
|
-
const headers = this.buildHeaders();
|
|
47
|
-
|
|
48
|
-
// Configure timeout
|
|
49
|
-
const timeoutMs = this.config.timeout || 30000;
|
|
50
|
-
|
|
51
|
-
// Make HTTP request
|
|
52
|
-
return this.http.post<ChatApiResponse>(this.config.apiUrl, request, { headers }).pipe(
|
|
53
|
-
timeout(timeoutMs),
|
|
54
|
-
this.applyRetryStrategy(),
|
|
55
|
-
map((response) => this.validateResponse(response)),
|
|
56
|
-
catchError((error) => this.handleError(error)),
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Build request payload with current tenant context
|
|
62
|
-
*/
|
|
63
|
-
private buildRequest(message: string, history?: Message[]): ChatApiRequest {
|
|
64
|
-
const request: ChatApiRequest = {
|
|
65
|
-
message,
|
|
66
|
-
timestamp: new Date().toISOString(),
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Include history if enabled and provided
|
|
70
|
-
if (this.config.includeHistory && history && history.length > 0) {
|
|
71
|
-
const maxMessages = this.config.maxHistoryMessages || 10;
|
|
72
|
-
request.history = history.slice(-maxMessages);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return request;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Build HTTP headers
|
|
80
|
-
*/
|
|
81
|
-
private buildHeaders(): HttpHeaders {
|
|
82
|
-
let headers = new HttpHeaders({
|
|
83
|
-
'Content-Type': 'application/json',
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// Add API key if provided
|
|
87
|
-
if (this.config.apiKey) {
|
|
88
|
-
headers = headers.set('Authorization', `Bearer ${this.config.apiKey}`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Headers (License and Auth) are now handled globally by AuthInterceptor
|
|
92
|
-
// Add custom headers if provided if any specific to this service
|
|
93
|
-
if (this.config.customHeaders) {
|
|
94
|
-
Object.entries(this.config.customHeaders).forEach(([key, value]) => {
|
|
95
|
-
headers = headers.set(key, value);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return headers;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Apply retry strategy based on configuration
|
|
104
|
-
*/
|
|
105
|
-
private applyRetryStrategy() {
|
|
106
|
-
return (source: Observable<ChatApiResponse>) => {
|
|
107
|
-
if (!this.config.enableRetry) {
|
|
108
|
-
return source;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const retryAttempts = this.config.retryAttempts || 2;
|
|
112
|
-
const retryDelay = this.config.retryDelay || 1000;
|
|
113
|
-
|
|
114
|
-
return source.pipe(
|
|
115
|
-
retry({
|
|
116
|
-
count: retryAttempts,
|
|
117
|
-
delay: (error, retryCount) => {
|
|
118
|
-
// Only retry on network errors or 5xx server errors
|
|
119
|
-
if (this.shouldRetry(error)) {
|
|
120
|
-
logger.warn(`Retrying API request (attempt: ${retryCount}/${retryAttempts})...`);
|
|
121
|
-
return timer(retryDelay * retryCount);
|
|
122
|
-
}
|
|
123
|
-
// Don't retry on client errors (4xx)
|
|
124
|
-
return throwError(() => error);
|
|
125
|
-
},
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Determine if error should trigger a retry
|
|
133
|
-
*/
|
|
134
|
-
private shouldRetry(error: any): boolean {
|
|
135
|
-
if (error instanceof HttpErrorResponse) {
|
|
136
|
-
// Retry on network errors or 5xx server errors
|
|
137
|
-
return error.status === 0 || error.status >= 500;
|
|
138
|
-
}
|
|
139
|
-
// Retry on timeout errors
|
|
140
|
-
if (error.name === 'TimeoutError') {
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Validate API response
|
|
148
|
-
*/
|
|
149
|
-
private validateResponse(response: ChatApiResponse): ChatApiResponse {
|
|
150
|
-
if (!response || !response.reply) {
|
|
151
|
-
throw {
|
|
152
|
-
message: 'Invalid API response: missing reply field',
|
|
153
|
-
code: 'INVALID_RESPONSE',
|
|
154
|
-
} as ChatApiError;
|
|
155
|
-
}
|
|
156
|
-
return response;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Handle API errors
|
|
161
|
-
*/
|
|
162
|
-
private handleError(error: any): Observable<never> {
|
|
163
|
-
let apiError: ChatApiError;
|
|
164
|
-
|
|
165
|
-
if (error instanceof HttpErrorResponse) {
|
|
166
|
-
// HTTP error
|
|
167
|
-
apiError = {
|
|
168
|
-
message: ErrorHandlerUtil.handleError(error),
|
|
169
|
-
code: error.error?.code || 'HTTP_ERROR',
|
|
170
|
-
statusCode: error.status,
|
|
171
|
-
details: error.error,
|
|
172
|
-
};
|
|
173
|
-
} else if (error.name === 'TimeoutError') {
|
|
174
|
-
// Timeout error
|
|
175
|
-
apiError = {
|
|
176
|
-
message: 'Request timeout - please try again',
|
|
177
|
-
code: 'TIMEOUT',
|
|
178
|
-
statusCode: 408,
|
|
179
|
-
};
|
|
180
|
-
} else {
|
|
181
|
-
// Other errors
|
|
182
|
-
apiError = {
|
|
183
|
-
message: error.message || 'Unknown error occurred',
|
|
184
|
-
code: error.code || 'UNKNOWN_ERROR',
|
|
185
|
-
details: error,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
logger.error('Chatbot API Error:', apiError);
|
|
190
|
-
SnackbarUtils.error(apiError.message);
|
|
191
|
-
return throwError(() => apiError);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Check if API is enabled
|
|
196
|
-
*/
|
|
197
|
-
isApiEnabled(): boolean {
|
|
198
|
-
return this.config.enableApi === true && !!this.config.apiUrl;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Get current API configuration
|
|
203
|
-
*/
|
|
204
|
-
getConfig(): DoohbotApiConfig {
|
|
205
|
-
return { ...this.config };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { inject, Injectable, signal } from '@angular/core';
|
|
2
|
-
import { HttpClient } from '@angular/common/http';
|
|
3
|
-
import { firstValueFrom } from 'rxjs';
|
|
4
|
-
import {
|
|
5
|
-
LicenseFileContent,
|
|
6
|
-
LicenseRegistry,
|
|
7
|
-
LicensingContext,
|
|
8
|
-
LicensePackage,
|
|
9
|
-
} from '../models/license.model';
|
|
10
|
-
import logger from '../utils/logger.service';
|
|
11
|
-
import { CoreConfigService } from './core-config.service';
|
|
12
|
-
|
|
13
|
-
@Injectable({
|
|
14
|
-
providedIn: 'root',
|
|
15
|
-
})
|
|
16
|
-
export class LicenseService {
|
|
17
|
-
private http = inject(HttpClient);
|
|
18
|
-
private coreConfig = inject(CoreConfigService);
|
|
19
|
-
private registry = signal<LicenseRegistry | null>(null);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Load the license configuration from a JSON file.
|
|
23
|
-
* Supports both Hierarchical (entitlements) and Flat-map (package:key) formats.
|
|
24
|
-
* @param filePath Path to the license JSON file
|
|
25
|
-
*/
|
|
26
|
-
async loadLicenseFile(filePath?: string): Promise<void> {
|
|
27
|
-
try {
|
|
28
|
-
const finalPath = filePath || this.coreConfig.licenseFilePath;
|
|
29
|
-
|
|
30
|
-
const data = await firstValueFrom(this.http.get<any>(finalPath));
|
|
31
|
-
|
|
32
|
-
if (!data) {
|
|
33
|
-
throw new Error('Empty license file');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Detection: Hierarchical Format (subjectId/licenses array)
|
|
37
|
-
if (data.licenses && Array.isArray(data.licenses)) {
|
|
38
|
-
this.processHierarchicalLicense(data);
|
|
39
|
-
}
|
|
40
|
-
// Detection: Flat Map Format (packageId: key)
|
|
41
|
-
else {
|
|
42
|
-
this.processFlatMapLicense(data);
|
|
43
|
-
}
|
|
44
|
-
} catch (error) {
|
|
45
|
-
// Industry pattern: Silent loading for optional registry files
|
|
46
|
-
logger.log(
|
|
47
|
-
'[LicenseService] No external license file found or failed to load. Falling back to AppConst.',
|
|
48
|
-
);
|
|
49
|
-
this.registry.set(null);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private processHierarchicalLicense(data: LicenseFileContent): void {
|
|
54
|
-
const subjectMap = new Map<string, LicensePackage>();
|
|
55
|
-
|
|
56
|
-
data.licenses.forEach((license) => {
|
|
57
|
-
const key = `${license.subjectType}:${license.subjectId}`;
|
|
58
|
-
subjectMap.set(key, license.packages);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
this.registry.set({
|
|
62
|
-
accountId: data.accountId,
|
|
63
|
-
subjectLicenses: subjectMap,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
logger.log(`[LicenseService] Hierarchical Registry loaded for account: ${data.accountId}`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private processFlatMapLicense(data: Record<string, string>): void {
|
|
70
|
-
// Flat-map format: { "tenantName": "license_key" }
|
|
71
|
-
// Convert each entry to: tenant:tenantName -> { doohbot: license_key }
|
|
72
|
-
|
|
73
|
-
const subjectMap = new Map<string, LicensePackage>();
|
|
74
|
-
|
|
75
|
-
Object.entries(data).forEach(([tenantName, licenseKey]) => {
|
|
76
|
-
const tenantKey = `tenant:${tenantName}`;
|
|
77
|
-
subjectMap.set(tenantKey, {
|
|
78
|
-
doohbot: licenseKey,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
this.registry.set({
|
|
83
|
-
accountId: 'FLAT_MAP_REGISTRY',
|
|
84
|
-
subjectLicenses: subjectMap,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
logger.log(`[LicenseService] Flat-map registry loaded with ${subjectMap.size} tenant(s)`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Resolve the correct license key based on context and requested package
|
|
92
|
-
* @param context The current licensing context (tenant, user, roles)
|
|
93
|
-
* @param packageId The ID of the package requesting a license
|
|
94
|
-
* @returns The resolved license key, or null if unauthorized
|
|
95
|
-
*/
|
|
96
|
-
resolveLicenseKey(context: LicensingContext, packageId: string): string | null {
|
|
97
|
-
// Hierarchical Registry (Most Specific)
|
|
98
|
-
const keyFromRegistry = this.resolveFromRegistry(context, packageId);
|
|
99
|
-
if (keyFromRegistry) return keyFromRegistry;
|
|
100
|
-
|
|
101
|
-
logger.warn(
|
|
102
|
-
`[LicenseService] No license found for package: ${packageId} and user: ${context.principalId}`,
|
|
103
|
-
);
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private resolveFromRegistry(context: LicensingContext, packageId: string): string | null {
|
|
108
|
-
const reg = this.registry();
|
|
109
|
-
if (!reg) return null;
|
|
110
|
-
|
|
111
|
-
// Strict Account Check
|
|
112
|
-
if (reg.accountId !== 'EXTERNAL_OVERRIDE' && reg.accountId !== context.tenantId) {
|
|
113
|
-
logger.error(
|
|
114
|
-
`[LicenseService] Account mismatch! Registry: ${reg.accountId}, Context: ${context.tenantId}`,
|
|
115
|
-
);
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const subjectsToSearch = [
|
|
120
|
-
`user:${context.principalId}`,
|
|
121
|
-
...(context.roles?.map((r) => `role:${r}`) || []),
|
|
122
|
-
`tenant:${context.tenantId}`,
|
|
123
|
-
'tenant:default', // Fallback for flat-map external files
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
for (const subjectKey of subjectsToSearch) {
|
|
127
|
-
const packages = reg.subjectLicenses.get(subjectKey);
|
|
128
|
-
if (packages && packages[packageId]) {
|
|
129
|
-
logger.debug(`[LicenseService] Resolved key for ${packageId} via Registry (${subjectKey})`);
|
|
130
|
-
return packages[packageId];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Resolves the license key for the current tenant.
|
|
138
|
-
*/
|
|
139
|
-
resolveTenantLicenseKey(tenancyName?: string): string | null {
|
|
140
|
-
const activeTenancy = tenancyName || this.coreConfig.tenancyName;
|
|
141
|
-
|
|
142
|
-
if (!activeTenancy) {
|
|
143
|
-
logger.warn('[LicenseService] No tenancy name found.');
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const reg = this.registry();
|
|
148
|
-
if (!reg) {
|
|
149
|
-
logger.error('[LicenseService] License registry not loaded.');
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const tenantLicenses = reg.subjectLicenses.get(`tenant:${activeTenancy}`);
|
|
154
|
-
const licenseKey = tenantLicenses?.['doohbot'] || null;
|
|
155
|
-
|
|
156
|
-
if (licenseKey) {
|
|
157
|
-
logger.info(`[LicenseService] Resolved Doohbot license for: ${activeTenancy}`);
|
|
158
|
-
} else {
|
|
159
|
-
logger.warn(`[LicenseService] No license key found for tenant: ${activeTenancy}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return licenseKey;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Check if a registry is currently loaded
|
|
167
|
-
*/
|
|
168
|
-
isRegistryLoaded(): boolean {
|
|
169
|
-
return this.registry() !== null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
@Injectable({
|
|
4
|
-
providedIn: 'root',
|
|
5
|
-
})
|
|
6
|
-
export class MarkdownService {
|
|
7
|
-
constructor() {}
|
|
8
|
-
|
|
9
|
-
convert(markdown: string): string {
|
|
10
|
-
if (!markdown) return '';
|
|
11
|
-
|
|
12
|
-
// 1. Escape HTML first to prevent XSS
|
|
13
|
-
let html = this.escapeHtml(markdown);
|
|
14
|
-
|
|
15
|
-
// 2. Process Heads (h1-h3)
|
|
16
|
-
// # Header -> <h1>Header</h1>
|
|
17
|
-
html = html.replace(/^### (.*$)/gim, '<h3>$1</h3>');
|
|
18
|
-
html = html.replace(/^## (.*$)/gim, '<h2>$1</h2>');
|
|
19
|
-
html = html.replace(/^# (.*$)/gim, '<h1>$1</h1>');
|
|
20
|
-
|
|
21
|
-
// 3. Bold (** or __)
|
|
22
|
-
html = html.replace(/\*\*(.*?)\*\*/gim, '<strong>$1</strong>');
|
|
23
|
-
html = html.replace(/__(.*?)__/gim, '<strong>$1</strong>');
|
|
24
|
-
|
|
25
|
-
// 4. Italic (* or _)
|
|
26
|
-
html = html.replace(/\*(.*?)\*/gim, '<em>$1</em>');
|
|
27
|
-
html = html.replace(/_(.*?)_/gim, '<em>$1</em>');
|
|
28
|
-
|
|
29
|
-
// 5. Lists (unordered)
|
|
30
|
-
// Note: This is a simple regex that wraps each list item in <li>.
|
|
31
|
-
// Full list wrapping <ul> needs state awareness, but for simple chat line-by-line:
|
|
32
|
-
html = html.replace(/^\s*-\s+(.*$)/gim, '<li>$1</li>');
|
|
33
|
-
html = html.replace(/^\s*\*\s+(.*$)/gim, '<li>$1</li>');
|
|
34
|
-
|
|
35
|
-
// 6. Lists (ordered)
|
|
36
|
-
html = html.replace(/^\s*\d+\.\s+(.*$)/gim, '<li>$1</li>');
|
|
37
|
-
|
|
38
|
-
// 7. Paragraphs
|
|
39
|
-
// Split by double newline to form paragraphs, but avoid wrapping existing tags
|
|
40
|
-
// This is a naive implementation; for robust parsing, we'd need a token,
|
|
41
|
-
// but for simple chat, we can just replace \n with <br> inside paragraphs.
|
|
42
|
-
|
|
43
|
-
// Simple line break handling
|
|
44
|
-
html = html.replace(/\n/gim, '<br>');
|
|
45
|
-
|
|
46
|
-
// Optional: Wrap loose text in paragraphs if completely robust is needed,
|
|
47
|
-
// but <br> is usually sufficient for chat bubbles.
|
|
48
|
-
|
|
49
|
-
// Wrap adjacent <li>s in <ul> or <ol> is tricky with pure regex on the whole string.
|
|
50
|
-
// Improvement: We can wrap the whole block.
|
|
51
|
-
|
|
52
|
-
// Basic List Wrapping (very simple heuristic)
|
|
53
|
-
// Replace sequences of <li>...</li> with <ul>...</ul> is hard without multiple passes.
|
|
54
|
-
// For now, we will style straight <li>s if they appear, or just accept that they might lack a parent <ul>
|
|
55
|
-
// which browsers often handle okay visually, OR we try to group them.
|
|
56
|
-
|
|
57
|
-
// Let's try to group <li>s
|
|
58
|
-
html = html.replace(/(<li>.*<\/li>(\s*<br>\s*)*)+/gim, '<ul>$&</ul>');
|
|
59
|
-
|
|
60
|
-
// Clean up <br> inside <ul>
|
|
61
|
-
html = html.replace(/<\/li>\s*<br>\s*<li>/gim, '</li><li>');
|
|
62
|
-
html = html.replace(/<ul>\s*<br>/gim, '<ul>');
|
|
63
|
-
html = html.replace(/<br>\s*<\/ul>/gim, '</ul>');
|
|
64
|
-
|
|
65
|
-
return html;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private escapeHtml(text: string): string {
|
|
69
|
-
const div = document.createElement('div');
|
|
70
|
-
div.textContent = text;
|
|
71
|
-
return div.innerHTML;
|
|
72
|
-
}
|
|
73
|
-
}
|