Skip to content

Commit 9c477f8

Browse files
ochafikclaude
andcommitted
refactor: derive ProgressSchema and Progress type from generated schemas
- ProgressSchema now uses .omit({ progressToken: true }) on ProgressNotificationParamsSchema - Progress type uses Omit<ProgressNotificationParams, 'progressToken'> - Added type check to ensure schema and type stay in sync 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent efbbcc1 commit 9c477f8

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/types.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
ResourceTemplateReference,
2424
PromptReference,
2525
CompleteRequestParams,
26+
ProgressNotificationParams,
2627
} from './generated/sdk.types.js';
2728

2829
// =============================================================================
@@ -478,20 +479,11 @@ export const isInitializedNotification = (value: unknown): value is InitializedN
478479
/* Ping */
479480

480481
/* Progress notifications */
481-
export const ProgressSchema = z.object({
482-
/**
483-
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
484-
*/
485-
progress: z.number(),
486-
/**
487-
* Total number of items to process (or total progress required), if known.
488-
*/
489-
total: z.optional(z.number()),
490-
/**
491-
* An optional message describing the current progress.
492-
*/
493-
message: z.optional(z.string())
494-
});
482+
/**
483+
* Progress schema - derived from ProgressNotificationParams without progressToken.
484+
* Used for the ProgressCallback signature in RequestOptions.
485+
*/
486+
export const ProgressSchema = ProgressNotificationParamsSchema.omit({ progressToken: true });
495487

496488
/* Pagination */
497489

@@ -995,8 +987,11 @@ export type RequestMeta = RequestParams['_meta'];
995987
// JSONRPCResponse is defined locally (union of result/error)
996988
export type JSONRPCResponse = Infer<typeof JSONRPCResponseSchema>;
997989

998-
// Progress type (SDK-specific schema)
999-
export type Progress = Infer<typeof ProgressSchema>;
990+
// Progress type - derived from ProgressNotificationParams without progressToken
991+
export type Progress = Omit<ProgressNotificationParams, 'progressToken'>;
992+
// Type check: ensure Progress matches the inferred schema type
993+
type _ProgressCheck = Progress extends Infer<typeof ProgressSchema> ? Infer<typeof ProgressSchema> extends Progress ? true : never : never;
994+
const _progressTypeCheck: _ProgressCheck = true;
1000995

1001996
// Task creation params (SDK-specific)
1002997
export type TaskCreationParams = Infer<typeof TaskCreationParamsSchema>;

0 commit comments

Comments
 (0)