@@ -15,6 +15,10 @@ import {
1515 IssueCommentSchema ,
1616 ListCommentsParams ,
1717 AddCommentParams ,
18+ IssueWorklog ,
19+ IssueWorklogContainer ,
20+ IssueWorklogContainerSchema ,
21+ IssueWorklogSchema ,
1822} from './vendor.atlassian.issues.types.js' ;
1923import {
2024 createAuthMissingError ,
@@ -24,6 +28,40 @@ import {
2428import { validateResponse } from '../utils/validation.util.js' ;
2529import { z } from 'zod' ;
2630
31+ // Worklog types for API interactions
32+ interface WorklogCreateData {
33+ timeSpentSeconds ?: number ;
34+ timeSpent ?: string ;
35+ started ?: string ;
36+ comment ?: string | { type : string ; version : number ; content : unknown [ ] } ;
37+ visibility ?: {
38+ type : string ;
39+ identifier ?: string ;
40+ value ?: string ;
41+ } ;
42+ adjustEstimate ?: string ;
43+ newEstimate ?: string ;
44+ reduceBy ?: string ;
45+ }
46+
47+ interface WorklogUpdateData {
48+ timeSpentSeconds ?: number ;
49+ timeSpent ?: string ;
50+ started ?: string ;
51+ comment ?: string | { type : string ; version : number ; content : unknown [ ] } ;
52+ visibility ?: {
53+ type : string ;
54+ identifier ?: string ;
55+ value ?: string ;
56+ } ;
57+ }
58+
59+ interface WorklogDeleteParams {
60+ adjustEstimate ?: string ;
61+ newEstimate ?: string ;
62+ increaseBy ?: string ;
63+ }
64+
2765// Create a contextualized logger for this file
2866const serviceLogger = Logger . forContext (
2967 'services/vendor.atlassian.issues.service.ts' ,
@@ -468,7 +506,7 @@ async function addComment(
468506 * @param {number } [params.startAt] - Pagination start index
469507 * @param {number } [params.maxResults] - Maximum number of results to return
470508 * @param {string[] } [params.expand] - Worklog data to expand in response
471- * @returns {Promise<any > } Promise containing the worklogs with pagination information
509+ * @returns {Promise<IssueWorklogContainer > } Promise containing the worklogs with pagination information
472510 * @throws {Error } If Atlassian credentials are missing or API request fails
473511 * @example
474512 * // Get worklogs for an issue with pagination
@@ -484,7 +522,7 @@ async function getWorklogs(
484522 maxResults ?: number ;
485523 expand ?: string [ ] ;
486524 } = { } ,
487- ) : Promise < unknown > {
525+ ) : Promise < IssueWorklogContainer > {
488526 const methodLogger = Logger . forContext (
489527 'services/vendor.atlassian.issues.service.ts' ,
490528 'getWorklogs' ,
@@ -526,9 +564,12 @@ async function getWorklogs(
526564
527565 try {
528566 const rawData = await fetchAtlassian ( credentials , path ) ;
529- // For worklogs, we don't have a specific schema validation yet
530- // so we'll return the raw data
531- return rawData ;
567+ // Validate response against schema
568+ return validateResponse (
569+ rawData ,
570+ IssueWorklogContainerSchema ,
571+ 'getWorklogs' ,
572+ ) ;
532573 } catch ( error ) {
533574 // McpError is already properly structured from fetchAtlassian
534575 if ( error instanceof McpError ) {
@@ -557,8 +598,8 @@ async function getWorklogs(
557598 * @async
558599 * @memberof VendorAtlassianIssuesService
559600 * @param {string } issueIdOrKey - The ID or key of the issue to add a worklog to
560- * @param {any } worklogData - Parameters for the worklog to add
561- * @returns {Promise<any > } Promise containing the created worklog information
601+ * @param {WorklogCreateData } worklogData - Parameters for the worklog to add
602+ * @returns {Promise<IssueWorklog > } Promise containing the created worklog information
562603 * @throws {Error } If Atlassian credentials are missing or API request fails
563604 * @example
564605 * // Add a worklog with time spent and comment
@@ -570,8 +611,8 @@ async function getWorklogs(
570611 */
571612async function addWorklog (
572613 issueIdOrKey : string ,
573- worklogData : any , // eslint-disable-line @typescript-eslint/no-explicit-any
574- ) : Promise < unknown > {
614+ worklogData : WorklogCreateData ,
615+ ) : Promise < IssueWorklog > {
575616 const methodLogger = Logger . forContext (
576617 'services/vendor.atlassian.issues.service.ts' ,
577618 'addWorklog' ,
@@ -629,7 +670,8 @@ async function addWorklog(
629670 body : requestBody ,
630671 } ) ;
631672
632- return response ;
673+ // Validate response against schema
674+ return validateResponse ( response , IssueWorklogSchema , 'addWorklog' ) ;
633675 } catch ( error ) {
634676 // McpError is already properly structured from fetchAtlassian
635677 if ( error instanceof McpError ) {
@@ -658,15 +700,15 @@ async function addWorklog(
658700 * @memberof VendorAtlassianIssuesService
659701 * @param {string } issueIdOrKey - The ID or key of the issue
660702 * @param {string } worklogId - The ID of the worklog to update
661- * @param {any } updateData - Parameters for the worklog update
662- * @returns {Promise<any > } Promise containing the updated worklog information
703+ * @param {WorklogUpdateData } updateData - Parameters for the worklog update
704+ * @returns {Promise<IssueWorklog > } Promise containing the updated worklog information
663705 * @throws {Error } If Atlassian credentials are missing or API request fails
664706 */
665707async function updateWorklog (
666708 issueIdOrKey : string ,
667709 worklogId : string ,
668- updateData : any , // eslint-disable-line @typescript-eslint/no-explicit-any
669- ) : Promise < unknown > {
710+ updateData : WorklogUpdateData ,
711+ ) : Promise < IssueWorklog > {
670712 const methodLogger = Logger . forContext (
671713 'services/vendor.atlassian.issues.service.ts' ,
672714 'updateWorklog' ,
@@ -693,7 +735,8 @@ async function updateWorklog(
693735 body : updateData ,
694736 } ) ;
695737
696- return response ;
738+ // Validate response against schema
739+ return validateResponse ( response , IssueWorklogSchema , 'updateWorklog' ) ;
697740 } catch ( error ) {
698741 if ( error instanceof McpError ) {
699742 throw error ;
@@ -720,14 +763,14 @@ async function updateWorklog(
720763 * @memberof VendorAtlassianIssuesService
721764 * @param {string } issueIdOrKey - The ID or key of the issue
722765 * @param {string } worklogId - The ID of the worklog to delete
723- * @param {any } [params={}] - Optional parameters for estimate adjustment
766+ * @param {WorklogDeleteParams } [params={}] - Optional parameters for estimate adjustment
724767 * @returns {Promise<void> } Promise that resolves when the worklog is deleted
725768 * @throws {Error } If Atlassian credentials are missing or API request fails
726769 */
727770async function deleteWorklog (
728771 issueIdOrKey : string ,
729772 worklogId : string ,
730- params : any = { } , // eslint-disable-line @typescript-eslint/no-explicit-any
773+ params : WorklogDeleteParams = { } ,
731774) : Promise < void > {
732775 const methodLogger = Logger . forContext (
733776 'services/vendor.atlassian.issues.service.ts' ,
0 commit comments