@@ -31,7 +31,7 @@ export async function listAgentKeys(
3131 const { data, error } = await supabase
3232 . from ( 'agent_keys' )
3333 . select (
34- 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, default_project_id, default_department_id ' ,
34+ 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, project_id, department_id ' ,
3535 )
3636 . order ( 'created_at' , { ascending : false } ) ;
3737
@@ -47,8 +47,8 @@ export async function createAgentKey(
4747 specialPrompt ?: string | null ;
4848 createdBy : string ;
4949 workspaceId : string ;
50- defaultProjectId ?: string | null ;
51- defaultDepartmentId ?: string | null ;
50+ projectId ?: string | null ;
51+ departmentId ?: string | null ;
5252 } ,
5353) : Promise < { key : Omit < AgentKey , 'key_hash' > ; fullKey : string } > {
5454 const keyId = crypto . randomUUID ( ) ;
@@ -65,11 +65,11 @@ export async function createAgentKey(
6565 special_prompt : params . specialPrompt ?? null ,
6666 created_by : params . createdBy ,
6767 workspace_id : params . workspaceId ,
68- default_project_id : params . defaultProjectId ?? null ,
69- default_department_id : params . defaultDepartmentId ?? null ,
68+ project_id : params . projectId ?? null ,
69+ department_id : params . departmentId ?? null ,
7070 } )
7171 . select (
72- 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, default_project_id, default_department_id ' ,
72+ 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, project_id, department_id ' ,
7373 )
7474 . single ( ) ;
7575
@@ -98,8 +98,8 @@ export async function updateAgentKey(
9898 name ?: string ;
9999 specialPrompt ?: string | null ;
100100 isActive ?: boolean ;
101- defaultProjectId ?: string | null ;
102- defaultDepartmentId ?: string | null ;
101+ projectId ?: string | null ;
102+ departmentId ?: string | null ;
103103 actorId : string ;
104104 workspaceId : string ;
105105 } ,
@@ -108,20 +108,19 @@ export async function updateAgentKey(
108108 if ( params . name !== undefined ) updates . name = params . name ;
109109 if ( params . specialPrompt !== undefined ) updates . special_prompt = params . specialPrompt ;
110110 if ( params . isActive !== undefined ) updates . is_active = params . isActive ;
111- if ( params . defaultProjectId !== undefined ) {
112- updates . default_project_id = params . defaultProjectId ;
111+ if ( params . projectId !== undefined ) {
112+ updates . project_id = params . projectId ;
113113 // Clearing project must also clear department (DB CHECK constraint)
114- if ( params . defaultProjectId === null ) updates . default_department_id = null ;
114+ if ( params . projectId === null ) updates . department_id = null ;
115115 }
116- if ( params . defaultDepartmentId !== undefined )
117- updates . default_department_id = params . defaultDepartmentId ;
116+ if ( params . departmentId !== undefined ) updates . department_id = params . departmentId ;
118117
119118 const { data, error } = await supabase
120119 . from ( 'agent_keys' )
121120 . update ( updates )
122121 . eq ( 'id' , params . id )
123122 . select (
124- 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, default_project_id, default_department_id ' ,
123+ 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, project_id, department_id ' ,
125124 )
126125 . single ( ) ;
127126
@@ -154,7 +153,7 @@ export async function rotateAgentKey(
154153 . update ( { key_hash : hash , key_prefix : prefix } )
155154 . eq ( 'id' , params . id )
156155 . select (
157- 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, default_project_id, default_department_id ' ,
156+ 'id, name, role, key_prefix, is_active, special_prompt, created_at, last_used_at, created_by, project_id, department_id ' ,
158157 )
159158 . single ( ) ;
160159
0 commit comments