@greatapps/greatagents 0.1.10 → 0.1.12

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.
Files changed (54) hide show
  1. package/package.json +1 -1
  2. package/src/modules/{channels → contacts}/index.js +1 -1
  3. package/src/modules/{tags → contacts}/properties.js +49 -17
  4. package/src/modules/conversations/index.js +1 -1
  5. package/src/modules/conversations/properties.js +35 -80
  6. package/src/modules/objectives/index.js +1 -1
  7. package/src/modules/objectives/properties.js +8 -7
  8. package/src/product.js +4 -24
  9. package/docs/ERD_GAGents_Database.mmd +0 -331
  10. package/scripts/MIGRATION_COMPLETE_DOCUMENTATION.md +0 -672
  11. package/scripts/README.md +0 -165
  12. package/scripts/constraints.sql +0 -585
  13. package/scripts/indexes.sql +0 -661
  14. package/scripts/migrate_v1.sql +0 -1225
  15. package/scripts/tables/001_accounts.sql +0 -51
  16. package/scripts/tables/002_users.sql +0 -69
  17. package/scripts/tables/003_people.sql +0 -70
  18. package/scripts/tables/004_tags.sql +0 -62
  19. package/scripts/tables/005_credentials.sql +0 -79
  20. package/scripts/tables/006_agents.sql +0 -70
  21. package/scripts/tables/007_tools.sql +0 -68
  22. package/scripts/tables/008_channels.sql +0 -75
  23. package/scripts/tables/009_leads.sql +0 -85
  24. package/scripts/tables/010_missions.sql +0 -62
  25. package/scripts/tables/011_objectives.sql +0 -68
  26. package/scripts/tables/012_conversations.sql +0 -80
  27. package/scripts/tables/013_objectives_tools.sql +0 -66
  28. package/scripts/tables/014_messages.sql +0 -78
  29. package/scripts/tables/015_companies.sql +0 -77
  30. package/scripts/tables/016_conversations_tags.sql +0 -64
  31. package/scripts/tables/017_leads_tags.sql +0 -64
  32. package/scripts/triggers.sql +0 -497
  33. package/src/modules/channels/properties.js +0 -150
  34. package/src/modules/companies/index.js +0 -10
  35. package/src/modules/companies/properties.js +0 -168
  36. package/src/modules/conversations_tags/index.js +0 -10
  37. package/src/modules/conversations_tags/properties.js +0 -84
  38. package/src/modules/credentials/index.js +0 -10
  39. package/src/modules/credentials/properties.js +0 -271
  40. package/src/modules/leads/index.js +0 -10
  41. package/src/modules/leads/properties.js +0 -193
  42. package/src/modules/leads_tags/index.js +0 -10
  43. package/src/modules/leads_tags/properties.js +0 -84
  44. package/src/modules/messages/index.js +0 -10
  45. package/src/modules/messages/properties.js +0 -152
  46. package/src/modules/missions/index.js +0 -10
  47. package/src/modules/missions/properties.js +0 -101
  48. package/src/modules/objectives_tools/index.js +0 -10
  49. package/src/modules/objectives_tools/properties.js +0 -109
  50. package/src/modules/people/index.js +0 -10
  51. package/src/modules/people/properties.js +0 -161
  52. package/src/modules/tags/index.js +0 -10
  53. package/src/modules/tools/index.js +0 -10
  54. package/src/modules/tools/properties.js +0 -121
