Skip to content

Commit 18a4978

Browse files
Copilothotlong
andcommitted
Address code review feedback
- Add detailed documentation for onProgress callback in BatchTaskSchema - Fix naming collision by converting EventBusConfig helper to function - All 2955 tests passing Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 21ce734 commit 18a4978

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/spec/src/system/events.zod.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -740,20 +740,20 @@ export type EventBusConfig = z.infer<typeof EventBusConfigSchema>;
740740
/**
741741
* Helper to create event bus configuration
742742
*/
743-
export const EventBusConfig = Object.assign(EventBusConfigSchema, {
744-
create: <T extends z.input<typeof EventBusConfigSchema>>(config: T) => config,
745-
});
743+
export function createEventBusConfig<T extends z.input<typeof EventBusConfigSchema>>(config: T): T {
744+
return config;
745+
}
746746

747747
/**
748748
* Helper to create event type definition
749749
*/
750-
export const EventTypeDefinition = Object.assign(EventTypeDefinitionSchema, {
751-
create: <T extends z.input<typeof EventTypeDefinitionSchema>>(definition: T) => definition,
752-
});
750+
export function createEventTypeDefinition<T extends z.input<typeof EventTypeDefinitionSchema>>(definition: T): T {
751+
return definition;
752+
}
753753

754754
/**
755755
* Helper to create event webhook configuration
756756
*/
757-
export const EventWebhookConfig = Object.assign(EventWebhookConfigSchema, {
758-
create: <T extends z.input<typeof EventWebhookConfigSchema>>(config: T) => config,
759-
});
757+
export function createEventWebhookConfig<T extends z.input<typeof EventWebhookConfigSchema>>(config: T): T {
758+
return config;
759+
}

packages/spec/src/system/worker.zod.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ export const BatchTaskSchema = z.object({
359359

360360
/**
361361
* Progress callback
362+
*
363+
* Called after each batch completes to report progress.
364+
* Invoked asynchronously and should not throw errors.
365+
* If the callback throws, the error is logged but batch processing continues.
366+
*
367+
* @param progress - Object containing processed count, total count, and failed count
362368
*/
363369
onProgress: z.function()
364370
.args(z.object({
@@ -368,7 +374,7 @@ export const BatchTaskSchema = z.object({
368374
}))
369375
.returns(z.void())
370376
.optional()
371-
.describe('Progress callback function'),
377+
.describe('Progress callback function (called after each batch)'),
372378
});
373379

374380
export type BatchTask = z.infer<typeof BatchTaskSchema>;

0 commit comments

Comments
 (0)