Skip to content

Commit b1e0ec2

Browse files
committed
Pass maxResults to streamers
1 parent 2af7bf0 commit b1e0ec2

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

components/zoho_desk/actions/list-articles/list-articles.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import zohoDesk from "../../zoho_desk.app.mjs";
2+
import constants from "../../common/constants.mjs";
23

34
export default {
45
key: "zoho_desk-list-articles",
@@ -59,6 +60,7 @@ export default {
5960
label: "Max Results",
6061
description: "Maximum number of articles to return. Leave blank to return all available results.",
6162
optional: true,
63+
default: constants.MAX_RESOURCES,
6264
},
6365
},
6466
async run({ $ }) {
@@ -80,12 +82,10 @@ export default {
8082
const articles = [];
8183
const stream = this.zohoDesk.listKnowledgeBaseArticlesStream({
8284
params,
85+
max: maxResults,
8386
});
8487
for await (const article of stream) {
8588
articles.push(article);
86-
if (maxResults && articles.length >= maxResults) {
87-
break;
88-
}
8989
}
9090

9191
$.export("$summary", `Retrieved ${articles.length} article${articles.length === 1

components/zoho_desk/actions/list-root-categories/list-root-categories.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import zohoDesk from "../../zoho_desk.app.mjs";
2+
import constants from "../../common/constants.mjs";
23

34
export default {
45
key: "zoho_desk-list-root-categories",
@@ -67,6 +68,7 @@ export default {
6768
label: "Max Results",
6869
description: "Maximum number of categories to return. Leave blank to return all available results.",
6970
optional: true,
71+
default: constants.MAX_RESOURCES,
7072
},
7173
},
7274
async run({ $ }) {
@@ -89,15 +91,13 @@ export default {
8991
hasArticles,
9092
};
9193

92-
const categories = [];
9394
const stream = this.zohoDesk.listKnowledgeBaseRootCategoriesStream({
9495
params,
96+
max: maxResults,
9597
});
98+
const categories = [];
9699
for await (const category of stream) {
97100
categories.push(category);
98-
if (maxResults && categories.length >= maxResults) {
99-
break;
100-
}
101101
}
102102

103103
$.export("$summary", `Retrieved ${categories.length} root categor${categories.length === 1

components/zoho_desk/actions/search-articles/search-articles.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import zohoDesk from "../../zoho_desk.app.mjs";
2+
import constants from "../../common/constants.mjs";
23

34
export default {
45
key: "zoho_desk-search-articles",
@@ -72,6 +73,7 @@ export default {
7273
label: "Max Results",
7374
description: "Maximum number of articles to return. Leave blank to return all available matches.",
7475
optional: true,
76+
default: constants.MAX_RESOURCES,
7577
},
7678
},
7779
async run({ $ }) {
@@ -92,15 +94,13 @@ export default {
9294
searchKeyWordMatch,
9395
};
9496

95-
const articles = [];
9697
const stream = this.zohoDesk.searchKnowledgeBaseArticlesStream({
9798
params,
99+
max: maxResults,
98100
});
101+
const articles = [];
99102
for await (const article of stream) {
100103
articles.push(article);
101-
if (maxResults && articles.length >= maxResults) {
102-
break;
103-
}
104104
}
105105

106106
$.export("$summary", `Found ${articles.length} article${articles.length === 1

components/zoho_desk/zoho_desk.app.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export default {
308308
},
309309
async *listKnowledgeBaseArticlesStream({
310310
params,
311+
max,
311312
...args
312313
} = {}) {
313314
yield* this.getResourcesStream({
@@ -316,6 +317,7 @@ export default {
316317
...args,
317318
params,
318319
},
320+
max,
319321
});
320322
},
321323
getKnowledgeBaseArticle({
@@ -337,6 +339,7 @@ export default {
337339
},
338340
async *searchKnowledgeBaseArticlesStream({
339341
params,
342+
max,
340343
...args
341344
} = {}) {
342345
yield* this.getResourcesStream({
@@ -345,6 +348,7 @@ export default {
345348
...args,
346349
params,
347350
},
351+
max,
348352
});
349353
},
350354
listKnowledgeBaseRootCategories(args = {}) {
@@ -356,6 +360,7 @@ export default {
356360
},
357361
async *listKnowledgeBaseRootCategoriesStream({
358362
params,
363+
max,
359364
...args
360365
} = {}) {
361366
yield* this.getResourcesStream({
@@ -364,6 +369,7 @@ export default {
364369
...args,
365370
params,
366371
},
372+
max,
367373
});
368374
},
369375
sendReply({

0 commit comments

Comments
 (0)