@senior-gestao-relacionamento/angular-components 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/chatbot/chatbot.component.mjs +198 -0
- package/esm2022/lib/components/chatbot/pipes/markdown.pipe.mjs +48 -0
- package/esm2022/lib/components/chatbot/services/chatbot.service.mjs +30 -0
- package/esm2022/lib/i18n/en-US.json +10 -1
- package/esm2022/lib/i18n/es-ES.json +10 -1
- package/esm2022/lib/i18n/pt-BR.json +10 -1
- package/esm2022/public-api.mjs +3 -1
- package/fesm2022/senior-gestao-relacionamento-angular-components.mjs +303 -16
- package/fesm2022/senior-gestao-relacionamento-angular-components.mjs.map +1 -1
- package/lib/components/chatbot/chatbot.component.d.ts +49 -0
- package/lib/components/chatbot/pipes/markdown.pipe.d.ts +23 -0
- package/lib/components/chatbot/services/chatbot.service.d.ts +17 -0
- package/package.json +4 -2
- package/public-api.d.ts +2 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export interface ChatbotMessage {
|
|
4
|
+
role: 'user' | 'assistant';
|
|
5
|
+
content: string;
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
responseTime?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Chatbot global do CRM.
|
|
11
|
+
*
|
|
12
|
+
* Standalone, plug-and-play: basta declarar `<s-chatbot></s-chatbot>` no
|
|
13
|
+
* `app.component.html` da aplicação consumidora. Toda a integração
|
|
14
|
+
* (WebSocket de respostas, REST de envio, traduções e renderização de
|
|
15
|
+
* Markdown) está encapsulada na biblioteca.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ChatbotComponent implements OnInit, OnDestroy {
|
|
18
|
+
private readonly chatMessagesContainer;
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
userInput: string;
|
|
21
|
+
sendingMessage: boolean;
|
|
22
|
+
chatMessages: ChatbotMessage[];
|
|
23
|
+
chatId: string | null;
|
|
24
|
+
unreadCount: number;
|
|
25
|
+
typingPhraseKey: string;
|
|
26
|
+
private wsSubscription;
|
|
27
|
+
private typingPhraseTimer;
|
|
28
|
+
private typingPhraseIndex;
|
|
29
|
+
private readonly wsConfig;
|
|
30
|
+
private readonly webSocketService;
|
|
31
|
+
private readonly ngZone;
|
|
32
|
+
private readonly chatbotService;
|
|
33
|
+
private readonly translationService;
|
|
34
|
+
ngOnInit(): void;
|
|
35
|
+
ngOnDestroy(): void;
|
|
36
|
+
toggleChat(): void;
|
|
37
|
+
sendMessage(): void;
|
|
38
|
+
onChatKeydown(event: KeyboardEvent): void;
|
|
39
|
+
private subscribeToWebSocket;
|
|
40
|
+
private scrollChatToBottom;
|
|
41
|
+
/**
|
|
42
|
+
* Starts cycling through the typing phrases. Always begins from the first
|
|
43
|
+
* key so the user sees the same friendly opening every time.
|
|
44
|
+
*/
|
|
45
|
+
private startTypingPhraseRotation;
|
|
46
|
+
private stopTypingPhraseRotation;
|
|
47
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChatbotComponent, never>;
|
|
48
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ChatbotComponent, "s-chatbot", never, {}, {}, never, never, true, never>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Pipe interno do chatbot para renderizar Markdown como HTML seguro.
|
|
6
|
+
*
|
|
7
|
+
* Fluxo de segurança:
|
|
8
|
+
* 1. `marked.parse` converte Markdown em HTML (sem JS executável por padrão).
|
|
9
|
+
* 2. `DOMPurify.sanitize` remove qualquer tag/atributo potencialmente
|
|
10
|
+
* malicioso (script, on*, javascript:..., etc.).
|
|
11
|
+
* 3. `bypassSecurityTrustHtml` libera o HTML já sanitizado para o
|
|
12
|
+
* `[innerHTML]` sem que o Angular faça uma segunda sanitização que
|
|
13
|
+
* removeria estilos e classes legítimas do markdown.
|
|
14
|
+
*
|
|
15
|
+
* Não exportado no public-api: uso restrito ao componente de chatbot.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ChatbotMarkdownPipe implements PipeTransform {
|
|
18
|
+
private readonly sanitizer;
|
|
19
|
+
constructor(sanitizer: DomSanitizer);
|
|
20
|
+
transform(value: string): SafeHtml;
|
|
21
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChatbotMarkdownPipe, never>;
|
|
22
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<ChatbotMarkdownPipe, "sChatbotMarkdown", true>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Serviço de integração com o backend do chatbot.
|
|
6
|
+
*
|
|
7
|
+
* Endpoint fixo: `crmx/chatbot/signals/chat` (compartilhado por todos os
|
|
8
|
+
* frontends do CRM).
|
|
9
|
+
*/
|
|
10
|
+
export declare class ChatbotService {
|
|
11
|
+
private readonly http;
|
|
12
|
+
private readonly signalsUrl;
|
|
13
|
+
constructor(http: HttpClient);
|
|
14
|
+
chat(message: string, chatId?: string): Observable<void>;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ChatbotService, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ChatbotService>;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senior-gestao-relacionamento/angular-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Biblioteca de componentes reutilizáveis para aplicações Angular do CRM Senior Sistemas",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"@seniorsistemas/components-ai": ">=2.1.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"tslib": "^2.3.0"
|
|
33
|
+
"tslib": "^2.3.0",
|
|
34
|
+
"marked": "^18.0.2",
|
|
35
|
+
"dompurify": "^2.5.9"
|
|
34
36
|
},
|
|
35
37
|
"sideEffects": false,
|
|
36
38
|
"module": "fesm2022/senior-gestao-relacionamento-angular-components.mjs",
|
package/public-api.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { StorageService } from './lib/services/storage/storage.service';
|
|
|
3
3
|
export { CurrentCollaboratorService } from './lib/services/current-collaborator/current-collaborator.service';
|
|
4
4
|
export { provideAngularComponentsTranslations } from './lib/config/provide-angular-components-translations';
|
|
5
5
|
export type { Collaborator, CollaboratorLeader, CollaboratorBranch, Branch, Company, JobTitle } from './lib/services/current-collaborator/models/collaborator.model';
|
|
6
|
+
export { ChatbotComponent } from './lib/components/chatbot/chatbot.component';
|
|
7
|
+
export type { ChatbotMessage } from './lib/components/chatbot/chatbot.component';
|
|
6
8
|
export { ScheduleFormComponent } from './lib/components/schedule/schedule-form/schedule-form.component';
|
|
7
9
|
export { ScheduleDetailComponent } from './lib/components/schedule/schedule-detail/schedule-detail.component';
|
|
8
10
|
export { ScheduleService } from './lib/components/schedule/services/schedule.service';
|