@@ -1,331 +0,0 @@
1
- %%{init: {
2
- 'title': 'GAGents Database - Entity Relationship Diagram',
3
- 'theme': 'base',
4
- 'themeVariables': {
5
- 'primaryColor': '#2E86AB',
6
- 'primaryTextColor': '#000000',
7
- 'primaryBorderColor': '#A23B72',
8
- 'lineColor': '#F18F01',
9
- 'sectionBkgColor': '#A23B72',
10
- 'altSectionBkgColor': '#C73E1D'
11
- }
12
- }}%%
13
-
14
- erDiagram
15
-
16
- accounts {
17
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
18
- VARCHAR(100) name "searchable, maxLength=100"
19
- BOOLEAN deleted "DEFAULT false"
20
- TIMESTAMP datetime_add "filterable, updatable=false"
21
- TIMESTAMP datetime_alt "filterable"
22
- TIMESTAMP datetime_del "filterable"
23
- }
24
-
25
- users {
26
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
27
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
28
- VARCHAR(50) name "searchable, maxLength=50"
29
- VARCHAR last_name "searchable"
30
- VARCHAR email "NOT NULL, searchable, filterable, format=email"
31
- VARCHAR profile "DEFAULT 'collaborator'"
32
- IMAGE photo "types=[png,jpg,jpeg,gif,svg,webp], storage=gapps-r1-storage, 160x160"
33
- BOOLEAN deleted "DEFAULT false"
34
- TIMESTAMP datetime_add "filterable, updatable=false"
35
- TIMESTAMP datetime_alt "filterable"
36
- TIMESTAMP datetime_del "filterable"
37
- }
38
-
39
- people {
40
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
41
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
42
- VARCHAR(255) full_name "searchable, maxLength=255"
43
- VARCHAR(255) first_name "searchable, maxLength=255"
44
- VARCHAR(255) last_name "searchable, maxLength=255"
45
- IMAGE photo "types=[png,jpg,jpeg,gif,svg,webp], storage=gpages, 200x200"
46
- VARCHAR(50) document "searchable, maxLength=50"
47
- DATE birth_date "filterable"
48
- BOOLEAN deleted "DEFAULT false, filterable"
49
- TIMESTAMP datetime_add "filterable, updatable=false"
50
- TIMESTAMP datetime_alt "filterable"
51
- TIMESTAMP datetime_del "filterable"
52
- }
53
-
54
- tags {
55
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
56
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
57
- VARCHAR(255) name "NOT NULL, searchable, filterable, maxLength=255"
58
- VARCHAR color "DEFAULT '#000000', filterable"
59
- BOOLEAN deleted "DEFAULT false, filterable"
60
- TIMESTAMP datetime_add "filterable, updatable=false"
61
- TIMESTAMP datetime_alt "filterable"
62
- TIMESTAMP datetime_del "filterable"
63
- }
64
-
65
- credentials {
66
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
67
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
68
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
69
- VARCHAR provider "NOT NULL, filterable, DEFAULT 'web-chat'"
70
- VARCHAR authType "NOT NULL, filterable, DEFAULT 'none'"
71
- VARCHAR userName
72
- VARCHAR password
73
- VARCHAR apiKey
74
- VARCHAR token
75
- VARCHAR paramName
76
- VARCHAR refreshToken
77
- VARCHAR clientSecret
78
- VARCHAR clientId
79
- VARCHAR sendIn "DEFAULT 'none'"
80
- VARCHAR scheme "DEFAULT 'none'"
81
- VARCHAR prefix
82
- BOOLEAN deleted "DEFAULT false, filterable"
83
- TIMESTAMP datetime_add "filterable, updatable=false"
84
- TIMESTAMP datetime_alt "filterable"
85
- TIMESTAMP datetime_del "filterable"
86
- }
87
-
88
- %% ==========================================
89
- %% AI & AUTOMATION DOMAIN (Domínio de IA)
90
- %% ==========================================
91
-
92
- agents {
93
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
94
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
95
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
96
- IMAGE photo "types=[png,jpg,jpeg,gif,svg,webp], storage=gpages, 200x200"
97
- TEXT prompt
98
- INTEGER delay_typing "DEFAULT 0, filterable"
99
- INTEGER waiting_time "DEFAULT 0, filterable"
100
- BOOLEAN deleted "DEFAULT false, filterable"
101
- TIMESTAMP datetime_add "filterable, updatable=false"
102
- TIMESTAMP datetime_alt "filterable"
103
- TIMESTAMP datetime_del "filterable"
104
- }
105
-
106
- tools {
107
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
108
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
109
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
110
- VARCHAR type "filterable, DEFAULT 'mcp'"
111
- VARCHAR(1000) description "searchable, filterable, maxLength=1000"
112
- INTEGER id_credential FK "filterable, index, optional"
113
- BOOLEAN deleted "DEFAULT false, filterable"
114
- TIMESTAMP datetime_add "filterable, updatable=false"
115
- TIMESTAMP datetime_alt "filterable"
116
- TIMESTAMP datetime_del "filterable"
117
- }
118
-
119
- missions {
120
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
121
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
122
- INTEGER id_agent FK "NOT NULL, filterable, index, reference=agents.id"
123
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
124
- TEXT prompt
125
- BOOLEAN deleted "DEFAULT false, filterable"
126
- TIMESTAMP datetime_add "filterable, updatable=false"
127
- TIMESTAMP datetime_alt "filterable"
128
- TIMESTAMP datetime_del "filterable"
129
- }
130
-
131
- objectives {
132
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
133
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
134
- INTEGER id_mission FK "NOT NULL, filterable, index, reference=missions.id"
135
- INTEGER order "NOT NULL, filterable, DEFAULT 0"
136
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
137
- TEXT prompt
138
- BOOLEAN deleted "DEFAULT false, filterable"
139
- TIMESTAMP datetime_add "filterable, updatable=false"
140
- TIMESTAMP datetime_alt "filterable"
141
- TIMESTAMP datetime_del "filterable"
142
- }
143
-
144
- objectives_tools {
145
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
146
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.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
- TEXT instructions
150
- BOOLEAN wait "DEFAULT false"
151
- BOOLEAN deleted "DEFAULT false, filterable"
152
- TIMESTAMP datetime_add "filterable, updatable=false"
153
- TIMESTAMP datetime_alt "filterable"
154
- TIMESTAMP datetime_del "filterable"
155
- }
156
-
157
- %% ==========================================
158
- %% COMMUNICATION DOMAIN (Domínio de Comunicação)
159
- %% ==========================================
160
-
161
- channels {
162
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
163
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
164
- VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
165
- VARCHAR provider "NOT NULL, filterable, DEFAULT 'web-chat'"
166
- VARCHAR url
167
- BOOLEAN active "DEFAULT true, filterable"
168
- INTEGER id_credential FK "optional, reference=credentials.id"
169
- VARCHAR(255) handle "filterable, maxLength=255"
170
- BOOLEAN deleted "DEFAULT false, filterable"
171
- TIMESTAMP datetime_add "filterable, updatable=false"
172
- TIMESTAMP datetime_alt "filterable"
173
- TIMESTAMP datetime_del "filterable"
174
- }
175
-
176
- conversations {
177
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
178
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.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
- INTEGER id_assignee FK "filterable, index, reference=users.id"
182
- TIMESTAMP last_message_at "filterable, optional"
183
- INTEGER id_last_message FK "filterable, index, optional, reference=messages.id"
184
- BOOLEAN stop_ai "DEFAULT false, filterable"
185
- VARCHAR status "filterable, DEFAULT 'open'"
186
- BOOLEAN deleted "DEFAULT false, filterable"
187
- TIMESTAMP datetime_add "filterable, updatable=false"
188
- TIMESTAMP datetime_alt "filterable"
189
- TIMESTAMP datetime_del "filterable"
190
- }
191
-
192
- messages {
193
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
194
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
195
- INTEGER id_conversation FK "NOT NULL, filterable, index, reference=conversations.id"
196
- INTEGER id_agent FK "filterable, index, optional, reference=agents.id"
197
- INTEGER id_user FK "filterable, index, optional, reference=users.id"
198
- VARCHAR direction "DEFAULT 'in', filterable"
199
- VARCHAR role "DEFAULT 'user', filterable"
200
- TEXT content "NOT NULL"
201
- BOOLEAN deleted "DEFAULT false, filterable"
202
- TIMESTAMP datetime_add "filterable, updatable=false"
203
- TIMESTAMP datetime_alt "filterable"
204
- TIMESTAMP datetime_del "filterable"
205
- }
206
-
207
- %% ==========================================
208
- %% CRM & ORGANIZATION DOMAIN (Domínio CRM)
209
- %% ==========================================
210
-
211
- leads {
212
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
213
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
214
- INTEGER id_person FK "NOT NULL, filterable, reference=people.id"
215
- VARCHAR(255) email "searchable, maxLength=255, pattern=email"
216
- VARCHAR(20) phone "searchable, maxLength=20, pattern=phone"
217
- INTEGER id_user_owner FK "filterable, index, reference=users.id"
218
- INTEGER id_current_agent FK "filterable, index, reference=agents.id"
219
- INTEGER id_current_mission FK "filterable, index, reference=missions.id"
220
- INTEGER id_current_objective FK "filterable, index, reference=objectives.id"
221
- TEXT notes "searchable"
222
- BOOLEAN deleted "DEFAULT false, filterable"
223
- TIMESTAMP datetime_add "filterable, updatable=false"
224
- TIMESTAMP datetime_alt "filterable"
225
- TIMESTAMP datetime_del "filterable"
226
- }
227
-
228
- companies {
229
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
230
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
231
- INTEGER id_lead FK "NOT NULL, filterable, reference=leads.id"
232
- VARCHAR(255) name "searchable, maxLength=255"
233
- VARCHAR(255) website "searchable, maxLength=255, pattern=url"
234
- VARCHAR(50) document "searchable, maxLength=50"
235
- TEXT notes "searchable"
236
- VARCHAR industry "searchable"
237
- VARCHAR size "searchable"
238
- BOOLEAN deleted "DEFAULT false, filterable"
239
- TIMESTAMP datetime_add "filterable, updatable=false"
240
- TIMESTAMP datetime_alt "filterable"
241
- TIMESTAMP datetime_del "filterable"
242
- }
243
-
244
- conversations_tags {
245
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
246
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
247
- INTEGER id_conversation FK "filterable, index, reference=conversations.id"
248
- INTEGER id_tag FK "filterable, index, reference=tags.id"
249
- BOOLEAN deleted "DEFAULT false, filterable"
250
- TIMESTAMP datetime_add "filterable, updatable=false"
251
- TIMESTAMP datetime_alt "filterable"
252
- TIMESTAMP datetime_del "filterable"
253
- }
254
-
255
- leads_tags {
256
- SERIAL id PK "AUTO_INCREMENT, UNIQUE, INDEX"
257
- INTEGER id_account FK "NOT NULL, filterable, reference=accounts.id"
258
- INTEGER id_lead FK "filterable, index, reference=leads.id"
259
- INTEGER id_tag FK "filterable, index, reference=tags.id"
260
- BOOLEAN deleted "DEFAULT false, filterable"
261
- TIMESTAMP datetime_add "filterable, updatable=false"
262
- TIMESTAMP datetime_alt "filterable"
263
- TIMESTAMP datetime_del "filterable"
264
- }
265
-
266
- %% ==========================================
267
- %% RELACIONAMENTOS 1:N (Um para Muitos)
268
- %% ==========================================
269
-
270
- %% ACCOUNTS como entidade central (Multi-tenancy)
271
- accounts ||--o{ users : "Multi-tenant"
272
- accounts ||--o{ people : "Multi-tenant"
273
- accounts ||--o{ tags : "Multi-tenant"
274
- accounts ||--o{ credentials : "Multi-tenant"
275
- accounts ||--o{ agents : "Multi-tenant"
276
- accounts ||--o{ tools : "Multi-tenant"
277
- accounts ||--o{ missions : "Multi-tenant"
278
- accounts ||--o{ objectives : "Multi-tenant"
279
- accounts ||--o{ objectives_tools : "Multi-tenant"
280
- accounts ||--o{ channels : "Multi-tenant"
281
- accounts ||--o{ conversations : "Multi-tenant"
282
- accounts ||--o{ messages : "Multi-tenant"
283
- accounts ||--o{ leads : "Multi-tenant"
284
- accounts ||--o{ companies : "Multi-tenant"
285
- accounts ||--o{ conversations_tags : "Multi-tenant"
286
- accounts ||--o{ leads_tags : "Multi-tenant"
287
-
288
- %% RELACIONAMENTOS PRINCIPAIS
289
- people ||--o{ leads : "Person-Lead"
290
- leads ||--o{ companies : "Lead-Company"
291
- leads ||--o{ conversations : "Lead-Conversation"
292
-
293
- %% AI & AUTOMATION RELATIONSHIPS
294
- agents ||--o{ missions : "Agent-Mission"
295
- missions ||--o{ objectives : "Mission-Objective"
296
- objectives ||--o{ objectives_tools : "Objective-ObjectiveTool"
297
- tools ||--o{ objectives_tools : "Tool-ObjectiveTool"
298
-
299
- %% COMMUNICATION RELATIONSHIPS
300
- channels ||--o{ conversations : "Channel-Conversation"
301
- conversations ||--o{ messages : "Conversation-Message"
302
-
303
- %% USER ASSIGNMENTS
304
- users ||--o{ conversations : "User-ConversationAssignee"
305
- users ||--o{ leads : "User-LeadOwner"
306
- users ||--o{ messages : "User-Message"
307
-
308
- %% AGENT RELATIONSHIPS
309
- agents ||--o{ messages : "Agent-Message"
310
- agents ||--o{ leads : "Agent-CurrentAgent"
311
-
312
- %% MISSION & OBJECTIVE CURRENT STATES
313
- missions ||--o{ leads : "Mission-CurrentMission"
314
- objectives ||--o{ leads : "Objective-CurrentObjective"
315
-
316
- %% CREDENTIAL RELATIONSHIPS
317
- credentials ||--o{ tools : "Credential-Tool"
318
- credentials ||--o{ channels : "Credential-Channel"
319
-
320
- %% TAG RELATIONSHIPS
321
- tags ||--o{ conversations_tags : "Tag-ConversationTag"
322
- tags ||--o{ leads_tags : "Tag-LeadTag"
323
- conversations ||--o{ conversations_tags : "Conversation-ConversationTag"
324
- leads ||--o{ leads_tags : "Lead-LeadTag"
325
-
326
- %% ==========================================
327
- %% RELACIONAMENTO CÍCLICO ESPECIAL
328
- %% ==========================================
329
-
330
- %% CYCLIC REFERENCE: conversations ↔ messages
331
- conversations ||--o| messages : "LastMessage"