@@ -21,9 +21,47 @@ 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 =
32+ body . items ?. map ( ( app ) => ( {
33+ metadata : {
34+ name : app . metadata ?. name ,
35+ namespace : app . metadata ?. namespace ,
36+ labels : app . metadata ?. labels ,
37+ creationTimestamp : app . metadata ?. creationTimestamp
38+ } ,
39+ spec : {
40+ project : app . spec ?. project ,
41+ source : app . spec ?. source ,
42+ destination : app . spec ?. destination
43+ } ,
44+ status : {
45+ sync : app . status ?. sync ,
46+ health : app . status ?. health ,
47+ summary : app . status ?. summary
48+ }
49+ } ) ) ?? [ ] ;
50+
51+ // Apply pagination
52+ const start = params ?. offset ?? 0 ;
53+ const end = params ?. limit ? start + params . limit : strippedItems . length ;
54+ const items = strippedItems . slice ( start , end ) ;
55+
56+ return {
57+ items,
58+ metadata : {
59+ resourceVersion : body . metadata ?. resourceVersion ,
60+ totalItems : strippedItems . length ,
61+ returnedItems : items . length ,
62+ hasMore : end < strippedItems . length
63+ }
64+ } ;
2765 }
2866
2967 public async getApplication ( applicationName : string ) {
0 commit comments