|
| 1 | +import { ADTClient } from 'abap-adt-api'; |
| 2 | +import { BaseHandler } from './BaseHandler.js'; |
| 3 | +import type { ToolDefinition } from '../types/tools.js'; |
| 4 | +import { AtcProposal } from 'abap-adt-api'; |
| 5 | + |
| 6 | +export class AtcHandlers extends BaseHandler { |
| 7 | + getTools(): ToolDefinition[] { |
| 8 | + return [ |
| 9 | + { |
| 10 | + name: 'atcCustomizing', |
| 11 | + description: 'Retrieves ATC customizing information.', |
| 12 | + inputSchema: { |
| 13 | + type: 'object', |
| 14 | + properties: {} |
| 15 | + } |
| 16 | + }, |
| 17 | + { |
| 18 | + name: 'atcCheckVariant', |
| 19 | + description: 'Retrieves information about an ATC check variant.', |
| 20 | + inputSchema: { |
| 21 | + type: 'object', |
| 22 | + properties: { |
| 23 | + variant: { |
| 24 | + type: 'string', |
| 25 | + description: 'The name of the ATC check variant.' |
| 26 | + } |
| 27 | + }, |
| 28 | + required: ['variant'] |
| 29 | + } |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'createAtcRun', |
| 33 | + description: 'Creates an ATC run.', |
| 34 | + inputSchema: { |
| 35 | + type: 'object', |
| 36 | + properties: { |
| 37 | + variant: { |
| 38 | + type: 'string', |
| 39 | + description: 'The name of the ATC check variant.' |
| 40 | + }, |
| 41 | + mainUrl: { |
| 42 | + type: 'string', |
| 43 | + description: 'The main URL for the ATC run.' |
| 44 | + }, |
| 45 | + maxResults: { |
| 46 | + type: 'number', |
| 47 | + description: 'The maximum number of results to retrieve.', |
| 48 | + optional: true |
| 49 | + } |
| 50 | + }, |
| 51 | + required: ['variant', 'mainUrl'] |
| 52 | + } |
| 53 | + }, |
| 54 | + { |
| 55 | + name: 'atcWorklists', |
| 56 | + description: 'Retrieves ATC worklists.', |
| 57 | + inputSchema: { |
| 58 | + type: 'object', |
| 59 | + properties: { |
| 60 | + runResultId: { |
| 61 | + type: 'string', |
| 62 | + description: 'The ID of the ATC run result.' |
| 63 | + }, |
| 64 | + timestamp: { |
| 65 | + type: 'number', |
| 66 | + description: 'The timestamp.', |
| 67 | + optional: true |
| 68 | + }, |
| 69 | + usedObjectSet: { |
| 70 | + type: 'string', |
| 71 | + description: 'The used object set.', |
| 72 | + optional: true |
| 73 | + }, |
| 74 | + includeExempted: { |
| 75 | + type: 'boolean', |
| 76 | + description: 'Whether to include exempted findings.', |
| 77 | + optional: true |
| 78 | + } |
| 79 | + }, |
| 80 | + required: ['runResultId'] |
| 81 | + } |
| 82 | + }, |
| 83 | + { |
| 84 | + name: 'atcUsers', |
| 85 | + description: 'Retrieves a list of ATC users.', |
| 86 | + inputSchema: { |
| 87 | + type: 'object', |
| 88 | + properties: {} |
| 89 | + } |
| 90 | + }, |
| 91 | + { |
| 92 | + name: 'atcExemptProposal', |
| 93 | + description: 'Retrieves an ATC exemption proposal.', |
| 94 | + inputSchema: { |
| 95 | + type: 'object', |
| 96 | + properties: { |
| 97 | + markerId: { |
| 98 | + type: 'string', |
| 99 | + description: 'The ID of the marker.' |
| 100 | + } |
| 101 | + }, |
| 102 | + required: ['markerId'] |
| 103 | + } |
| 104 | + }, |
| 105 | + { |
| 106 | + name: 'atcRequestExemption', |
| 107 | + description: 'Requests an ATC exemption.', |
| 108 | + inputSchema: { |
| 109 | + type: 'object', |
| 110 | + properties: { |
| 111 | + proposal: { |
| 112 | + type: 'object', |
| 113 | + description: 'The ATC exemption proposal.' |
| 114 | + } |
| 115 | + }, |
| 116 | + required: ['proposal'] |
| 117 | + } |
| 118 | + }, |
| 119 | + { |
| 120 | + name: 'isProposalMessage', |
| 121 | + description: 'Checks if a given object is a proposal message.', |
| 122 | + inputSchema: { |
| 123 | + type: 'object', |
| 124 | + properties: {} |
| 125 | + } |
| 126 | + }, |
| 127 | + { |
| 128 | + name: 'atcContactUri', |
| 129 | + description: 'Retrieves the contact URI for an ATC finding.', |
| 130 | + inputSchema: { |
| 131 | + type: 'object', |
| 132 | + properties: { |
| 133 | + findingUri: { |
| 134 | + type: 'string', |
| 135 | + description: 'The URI of the ATC finding.' |
| 136 | + } |
| 137 | + }, |
| 138 | + required: ['findingUri'] |
| 139 | + } |
| 140 | + }, |
| 141 | + { |
| 142 | + name: 'atcChangeContact', |
| 143 | + description: 'Changes the contact for an ATC finding.', |
| 144 | + inputSchema: { |
| 145 | + type: 'object', |
| 146 | + properties: { |
| 147 | + itemUri: { |
| 148 | + type: 'string', |
| 149 | + description: 'The URI of the item.' |
| 150 | + }, |
| 151 | + userId: { |
| 152 | + type: 'string', |
| 153 | + description: 'The ID of the user.' |
| 154 | + } |
| 155 | + }, |
| 156 | + required: ['itemUri', 'userId'] |
| 157 | + } |
| 158 | + } |
| 159 | + ]; |
| 160 | + } |
| 161 | + |
| 162 | + async handle(toolName: string, arguments_: any): Promise<any> { |
| 163 | + switch (toolName) { |
| 164 | + case 'atcCustomizing': |
| 165 | + return this.adtclient.atcCustomizing(); |
| 166 | + case 'atcCheckVariant': |
| 167 | + const atcCheckVariantArgs: { variant: string } = arguments_; |
| 168 | + return this.adtclient.atcCheckVariant(atcCheckVariantArgs.variant); |
| 169 | + case 'createAtcRun': |
| 170 | + const createAtcRunArgs: { variant: string, mainUrl: string, maxResults?: number } = arguments_; |
| 171 | + return this.adtclient.createAtcRun(createAtcRunArgs.variant, createAtcRunArgs.mainUrl, createAtcRunArgs.maxResults); |
| 172 | + case 'atcWorklists': |
| 173 | + const atcWorklistsArgs: { runResultId: string, timestamp?: number, usedObjectSet?: string, includeExempted?: boolean } = arguments_; |
| 174 | + return this.adtclient.atcWorklists(atcWorklistsArgs.runResultId, atcWorklistsArgs.timestamp || 0, atcWorklistsArgs.usedObjectSet || "", atcWorklistsArgs.includeExempted); |
| 175 | + case 'atcUsers': |
| 176 | + return this.adtclient.atcUsers(); |
| 177 | + case 'atcExemptProposal': |
| 178 | + const atcExemptProposalArgs: { markerId: string } = arguments_; |
| 179 | + return this.adtclient.atcExemptProposal(atcExemptProposalArgs.markerId); |
| 180 | + case 'atcRequestExemption': |
| 181 | + const atcRequestExemptionArgs: { proposal: AtcProposal } = arguments_; |
| 182 | + return this.adtclient.atcRequestExemption(atcRequestExemptionArgs.proposal); |
| 183 | + case 'isProposalMessage': |
| 184 | + return this.adtclient.isProposalMessage; |
| 185 | + case 'atcContactUri': |
| 186 | + const atcContactUriArgs: { findingUri: string } = arguments_; |
| 187 | + return this.adtclient.atcContactUri(atcContactUriArgs.findingUri); |
| 188 | + case 'atcChangeContact': |
| 189 | + const atcChangeContactArgs: { itemUri: string, userId: string } = arguments_; |
| 190 | + return this.adtclient.atcChangeContact(atcChangeContactArgs.itemUri, atcChangeContactArgs.userId); |
| 191 | + default: |
| 192 | + throw new Error(`Tool ${toolName} not implemented in AtcHandlers`); |
| 193 | + } |
| 194 | + } |
| 195 | +} |
0 commit comments