diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de5739..af1d6a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Added +- TypeScript type definitions. Thanks to [@AlexGalichenko](https://github.com/AlexGalichenko). +### Security +- Updated versions of vulnerable packages (form-data). ## [5.4.0] - 2025-03-27 ### Changed diff --git a/VERSION b/VERSION index 8a30e8f..585553d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.4.0 +5.4.1-SNAPSHOT diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..fd974fe --- /dev/null +++ b/index.d.ts @@ -0,0 +1,288 @@ +declare module '@reportportal/client-javascript' { + /** + * Configuration options for initializing the Report Portal client. + * + * @example + * ```typescript + * const rp = new ReportPortalClient({ + * endpoint: 'https://your.reportportal.server/api/v1', + * project: 'your_project_name', + * apiKey: 'your_api_key', + * }); + * ``` + */ + export interface ReportPortalConfig { + apiKey: string; + endpoint: string; + launch: string; + project: string; + headers?: Record; + debug?: boolean; + isLaunchMergeRequired?: boolean; + launchUuidPrint?: boolean; + launchUuidPrintOutput?: string; + restClientConfig?: Record; + token?: string; + } + + /** + * Options to start a new launch. + * + * @example + * ```typescript + * const launch = rp.startLaunch({ + * name: 'My Test Launch', + * startTime: rp.helpers.now(), + * }); + * ``` + */ + export interface LaunchOptions { + name?: string; + startTime?: string; + description?: string; + attributes?: Array<{ key: string; value?: string } | string>; + mode?: string; + id?: string; + } + + /** + * Options to start a new test item (e.g., test case or suite). + * + * @example + * ```typescript + * const testItem = rp.startTestItem({ + * name: 'My Test Case', + * type: 'TEST', + * startTime: rp.helpers.now(), + * }); + * ``` + */ + export interface StartTestItemOptions { + name: string; + type: string; + description?: string; + startTime?: string; + attributes?: Array<{ key: string; value?: string } | string>; + hasStats?: boolean; + } + + /** + * Options to send logs to Report Portal. + * + * @example + * ```typescript + * await rp.sendLog(testItem.tempId, { + * level: 'INFO', + * message: 'Step executed successfully', + * time: rp.helpers.now(), + * }); + * ``` + */ + export interface LogOptions { + level?: string; + message?: string; + time?: string; + file?: { + name: string; + content: string; + type: string; + }; + } + + /** + * Options to finish a test item. + * + * @example + * ```typescript + * await rp.finishTestItem(testItem.tempId, { + * status: 'PASSED', + * endTime: rp.helpers.now(), + * }); + * ``` + */ + export interface FinishTestItemOptions { + status?: string; + endTime?: string; + issue?: { + issueType: string; + comment?: string; + externalSystemIssues?: Array + }; + } + + /** + * Options to finish a launch. + * + * @example + * ```typescript + * await rp.finishLaunch(launch.tempId, { + * endTime: rp.helpers.now(), + * }); + * ``` + */ + export interface FinishLaunchOptions { + endTime?: string; + status?: string; + } + + /** + * Main Report Portal client for interacting with the API. + */ + export default class ReportPortalClient { + /** + * Initializes a new Report Portal client. + */ + constructor(config: ReportPortalConfig); + + /** + * Starts a new launch. + * @example + * ```typescript + * const launchObj = rpClient.startLaunch({ + * name: 'Client test', + * startTime: rpClient.helpers.now(), + * description: 'description of the launch', + * attributes: [ + * { + * 'key': 'yourKey', + * 'value': 'yourValue' + * }, + * { + * 'value': 'yourValue' + * } + * ], + * //this param used only when you need client to send data into the existing launch + * id: 'id' + * }); + * await launchObj.promise; + * ``` + */ + startLaunch(options: LaunchOptions): { tempId: string; promise: Promise }; + + /** + * Finishes an active launch. + * @example + * ```typescript + * const launchFinishObj = rpClient.finishLaunch(launchObj.tempId, { + * endTime: rpClient.helpers.now() + * }); + * await launchFinishObj.promise; + * ``` + */ + finishLaunch(launchId: string, options?: FinishLaunchOptions): Promise; + + /** + * Update the launch data + * @example + * ```typescript + * const updateLunch = rpClient.updateLaunch( + * launchObj.tempId, + * { + * description: 'new launch description', + * attributes: [ + * { + * key: 'yourKey', + * value: 'yourValue' + * }, + * { + * value: 'yourValue' + * } + * ], + * mode: 'DEBUG' + * } + * ); + * await updateLaunch.promise; + * ``` + */ + updateLaunch(options: LaunchOptions): { tempId: string; promise: Promise }; + + /** + * Starts a new test item under a launch or parent item. + * @example + * ```typescript + * const suiteObj = rpClient.startTestItem({ + * description: makeid(), + * name: makeid(), + * startTime: rpClient.helpers.now(), + * type: 'SUITE' + * }, launchObj.tempId); + * const stepObj = rpClient.startTestItem({ + * description: makeid(), + * name: makeid(), + * startTime: rpClient.helpers.now(), + * attributes: [ + * { + * key: 'yourKey', + * value: 'yourValue' + * }, + * { + * value: 'yourValue' + * } + * ], + * type: 'STEP' + * }, launchObj.tempId, suiteObj.tempId); + * ``` + */ + startTestItem(options: StartTestItemOptions, launchId: string, parentId?: string): { + tempId: string; + promise: Promise + }; + + /** + * Finishes a test item. + * @example + * ```typescript + * rpClient.finishTestItem(itemObj.tempId, { + * status: 'failed' + * }); + * ``` + */ + finishTestItem(itemId: string, options: FinishTestItemOptions): Promise; + + /** + * Sends a log entry to a test item. + * @example + * ```typescript + * await rpClient.sendLog(stepObj.tempId, { + * level: 'INFO', + * message: 'User clicks login button', + * time: rpClient.helpers.now() + * }); + * ``` + */ + sendLog(itemId: string, options: LogOptions): Promise; + + /** + * Waits for all test items to be finished. + * @example + * ```typescript + * await agent.getPromiseFinishAllItems(agent.tempLaunchId); + * ``` + */ + getPromiseFinishAllItems(launchId: string): Promise; + + /** + * Check if connection is established + * @example + * ```typescript + * await agent.checkConnect(); + * ``` + */ + checkConnect(): Promise; + + helpers: { + /** + * Generate ISO timestamp + * @example + * ```typescript + * await rpClient.sendLog(stepObj.tempId, { + * level: 'INFO', + * message: 'User clicks login button', + * time: rpClient.helpers.now() + * }); + * ``` + */ + now(): string + } + } +} diff --git a/package-lock.json b/package-lock.json index 81d3d8c..83b9de4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@reportportal/client-javascript", - "version": "5.3.1", + "version": "5.4.0", "license": "Apache-2.0", "dependencies": { "axios": "^1.8.4", @@ -1999,9 +1999,9 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "dependencies": { "balanced-match": "^1.0.0", @@ -2093,6 +2093,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2424,6 +2436,19 @@ "node": ">=6.0.0" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.811", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.811.tgz", @@ -2522,15 +2547,42 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/es-set-tostringtag": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", - "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", - "dev": true, + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", "dependencies": { - "get-intrinsic": "^1.1.3", - "has": "^1.0.3", - "has-tostringtag": "^1.0.0" + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" }, "engines": { "node": ">= 0.4" @@ -3225,12 +3277,14 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", "mime-types": "^2.1.12" }, "engines": { @@ -3260,7 +3314,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3317,15 +3370,23 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", - "dev": true, + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3340,6 +3401,18 @@ "node": ">=8.0.0" } }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -3399,9 +3472,9 @@ } }, "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dependencies": { "balanced-match": "^1.0.0" } @@ -3468,12 +3541,11 @@ } }, "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dev": true, - "dependencies": { - "get-intrinsic": "^1.1.3" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3546,10 +3618,9 @@ } }, "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true, + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", "engines": { "node": ">= 0.4" }, @@ -3558,12 +3629,11 @@ } }, "node_modules/has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dependencies": { - "has-symbols": "^1.0.2" + "has-symbols": "^1.0.3" }, "engines": { "node": ">= 0.4" @@ -3573,10 +3643,9 @@ } }, "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", - "dev": true, + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dependencies": { "function-bind": "^1.1.2" }, @@ -4879,6 +4948,14 @@ "tmpl": "1.0.5" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", diff --git a/package.json b/package.json index 4715146..431da88 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "/VERSION" ], "main": "./lib/report-portal-client", + "types": "./index.d.ts", "engines": { "node": ">=14.x" }, diff --git a/version_fragment b/version_fragment index acb503f..9eb7b90 100644 --- a/version_fragment +++ b/version_fragment @@ -1 +1 @@ -minor +patch