@@ -21,9 +21,46 @@ export class ArgoCDClient {
2121 this . client = new HttpClient ( this . baseUrl , this . apiToken ) ;
2222 }
2323
24- public async listApplications ( params ?: { search ?: string } ) {
25- const { body } = await this . client . get < V1alpha1ApplicationList > ( `/api/v1/applications` , params ) ;
26- return body ;
24+ public async listApplications ( params ?: { search ?: string ; limit ?: number ; offset ?: number } ) {
25+ const { body } = await this . client . get < V1alpha1ApplicationList > (
26+ `/api/v1/applications` ,
27+ params ?. search ? { search : params . search } : undefined
28+ ) ;
29+
30+ // Strip heavy fields to reduce token usage
31+ const strippedItems = body . items ?. map ( ( app ) => ( {
32+ metadata : {
33+ name : app . metadata ?. name ,
34+ namespace : app . metadata ?. namespace ,
35+ labels : app . metadata ?. labels ,
36+ creationTimestamp : app . metadata ?. creationTimestamp
37+ } ,
38+ spec : {
39+ project : app . spec ?. project ,
40+ source : app . spec ?. source ,
41+ destination : app . spec ?. destination
42+ } ,
43+ status : {
44+ sync : app . status ?. sync ,
45+ health : app . status ?. health ,
46+ summary : app . status ?. summary
47+ }
48+ } ) ) ?? [ ] ;
49+
50+ // Apply pagination
51+ const start = params ?. offset ?? 0 ;
52+ const end = params ?. limit ? start + params . limit : strippedItems . length ;
53+ const items = strippedItems . slice ( start , end ) ;
54+
55+ return {
56+ items,
57+ metadata : {
58+ resourceVersion : body . metadata ?. resourceVersion ,
59+ totalItems : strippedItems . length ,
60+ returnedItems : items . length ,
61+ hasMore : end < strippedItems . length
62+ }
63+ } ;
2764 }
2865
2966 public async getApplication ( applicationName : string ) {
0 commit comments