ваше сообщение коммита
This commit is contained in:
36
backend/db/migrations/028_create_dynamic_tables.sql
Normal file
36
backend/db/migrations/028_create_dynamic_tables.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- Миграция для динамических пользовательских таблиц (аналог Notion)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_tables (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_columns (
|
||||
id SERIAL PRIMARY KEY,
|
||||
table_id INTEGER NOT NULL REFERENCES user_tables(id) ON DELETE CASCADE,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(50) NOT NULL, -- text, number, select, multiselect, date, etc.
|
||||
options JSONB DEFAULT NULL, -- для select/multiselect
|
||||
"order" INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_rows (
|
||||
id SERIAL PRIMARY KEY,
|
||||
table_id INTEGER NOT NULL REFERENCES user_tables(id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_cell_values (
|
||||
id SERIAL PRIMARY KEY,
|
||||
row_id INTEGER NOT NULL REFERENCES user_rows(id) ON DELETE CASCADE,
|
||||
column_id INTEGER NOT NULL REFERENCES user_columns(id) ON DELETE CASCADE,
|
||||
value TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(row_id, column_id)
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,110 @@
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.102Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.103Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.104Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.104Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.104Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.104Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:47:23.104Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:49:29.092Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:49:29.092Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:49:29.093Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:49:29.093Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:49:29.093Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:51:57.933Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:51:57.933Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:51:57.933Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:51:57.934Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-05-28T13:51:57.934Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-05-28T13:52:49.080Z"}
|
||||
{"body":{"language":["ru"]},"error":{"code":"22P02","detail":"Expected \":\", but found \"}\".","file":"jsonfuncs.c","length":193,"line":"646","name":"error","routine":"json_errsave_error","severity":"ERROR","where":"JSON data, line 1: {\"ru\"}\nunnamed portal parameter $1 = '...'"},"level":"error","message":"PATCH /api/users/:id error","stack":"error: invalid input syntax for type json\n at /app/node_modules/pg-pool/index.js:45:11\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /app/routes/users.js:165:20","timestamp":"2025-05-28T14:00:22.853Z"}
|
||||
{"body":{"language":["ru","en"]},"error":{"code":"22P02","detail":"Expected \":\", but found \",\".","file":"jsonfuncs.c","length":196,"line":"646","name":"error","routine":"json_errsave_error","severity":"ERROR","where":"JSON data, line 1: {\"ru\",...\nunnamed portal parameter $1 = '...'"},"level":"error","message":"PATCH /api/users/:id error","stack":"error: invalid input syntax for type json\n at /app/node_modules/pg-pool/index.js:45:11\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /app/routes/users.js:165:20","timestamp":"2025-05-28T14:00:37.773Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:09:35.925Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:09:35.927Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:09:35.927Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:09:51.210Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.958Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.958Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.959Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.959Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.959Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.960Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.960Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.960Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.961Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.961Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.961Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.961Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.962Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.962Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.962Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.963Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.963Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:17:27.964Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.321Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.322Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.322Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.322Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.323Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.323Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.323Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.323Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.324Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.324Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.324Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:23:00.324Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:24:20.893Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.717Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.719Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.719Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.719Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.719Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:34:53.720Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:39:16.697Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:39:16.698Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:39:24.562Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:42:24.304Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:42:24.305Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:42:24.305Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:42:24.305Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:42:24.305Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:46:56.098Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.393Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:51:47.394Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:52:05.373Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:52:05.374Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:53:38.082Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:54:14.127Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:54:14.128Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:54:51.568Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:54:51.569Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:55:46.954Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:55:46.955Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:55:46.955Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:56:24.274Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T11:56:24.275Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.191Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:05:47.192Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:37.812Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:37.812Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:37.813Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:37.813Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:37.813Z"}
|
||||
{"level":"error","message":"Uncaught Exception: Cannot set properties of undefined (setting 'name')","stack":"TypeError: Cannot set properties of undefined (setting 'name')\n at Connection.<anonymous> (/app/node_modules/imap/lib/Connection.js:431:22)\n at Connection._resTagged (/app/node_modules/imap/lib/Connection.js:1535:22)\n at Parser.<anonymous> (/app/node_modules/imap/lib/Connection.js:194:10)\n at Parser.emit (node:events:524:28)\n at Parser._resTagged (/app/node_modules/imap/lib/Parser.js:175:10)\n at Parser._parse (/app/node_modules/imap/lib/Parser.js:139:16)\n at Parser._tryread (/app/node_modules/imap/lib/Parser.js:82:15)\n at Parser._cbReadable (/app/node_modules/imap/lib/Parser.js:53:12)\n at TLSSocket.emit (node:events:524:28)\n at emitReadable_ (node:internal/streams/readable:834:12)","timestamp":"2025-06-01T12:07:51.222Z"}
|
||||
{"level":"error","message":"Uncaught Exception: Cannot read properties of undefined (reading 'type')","stack":"TypeError: Cannot read properties of undefined (reading 'type')\n at Connection._resUntagged (/app/node_modules/imap/lib/Connection.js:1265:52)\n at Parser.<anonymous> (/app/node_modules/imap/lib/Connection.js:191:10)\n at Parser.emit (node:events:524:28)\n at Parser._resUntagged (/app/node_modules/imap/lib/Parser.js:271:10)\n at Parser._parse (/app/node_modules/imap/lib/Parser.js:137:16)\n at Parser._tryread (/app/node_modules/imap/lib/Parser.js:82:15)\n at Parser._cbReadable (/app/node_modules/imap/lib/Parser.js:53:12)\n at TLSSocket.emit (node:events:524:28)\n at emitReadable_ (node:internal/streams/readable:834:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:81:21)","timestamp":"2025-06-01T12:07:51.310Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:51.509Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:51.510Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:07:51.510Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:28.645Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:28.646Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:28.646Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:28.646Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:46.751Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:09:46.752Z"}
|
||||
{"ip":"::ffff:172.18.0.1","level":"error","message":"Error: Требуется аутентификация","method":"GET","stack":"Error: Требуется аутентификация\n at createError (/app/utils/error.js:8:17)\n at requireAdmin (/app/middleware/auth.js:97:19)\n at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)\n at next (/app/node_modules/express/lib/router/route.js:149:13)\n at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)\n at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)\n at /app/node_modules/express/lib/router/index.js:284:15\n at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12)\n at next (/app/node_modules/express/lib/router/index.js:280:10)\n at Function.handle (/app/node_modules/express/lib/router/index.js:175:3)","timestamp":"2025-06-01T12:09:57.262Z","url":"/api/settings/rpc"}
|
||||
{"ip":"::ffff:172.18.0.1","level":"error","message":"Error: Требуется аутентификация","method":"GET","stack":"Error: Требуется аутентификация\n at createError (/app/utils/error.js:8:17)\n at requireAdmin (/app/middleware/auth.js:97:19)\n at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)\n at next (/app/node_modules/express/lib/router/route.js:149:13)\n at Route.dispatch (/app/node_modules/express/lib/router/route.js:119:3)\n at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)\n at /app/node_modules/express/lib/router/index.js:284:15\n at param (/app/node_modules/express/lib/router/index.js:365:14)\n at param (/app/node_modules/express/lib/router/index.js:376:14)\n at Function.process_params (/app/node_modules/express/lib/router/index.js:421:3)","timestamp":"2025-06-01T12:10:24.332Z","url":"/api/settings/ai-settings/google"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:10:37.655Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:10:37.655Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:10:37.655Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:11:33.089Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:11:33.089Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:11:33.090Z"}
|
||||
{"level":"error","message":"[EmailBot] IMAP connection error: Timed out while authenticating with server","timestamp":"2025-06-01T12:13:04.750Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:13:04.751Z"}
|
||||
{"level":"error","message":"IMAP connection error during check: Timed out while authenticating with server","timestamp":"2025-06-01T12:13:04.751Z"}
|
||||
|
||||
@@ -5,13 +5,12 @@ const { ERROR_CODES } = require('../utils/constants');
|
||||
/**
|
||||
* Middleware для обработки ошибок
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const errorHandler = (err, req, res, /* next */) => {
|
||||
const errorHandler = (err, req, res, next) => {
|
||||
console.log('errorHandler called, arguments:', arguments);
|
||||
console.log('typeof res:', typeof res, 'isFunction:', typeof res === 'function');
|
||||
console.error('errorHandler: err =', err);
|
||||
console.error('errorHandler: typeof err =', typeof err);
|
||||
console.error('errorHandler: stack =', err && err.stack);
|
||||
console.log('errorHandler called, typeof res:', typeof res, 'res:', res);
|
||||
console.log('typeof res:', typeof res, 'isFunction:', typeof res === 'function');
|
||||
// Логируем ошибку
|
||||
logger.error(`Error: ${err.message}`, {
|
||||
stack: err.stack,
|
||||
|
||||
@@ -5,6 +5,5 @@
|
||||
"env": {
|
||||
"NODE_ENV": "development"
|
||||
},
|
||||
"ext": "js,json,env",
|
||||
"exec": "node server.js"
|
||||
"ext": "js,json,env"
|
||||
}
|
||||
|
||||
220
backend/routes/tables.js
Normal file
220
backend/routes/tables.js
Normal file
@@ -0,0 +1,220 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const db = require('../db');
|
||||
const { requireAuth } = require('../middleware/auth');
|
||||
|
||||
router.use((req, res, next) => {
|
||||
console.log('Tables router received:', req.method, req.originalUrl);
|
||||
next();
|
||||
});
|
||||
|
||||
// Получить список всех таблиц (доступно всем)
|
||||
router.get('/', async (req, res, next) => {
|
||||
try {
|
||||
const result = await db.getQuery()('SELECT * FROM user_tables ORDER BY id');
|
||||
res.json(result.rows);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Создать новую таблицу (доступно всем)
|
||||
router.post('/', async (req, res, next) => {
|
||||
try {
|
||||
const { name, description } = req.body;
|
||||
const result = await db.getQuery()(
|
||||
'INSERT INTO user_tables (name, description) VALUES ($1, $2) RETURNING *',
|
||||
[name, description || null]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Получить структуру и данные таблицы (доступно всем)
|
||||
router.get('/:id', async (req, res, next) => {
|
||||
try {
|
||||
const tableId = req.params.id;
|
||||
const columns = (await db.getQuery()('SELECT * FROM user_columns WHERE table_id = $1 ORDER BY "order" ASC, id ASC', [tableId])).rows;
|
||||
const rows = (await db.getQuery()('SELECT * FROM user_rows WHERE table_id = $1 ORDER BY id', [tableId])).rows;
|
||||
const cellValues = (await db.getQuery()('SELECT * FROM user_cell_values WHERE row_id IN (SELECT id FROM user_rows WHERE table_id = $1)', [tableId])).rows;
|
||||
res.json({ columns, rows, cellValues });
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Добавить столбец (доступно всем)
|
||||
router.post('/:id/columns', async (req, res, next) => {
|
||||
try {
|
||||
const tableId = req.params.id;
|
||||
const { name, type, options, order } = req.body;
|
||||
const result = await db.getQuery()(
|
||||
'INSERT INTO user_columns (table_id, name, type, options, "order") VALUES ($1, $2, $3, $4, $5) RETURNING *',
|
||||
[tableId, name, type, options ? JSON.stringify(options) : null, order || 0]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Добавить строку (доступно всем)
|
||||
router.post('/:id/rows', async (req, res, next) => {
|
||||
try {
|
||||
const tableId = req.params.id;
|
||||
const result = await db.getQuery()(
|
||||
'INSERT INTO user_rows (table_id) VALUES ($1) RETURNING *',
|
||||
[tableId]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Изменить значение ячейки (доступно всем)
|
||||
router.patch('/cell/:cellId', async (req, res, next) => {
|
||||
try {
|
||||
const cellId = req.params.cellId;
|
||||
const { value } = req.body;
|
||||
const result = await db.getQuery()(
|
||||
'UPDATE user_cell_values SET value = $1, updated_at = NOW() WHERE id = $2 RETURNING *',
|
||||
[value, cellId]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Создать/обновить значение ячейки (upsert) (доступно всем)
|
||||
router.post('/cell', async (req, res, next) => {
|
||||
try {
|
||||
const { row_id, column_id, value } = req.body;
|
||||
const result = await db.getQuery()(
|
||||
`INSERT INTO user_cell_values (row_id, column_id, value) VALUES ($1, $2, $3)
|
||||
ON CONFLICT (row_id, column_id) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
|
||||
RETURNING *`,
|
||||
[row_id, column_id, value]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Удалить строку (доступно всем)
|
||||
router.delete('/row/:rowId', async (req, res, next) => {
|
||||
try {
|
||||
const rowId = req.params.rowId;
|
||||
await db.getQuery()('DELETE FROM user_rows WHERE id = $1', [rowId]);
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// Удалить столбец (доступно всем)
|
||||
router.delete('/column/:columnId', async (req, res, next) => {
|
||||
try {
|
||||
const columnId = req.params.columnId;
|
||||
await db.getQuery()('DELETE FROM user_columns WHERE id = $1', [columnId]);
|
||||
res.json({ success: true });
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// PATCH для обновления столбца (доступно всем)
|
||||
router.patch('/column/:columnId', async (req, res, next) => {
|
||||
try {
|
||||
const columnId = req.params.columnId;
|
||||
const { name, type, options, order } = req.body;
|
||||
|
||||
// Построение динамического запроса
|
||||
const updates = [];
|
||||
const values = [];
|
||||
let paramIndex = 1;
|
||||
|
||||
if (name !== undefined) {
|
||||
updates.push(`name = $${paramIndex++}`);
|
||||
values.push(name);
|
||||
}
|
||||
if (type !== undefined) {
|
||||
updates.push(`type = $${paramIndex++}`);
|
||||
values.push(type);
|
||||
}
|
||||
if (options !== undefined) {
|
||||
updates.push(`options = $${paramIndex++}`);
|
||||
values.push(options ? JSON.stringify(options) : null);
|
||||
}
|
||||
if (order !== undefined) {
|
||||
updates.push(`"order" = $${paramIndex++}`);
|
||||
values.push(order);
|
||||
}
|
||||
|
||||
if (updates.length === 0) {
|
||||
return res.status(400).json({ error: 'No fields to update' });
|
||||
}
|
||||
|
||||
updates.push(`updated_at = NOW()`);
|
||||
values.push(columnId);
|
||||
|
||||
const query = `UPDATE user_columns SET ${updates.join(', ')} WHERE id = $${paramIndex} RETURNING *`;
|
||||
const result = await db.getQuery()(query, values);
|
||||
|
||||
if (result.rows.length === 0) {
|
||||
return res.status(404).json({ error: 'Column not found' });
|
||||
}
|
||||
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// PATCH: обновить название/описание таблицы (доступно всем)
|
||||
router.patch('/:id', async (req, res, next) => {
|
||||
try {
|
||||
const tableId = req.params.id;
|
||||
const { name, description } = req.body;
|
||||
const result = await db.getQuery()(
|
||||
`UPDATE user_tables SET
|
||||
name = COALESCE($1, name),
|
||||
description = COALESCE($2, description),
|
||||
updated_at = NOW()
|
||||
WHERE id = $3 RETURNING *`,
|
||||
[name, description, tableId]
|
||||
);
|
||||
res.json(result.rows[0]);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
// DELETE: удалить таблицу и каскадно все связанные строки/столбцы/ячейки (доступно всем)
|
||||
router.delete('/:id', requireAuth, async (req, res, next) => {
|
||||
try {
|
||||
const tableId = Number(req.params.id);
|
||||
console.log('Backend: typeof tableId:', typeof tableId, 'value:', tableId);
|
||||
// Проверяем, существует ли таблица
|
||||
const checkResult = await db.getQuery()('SELECT id, name FROM user_tables WHERE id = $1', [tableId]);
|
||||
console.log('Backend: Table check result:', checkResult.rows);
|
||||
if (checkResult.rows.length === 0) {
|
||||
console.log('Backend: Table not found');
|
||||
return res.status(404).json({ error: 'Table not found' });
|
||||
}
|
||||
// Удаляем только основную таблицу - каскадное удаление сработает автоматически
|
||||
console.log('Backend: Executing DELETE query for table_id:', tableId);
|
||||
const result = await db.getQuery()('DELETE FROM user_tables WHERE id = $1', [tableId]);
|
||||
console.log('Backend: Delete result - rowCount:', result.rowCount);
|
||||
res.json({ success: true, deleted: result.rowCount });
|
||||
} catch (err) {
|
||||
console.error('Backend: Error deleting table:', err);
|
||||
next(err);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -15,6 +15,8 @@ const pgSession = require('connect-pg-simple')(session);
|
||||
const authService = require('./services/auth-service');
|
||||
const logger = require('./utils/logger');
|
||||
const EmailBotService = require('./services/emailBot.js');
|
||||
const tablesRouter = require('./routes/tables');
|
||||
const errorHandler = require('./middleware/errorHandler');
|
||||
|
||||
const PORT = process.env.PORT || 8000;
|
||||
|
||||
@@ -94,6 +96,7 @@ app.use('/api/users', usersRouter);
|
||||
app.use('/api/auth', authRouter);
|
||||
app.use('/api/identities', identitiesRouter);
|
||||
app.use('/api/chat', chatRouter);
|
||||
app.use('/api/tables', tablesRouter);
|
||||
|
||||
// Эндпоинт для проверки состояния сервера
|
||||
app.get('/api/health', (req, res) => {
|
||||
@@ -122,4 +125,6 @@ process.on('uncaughtException', (err) => {
|
||||
logger.error('Uncaught Exception:', err);
|
||||
});
|
||||
|
||||
app.use(errorHandler);
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user