@@ -192,6 +192,10 @@ type QueryModel struct {
192192 // True when the table has properties column
193193 HasProperties bool
194194
195+ // True when the table has a "deleted_at" column.
196+ // When false, the default `deleted_at IS NULL` filter is not applied.
197+ HasDeletedAt bool
198+
195199 // FieldMapper maps the value of these fields
196200 FieldMapper map [string ]func (ctx context.Context , id string ) (any , error )
197201}
@@ -211,6 +215,7 @@ var ConfigItemQueryModel = QueryModel{
211215 HasTags : true ,
212216 HasAgents : true ,
213217 HasLabels : true ,
218+ HasDeletedAt : true ,
214219 Aliases : map [string ]string {
215220 "created" : "created_at" ,
216221 "updated" : "updated_at" ,
@@ -243,6 +248,7 @@ var ConfigItemSummaryQueryModel = QueryModel{
243248 HasAgents : true ,
244249 HasLabels : true ,
245250 HasProperties : true ,
251+ HasDeletedAt : true ,
246252 Aliases : map [string ]string {
247253 "created" : "created_at" ,
248254 "updated" : "updated_at" ,
@@ -293,6 +299,7 @@ var ComponentQueryModel = QueryModel{
293299 HasProperties : true ,
294300 HasAgents : true ,
295301 HasLabels : true ,
302+ HasDeletedAt : true ,
296303 FieldMapper : map [string ]func (ctx context.Context , id string ) (any , error ){
297304 "agent_id" : AgentMapper ,
298305 "created_at" : DateMapper ,
@@ -316,8 +323,9 @@ var CheckQueryModel = QueryModel{
316323 "health" : "status" ,
317324 "check_type" : "type" ,
318325 },
319- HasAgents : true ,
320- HasLabels : true ,
326+ HasAgents : true ,
327+ HasLabels : true ,
328+ HasDeletedAt : true ,
321329 FieldMapper : map [string ]func (ctx context.Context , id string ) (any , error ){
322330 "agent_id" : AgentMapper ,
323331 "created_at" : DateMapper ,
@@ -327,9 +335,10 @@ var CheckQueryModel = QueryModel{
327335}
328336
329337var PlaybookQueryModel = QueryModel {
330- Table : models.Playbook {}.TableName (),
331- HasTags : true ,
332- Columns : []string {"id" , "name" , "namespace" , "created_at" , "updated_at" , "deleted_at" },
338+ Table : models.Playbook {}.TableName (),
339+ HasTags : true ,
340+ HasDeletedAt : true ,
341+ Columns : []string {"id" , "name" , "namespace" , "created_at" , "updated_at" , "deleted_at" },
333342 Aliases : map [string ]string {
334343 "created" : "created_at" ,
335344 "updated" : "updated_at" ,
@@ -343,8 +352,9 @@ var PlaybookQueryModel = QueryModel{
343352}
344353
345354var ConnectionQueryModel = QueryModel {
346- Table : models.Connection {}.TableName (),
347- Columns : []string {"id" , "name" , "namespace" , "type" },
355+ Table : models.Connection {}.TableName (),
356+ Columns : []string {"id" , "name" , "namespace" , "type" },
357+ HasDeletedAt : true ,
348358}
349359
350360var ConfigChangeQueryModel = QueryModel {
@@ -356,6 +366,7 @@ var ConfigChangeQueryModel = QueryModel{
356366 JSONMapColumns : []string {"tags" , "details" },
357367 HasAgents : true ,
358368 HasTags : true ,
369+ HasDeletedAt : true ,
359370 Aliases : map [string ]string {
360371 "created" : "created_at" ,
361372 "first_observed" : "first_observed" ,
@@ -374,6 +385,7 @@ var ViewQueryModel = QueryModel{
374385 Columns : []string {"name" , "namespace" },
375386 JSONMapColumns : []string {"labels" },
376387 HasLabels : true ,
388+ HasDeletedAt : true ,
377389}
378390
379391var CanaryQueryModel = QueryModel {
@@ -385,6 +397,7 @@ var CanaryQueryModel = QueryModel{
385397 JSONMapColumns : []string {"labels" , "spec" },
386398 HasLabels : true ,
387399 HasAgents : true ,
400+ HasDeletedAt : true ,
388401 Aliases : map [string ]string {
389402 "created" : "created_at" ,
390403 "updated" : "updated_at" ,
@@ -399,6 +412,30 @@ var CanaryQueryModel = QueryModel{
399412 },
400413}
401414
415+ // ConfigAnalysisQueryModel powers resource selector search for config insights
416+ // (the config_analysis table). The table has neither name/namespace nor
417+ // deleted_at/agent_id/tags/labels columns, so those features stay disabled.
418+ var ConfigAnalysisQueryModel = QueryModel {
419+ Table : models.ConfigAnalysis {}.TableName (),
420+ Columns : []string {
421+ "id" , "config_id" , "scraper_id" , "source" , "analyzer" , "analysis_type" ,
422+ "severity" , "status" , "summary" , "message" , "first_observed" , "last_observed" ,
423+ },
424+ JSONMapColumns : []string {"analysis" },
425+ HasProperties : true ,
426+ Aliases : map [string ]string {
427+ "type" : "analysis_type" ,
428+ "analyzer_type" : "analysis_type" ,
429+ "config" : "config_id" ,
430+ "first_observed" : "first_observed" ,
431+ "last_observed" : "last_observed" ,
432+ },
433+ FieldMapper : map [string ]func (ctx context.Context , id string ) (any , error ){
434+ "first_observed" : DateMapper ,
435+ "last_observed" : DateMapper ,
436+ },
437+ }
438+
402439func GetModelFromTable (table string ) (QueryModel , error ) {
403440 switch table {
404441 case models.ConfigItem {}.TableName ():
@@ -419,6 +456,8 @@ func GetModelFromTable(table string) (QueryModel, error) {
419456 return ConfigItemSummaryQueryModel , nil
420457 case models.View {}.TableName ():
421458 return ViewQueryModel , nil
459+ case models.ConfigAnalysis {}.TableName ():
460+ return ConfigAnalysisQueryModel , nil
422461 default :
423462 return QueryModel {}, fmt .Errorf ("invalid table" )
424463 }
0 commit comments