feat(desktop): implement workspace foundation + desktop-client skeleton
Plan 0 (workspaces): add workspaces + workspace_memberships schema, extend JWT/Actor/claims with primary_workspace_id, seed default workspace per tenant, thread workspace_id through tenant monitoring quota. Plan A (desktop skeleton): new Electron app (apps/desktop-client) with main/ preload/renderer, shared Vue component package (packages/ui-shared), and server surface — desktop client registration + token rotation + heartbeat, SSE task event stream, desktop accounts/tasks/content handlers, publish job endpoint, and supporting repositories, services, sqlc queries, and migrations. Hard cutover per plan: remove browser-extension monitoring callback endpoints, stub legacy media API in admin-web, and delete monitoring_callback_handler.go.
This commit is contained in:
@@ -12,18 +12,28 @@ import (
|
||||
)
|
||||
|
||||
const getTenantMembership = `-- name: GetTenantMembership :one
|
||||
SELECT id, tenant_id, user_id, tenant_role, created_at
|
||||
FROM tenant_memberships
|
||||
WHERE user_id = $1 AND deleted_at IS NULL
|
||||
SELECT tm.id,
|
||||
tm.tenant_id,
|
||||
tm.user_id,
|
||||
tm.tenant_role,
|
||||
tm.created_at,
|
||||
wm.workspace_id AS primary_workspace_id
|
||||
FROM tenant_memberships tm
|
||||
JOIN workspace_memberships wm
|
||||
ON wm.tenant_id = tm.tenant_id
|
||||
AND wm.user_id = tm.user_id
|
||||
AND wm.is_primary = TRUE
|
||||
WHERE tm.user_id = $1 AND tm.deleted_at IS NULL
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetTenantMembershipRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TenantRole string `json:"tenant_role"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TenantRole string `json:"tenant_role"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
PrimaryWorkspaceID int64 `json:"primary_workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTenantMembership(ctx context.Context, userID int64) (GetTenantMembershipRow, error) {
|
||||
@@ -35,14 +45,24 @@ func (q *Queries) GetTenantMembership(ctx context.Context, userID int64) (GetTen
|
||||
&i.UserID,
|
||||
&i.TenantRole,
|
||||
&i.CreatedAt,
|
||||
&i.PrimaryWorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTenantMembershipByTenantAndUser = `-- name: GetTenantMembershipByTenantAndUser :one
|
||||
SELECT id, tenant_id, user_id, tenant_role, created_at
|
||||
FROM tenant_memberships
|
||||
WHERE tenant_id = $1 AND user_id = $2 AND deleted_at IS NULL
|
||||
SELECT tm.id,
|
||||
tm.tenant_id,
|
||||
tm.user_id,
|
||||
tm.tenant_role,
|
||||
tm.created_at,
|
||||
wm.workspace_id AS primary_workspace_id
|
||||
FROM tenant_memberships tm
|
||||
JOIN workspace_memberships wm
|
||||
ON wm.tenant_id = tm.tenant_id
|
||||
AND wm.user_id = tm.user_id
|
||||
AND wm.is_primary = TRUE
|
||||
WHERE tm.tenant_id = $1 AND tm.user_id = $2 AND tm.deleted_at IS NULL
|
||||
`
|
||||
|
||||
type GetTenantMembershipByTenantAndUserParams struct {
|
||||
@@ -51,11 +71,12 @@ type GetTenantMembershipByTenantAndUserParams struct {
|
||||
}
|
||||
|
||||
type GetTenantMembershipByTenantAndUserRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TenantRole string `json:"tenant_role"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
TenantRole string `json:"tenant_role"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
PrimaryWorkspaceID int64 `json:"primary_workspace_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetTenantMembershipByTenantAndUser(ctx context.Context, arg GetTenantMembershipByTenantAndUserParams) (GetTenantMembershipByTenantAndUserRow, error) {
|
||||
@@ -67,6 +88,7 @@ func (q *Queries) GetTenantMembershipByTenantAndUser(ctx context.Context, arg Ge
|
||||
&i.UserID,
|
||||
&i.TenantRole,
|
||||
&i.CreatedAt,
|
||||
&i.PrimaryWorkspaceID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user