@greatapps/greatagents 0.1.7 → 0.1.9
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/docs/ERD_GAGents_Database.mmd +5 -7
- package/package.json +1 -1
- package/scripts/indexes.sql +0 -1
- package/scripts/migrate_v1.sql +9 -11
- package/scripts/tables/012_conversations.sql +4 -8
- package/scripts/tables/013_objectives_tools.sql +2 -2
- package/scripts/tables/014_messages.sql +1 -1
- package/scripts/tables/016_conversations_tags.sql +2 -2
- package/scripts/tables/017_leads_tags.sql +2 -2
- package/src/modules/conversations/properties.js +0 -19
|
@@ -144,8 +144,8 @@ erDiagram
|
|
|
144
144
|
objectives_tools {
|
|
145
145
|
SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
|
|
146
146
|
INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
|
|
147
|
-
INTEGER id_objective FK "filterable, index, reference=objectives.id"
|
|
148
|
-
INTEGER id_tool FK "filterable, index, reference=tools.id"
|
|
147
|
+
INTEGER id_objective FK "NOT NULL, filterable, index, reference=objectives.id"
|
|
148
|
+
INTEGER id_tool FK "NOT NULL, filterable, index, reference=tools.id"
|
|
149
149
|
TEXT instructions
|
|
150
150
|
BOOLEAN wait "DEFAULT false"
|
|
151
151
|
BOOLEAN deleted "DEFAULT false, filterable"
|
|
@@ -176,10 +176,9 @@ erDiagram
|
|
|
176
176
|
conversations {
|
|
177
177
|
SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
|
|
178
178
|
INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
|
|
179
|
-
INTEGER id_lead FK "filterable, index, reference=leads.id"
|
|
180
|
-
INTEGER id_channel FK "filterable, index, reference=channels.id"
|
|
179
|
+
INTEGER id_lead FK "NOT NULL, filterable, index, reference=leads.id"
|
|
180
|
+
INTEGER id_channel FK "NOT NULL, filterable, index, reference=channels.id"
|
|
181
181
|
INTEGER id_assignee FK "filterable, index, reference=users.id"
|
|
182
|
-
INTEGER id_last_agent FK "filterable, index, optional, reference=agents.id"
|
|
183
182
|
TIMESTAMP last_message_at "filterable, optional"
|
|
184
183
|
INTEGER id_last_message FK "filterable, index, optional, reference=messages.id"
|
|
185
184
|
BOOLEAN stop_ai "DEFAULT false, filterable"
|
|
@@ -193,7 +192,7 @@ erDiagram
|
|
|
193
192
|
messages {
|
|
194
193
|
SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
|
|
195
194
|
INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
|
|
196
|
-
INTEGER id_conversation FK "filterable, index, reference=conversations.id"
|
|
195
|
+
INTEGER id_conversation FK "NOT NULL, filterable, index, reference=conversations.id"
|
|
197
196
|
INTEGER id_agent FK "filterable, index, optional, reference=agents.id"
|
|
198
197
|
INTEGER id_user FK "filterable, index, optional, reference=users.id"
|
|
199
198
|
VARCHAR direction "DEFAULT 'in', filterable"
|
|
@@ -307,7 +306,6 @@ erDiagram
|
|
|
307
306
|
users ||--o{ messages : "User-Message"
|
|
308
307
|
|
|
309
308
|
%% AGENT RELATIONSHIPS
|
|
310
|
-
agents ||--o{ conversations : "Agent-LastAgent"
|
|
311
309
|
agents ||--o{ messages : "Agent-Message"
|
|
312
310
|
agents ||--o{ leads : "Agent-CurrentAgent"
|
|
313
311
|
|
package/package.json
CHANGED
package/scripts/indexes.sql
CHANGED
|
@@ -394,7 +394,6 @@ BEGIN
|
|
|
394
394
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_lead ON conversations(id_lead);
|
|
395
395
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_channel ON conversations(id_channel);
|
|
396
396
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_assignee ON conversations(id_assignee);
|
|
397
|
-
CREATE INDEX IF NOT EXISTS idx_conversations_id_last_agent ON conversations(id_last_agent);
|
|
398
397
|
CREATE INDEX IF NOT EXISTS idx_conversations_last_message_at ON conversations(last_message_at);
|
|
399
398
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_last_message ON conversations(id_last_message);
|
|
400
399
|
CREATE INDEX IF NOT EXISTS idx_conversations_stop_ai ON conversations(stop_ai);
|
package/scripts/migrate_v1.sql
CHANGED
|
@@ -423,10 +423,9 @@ BEGIN
|
|
|
423
423
|
datetime_alt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
424
424
|
datetime_del TIMESTAMP WITH TIME ZONE NULL,
|
|
425
425
|
id_account INTEGER NOT NULL,
|
|
426
|
-
id_lead INTEGER,
|
|
427
|
-
id_channel INTEGER,
|
|
426
|
+
id_lead INTEGER NOT NULL,
|
|
427
|
+
id_channel INTEGER NOT NULL,
|
|
428
428
|
id_assignee INTEGER,
|
|
429
|
-
id_last_agent INTEGER,
|
|
430
429
|
last_message_at TIMESTAMP WITH TIME ZONE,
|
|
431
430
|
id_last_message INTEGER,
|
|
432
431
|
stop_ai BOOLEAN DEFAULT FALSE,
|
|
@@ -435,7 +434,6 @@ BEGIN
|
|
|
435
434
|
FOREIGN KEY (id_lead) REFERENCES leads(id) ON DELETE SET NULL,
|
|
436
435
|
FOREIGN KEY (id_channel) REFERENCES channels(id) ON DELETE SET NULL,
|
|
437
436
|
FOREIGN KEY (id_assignee) REFERENCES users(id) ON DELETE SET NULL,
|
|
438
|
-
FOREIGN KEY (id_last_agent) REFERENCES agents(id) ON DELETE SET NULL,
|
|
439
437
|
CONSTRAINT conversations_status_valid CHECK (status IN ('open', 'pending', 'closed'))
|
|
440
438
|
);
|
|
441
439
|
COMMENT ON TABLE conversations IS 'Tabela de conversas do sistema';
|
|
@@ -449,8 +447,8 @@ BEGIN
|
|
|
449
447
|
datetime_alt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
450
448
|
datetime_del TIMESTAMP WITH TIME ZONE NULL,
|
|
451
449
|
id_account INTEGER NOT NULL,
|
|
452
|
-
id_objective INTEGER,
|
|
453
|
-
id_tool INTEGER,
|
|
450
|
+
id_objective INTEGER NOT NULL,
|
|
451
|
+
id_tool INTEGER NOT NULL,
|
|
454
452
|
instructions TEXT,
|
|
455
453
|
wait BOOLEAN DEFAULT FALSE,
|
|
456
454
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
@@ -468,7 +466,7 @@ BEGIN
|
|
|
468
466
|
datetime_alt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
469
467
|
datetime_del TIMESTAMP WITH TIME ZONE NULL,
|
|
470
468
|
id_account INTEGER NOT NULL,
|
|
471
|
-
id_conversation INTEGER,
|
|
469
|
+
id_conversation INTEGER NOT NULL,
|
|
472
470
|
id_agent INTEGER,
|
|
473
471
|
id_user INTEGER,
|
|
474
472
|
direction VARCHAR(10) DEFAULT 'in',
|
|
@@ -514,8 +512,8 @@ BEGIN
|
|
|
514
512
|
datetime_alt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
515
513
|
datetime_del TIMESTAMP WITH TIME ZONE NULL,
|
|
516
514
|
id_account INTEGER NOT NULL,
|
|
517
|
-
id_conversation INTEGER,
|
|
518
|
-
id_tag INTEGER,
|
|
515
|
+
id_conversation INTEGER NOT NULL,
|
|
516
|
+
id_tag INTEGER NOT NULL,
|
|
519
517
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
520
518
|
FOREIGN KEY (id_conversation) REFERENCES conversations(id) ON DELETE CASCADE,
|
|
521
519
|
FOREIGN KEY (id_tag) REFERENCES tags(id) ON DELETE CASCADE
|
|
@@ -531,8 +529,8 @@ BEGIN
|
|
|
531
529
|
datetime_alt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
532
530
|
datetime_del TIMESTAMP WITH TIME ZONE NULL,
|
|
533
531
|
id_account INTEGER NOT NULL,
|
|
534
|
-
id_lead INTEGER,
|
|
535
|
-
id_tag INTEGER,
|
|
532
|
+
id_lead INTEGER NOT NULL,
|
|
533
|
+
id_tag INTEGER NOT NULL,
|
|
536
534
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
537
535
|
FOREIGN KEY (id_lead) REFERENCES leads(id) ON DELETE CASCADE,
|
|
538
536
|
FOREIGN KEY (id_tag) REFERENCES tags(id) ON DELETE CASCADE
|
|
@@ -29,10 +29,9 @@ CREATE TABLE IF NOT EXISTS conversations (
|
|
|
29
29
|
|
|
30
30
|
-- Campos específicos da tabela conversations
|
|
31
31
|
id_account INTEGER NOT NULL,
|
|
32
|
-
id_lead INTEGER
|
|
33
|
-
id_channel INTEGER
|
|
32
|
+
id_lead INTEGER NOT NULL,
|
|
33
|
+
id_channel INTEGER NOT NULL,
|
|
34
34
|
id_assignee INTEGER, -- opcional (usuário atribuído)
|
|
35
|
-
id_last_agent INTEGER, -- opcional
|
|
36
35
|
last_message_at TIMESTAMP WITH TIME ZONE, -- opcional
|
|
37
36
|
id_last_message INTEGER, -- IMPORTANTE: SEM FK - referência cíclica será adicionada em constraints.sql
|
|
38
37
|
stop_ai BOOLEAN DEFAULT FALSE, -- default: false
|
|
@@ -40,10 +39,9 @@ CREATE TABLE IF NOT EXISTS conversations (
|
|
|
40
39
|
|
|
41
40
|
-- Foreign keys (EXCETO id_last_message devido à referência cíclica)
|
|
42
41
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
43
|
-
FOREIGN KEY (id_lead) REFERENCES leads(id) ON DELETE
|
|
44
|
-
FOREIGN KEY (id_channel) REFERENCES channels(id) ON DELETE
|
|
42
|
+
FOREIGN KEY (id_lead) REFERENCES leads(id) ON DELETE CASCADE,
|
|
43
|
+
FOREIGN KEY (id_channel) REFERENCES channels(id) ON DELETE CASCADE,
|
|
45
44
|
FOREIGN KEY (id_assignee) REFERENCES users(id) ON DELETE SET NULL,
|
|
46
|
-
FOREIGN KEY (id_last_agent) REFERENCES agents(id) ON DELETE SET NULL,
|
|
47
45
|
|
|
48
46
|
-- Constraints
|
|
49
47
|
CONSTRAINT conversations_status_valid CHECK (status IN ('open', 'pending', 'closed'))
|
|
@@ -54,7 +52,6 @@ CREATE INDEX IF NOT EXISTS idx_conversations_id_account ON conversations(id_acco
|
|
|
54
52
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_lead ON conversations(id_lead);
|
|
55
53
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_channel ON conversations(id_channel);
|
|
56
54
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_assignee ON conversations(id_assignee);
|
|
57
|
-
CREATE INDEX IF NOT EXISTS idx_conversations_id_last_agent ON conversations(id_last_agent);
|
|
58
55
|
CREATE INDEX IF NOT EXISTS idx_conversations_last_message_at ON conversations(last_message_at);
|
|
59
56
|
CREATE INDEX IF NOT EXISTS idx_conversations_id_last_message ON conversations(id_last_message);
|
|
60
57
|
CREATE INDEX IF NOT EXISTS idx_conversations_stop_ai ON conversations(stop_ai);
|
|
@@ -67,7 +64,6 @@ COMMENT ON COLUMN conversations.id_account IS 'Referência à conta (FK)';
|
|
|
67
64
|
COMMENT ON COLUMN conversations.id_lead IS 'Referência ao lead (FK, opcional)';
|
|
68
65
|
COMMENT ON COLUMN conversations.id_channel IS 'Referência ao canal (FK, opcional)';
|
|
69
66
|
COMMENT ON COLUMN conversations.id_assignee IS 'Usuário atribuído à conversa (FK, opcional)';
|
|
70
|
-
COMMENT ON COLUMN conversations.id_last_agent IS 'Último agente da conversa (FK, opcional)';
|
|
71
67
|
COMMENT ON COLUMN conversations.last_message_at IS 'Data e hora da última mensagem';
|
|
72
68
|
COMMENT ON COLUMN conversations.id_last_message IS 'Referência à última mensagem (sem FK devido a referência cíclica)';
|
|
73
69
|
COMMENT ON COLUMN conversations.stop_ai IS 'Flag para parar processamento de I.A.';
|
|
@@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS objectives_tools (
|
|
|
29
29
|
|
|
30
30
|
-- Campos específicos da tabela objectives_tools
|
|
31
31
|
id_account INTEGER NOT NULL,
|
|
32
|
-
id_objective INTEGER
|
|
33
|
-
id_tool INTEGER
|
|
32
|
+
id_objective INTEGER NOT NULL,
|
|
33
|
+
id_tool INTEGER NOT NULL,
|
|
34
34
|
instructions TEXT, -- instruções de uso da ferramenta
|
|
35
35
|
wait BOOLEAN DEFAULT FALSE, -- default: false - aguardar resposta?
|
|
36
36
|
|
|
@@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS messages (
|
|
|
29
29
|
|
|
30
30
|
-- Campos específicos da tabela messages
|
|
31
31
|
id_account INTEGER NOT NULL,
|
|
32
|
-
id_conversation INTEGER
|
|
32
|
+
id_conversation INTEGER NOT NULL,
|
|
33
33
|
id_agent INTEGER, -- opcional
|
|
34
34
|
id_user INTEGER, -- opcional
|
|
35
35
|
direction VARCHAR(10) DEFAULT 'in', -- default: "in"
|
|
@@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS conversations_tags (
|
|
|
29
29
|
|
|
30
30
|
-- Campos específicos da tabela conversations_tags
|
|
31
31
|
id_account INTEGER NOT NULL,
|
|
32
|
-
id_conversation INTEGER
|
|
33
|
-
id_tag INTEGER
|
|
32
|
+
id_conversation INTEGER NOT NULL,
|
|
33
|
+
id_tag INTEGER NOT NULL,
|
|
34
34
|
|
|
35
35
|
-- Foreign keys
|
|
36
36
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
@@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS leads_tags (
|
|
|
29
29
|
|
|
30
30
|
-- Campos específicos da tabela leads_tags
|
|
31
31
|
id_account INTEGER NOT NULL,
|
|
32
|
-
id_lead INTEGER
|
|
33
|
-
id_tag INTEGER
|
|
32
|
+
id_lead INTEGER NOT NULL,
|
|
33
|
+
id_tag INTEGER NOT NULL,
|
|
34
34
|
|
|
35
35
|
-- Foreign keys
|
|
36
36
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
@@ -99,25 +99,6 @@ export const properties = {
|
|
|
99
99
|
component: "select"
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
|
-
id_last_agent: {
|
|
103
|
-
type: "number",
|
|
104
|
-
filterable: true,
|
|
105
|
-
index: true,
|
|
106
|
-
required: false,
|
|
107
|
-
reference: {
|
|
108
|
-
module: "agents",
|
|
109
|
-
label: "title",
|
|
110
|
-
value: "id",
|
|
111
|
-
disabled: true
|
|
112
|
-
},
|
|
113
|
-
interface: {
|
|
114
|
-
label: {
|
|
115
|
-
"pt-br": "Último Agente",
|
|
116
|
-
"en": "Last Agent"
|
|
117
|
-
},
|
|
118
|
-
component: "number"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
102
|
last_message_at: {
|
|
122
103
|
type: "date",
|
|
123
104
|
filterable: true,
|