@allurereport/service 3.0.0-beta.20 → 3.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/history.d.ts +3 -3
- package/dist/history.js +2 -8
- package/dist/service.d.ts +17 -16
- package/dist/service.js +43 -45
- package/dist/utils/http.js +6 -5
- package/package.json +4 -4
package/dist/history.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AllureHistory
|
|
1
|
+
import type { AllureHistory } from "@allurereport/core-api";
|
|
2
2
|
import type { AllureServiceClient } from "./service.js";
|
|
3
3
|
export declare class AllureRemoteHistory implements AllureHistory {
|
|
4
4
|
readonly allureServiceClient: AllureServiceClient;
|
|
5
5
|
constructor(allureServiceClient: AllureServiceClient);
|
|
6
|
-
readHistory(branch
|
|
7
|
-
appendHistory(
|
|
6
|
+
readHistory(branch: string): Promise<import("@allurereport/core-api").HistoryDataPoint[]>;
|
|
7
|
+
appendHistory(): Promise<void>;
|
|
8
8
|
}
|
package/dist/history.js
CHANGED
|
@@ -5,9 +5,7 @@ export class AllureRemoteHistory {
|
|
|
5
5
|
}
|
|
6
6
|
async readHistory(branch) {
|
|
7
7
|
try {
|
|
8
|
-
const res = await this.allureServiceClient.downloadHistory(
|
|
9
|
-
branch,
|
|
10
|
-
});
|
|
8
|
+
const res = await this.allureServiceClient.downloadHistory(branch);
|
|
11
9
|
return res;
|
|
12
10
|
}
|
|
13
11
|
catch (err) {
|
|
@@ -17,10 +15,6 @@ export class AllureRemoteHistory {
|
|
|
17
15
|
throw err;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
async appendHistory(
|
|
21
|
-
await this.allureServiceClient.appendHistory({
|
|
22
|
-
history: data,
|
|
23
|
-
branch,
|
|
24
|
-
});
|
|
18
|
+
async appendHistory() {
|
|
25
19
|
}
|
|
26
20
|
}
|
package/dist/service.d.ts
CHANGED
|
@@ -5,20 +5,28 @@ export declare class AllureServiceClient {
|
|
|
5
5
|
readonly config: Config["allureService"] & {
|
|
6
6
|
pollingDelay?: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
currentProjectUuid: string | undefined;
|
|
9
9
|
constructor(config: Config["allureService"] & {
|
|
10
10
|
pollingDelay?: number;
|
|
11
11
|
});
|
|
12
12
|
setProject(project: string): void;
|
|
13
|
-
login(): Promise<
|
|
13
|
+
login(): Promise<any>;
|
|
14
14
|
logout(): Promise<void>;
|
|
15
15
|
profile(): Promise<{
|
|
16
16
|
email: string;
|
|
17
17
|
}>;
|
|
18
18
|
projects(): Promise<{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
projects: {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
project(uuid: string): Promise<{
|
|
25
|
+
project: {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
22
30
|
createProject(payload: {
|
|
23
31
|
name: string;
|
|
24
32
|
}): Promise<{
|
|
@@ -26,26 +34,19 @@ export declare class AllureServiceClient {
|
|
|
26
34
|
name: string;
|
|
27
35
|
}>;
|
|
28
36
|
deleteProject(payload: {
|
|
29
|
-
name: string;
|
|
30
|
-
}): Promise<{
|
|
31
37
|
id: string;
|
|
32
|
-
name: string;
|
|
33
|
-
}>;
|
|
34
|
-
appendHistory(payload: {
|
|
35
|
-
history: HistoryDataPoint;
|
|
36
|
-
branch?: string;
|
|
37
38
|
}): Promise<unknown>;
|
|
38
|
-
downloadHistory(
|
|
39
|
-
branch?: string;
|
|
40
|
-
}): Promise<HistoryDataPoint[]>;
|
|
39
|
+
downloadHistory(branch: string): Promise<HistoryDataPoint[]>;
|
|
41
40
|
createReport(payload: {
|
|
42
41
|
reportName: string;
|
|
43
42
|
reportUuid?: string;
|
|
43
|
+
branch?: string;
|
|
44
44
|
}): Promise<{
|
|
45
45
|
url: string;
|
|
46
46
|
}>;
|
|
47
47
|
completeReport(payload: {
|
|
48
48
|
reportUuid: string;
|
|
49
|
+
historyPoint: HistoryDataPoint;
|
|
49
50
|
}): Promise<unknown>;
|
|
50
51
|
addReportAsset(payload: {
|
|
51
52
|
filename: string;
|
|
@@ -54,7 +55,7 @@ export declare class AllureServiceClient {
|
|
|
54
55
|
}): Promise<unknown>;
|
|
55
56
|
addReportFile(payload: {
|
|
56
57
|
reportUuid: string;
|
|
57
|
-
pluginId
|
|
58
|
+
pluginId?: string;
|
|
58
59
|
filename: string;
|
|
59
60
|
file?: Buffer;
|
|
60
61
|
filepath?: string;
|
package/dist/service.js
CHANGED
|
@@ -9,14 +9,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _AllureServiceClient_client, _AllureServiceClient_url, _AllureServiceClient_pollingDelay;
|
|
12
|
+
var _AllureServiceClient_instances, _AllureServiceClient_client, _AllureServiceClient_url, _AllureServiceClient_pollingDelay, _AllureServiceClient_getClientUrl;
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
14
14
|
import { join as joinPosix } from "node:path/posix";
|
|
15
15
|
import open from "open";
|
|
16
16
|
import { createServiceHttpClient } from "./utils/http.js";
|
|
17
17
|
import { decryptExchangeToken, deleteAccessToken, writeAccessToken, writeExchangeToken } from "./utils/token.js";
|
|
18
|
+
const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
|
|
18
19
|
export class AllureServiceClient {
|
|
19
20
|
constructor(config) {
|
|
21
|
+
_AllureServiceClient_instances.add(this);
|
|
20
22
|
this.config = config;
|
|
21
23
|
_AllureServiceClient_client.set(this, void 0);
|
|
22
24
|
_AllureServiceClient_url.set(this, void 0);
|
|
@@ -27,14 +29,15 @@ export class AllureServiceClient {
|
|
|
27
29
|
__classPrivateFieldSet(this, _AllureServiceClient_url, config.url, "f");
|
|
28
30
|
__classPrivateFieldSet(this, _AllureServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), config?.accessToken), "f");
|
|
29
31
|
__classPrivateFieldSet(this, _AllureServiceClient_pollingDelay, config?.pollingDelay ?? 2500, "f");
|
|
30
|
-
this.
|
|
32
|
+
this.currentProjectUuid = config?.project;
|
|
31
33
|
}
|
|
32
34
|
setProject(project) {
|
|
33
|
-
this.
|
|
35
|
+
this.currentProjectUuid = project;
|
|
34
36
|
}
|
|
35
37
|
async login() {
|
|
38
|
+
const clientUrl = await __classPrivateFieldGet(this, _AllureServiceClient_instances, "m", _AllureServiceClient_getClientUrl).call(this);
|
|
36
39
|
const exchangeToken = await writeExchangeToken();
|
|
37
|
-
const connectUrl = new URL("/connect",
|
|
40
|
+
const connectUrl = new URL("/connect", clientUrl);
|
|
38
41
|
connectUrl.searchParams.set("token", decryptExchangeToken(exchangeToken));
|
|
39
42
|
await open(connectUrl.toString());
|
|
40
43
|
let currentExchangeAttemptTimeout;
|
|
@@ -42,7 +45,7 @@ export class AllureServiceClient {
|
|
|
42
45
|
const makeExchangeAttempt = () => {
|
|
43
46
|
return globalThis.setTimeout(async () => {
|
|
44
47
|
const token = decryptExchangeToken(exchangeToken);
|
|
45
|
-
const { accessToken } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/
|
|
48
|
+
const { accessToken } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/auth/exchange", {
|
|
46
49
|
headers: {
|
|
47
50
|
"Content-Type": "application/json",
|
|
48
51
|
},
|
|
@@ -66,67 +69,53 @@ export class AllureServiceClient {
|
|
|
66
69
|
await deleteAccessToken();
|
|
67
70
|
}
|
|
68
71
|
async profile() {
|
|
69
|
-
|
|
72
|
+
const { user } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/user/profile");
|
|
73
|
+
return user;
|
|
70
74
|
}
|
|
71
75
|
async projects() {
|
|
72
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/
|
|
76
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/projects");
|
|
77
|
+
}
|
|
78
|
+
async project(uuid) {
|
|
79
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get(`/projects/${uuid}`);
|
|
73
80
|
}
|
|
74
81
|
async createProject(payload) {
|
|
75
|
-
|
|
82
|
+
const { project } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/projects", {
|
|
76
83
|
body: payload,
|
|
77
84
|
});
|
|
85
|
+
return project;
|
|
78
86
|
}
|
|
79
87
|
async deleteProject(payload) {
|
|
80
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").
|
|
81
|
-
body: payload,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
async appendHistory(payload) {
|
|
85
|
-
if (!this.project) {
|
|
86
|
-
throw new Error("Project is not set");
|
|
87
|
-
}
|
|
88
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/api/history/append", {
|
|
89
|
-
headers: {
|
|
90
|
-
"Content-Type": "application/json",
|
|
91
|
-
},
|
|
92
|
-
body: {
|
|
93
|
-
...payload,
|
|
94
|
-
project: this.project,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
88
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").delete(`/projects/${payload.id}`);
|
|
97
89
|
}
|
|
98
|
-
async downloadHistory(
|
|
99
|
-
if (!this.
|
|
90
|
+
async downloadHistory(branch) {
|
|
91
|
+
if (!this.currentProjectUuid) {
|
|
100
92
|
throw new Error("Project is not set");
|
|
101
93
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
project: this.project,
|
|
105
|
-
...payload,
|
|
106
|
-
},
|
|
107
|
-
});
|
|
94
|
+
const { history } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get(`/projects/${this.currentProjectUuid}/${branch}/history`);
|
|
95
|
+
return history;
|
|
108
96
|
}
|
|
109
97
|
async createReport(payload) {
|
|
110
|
-
const { reportName, reportUuid } = payload;
|
|
111
|
-
if (!this.
|
|
98
|
+
const { reportName, reportUuid, branch } = payload;
|
|
99
|
+
if (!this.currentProjectUuid) {
|
|
112
100
|
throw new Error("Project is not set");
|
|
113
101
|
}
|
|
114
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/
|
|
102
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/reports", {
|
|
115
103
|
body: {
|
|
116
|
-
|
|
104
|
+
projectUuid: this.currentProjectUuid,
|
|
117
105
|
reportName,
|
|
118
106
|
reportUuid,
|
|
107
|
+
branch,
|
|
119
108
|
},
|
|
120
109
|
});
|
|
121
110
|
}
|
|
122
111
|
async completeReport(payload) {
|
|
123
|
-
const { reportUuid } = payload;
|
|
124
|
-
if (!this.
|
|
112
|
+
const { reportUuid, historyPoint } = payload;
|
|
113
|
+
if (!this.currentProjectUuid) {
|
|
125
114
|
throw new Error("Project is not set");
|
|
126
115
|
}
|
|
127
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(
|
|
116
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/complete`, {
|
|
128
117
|
body: {
|
|
129
|
-
|
|
118
|
+
historyPoint,
|
|
130
119
|
},
|
|
131
120
|
});
|
|
132
121
|
}
|
|
@@ -139,10 +128,13 @@ export class AllureServiceClient {
|
|
|
139
128
|
if (!content) {
|
|
140
129
|
content = await readFile(filepath);
|
|
141
130
|
}
|
|
131
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
132
|
+
throw new Error(`Asset size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
133
|
+
}
|
|
142
134
|
const form = new FormData();
|
|
143
135
|
form.set("filename", filename);
|
|
144
136
|
form.set("file", content);
|
|
145
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/
|
|
137
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/assets/upload", {
|
|
146
138
|
body: form,
|
|
147
139
|
headers: {
|
|
148
140
|
"Content-Type": "multipart/form-data",
|
|
@@ -158,10 +150,13 @@ export class AllureServiceClient {
|
|
|
158
150
|
if (!content) {
|
|
159
151
|
content = await readFile(filepath);
|
|
160
152
|
}
|
|
153
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
154
|
+
throw new Error(`Report file size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
155
|
+
}
|
|
161
156
|
const form = new FormData();
|
|
162
|
-
form.set("filename", joinPosix(pluginId, filename));
|
|
157
|
+
form.set("filename", pluginId ? joinPosix(pluginId, filename) : filename);
|
|
163
158
|
form.set("file", content);
|
|
164
|
-
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/
|
|
159
|
+
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/upload`, {
|
|
165
160
|
body: form,
|
|
166
161
|
headers: {
|
|
167
162
|
"Content-Type": "multipart/form-data",
|
|
@@ -170,4 +165,7 @@ export class AllureServiceClient {
|
|
|
170
165
|
return joinPosix(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), reportUuid, filename);
|
|
171
166
|
}
|
|
172
167
|
}
|
|
173
|
-
_AllureServiceClient_client = new WeakMap(), _AllureServiceClient_url = new WeakMap(), _AllureServiceClient_pollingDelay = new WeakMap()
|
|
168
|
+
_AllureServiceClient_client = new WeakMap(), _AllureServiceClient_url = new WeakMap(), _AllureServiceClient_pollingDelay = new WeakMap(), _AllureServiceClient_instances = new WeakSet(), _AllureServiceClient_getClientUrl = async function _AllureServiceClient_getClientUrl() {
|
|
169
|
+
const { url } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/info");
|
|
170
|
+
return url;
|
|
171
|
+
};
|
package/dist/utils/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, {
|
|
1
|
+
import axios, { isAxiosError } from "axios";
|
|
2
2
|
import { DEFAULT_HISTORY_SERVICE_URL } from "../model.js";
|
|
3
3
|
import { readAccessToken } from "./token.js";
|
|
4
4
|
export class KnownError extends Error {
|
|
@@ -46,15 +46,16 @@ export const createServiceHttpClient = (historyServiceURL = DEFAULT_HISTORY_SERV
|
|
|
46
46
|
return res.data;
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
|
-
|
|
49
|
+
const axiosError = isAxiosError(err);
|
|
50
|
+
if (!axiosError) {
|
|
50
51
|
throw err;
|
|
51
52
|
}
|
|
52
53
|
const { status = 500 } = err.response ?? {};
|
|
54
|
+
const errorMessage = err.response?.data?.error || err.response?.data || err.message;
|
|
53
55
|
if (status < 500) {
|
|
54
|
-
throw new KnownError(
|
|
56
|
+
throw new KnownError(errorMessage, status);
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
throw new UnknownError(response?.data ?? errors?.[0]?.message?.trim?.() ?? message, stack);
|
|
58
|
+
throw new UnknownError(errorMessage, err.stack);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/service",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.22",
|
|
4
4
|
"description": "Allure Service API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"test": "rimraf ./out && vitest run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.0.0-beta.
|
|
34
|
-
"@allurereport/plugin-api": "3.0.0-beta.
|
|
35
|
-
"axios": "^1.
|
|
33
|
+
"@allurereport/core-api": "3.0.0-beta.22",
|
|
34
|
+
"@allurereport/plugin-api": "3.0.0-beta.22",
|
|
35
|
+
"axios": "^1.13.1",
|
|
36
36
|
"open": "^10.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|