Skip to content

Commit fbb88e6

Browse files
ochafikclaude
andcommitted
refactor: remove useless aliases and redundant RequestMetaSchema
- Remove BaseRequestParamsSchema alias (use RequestParamsSchema directly) - Remove NotificationsParamsSchema alias (use NotificationParamsSchema directly) - Remove RequestMetaSchema (derive RequestMeta type from RequestParamsSchema['_meta']) The RELATED_TASK_META_KEY is already injected during spec->sdk type pre-processing, so there's no need for a separate RequestMetaSchema definition. Types.ts reduced from ~1267 to ~1256 lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 224351e commit fbb88e6

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/types.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ import {
196196
SamplingMessageContentBlockSchema,
197197
} from './generated/sdk.schemas.js';
198198

199-
// Alias RequestParamsSchema to BaseRequestParamsSchema for internal use
200-
const BaseRequestParamsSchema = RequestParamsSchema;
201-
// Alias NotificationParamsSchema to NotificationsParamsSchema (plural) for backwards compat
202-
const NotificationsParamsSchema = NotificationParamsSchema;
203-
204199
export {
205200
ProgressTokenSchema,
206201
CursorSchema,
@@ -377,18 +372,9 @@ export const TaskCreationParamsSchema = z.looseObject({
377372
pollInterval: z.number().optional()
378373
});
379374

380-
// Note: RequestParamsSchema (aliased as BaseRequestParamsSchema) and
381-
// TaskAugmentedRequestParamsSchema are re-exported from generated.
382-
// They include RELATED_TASK_META_KEY in _meta, injected during pre-processing.
383-
384-
/**
385-
* Request metadata schema - used in _meta field of requests, notifications, and results.
386-
* This is extracted for reuse but the canonical definition is in RequestParamsSchema.
387-
*/
388-
const RequestMetaSchema = z.looseObject({
389-
progressToken: ProgressTokenSchema.optional(),
390-
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
391-
});
375+
// Note: RequestParamsSchema, NotificationParamsSchema, and TaskAugmentedRequestParamsSchema
376+
// are re-exported from generated. They include RELATED_TASK_META_KEY in _meta, injected
377+
// during pre-processing.
392378

393379
/**
394380
* Checks if a value is a valid TaskAugmentedRequestParams.
@@ -671,7 +657,7 @@ export const ProgressSchema = z.object({
671657
});
672658

673659
export const ProgressNotificationParamsSchema = z.object({
674-
...NotificationsParamsSchema.shape,
660+
...NotificationParamsSchema.shape,
675661
...ProgressSchema.shape,
676662
/**
677663
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
@@ -870,7 +856,7 @@ export const CreateMessageResultWithToolsSchema = ResultSchema.extend({
870856
*
871857
* @category notifications/elicitation/complete
872858
*/
873-
export const ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
859+
export const ElicitationCompleteNotificationParamsSchema = NotificationParamsSchema.extend({
874860
/**
875861
* The ID of the elicitation that completed.
876862
*/
@@ -1015,7 +1001,6 @@ export type ProgressToken = Infer<typeof ProgressTokenSchema>;
10151001
export type Cursor = Infer<typeof CursorSchema>;
10161002
export type Request = Infer<typeof RequestSchema>;
10171003
export type TaskAugmentedRequestParams = Infer<typeof TaskAugmentedRequestParamsSchema>;
1018-
export type RequestMeta = Infer<typeof RequestMetaSchema>;
10191004
export type Notification = Infer<typeof NotificationSchema>;
10201005
export type Result = Infer<typeof ResultSchema>;
10211006
export type RequestId = Infer<typeof RequestIdSchema>;
@@ -1026,8 +1011,12 @@ export type JSONRPCErrorResponse = Infer<typeof JSONRPCErrorResponseSchema>;
10261011
export type JSONRPCResultResponse = Infer<typeof JSONRPCResultResponseSchema>;
10271012

10281013
export type JSONRPCMessage = Infer<typeof JSONRPCMessageSchema>;
1029-
export type RequestParams = Infer<typeof BaseRequestParamsSchema>;
1030-
export type NotificationParams = Infer<typeof NotificationsParamsSchema>;
1014+
export type RequestParams = Infer<typeof RequestParamsSchema>;
1015+
export type NotificationParams = Infer<typeof NotificationParamsSchema>;
1016+
/**
1017+
* Request metadata - the _meta field type from RequestParams.
1018+
*/
1019+
export type RequestMeta = RequestParams['_meta'];
10311020

10321021
/* Empty result */
10331022
export type EmptyResult = Infer<typeof EmptyResultSchema>;

0 commit comments

Comments
 (0)