|
| 1 | +declare module '@reportportal/client-javascript' { |
| 2 | + /** |
| 3 | + * Configuration options for initializing the Report Portal client. |
| 4 | + * |
| 5 | + * @example |
| 6 | + * ```typescript |
| 7 | + * const rp = new ReportPortalClient({ |
| 8 | + * endpoint: 'https://your.reportportal.server/api/v1', |
| 9 | + * project: 'your_project_name', |
| 10 | + * apiKey: 'your_api_key', |
| 11 | + * }); |
| 12 | + * ``` |
| 13 | + */ |
| 14 | + export interface ReportPortalConfig { |
| 15 | + apiKey: string; |
| 16 | + endpoint: string; |
| 17 | + launch: string; |
| 18 | + project: string; |
| 19 | + headers?: Record<string, string>; |
| 20 | + debug?: boolean; |
| 21 | + isLaunchMergeRequired?: boolean; |
| 22 | + launchUuidPrint?: boolean; |
| 23 | + launchUuidPrintOutput?: string; |
| 24 | + restClientConfig?: Record<string, unknown>; |
| 25 | + token?: string; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Options to start a new launch. |
| 30 | + * |
| 31 | + * @example |
| 32 | + * ```typescript |
| 33 | + * const launch = rp.startLaunch({ |
| 34 | + * name: 'My Test Launch', |
| 35 | + * startTime: rp.helpers.now(), |
| 36 | + * }); |
| 37 | + * ``` |
| 38 | + */ |
| 39 | + export interface LaunchOptions { |
| 40 | + name?: string; |
| 41 | + startTime?: string; |
| 42 | + description?: string; |
| 43 | + attributes?: Array<{ key: string; value?: string } | string>; |
| 44 | + mode?: string; |
| 45 | + id?: string; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Options to start a new test item (e.g., test case or suite). |
| 50 | + * |
| 51 | + * @example |
| 52 | + * ```typescript |
| 53 | + * const testItem = rp.startTestItem({ |
| 54 | + * name: 'My Test Case', |
| 55 | + * type: 'TEST', |
| 56 | + * startTime: rp.helpers.now(), |
| 57 | + * }); |
| 58 | + * ``` |
| 59 | + */ |
| 60 | + export interface StartTestItemOptions { |
| 61 | + name: string; |
| 62 | + type: string; |
| 63 | + description?: string; |
| 64 | + startTime?: string; |
| 65 | + attributes?: Array<{ key: string; value?: string } | string>; |
| 66 | + hasStats?: boolean; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Options to send logs to Report Portal. |
| 71 | + * |
| 72 | + * @example |
| 73 | + * ```typescript |
| 74 | + * await rp.sendLog(testItem.tempId, { |
| 75 | + * level: 'INFO', |
| 76 | + * message: 'Step executed successfully', |
| 77 | + * time: rp.helpers.now(), |
| 78 | + * }); |
| 79 | + * ``` |
| 80 | + */ |
| 81 | + export interface LogOptions { |
| 82 | + level?: string; |
| 83 | + message?: string; |
| 84 | + time?: string; |
| 85 | + file?: { |
| 86 | + name: string; |
| 87 | + content: string; |
| 88 | + type: string; |
| 89 | + }; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Options to finish a test item. |
| 94 | + * |
| 95 | + * @example |
| 96 | + * ```typescript |
| 97 | + * await rp.finishTestItem(testItem.tempId, { |
| 98 | + * status: 'PASSED', |
| 99 | + * endTime: rp.helpers.now(), |
| 100 | + * }); |
| 101 | + * ``` |
| 102 | + */ |
| 103 | + export interface FinishTestItemOptions { |
| 104 | + status?: string; |
| 105 | + endTime?: string; |
| 106 | + issue?: { |
| 107 | + issueType: string; |
| 108 | + comment?: string; |
| 109 | + externalSystemIssues?: Array<any> |
| 110 | + }; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Options to finish a launch. |
| 115 | + * |
| 116 | + * @example |
| 117 | + * ```typescript |
| 118 | + * await rp.finishLaunch(launch.tempId, { |
| 119 | + * endTime: rp.helpers.now(), |
| 120 | + * }); |
| 121 | + * ``` |
| 122 | + */ |
| 123 | + export interface FinishLaunchOptions { |
| 124 | + endTime?: string; |
| 125 | + status?: string; |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Main Report Portal client for interacting with the API. |
| 130 | + */ |
| 131 | + export default class ReportPortalClient { |
| 132 | + /** |
| 133 | + * Initializes a new Report Portal client. |
| 134 | + */ |
| 135 | + constructor(config: ReportPortalConfig); |
| 136 | + |
| 137 | + /** |
| 138 | + * Starts a new launch. |
| 139 | + * @example |
| 140 | + * ```typescript |
| 141 | + * const launchObj = rpClient.startLaunch({ |
| 142 | + * name: 'Client test', |
| 143 | + * startTime: rpClient.helpers.now(), |
| 144 | + * description: 'description of the launch', |
| 145 | + * attributes: [ |
| 146 | + * { |
| 147 | + * 'key': 'yourKey', |
| 148 | + * 'value': 'yourValue' |
| 149 | + * }, |
| 150 | + * { |
| 151 | + * 'value': 'yourValue' |
| 152 | + * } |
| 153 | + * ], |
| 154 | + * //this param used only when you need client to send data into the existing launch |
| 155 | + * id: 'id' |
| 156 | + * }); |
| 157 | + * await launchObj.promise; |
| 158 | + * ``` |
| 159 | + */ |
| 160 | + startLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> }; |
| 161 | + |
| 162 | + /** |
| 163 | + * Finishes an active launch. |
| 164 | + * @example |
| 165 | + * ```typescript |
| 166 | + * const launchFinishObj = rpClient.finishLaunch(launchObj.tempId, { |
| 167 | + * endTime: rpClient.helpers.now() |
| 168 | + * }); |
| 169 | + * await launchFinishObj.promise; |
| 170 | + * ``` |
| 171 | + */ |
| 172 | + finishLaunch(launchId: string, options?: FinishLaunchOptions): Promise<any>; |
| 173 | + |
| 174 | + /** |
| 175 | + * Update the launch data |
| 176 | + * @example |
| 177 | + * ```typescript |
| 178 | + * const updateLunch = rpClient.updateLaunch( |
| 179 | + * launchObj.tempId, |
| 180 | + * { |
| 181 | + * description: 'new launch description', |
| 182 | + * attributes: [ |
| 183 | + * { |
| 184 | + * key: 'yourKey', |
| 185 | + * value: 'yourValue' |
| 186 | + * }, |
| 187 | + * { |
| 188 | + * value: 'yourValue' |
| 189 | + * } |
| 190 | + * ], |
| 191 | + * mode: 'DEBUG' |
| 192 | + * } |
| 193 | + * ); |
| 194 | + * await updateLaunch.promise; |
| 195 | + * ``` |
| 196 | + */ |
| 197 | + updateLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> }; |
| 198 | + |
| 199 | + /** |
| 200 | + * Starts a new test item under a launch or parent item. |
| 201 | + * @example |
| 202 | + * ```typescript |
| 203 | + * const suiteObj = rpClient.startTestItem({ |
| 204 | + * description: makeid(), |
| 205 | + * name: makeid(), |
| 206 | + * startTime: rpClient.helpers.now(), |
| 207 | + * type: 'SUITE' |
| 208 | + * }, launchObj.tempId); |
| 209 | + * const stepObj = rpClient.startTestItem({ |
| 210 | + * description: makeid(), |
| 211 | + * name: makeid(), |
| 212 | + * startTime: rpClient.helpers.now(), |
| 213 | + * attributes: [ |
| 214 | + * { |
| 215 | + * key: 'yourKey', |
| 216 | + * value: 'yourValue' |
| 217 | + * }, |
| 218 | + * { |
| 219 | + * value: 'yourValue' |
| 220 | + * } |
| 221 | + * ], |
| 222 | + * type: 'STEP' |
| 223 | + * }, launchObj.tempId, suiteObj.tempId); |
| 224 | + * ``` |
| 225 | + */ |
| 226 | + startTestItem(options: StartTestItemOptions, launchId: string, parentId?: string): { |
| 227 | + tempId: string; |
| 228 | + promise: Promise<any> |
| 229 | + }; |
| 230 | + |
| 231 | + /** |
| 232 | + * Finishes a test item. |
| 233 | + * @example |
| 234 | + * ```typescript |
| 235 | + * rpClient.finishTestItem(itemObj.tempId, { |
| 236 | + * status: 'failed' |
| 237 | + * }); |
| 238 | + * ``` |
| 239 | + */ |
| 240 | + finishTestItem(itemId: string, options: FinishTestItemOptions): Promise<any>; |
| 241 | + |
| 242 | + /** |
| 243 | + * Sends a log entry to a test item. |
| 244 | + * @example |
| 245 | + * ```typescript |
| 246 | + * await rpClient.sendLog(stepObj.tempId, { |
| 247 | + * level: 'INFO', |
| 248 | + * message: 'User clicks login button', |
| 249 | + * time: rpClient.helpers.now() |
| 250 | + * }); |
| 251 | + * ``` |
| 252 | + */ |
| 253 | + sendLog(itemId: string, options: LogOptions): Promise<any>; |
| 254 | + |
| 255 | + /** |
| 256 | + * Waits for all test items to be finished. |
| 257 | + * @example |
| 258 | + * ```typescript |
| 259 | + * await agent.getPromiseFinishAllItems(agent.tempLaunchId); |
| 260 | + * ``` |
| 261 | + */ |
| 262 | + getPromiseFinishAllItems(launchId: string): Promise<any>; |
| 263 | + |
| 264 | + /** |
| 265 | + * Check if connection is established |
| 266 | + * @example |
| 267 | + * ```typescript |
| 268 | + * await agent.checkConnect(); |
| 269 | + * ``` |
| 270 | + */ |
| 271 | + checkConnect(): Promise<any>; |
| 272 | + |
| 273 | + helpers: { |
| 274 | + /** |
| 275 | + * Generate ISO timestamp |
| 276 | + * @example |
| 277 | + * ```typescript |
| 278 | + * await rpClient.sendLog(stepObj.tempId, { |
| 279 | + * level: 'INFO', |
| 280 | + * message: 'User clicks login button', |
| 281 | + * time: rpClient.helpers.now() |
| 282 | + * }); |
| 283 | + * ``` |
| 284 | + */ |
| 285 | + now(): string |
| 286 | + } |
| 287 | + } |
| 288 | +} |
0 commit comments