refactor(core): migrate channel identity and binding across app

Align channel identity and bind flow across backend and app-facing layers, including generated swagger artifacts and package lock updates while excluding docs content changes.
This commit is contained in:
BBQ
2026-02-11 14:47:03 +08:00
parent 155c70685f
commit 06e8619a37
147 changed files with 11931 additions and 9234 deletions
+8 -39
View File
@@ -34,54 +34,23 @@ WHERE channel_type = $1
ORDER BY created_at DESC;
-- name: GetUserChannelBinding :one
SELECT id, user_id, channel_type, config, created_at, updated_at
SELECT id, user_id, platform, config, created_at, updated_at
FROM user_channel_bindings
WHERE user_id = $1 AND channel_type = $2
WHERE user_id = $1 AND platform = $2
LIMIT 1;
-- name: UpsertUserChannelBinding :one
INSERT INTO user_channel_bindings (user_id, channel_type, config)
INSERT INTO user_channel_bindings (user_id, platform, config)
VALUES ($1, $2, $3)
ON CONFLICT (user_id, channel_type)
ON CONFLICT (user_id, platform)
DO UPDATE SET
config = EXCLUDED.config,
updated_at = now()
RETURNING id, user_id, channel_type, config, created_at, updated_at;
RETURNING id, user_id, platform, config, created_at, updated_at;
-- name: ListUserChannelBindingsByType :many
SELECT id, user_id, channel_type, config, created_at, updated_at
-- name: ListUserChannelBindingsByPlatform :many
SELECT id, user_id, platform, config, created_at, updated_at
FROM user_channel_bindings
WHERE channel_type = $1
WHERE platform = $1
ORDER BY created_at DESC;
-- name: GetChannelSessionByID :one
SELECT session_id, bot_id, channel_config_id, user_id, contact_id, platform, reply_target, thread_id, metadata, created_at, updated_at
FROM channel_sessions
WHERE session_id = $1
LIMIT 1;
-- name: ListChannelSessionsByBotPlatform :many
SELECT session_id, bot_id, channel_config_id, user_id, contact_id, platform, reply_target, thread_id, metadata, created_at, updated_at
FROM channel_sessions
WHERE bot_id = $1 AND platform = $2
ORDER BY updated_at DESC;
-- name: UpsertChannelSession :one
INSERT INTO channel_sessions (session_id, bot_id, channel_config_id, user_id, contact_id, platform, reply_target, thread_id, metadata)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (session_id)
DO UPDATE SET
bot_id = EXCLUDED.bot_id,
channel_config_id = EXCLUDED.channel_config_id,
user_id = EXCLUDED.user_id,
contact_id = EXCLUDED.contact_id,
platform = EXCLUDED.platform,
reply_target = EXCLUDED.reply_target,
thread_id = EXCLUDED.thread_id,
metadata = EXCLUDED.metadata,
updated_at = now()
RETURNING session_id, bot_id, channel_config_id, user_id, contact_id, platform, reply_target, thread_id, metadata, created_at, updated_at;
-- name: DeleteChannelSession :exec
DELETE FROM channel_sessions
WHERE session_id = $1;