Skip to content

Commit a54dda8

Browse files
author
flowcore-platform
committed
fix(index): 🐛 Adjust default pageSize to 10 and improve cursor handling in event ingestion
1 parent ece6df3 commit a54dda8

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ server.tool(
170170
.describe(
171171
"The time bucket to get events from, the timebucket is in the format of YYYYMMDDhhiiss, normally the ii and ss are 0000",
172172
),
173-
cursor: z.string().optional().describe("The paging cursor for pagination, this will be the nextCursor returned from the previous call"),
174-
pageSize: z.number().default(500).describe("The number of events per page (default is 500)"),
173+
cursor: z
174+
.string()
175+
.optional()
176+
.describe("The paging cursor for pagination, this will be the nextCursor returned from the previous call"),
177+
pageSize: z.number().default(10).describe("The number of events per page (default is 10) (max is 100)"),
175178
fromEventId: z.string().optional().describe("Start from this event ID"),
176179
afterEventId: z
177180
.string()
@@ -210,9 +213,7 @@ if (values.apiKey) {
210213
dataCoreId: z.string().describe("The data core ID to ingest events for"),
211214
flowTypeName: z.string().describe("The flow type name to ingest events for"),
212215
eventTypeName: z.string().describe("The event type name to ingest events for"),
213-
events: z
214-
.array(z.any())
215-
.describe("The events to ingest in the format of an array of events in JSON format"),
216+
events: z.array(z.any()).describe("The events to ingest in the format of an array of events in JSON format"),
216217
},
217218
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
218219
ingestHandler(values.apiKey as string) as any,

src/tools/get-events.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
import {
2-
EventListCommand,
3-
type EventListInput,
4-
type FlowcoreClient,
5-
} from "@flowcore/sdk";
1+
import { EventListCommand, type EventListInput, type FlowcoreClient } from "@flowcore/sdk"
62

7-
export const getEventsHandler =
8-
(flowcoreClient: FlowcoreClient) => async (input: EventListInput) => {
9-
try {
10-
const result = await flowcoreClient.execute(new EventListCommand(input));
3+
export const getEventsHandler = (flowcoreClient: FlowcoreClient) => async (input: EventListInput) => {
4+
try {
5+
if (input.pageSize && input.pageSize > 100) {
6+
input.pageSize = 100
7+
}
118

12-
return {
13-
content: [
14-
{
15-
type: "text" as const,
16-
text: JSON.stringify(result),
17-
},
18-
],
19-
};
20-
} catch (error) {
21-
// Create properly typed content array for error
22-
const content = [
23-
{
24-
type: "text" as const,
25-
text: JSON.stringify(`Failed to get events with error: ${error}`),
26-
},
27-
];
9+
const result = await flowcoreClient.execute(new EventListCommand(input))
2810

29-
return { isError: true, content };
30-
}
31-
};
11+
return {
12+
content: [
13+
{
14+
type: "text" as const,
15+
text: JSON.stringify(result),
16+
},
17+
],
18+
}
19+
} catch (error) {
20+
// Create properly typed content array for error
21+
const content = [
22+
{
23+
type: "text" as const,
24+
text: JSON.stringify(`Failed to get events with error: ${error}`),
25+
},
26+
]
27+
28+
return { isError: true, content }
29+
}
30+
}

0 commit comments

Comments
 (0)