use super::*; impl PostgresRegistry { pub async fn get_published_operation( &self, operation_id: &OperationId, ) -> Result, RegistryError> { let row = sqlx::query!( "select o.id, o.workspace_id, ov.name, ov.display_name, ov.category, ov.protocol, ov.security_level, ov.created_at as \"operation_created_at!: time::OffsetDateTime\", ov.created_at as \"operation_updated_at!: time::OffsetDateTime\", ov.published_at as \"operation_published_at: time::OffsetDateTime\", ov.version, ov.status, ov.target_json, ov.input_schema_json, ov.output_schema_json, ov.input_mapping_json, ov.output_mapping_json, ov.execution_config_json, ov.tool_description_json, ov.samples_json, ov.generated_draft_json, ov.config_export_json, ov.wizard_state_json, ov.change_note, ov.created_at as \"created_at!: time::OffsetDateTime\", ov.created_by from published_operations po join operation_versions ov on ov.operation_id = po.operation_id and ov.version = po.version join operations o on o.id = po.operation_id where po.operation_id = $1", operation_id.as_str(), ) .fetch_optional(&self.pool) .await?; row.map(|row| { build_operation_version_record( row.id, row.workspace_id, row.name, row.display_name, row.category, row.protocol, row.security_level, row.operation_created_at, row.operation_updated_at, row.operation_published_at, row.version, row.status, row.target_json, row.input_schema_json, row.output_schema_json, row.input_mapping_json, row.output_mapping_json, row.execution_config_json, row.tool_description_json, row.samples_json, row.generated_draft_json, row.config_export_json, row.wizard_state_json, row.change_note, row.created_at, row.created_by, ) .map(|record| record.snapshot) }) .transpose() } pub async fn list_published_operations(&self) -> Result, RegistryError> { let rows = sqlx::query!( "select o.id, o.workspace_id, ov.name, ov.display_name, ov.category, ov.protocol, ov.security_level, ov.created_at as \"operation_created_at!: time::OffsetDateTime\", ov.created_at as \"operation_updated_at!: time::OffsetDateTime\", ov.published_at as \"operation_published_at: time::OffsetDateTime\", ov.version, ov.status, ov.target_json, ov.input_schema_json, ov.output_schema_json, ov.input_mapping_json, ov.output_mapping_json, ov.execution_config_json, ov.tool_description_json, ov.samples_json, ov.generated_draft_json, ov.config_export_json, ov.wizard_state_json, ov.change_note, ov.created_at as \"created_at!: time::OffsetDateTime\", ov.created_by from published_operations po join operation_versions ov on ov.operation_id = po.operation_id and ov.version = po.version join operations o on o.id = po.operation_id order by o.name asc", ) .fetch_all(&self.pool) .await?; rows.into_iter() .map(|row| { build_operation_version_record( row.id, row.workspace_id, row.name, row.display_name, row.category, row.protocol, row.security_level, row.operation_created_at, row.operation_updated_at, row.operation_published_at, row.version, row.status, row.target_json, row.input_schema_json, row.output_schema_json, row.input_mapping_json, row.output_mapping_json, row.execution_config_json, row.tool_description_json, row.samples_json, row.generated_draft_json, row.config_export_json, row.wizard_state_json, row.change_note, row.created_at, row.created_by, ) .map(|record| record.snapshot) }) .collect() } }