@greatapps/greatagents 0.1.21 → 0.1.22
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/CLAUDE.md +97 -0
- package/package.json +2 -2
- package/src/product.js +0 -4
- package/src/modules/accounts/index.js +0 -11
- package/src/modules/accounts/properties.js +0 -46
- package/src/modules/users/index.js +0 -11
- package/src/modules/users/properties.js +0 -156
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# gagents-schemas — Agente de Schemas
|
|
2
|
+
|
|
3
|
+
Pacote NPM `@greatapps/greatagents`: definições de schema compartilhadas por todos os serviços.
|
|
4
|
+
|
|
5
|
+
## Comandos
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Após alterar schemas, atualizar version e publicar:
|
|
9
|
+
npm version patch # ou minor/major
|
|
10
|
+
npm publish # Publica no registry
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
**IMPORTANTE**: Após publicar, atualizar a versão em `gagents-r1-api-postgresql/package.json` e `gagents-r3-api/package.json`, rodar `npm install` em ambos, e fazer deploy.
|
|
14
|
+
|
|
15
|
+
## Estrutura
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
src/
|
|
19
|
+
├── product.js # Export principal (importado como @greatapps/greatagents)
|
|
20
|
+
├── shared/
|
|
21
|
+
│ ├── parameters.js # Params de rota (language, id_wl, id_account)
|
|
22
|
+
│ └── responses.js # Respostas HTTP padrão (400, 401, 403, 404, 500)
|
|
23
|
+
└── modules/
|
|
24
|
+
├── accounts/ # params: [] (global)
|
|
25
|
+
├── users/ # params: ["id_account"]
|
|
26
|
+
├── agents/ # params: ["id_account"]
|
|
27
|
+
├── objectives/ # params: ["id_account", "id_agent"]
|
|
28
|
+
├── contacts/ # params: ["id_account"]
|
|
29
|
+
├── conversations/ # params: ["id_account"]
|
|
30
|
+
├── prompt_versions/ # params: ["id_account", "id_agent"]
|
|
31
|
+
├── tools/ # params: ["id_account"]
|
|
32
|
+
├── agent_tools/ # params: ["id_account", "id_agent"]
|
|
33
|
+
├── tool_credentials/ # params: ["id_account"]
|
|
34
|
+
└── contact_users/ # params: ["id_account"]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Cada módulo tem `index.js` (definição) e `properties.js` (propriedades/colunas).
|
|
38
|
+
|
|
39
|
+
## Padrão de Módulo
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
// modules/agents/index.js
|
|
43
|
+
export default {
|
|
44
|
+
product: "greatagents",
|
|
45
|
+
name: "agents", // Nome da tabela no banco
|
|
46
|
+
cache: { ttlView: 30, ttlList: 0 },
|
|
47
|
+
params: ["id_account"], // Params obrigatórios em WHERE (multi-tenancy)
|
|
48
|
+
properties: properties,
|
|
49
|
+
routes: {}
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Padrão de Propriedade
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// modules/agents/properties.js
|
|
57
|
+
title: {
|
|
58
|
+
type: "string", // string | number | boolean | date | image
|
|
59
|
+
required: true, // Obrigatório em INSERT
|
|
60
|
+
filterable: true, // Pode ser usado em WHERE
|
|
61
|
+
searchable: true, // Full-text search
|
|
62
|
+
updatable: true, // Pode ser modificado (false = imutável)
|
|
63
|
+
unique: false, // Constraint unique no banco
|
|
64
|
+
validation: { maxLength: 255 },
|
|
65
|
+
interface: { // Metadata para UI
|
|
66
|
+
label: { "pt-br": "Título", "en": "Title" },
|
|
67
|
+
component: "string",
|
|
68
|
+
placeholder: { "pt-br": "..." }
|
|
69
|
+
},
|
|
70
|
+
reference: { // FK para outro módulo
|
|
71
|
+
module: "accounts",
|
|
72
|
+
label: "name",
|
|
73
|
+
value: "id"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Propriedades de sistema (presentes em todos os módulos)
|
|
79
|
+
- `id` — autoIncrement, unique, index
|
|
80
|
+
- `deleted` — boolean (schema), **INTEGER no banco** (ver regra abaixo)
|
|
81
|
+
- `datetime_add` — date, updatable: false
|
|
82
|
+
- `datetime_alt` — date, updatable: true
|
|
83
|
+
- `datetime_del` — date
|
|
84
|
+
|
|
85
|
+
## `params` Array — Multi-Tenancy
|
|
86
|
+
|
|
87
|
+
O array `params` define quais campos são obrigatórios em WHERE clauses:
|
|
88
|
+
- `params: ["id_account"]` → buildWhere.js exige `id_account` em toda query
|
|
89
|
+
- `params: ["id_account", "id_agent"]` → exige ambos (hierárquico)
|
|
90
|
+
- `params: []` → sem restrição (ex: accounts)
|
|
91
|
+
|
|
92
|
+
## Regras Críticas
|
|
93
|
+
|
|
94
|
+
- **Coluna `deleted`**: Schema define como `boolean`, mas no PostgreSQL DEVE ser INTEGER (buildWhere.js appends `AND deleted = 0`)
|
|
95
|
+
- **`contacts.identifier`**: Tem constraint UNIQUE global, não per-account
|
|
96
|
+
- **Versionamento**: Sempre bumpar version antes de publicar — consumers usam versão fixa
|
|
97
|
+
- **Impacto cross-service**: Mudanças em schemas afetam gagents-r1-api-postgresql (validação, queries) e gagents-r3-api (serviços, lógica)
|
package/package.json
CHANGED
package/src/product.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* Modules */
|
|
2
2
|
|
|
3
|
-
import accounts from './modules/accounts/index.js';
|
|
4
|
-
import users from './modules/users/index.js';
|
|
5
3
|
import agents from './modules/agents/index.js';
|
|
6
4
|
import objectives from './modules/objectives/index.js';
|
|
7
5
|
import contacts from './modules/contacts/index.js';
|
|
@@ -35,8 +33,6 @@ export default {
|
|
|
35
33
|
},
|
|
36
34
|
},
|
|
37
35
|
modules: {
|
|
38
|
-
accounts,
|
|
39
|
-
users,
|
|
40
36
|
agents,
|
|
41
37
|
objectives,
|
|
42
38
|
contacts,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { properties } from "./properties.js";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
product: "gagents",
|
|
5
|
-
name: "accounts",
|
|
6
|
-
cache: { ttlView: 3600, ttlList: 0 },
|
|
7
|
-
summary: "Armazena informações de contas de usuários e suas configurações",
|
|
8
|
-
params: [],
|
|
9
|
-
properties: properties,
|
|
10
|
-
routes: {}
|
|
11
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export const properties = {
|
|
2
|
-
id: {
|
|
3
|
-
type: "number",
|
|
4
|
-
filterable: true,
|
|
5
|
-
unique: true,
|
|
6
|
-
autoIncrement: true,
|
|
7
|
-
index: true
|
|
8
|
-
},
|
|
9
|
-
name: {
|
|
10
|
-
type: "string",
|
|
11
|
-
searchable: true,
|
|
12
|
-
maxLength: 100,
|
|
13
|
-
interface: {
|
|
14
|
-
label: {
|
|
15
|
-
"pt-br": "Nome",
|
|
16
|
-
en: "Name"
|
|
17
|
-
},
|
|
18
|
-
description: {
|
|
19
|
-
"pt-br": "Informe seu nome",
|
|
20
|
-
en: "Enter your name"
|
|
21
|
-
},
|
|
22
|
-
placeholder: {
|
|
23
|
-
"pt-br": "Nome",
|
|
24
|
-
en: "Name"
|
|
25
|
-
},
|
|
26
|
-
component: "input"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
deleted: {
|
|
30
|
-
type: "boolean",
|
|
31
|
-
default: false
|
|
32
|
-
},
|
|
33
|
-
datetime_alt: {
|
|
34
|
-
type: "date",
|
|
35
|
-
filterable: true,
|
|
36
|
-
updatable: false
|
|
37
|
-
},
|
|
38
|
-
datetime_del: {
|
|
39
|
-
type: "date",
|
|
40
|
-
filterable: true
|
|
41
|
-
},
|
|
42
|
-
datetime_add: {
|
|
43
|
-
type: "date",
|
|
44
|
-
filterable: true
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { properties } from "./properties.js";
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
product: "greatagents",
|
|
5
|
-
name: "users",
|
|
6
|
-
cache: { ttlView: 3600, ttlList: 0 },
|
|
7
|
-
summary: "Armazena informações de usuários do sistema",
|
|
8
|
-
params: [ "id_account" ],
|
|
9
|
-
properties: properties,
|
|
10
|
-
routes: {}
|
|
11
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
export const properties = {
|
|
2
|
-
id: {
|
|
3
|
-
type: "number",
|
|
4
|
-
filterable: true,
|
|
5
|
-
unique: true,
|
|
6
|
-
autoIncrement: true,
|
|
7
|
-
index: true
|
|
8
|
-
},
|
|
9
|
-
id_account: {
|
|
10
|
-
type: "number",
|
|
11
|
-
required: true,
|
|
12
|
-
updatable: false,
|
|
13
|
-
filterable: true,
|
|
14
|
-
reference: {
|
|
15
|
-
module: "accounts",
|
|
16
|
-
label: "name",
|
|
17
|
-
value: "id",
|
|
18
|
-
disabled: true
|
|
19
|
-
},
|
|
20
|
-
interface: {
|
|
21
|
-
label: {
|
|
22
|
-
"pt-br": "Conta",
|
|
23
|
-
en: "Account"
|
|
24
|
-
},
|
|
25
|
-
component: "select",
|
|
26
|
-
disabled: true
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
name: {
|
|
30
|
-
type: "string",
|
|
31
|
-
searchable: true,
|
|
32
|
-
maxLength: 50,
|
|
33
|
-
interface: {
|
|
34
|
-
label: {
|
|
35
|
-
"pt-br": "Nome",
|
|
36
|
-
"en": "Name"
|
|
37
|
-
},
|
|
38
|
-
component: "input"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
last_name: {
|
|
42
|
-
type: "string",
|
|
43
|
-
searchable: true,
|
|
44
|
-
interface: {
|
|
45
|
-
label: {
|
|
46
|
-
"pt-br": "Sobrenome",
|
|
47
|
-
en: "Lastname"
|
|
48
|
-
},
|
|
49
|
-
component: "input"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
email: {
|
|
53
|
-
type: "string",
|
|
54
|
-
required: true,
|
|
55
|
-
searchable: true,
|
|
56
|
-
filterable: true,
|
|
57
|
-
interface: {
|
|
58
|
-
label: {
|
|
59
|
-
"pt-br": "E-mail",
|
|
60
|
-
en: "E-mail"
|
|
61
|
-
},
|
|
62
|
-
component: "input",
|
|
63
|
-
format: "email"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
profile: {
|
|
67
|
-
type: "string",
|
|
68
|
-
default: "collaborator",
|
|
69
|
-
options: [
|
|
70
|
-
{
|
|
71
|
-
value: "viewer",
|
|
72
|
-
icon: "",
|
|
73
|
-
title: {
|
|
74
|
-
"pt-br": "Visualizador",
|
|
75
|
-
en: "Viewer"
|
|
76
|
-
},
|
|
77
|
-
description: "",
|
|
78
|
-
style: ""
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
value: "collaborator",
|
|
82
|
-
icon: "",
|
|
83
|
-
title: {
|
|
84
|
-
"pt-br": "Colaborador",
|
|
85
|
-
en: "Collaborator"
|
|
86
|
-
},
|
|
87
|
-
description: "",
|
|
88
|
-
style: ""
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
value: "admin",
|
|
92
|
-
icon: "",
|
|
93
|
-
title: {
|
|
94
|
-
"pt-br": "Administrador",
|
|
95
|
-
en: "Admin"
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
value: "owner",
|
|
100
|
-
icon: "",
|
|
101
|
-
title: {
|
|
102
|
-
"pt-br": "Proprietário",
|
|
103
|
-
en: "Owner"
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
value: "attendant",
|
|
108
|
-
icon: "",
|
|
109
|
-
title: {
|
|
110
|
-
"pt-br": "Atendente",
|
|
111
|
-
en: "Attendant"
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
],
|
|
115
|
-
interface: {
|
|
116
|
-
label: {
|
|
117
|
-
"pt-br": "Perfil de acesso",
|
|
118
|
-
en: "Profile"
|
|
119
|
-
},
|
|
120
|
-
component: "select"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
photo: {
|
|
124
|
-
type: "image",
|
|
125
|
-
interface: {
|
|
126
|
-
label: {
|
|
127
|
-
"pt-br": "Foto",
|
|
128
|
-
en: "Photo"
|
|
129
|
-
},
|
|
130
|
-
component: "image"
|
|
131
|
-
},
|
|
132
|
-
file: {
|
|
133
|
-
types: ["png", "jpg", "jpeg", "gif", "svg", "webp"],
|
|
134
|
-
storage: "gapps-r1-storage",
|
|
135
|
-
width: 160,
|
|
136
|
-
height: 160
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
deleted: {
|
|
140
|
-
type: "boolean",
|
|
141
|
-
default: false
|
|
142
|
-
},
|
|
143
|
-
datetime_alt: {
|
|
144
|
-
type: "date",
|
|
145
|
-
filterable: true,
|
|
146
|
-
updatable: false
|
|
147
|
-
},
|
|
148
|
-
datetime_del: {
|
|
149
|
-
type: "date",
|
|
150
|
-
filterable: true
|
|
151
|
-
},
|
|
152
|
-
datetime_add: {
|
|
153
|
-
type: "date",
|
|
154
|
-
filterable: true
|
|
155
|
-
}
|
|
156
|
-
};
|