@greatapps/greatagents 0.1.9 → 0.1.10
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.
|
@@ -95,8 +95,8 @@ erDiagram
|
|
|
95
95
|
VARCHAR(255) title "NOT NULL, searchable, filterable, maxLength=255"
|
|
96
96
|
IMAGE photo "types=[png,jpg,jpeg,gif,svg,webp], storage=gpages, 200x200"
|
|
97
97
|
TEXT prompt
|
|
98
|
-
INTEGER
|
|
99
|
-
INTEGER
|
|
98
|
+
INTEGER delay_typing "DEFAULT 0, filterable"
|
|
99
|
+
INTEGER waiting_time "DEFAULT 0, filterable"
|
|
100
100
|
BOOLEAN deleted "DEFAULT false, filterable"
|
|
101
101
|
TIMESTAMP datetime_add "filterable, updatable=false"
|
|
102
102
|
TIMESTAMP datetime_alt "filterable"
|
package/package.json
CHANGED
package/scripts/constraints.sql
CHANGED
|
@@ -332,7 +332,7 @@ EXCEPTION
|
|
|
332
332
|
RAISE WARNING '[%] ✗ Erro ao adicionar constraint lógica messages autor: %', now(), SQLERRM;
|
|
333
333
|
END $$;
|
|
334
334
|
|
|
335
|
-
-- AGENTS -
|
|
335
|
+
-- AGENTS - delay_typing deve ser >= 0 (se não existir)
|
|
336
336
|
DO $$
|
|
337
337
|
BEGIN
|
|
338
338
|
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints
|
|
@@ -344,16 +344,16 @@ BEGIN
|
|
|
344
344
|
|
|
345
345
|
ALTER TABLE agents
|
|
346
346
|
ADD CONSTRAINT chk_agents_delay_positive
|
|
347
|
-
CHECK (
|
|
347
|
+
CHECK (delay_typing IS NULL OR delay_typing >= 0);
|
|
348
348
|
|
|
349
|
-
RAISE NOTICE '[%] ✓ Constraint lógica agents.
|
|
349
|
+
RAISE NOTICE '[%] ✓ Constraint lógica agents.delay_typing >= 0', now();
|
|
350
350
|
END IF;
|
|
351
351
|
EXCEPTION
|
|
352
352
|
WHEN OTHERS THEN
|
|
353
|
-
RAISE WARNING '[%] ✗ Erro ao adicionar constraint lógica agents.
|
|
353
|
+
RAISE WARNING '[%] ✗ Erro ao adicionar constraint lógica agents.delay_typing: %', now(), SQLERRM;
|
|
354
354
|
END $$;
|
|
355
355
|
|
|
356
|
-
-- AGENTS -
|
|
356
|
+
-- AGENTS - waiting_time deve ser >= 0 (se não existir)
|
|
357
357
|
DO $$
|
|
358
358
|
BEGIN
|
|
359
359
|
IF NOT EXISTS (SELECT 1 FROM information_schema.table_constraints
|
|
@@ -365,13 +365,13 @@ BEGIN
|
|
|
365
365
|
|
|
366
366
|
ALTER TABLE agents
|
|
367
367
|
ADD CONSTRAINT chk_agents_waiting_positive
|
|
368
|
-
CHECK (
|
|
368
|
+
CHECK (waiting_time IS NULL OR waiting_time >= 0);
|
|
369
369
|
|
|
370
|
-
RAISE NOTICE '[%] ✓ Constraint lógica agents.
|
|
370
|
+
RAISE NOTICE '[%] ✓ Constraint lógica agents.waiting_time >= 0', now();
|
|
371
371
|
END IF;
|
|
372
372
|
EXCEPTION
|
|
373
373
|
WHEN OTHERS THEN
|
|
374
|
-
RAISE WARNING '[%] ✗ Erro ao adicionar constraint lógica agents.
|
|
374
|
+
RAISE WARNING '[%] ✗ Erro ao adicionar constraint lógica agents.waiting_time: %', now(), SQLERRM;
|
|
375
375
|
END $$;
|
|
376
376
|
|
|
377
377
|
-- OBJECTIVES - order_number deve ser > 0 (se não existir)
|
package/scripts/indexes.sql
CHANGED
|
@@ -189,8 +189,8 @@ BEGIN
|
|
|
189
189
|
CREATE INDEX IF NOT EXISTS idx_agents_datetime_add ON agents(datetime_add);
|
|
190
190
|
CREATE INDEX IF NOT EXISTS idx_agents_datetime_alt ON agents(datetime_alt);
|
|
191
191
|
CREATE INDEX IF NOT EXISTS idx_agents_datetime_del ON agents(datetime_del);
|
|
192
|
-
CREATE INDEX IF NOT EXISTS idx_agents_delaytypying ON agents(
|
|
193
|
-
CREATE INDEX IF NOT EXISTS
|
|
192
|
+
CREATE INDEX IF NOT EXISTS idx_agents_delaytypying ON agents(delay_typing);
|
|
193
|
+
CREATE INDEX IF NOT EXISTS idx_agents_waiting_time ON agents(waiting_time);
|
|
194
194
|
|
|
195
195
|
-- Índices full-text para campos searchable
|
|
196
196
|
CREATE INDEX IF NOT EXISTS idx_agents_title_search ON agents
|
package/scripts/migrate_v1.sql
CHANGED
|
@@ -294,11 +294,11 @@ BEGIN
|
|
|
294
294
|
title VARCHAR(255) NOT NULL,
|
|
295
295
|
photo VARCHAR(255),
|
|
296
296
|
prompt TEXT,
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
delay_typing INTEGER DEFAULT 0,
|
|
298
|
+
waiting_time INTEGER DEFAULT 0,
|
|
299
299
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
300
|
-
CONSTRAINT agents_delay_typing_valid CHECK (
|
|
301
|
-
CONSTRAINT agents_waiting_time_valid CHECK (
|
|
300
|
+
CONSTRAINT agents_delay_typing_valid CHECK (delay_typing >= 0),
|
|
301
|
+
CONSTRAINT agents_waiting_time_valid CHECK (waiting_time >= 0)
|
|
302
302
|
);
|
|
303
303
|
COMMENT ON TABLE agents IS 'Tabela de agentes do sistema';
|
|
304
304
|
|
|
@@ -32,22 +32,22 @@ CREATE TABLE IF NOT EXISTS agents (
|
|
|
32
32
|
title VARCHAR(255) NOT NULL, -- required: true, maxLength: 255
|
|
33
33
|
photo VARCHAR(255), -- type: image -> VARCHAR para URL da imagem
|
|
34
34
|
prompt TEXT, -- type: string, pode ser longo
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
delay_typing INTEGER DEFAULT 0, -- type: number, default: 0
|
|
36
|
+
waiting_time INTEGER DEFAULT 0, -- type: number, default: 0
|
|
37
37
|
|
|
38
38
|
-- Foreign keys
|
|
39
39
|
FOREIGN KEY (id_account) REFERENCES accounts(id) ON DELETE CASCADE,
|
|
40
40
|
|
|
41
41
|
-- Constraints
|
|
42
|
-
CONSTRAINT agents_delay_typing_valid CHECK (
|
|
43
|
-
CONSTRAINT agents_waiting_time_valid CHECK (
|
|
42
|
+
CONSTRAINT agents_delay_typing_valid CHECK (delay_typing >= 0),
|
|
43
|
+
CONSTRAINT agents_waiting_time_valid CHECK (waiting_time >= 0)
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
-- Índices para otimização
|
|
47
47
|
CREATE INDEX IF NOT EXISTS idx_agents_id_account ON agents(id_account);
|
|
48
48
|
CREATE INDEX IF NOT EXISTS idx_agents_title ON agents(title);
|
|
49
|
-
CREATE INDEX IF NOT EXISTS idx_agents_delay_typing ON agents(
|
|
50
|
-
CREATE INDEX IF NOT EXISTS idx_agents_waiting_time ON agents(
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_agents_delay_typing ON agents(delay_typing);
|
|
50
|
+
CREATE INDEX IF NOT EXISTS idx_agents_waiting_time ON agents(waiting_time);
|
|
51
51
|
|
|
52
52
|
-- Comentários na tabela
|
|
53
53
|
COMMENT ON TABLE agents IS 'Tabela de agentes do sistema';
|
|
@@ -56,8 +56,8 @@ COMMENT ON COLUMN agents.id_account IS 'Referência à conta (FK)';
|
|
|
56
56
|
COMMENT ON COLUMN agents.title IS 'Título do agente (obrigatório)';
|
|
57
57
|
COMMENT ON COLUMN agents.photo IS 'URL da foto do agente';
|
|
58
58
|
COMMENT ON COLUMN agents.prompt IS 'Instruções do agente';
|
|
59
|
-
COMMENT ON COLUMN agents.
|
|
60
|
-
COMMENT ON COLUMN agents.
|
|
59
|
+
COMMENT ON COLUMN agents.delay_typing IS 'Atraso em segundos para mostrar "digitando..."';
|
|
60
|
+
COMMENT ON COLUMN agents.waiting_time IS 'Tempo em segundos para aguardar mensagens antes de responder';
|
|
61
61
|
|
|
62
62
|
-- Verificação pós-execução
|
|
63
63
|
DO $$
|
|
@@ -105,7 +105,7 @@ export const properties = {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
|
-
|
|
108
|
+
delay_typing: {
|
|
109
109
|
type: "number",
|
|
110
110
|
default: 0,
|
|
111
111
|
filterable: true,
|
|
@@ -121,7 +121,7 @@ export const properties = {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
-
|
|
124
|
+
waiting_time: {
|
|
125
125
|
type: "number",
|
|
126
126
|
default: 0,
|
|
127
127
|
filterable: true,
|