@allurereport/service 3.6.1 → 3.7.0
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 +6 -3
- package/dist/history.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/legacyService.d.ts +41 -0
- package/dist/legacyService.js +127 -0
- package/dist/model.d.ts +36 -0
- package/dist/service.d.ts +7 -24
- package/dist/service.js +39 -59
- package/package.json +3 -3
package/dist/history.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { type AllureHistory } from "@allurereport/core-api";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AllureServiceApiClient } from "./model.js";
|
|
3
3
|
export declare class AllureRemoteHistory implements AllureHistory {
|
|
4
4
|
readonly params: {
|
|
5
|
-
allureServiceClient:
|
|
5
|
+
allureServiceClient: AllureServiceApiClient;
|
|
6
6
|
limit?: number;
|
|
7
|
+
repo?: string;
|
|
7
8
|
branch?: string;
|
|
8
9
|
};
|
|
9
10
|
constructor(params: {
|
|
10
|
-
allureServiceClient:
|
|
11
|
+
allureServiceClient: AllureServiceApiClient;
|
|
11
12
|
limit?: number;
|
|
13
|
+
repo?: string;
|
|
12
14
|
branch?: string;
|
|
13
15
|
});
|
|
14
16
|
readHistory(params?: {
|
|
17
|
+
repo?: string;
|
|
15
18
|
branch?: string;
|
|
16
19
|
}): Promise<import("@allurereport/core-api").HistoryDataPoint[]>;
|
|
17
20
|
appendHistory(): Promise<void>;
|
package/dist/history.js
CHANGED
|
@@ -8,7 +8,8 @@ export class AllureRemoteHistory {
|
|
|
8
8
|
const { limit } = this.params;
|
|
9
9
|
try {
|
|
10
10
|
const res = await this.params.allureServiceClient.downloadHistory({
|
|
11
|
-
|
|
11
|
+
repo: params?.repo || this.params.repo || undefined,
|
|
12
|
+
branch: params?.branch || this.params.branch || undefined,
|
|
12
13
|
limit,
|
|
13
14
|
});
|
|
14
15
|
return res?.map(normalizeHistoryDataPointUrls);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type HistoryDataPoint } from "@allurereport/core-api";
|
|
2
|
+
import { type Config } from "@allurereport/plugin-api";
|
|
3
|
+
import type { AllureServiceApiClient } from "./model.js";
|
|
4
|
+
export declare class AllureLegacyServiceClient implements AllureServiceApiClient {
|
|
5
|
+
#private;
|
|
6
|
+
readonly config: Config["allureService"];
|
|
7
|
+
constructor(config: Config["allureService"]);
|
|
8
|
+
downloadHistory(payload: {
|
|
9
|
+
repo?: string;
|
|
10
|
+
branch?: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
}): Promise<HistoryDataPoint[]>;
|
|
13
|
+
createReport(payload: {
|
|
14
|
+
reportName: string;
|
|
15
|
+
reportUuid?: string;
|
|
16
|
+
repo?: string;
|
|
17
|
+
branch?: string;
|
|
18
|
+
}): Promise<URL>;
|
|
19
|
+
completeReport(payload: {
|
|
20
|
+
reportUuid: string;
|
|
21
|
+
historyPoint: HistoryDataPoint;
|
|
22
|
+
}): Promise<unknown>;
|
|
23
|
+
deleteReport(payload: {
|
|
24
|
+
reportUuid: string;
|
|
25
|
+
pluginId?: string;
|
|
26
|
+
}): Promise<unknown>;
|
|
27
|
+
addReportAsset(payload: {
|
|
28
|
+
filename: string;
|
|
29
|
+
file?: Buffer;
|
|
30
|
+
filepath?: string;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): Promise<unknown>;
|
|
33
|
+
addReportFile(payload: {
|
|
34
|
+
reportUuid: string;
|
|
35
|
+
pluginId?: string;
|
|
36
|
+
filename: string;
|
|
37
|
+
file?: Buffer;
|
|
38
|
+
filepath?: string;
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<string>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _AllureLegacyServiceClient_client, _AllureLegacyServiceClient_url, _AllureLegacyServiceClient_reportUrl;
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
14
|
+
import { join as joinPosix } from "node:path/posix";
|
|
15
|
+
import { createServiceHttpClient } from "./utils/http.js";
|
|
16
|
+
const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
|
|
17
|
+
const UPLOAD_CONTENT_TYPE = "application/octet-stream";
|
|
18
|
+
const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
|
|
19
|
+
const createReportFileUrl = (reportUrl, reportFilename) => {
|
|
20
|
+
const fileUrl = new URL(reportUrl);
|
|
21
|
+
fileUrl.pathname = joinPosix(fileUrl.pathname, reportFilename);
|
|
22
|
+
fileUrl.search = "";
|
|
23
|
+
fileUrl.hash = "";
|
|
24
|
+
return fileUrl.toString();
|
|
25
|
+
};
|
|
26
|
+
const createFallbackReportUrl = (baseUrl, reportUuid) => {
|
|
27
|
+
const reportUrl = new URL(`${baseUrl}/`);
|
|
28
|
+
reportUrl.pathname = joinPosix(reportUrl.pathname, reportUuid);
|
|
29
|
+
return reportUrl;
|
|
30
|
+
};
|
|
31
|
+
export class AllureLegacyServiceClient {
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.config = config;
|
|
34
|
+
_AllureLegacyServiceClient_client.set(this, void 0);
|
|
35
|
+
_AllureLegacyServiceClient_url.set(this, void 0);
|
|
36
|
+
_AllureLegacyServiceClient_reportUrl.set(this, void 0);
|
|
37
|
+
if (!config?.accessToken) {
|
|
38
|
+
throw new Error("Allure service access token is required");
|
|
39
|
+
}
|
|
40
|
+
const { url } = JSON.parse(atob(config.accessToken.split(".")[1]));
|
|
41
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_url, url.replace(/\/$/, ""), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), config.accessToken), "f");
|
|
43
|
+
}
|
|
44
|
+
async downloadHistory(payload) {
|
|
45
|
+
const { branch, limit } = payload ?? {};
|
|
46
|
+
const { history } = await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").get("/projects/history", {
|
|
47
|
+
params: {
|
|
48
|
+
limit: limit ? encodeURIComponent(limit) : undefined,
|
|
49
|
+
branch: branch ? encodeURIComponent(branch) : undefined,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return history;
|
|
53
|
+
}
|
|
54
|
+
async createReport(payload) {
|
|
55
|
+
const { reportName, reportUuid, branch } = payload;
|
|
56
|
+
const { url } = await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post("/reports", {
|
|
57
|
+
body: {
|
|
58
|
+
reportName,
|
|
59
|
+
reportUuid,
|
|
60
|
+
branch,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_reportUrl, new URL(url), "f");
|
|
64
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_reportUrl, "f");
|
|
65
|
+
}
|
|
66
|
+
async completeReport(payload) {
|
|
67
|
+
const { reportUuid, historyPoint } = payload;
|
|
68
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/complete`, {
|
|
69
|
+
body: {
|
|
70
|
+
historyPoint,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async deleteReport(payload) {
|
|
75
|
+
const { reportUuid, pluginId = "" } = payload;
|
|
76
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/delete`, {
|
|
77
|
+
body: {
|
|
78
|
+
pluginId,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async addReportAsset(payload) {
|
|
83
|
+
const { filename, file, filepath, signal } = payload;
|
|
84
|
+
if (!file && !filepath) {
|
|
85
|
+
throw new Error("File or filepath is required");
|
|
86
|
+
}
|
|
87
|
+
let content = file;
|
|
88
|
+
if (!content) {
|
|
89
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
90
|
+
}
|
|
91
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
92
|
+
throw new Error(`Asset size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
93
|
+
}
|
|
94
|
+
const form = new FormData();
|
|
95
|
+
form.set("filename", filename);
|
|
96
|
+
form.set("file", createUploadBlob(content), filename);
|
|
97
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post("/assets/upload", {
|
|
98
|
+
body: form,
|
|
99
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
100
|
+
...(signal ? { signal } : {}),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async addReportFile(payload) {
|
|
104
|
+
const { reportUuid, filename, file, filepath, pluginId, signal } = payload;
|
|
105
|
+
const reportFilename = pluginId ? joinPosix(pluginId, filename) : filename;
|
|
106
|
+
if (!file && !filepath) {
|
|
107
|
+
throw new Error("File or filepath is required");
|
|
108
|
+
}
|
|
109
|
+
let content = file;
|
|
110
|
+
if (!content) {
|
|
111
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
112
|
+
}
|
|
113
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
114
|
+
throw new Error(`Report file size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
115
|
+
}
|
|
116
|
+
const form = new FormData();
|
|
117
|
+
form.set("filename", reportFilename);
|
|
118
|
+
form.set("file", createUploadBlob(content), reportFilename);
|
|
119
|
+
await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/upload`, {
|
|
120
|
+
body: form,
|
|
121
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
122
|
+
...(signal ? { signal } : {}),
|
|
123
|
+
});
|
|
124
|
+
return createReportFileUrl(__classPrivateFieldGet(this, _AllureLegacyServiceClient_reportUrl, "f") ?? createFallbackReportUrl(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), reportUuid), reportFilename);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
_AllureLegacyServiceClient_client = new WeakMap(), _AllureLegacyServiceClient_url = new WeakMap(), _AllureLegacyServiceClient_reportUrl = new WeakMap();
|
package/dist/model.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
+
import type { HistoryDataPoint } from "@allurereport/core-api";
|
|
1
2
|
export declare const DEFAULT_HISTORY_SERVICE_URL = "https://history.allurereport.org";
|
|
2
3
|
export declare const ALLURE_FILES_DIRNAME: string;
|
|
3
4
|
export declare const ALLURE_LOGIN_EXCHANGE_TOKEN_PATH: string;
|
|
4
5
|
export declare const ALLURE_ACCESS_TOKEN_PATH: string;
|
|
6
|
+
export interface AllureServiceApiClient {
|
|
7
|
+
downloadHistory(payload: {
|
|
8
|
+
repo?: string;
|
|
9
|
+
branch?: string;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}): Promise<HistoryDataPoint[]>;
|
|
12
|
+
createReport(payload: {
|
|
13
|
+
reportName: string;
|
|
14
|
+
reportUuid?: string;
|
|
15
|
+
repo?: string;
|
|
16
|
+
branch?: string;
|
|
17
|
+
}): Promise<URL>;
|
|
18
|
+
completeReport(payload: {
|
|
19
|
+
reportUuid: string;
|
|
20
|
+
historyPoint: HistoryDataPoint;
|
|
21
|
+
}): Promise<unknown>;
|
|
22
|
+
deleteReport(payload: {
|
|
23
|
+
reportUuid: string;
|
|
24
|
+
pluginId?: string;
|
|
25
|
+
}): Promise<unknown>;
|
|
26
|
+
addReportAsset(payload: {
|
|
27
|
+
filename: string;
|
|
28
|
+
file?: Buffer;
|
|
29
|
+
filepath?: string;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<unknown>;
|
|
32
|
+
addReportFile(payload: {
|
|
33
|
+
reportUuid: string;
|
|
34
|
+
pluginId?: string;
|
|
35
|
+
filename: string;
|
|
36
|
+
file?: Buffer;
|
|
37
|
+
filepath?: string;
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
}): Promise<string>;
|
|
40
|
+
}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,40 +1,21 @@
|
|
|
1
1
|
import { type HistoryDataPoint } from "@allurereport/core-api";
|
|
2
2
|
import { type Config } from "@allurereport/plugin-api";
|
|
3
|
-
|
|
3
|
+
import type { AllureServiceApiClient } from "./model.js";
|
|
4
|
+
export declare class AllureServiceClient implements AllureServiceApiClient {
|
|
4
5
|
#private;
|
|
5
6
|
readonly config: Config["allureService"];
|
|
6
7
|
constructor(config: Config["allureService"]);
|
|
7
|
-
decodeToken(token: string): any;
|
|
8
|
-
profile(): Promise<{
|
|
9
|
-
user: {
|
|
10
|
-
email: string;
|
|
11
|
-
};
|
|
12
|
-
project: any;
|
|
13
|
-
}>;
|
|
14
|
-
generateNewAccessToken(projectUuid: string): Promise<string>;
|
|
15
|
-
projects(): Promise<{
|
|
16
|
-
projects: {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
}[];
|
|
20
|
-
}>;
|
|
21
|
-
project(uuid: string): Promise<{
|
|
22
|
-
project: {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
}>;
|
|
27
8
|
downloadHistory(payload: {
|
|
9
|
+
repo?: string;
|
|
28
10
|
branch?: string;
|
|
29
11
|
limit?: number;
|
|
30
12
|
}): Promise<HistoryDataPoint[]>;
|
|
31
13
|
createReport(payload: {
|
|
32
14
|
reportName: string;
|
|
33
15
|
reportUuid?: string;
|
|
16
|
+
repo?: string;
|
|
34
17
|
branch?: string;
|
|
35
|
-
}): Promise<
|
|
36
|
-
url: string;
|
|
37
|
-
}>;
|
|
18
|
+
}): Promise<import("url").URL>;
|
|
38
19
|
completeReport(payload: {
|
|
39
20
|
reportUuid: string;
|
|
40
21
|
historyPoint: HistoryDataPoint;
|
|
@@ -47,6 +28,7 @@ export declare class AllureServiceClient {
|
|
|
47
28
|
filename: string;
|
|
48
29
|
file?: Buffer;
|
|
49
30
|
filepath?: string;
|
|
31
|
+
signal?: AbortSignal;
|
|
50
32
|
}): Promise<unknown>;
|
|
51
33
|
addReportFile(payload: {
|
|
52
34
|
reportUuid: string;
|
|
@@ -54,5 +36,6 @@ export declare class AllureServiceClient {
|
|
|
54
36
|
filename: string;
|
|
55
37
|
file?: Buffer;
|
|
56
38
|
filepath?: string;
|
|
39
|
+
signal?: AbortSignal;
|
|
57
40
|
}): Promise<string>;
|
|
58
41
|
}
|
package/dist/service.js
CHANGED
|
@@ -14,134 +14,114 @@ import { readFile } from "node:fs/promises";
|
|
|
14
14
|
import { join as joinPosix } from "node:path/posix";
|
|
15
15
|
import { createServiceHttpClient } from "./utils/http.js";
|
|
16
16
|
const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
|
|
17
|
+
const UPLOAD_CONTENT_TYPE = "application/octet-stream";
|
|
18
|
+
const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
|
|
19
|
+
const createReportUrl = (baseUrl, reportUuid) => `${baseUrl}/${reportUuid}`;
|
|
20
|
+
const createReportFileUrl = (baseUrl, reportUuid, reportFilename) => `${baseUrl}/${joinPosix(reportUuid, reportFilename)}`;
|
|
17
21
|
export class AllureServiceClient {
|
|
18
22
|
constructor(config) {
|
|
19
23
|
this.config = config;
|
|
20
24
|
_AllureServiceClient_client.set(this, void 0);
|
|
21
25
|
_AllureServiceClient_url.set(this, void 0);
|
|
26
|
+
if (!config?.url) {
|
|
27
|
+
throw new Error("Allure service URL is required");
|
|
28
|
+
}
|
|
22
29
|
if (!config?.accessToken) {
|
|
23
30
|
throw new Error("Allure service access token is required");
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
if (iss !== "allure-service" || !baseUrl || !projectId) {
|
|
27
|
-
throw new Error("Invalid access token");
|
|
28
|
-
}
|
|
29
|
-
__classPrivateFieldSet(this, _AllureServiceClient_url, baseUrl, "f");
|
|
32
|
+
__classPrivateFieldSet(this, _AllureServiceClient_url, config.url.replace(/\/$/, ""), "f");
|
|
30
33
|
__classPrivateFieldSet(this, _AllureServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), config.accessToken), "f");
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async profile() {
|
|
43
|
-
const { user, project } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/user/profile");
|
|
44
|
-
return {
|
|
45
|
-
user,
|
|
46
|
-
project,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
async generateNewAccessToken(projectUuid) {
|
|
50
|
-
const { accessToken } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/auth/tokens", {
|
|
51
|
-
body: {
|
|
52
|
-
projectId: projectUuid,
|
|
35
|
+
async downloadHistory(payload) {
|
|
36
|
+
const { repo, branch, limit } = payload ?? {};
|
|
37
|
+
const { history } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/api/history", {
|
|
38
|
+
params: {
|
|
39
|
+
limit: limit ? encodeURIComponent(limit) : undefined,
|
|
40
|
+
repo: repo ? encodeURIComponent(repo) : undefined,
|
|
41
|
+
branch: branch ? encodeURIComponent(branch) : undefined,
|
|
53
42
|
},
|
|
54
43
|
});
|
|
55
|
-
return accessToken;
|
|
56
|
-
}
|
|
57
|
-
async projects() {
|
|
58
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/projects");
|
|
59
|
-
}
|
|
60
|
-
async project(uuid) {
|
|
61
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get(`/projects/${uuid}`);
|
|
62
|
-
}
|
|
63
|
-
async downloadHistory(payload) {
|
|
64
|
-
const { branch, limit } = payload ?? {};
|
|
65
|
-
const params = new URLSearchParams();
|
|
66
|
-
if (limit) {
|
|
67
|
-
params.append("limit", encodeURIComponent(limit));
|
|
68
|
-
}
|
|
69
|
-
if (branch) {
|
|
70
|
-
params.append("branch", encodeURIComponent(branch));
|
|
71
|
-
}
|
|
72
|
-
const { history } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get(params.size > 0 ? `/projects/history?${params.toString()}` : "/projects/history");
|
|
73
44
|
return history;
|
|
74
45
|
}
|
|
75
46
|
async createReport(payload) {
|
|
76
|
-
const { reportName, reportUuid, branch } = payload;
|
|
77
|
-
|
|
47
|
+
const { reportName, reportUuid, repo, branch } = payload;
|
|
48
|
+
const { url } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/api/reports", {
|
|
78
49
|
body: {
|
|
79
50
|
reportName,
|
|
80
51
|
reportUuid,
|
|
52
|
+
repo,
|
|
81
53
|
branch,
|
|
82
54
|
},
|
|
83
55
|
});
|
|
56
|
+
return new URL(url, __classPrivateFieldGet(this, _AllureServiceClient_url, "f"));
|
|
84
57
|
}
|
|
85
58
|
async completeReport(payload) {
|
|
86
59
|
const { reportUuid, historyPoint } = payload;
|
|
87
|
-
|
|
60
|
+
const completedHistoryPoint = {
|
|
61
|
+
...historyPoint,
|
|
62
|
+
url: createReportUrl(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), reportUuid),
|
|
63
|
+
};
|
|
64
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/complete`, {
|
|
88
65
|
body: {
|
|
89
|
-
historyPoint,
|
|
66
|
+
historyPoint: completedHistoryPoint,
|
|
90
67
|
},
|
|
91
68
|
});
|
|
92
69
|
}
|
|
93
70
|
async deleteReport(payload) {
|
|
94
71
|
const { reportUuid, pluginId = "" } = payload;
|
|
95
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/delete`, {
|
|
72
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/delete`, {
|
|
96
73
|
body: {
|
|
97
74
|
pluginId,
|
|
98
75
|
},
|
|
99
76
|
});
|
|
100
77
|
}
|
|
101
78
|
async addReportAsset(payload) {
|
|
102
|
-
const { filename, file, filepath } = payload;
|
|
79
|
+
const { filename, file, filepath, signal } = payload;
|
|
103
80
|
if (!file && !filepath) {
|
|
104
81
|
throw new Error("File or filepath is required");
|
|
105
82
|
}
|
|
106
83
|
let content = file;
|
|
107
84
|
if (!content) {
|
|
108
|
-
content = await readFile(filepath);
|
|
85
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
109
86
|
}
|
|
110
87
|
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
111
88
|
throw new Error(`Asset size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
112
89
|
}
|
|
113
90
|
const form = new FormData();
|
|
114
91
|
form.set("filename", filename);
|
|
115
|
-
form.set("file", content);
|
|
116
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/assets/upload", {
|
|
92
|
+
form.set("file", createUploadBlob(content), filename);
|
|
93
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/api/assets/upload", {
|
|
117
94
|
body: form,
|
|
118
95
|
headers: {
|
|
119
96
|
"Content-Type": "multipart/form-data",
|
|
120
97
|
},
|
|
98
|
+
...(signal ? { signal } : {}),
|
|
121
99
|
});
|
|
122
100
|
}
|
|
123
101
|
async addReportFile(payload) {
|
|
124
|
-
const { reportUuid, filename, file, filepath, pluginId } = payload;
|
|
102
|
+
const { reportUuid, filename, file, filepath, pluginId, signal } = payload;
|
|
103
|
+
const reportFilename = pluginId ? joinPosix(pluginId, filename) : filename;
|
|
125
104
|
if (!file && !filepath) {
|
|
126
105
|
throw new Error("File or filepath is required");
|
|
127
106
|
}
|
|
128
107
|
let content = file;
|
|
129
108
|
if (!content) {
|
|
130
|
-
content = await readFile(filepath);
|
|
109
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
131
110
|
}
|
|
132
111
|
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
133
112
|
throw new Error(`Report file size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
134
113
|
}
|
|
135
114
|
const form = new FormData();
|
|
136
|
-
form.set("filename",
|
|
137
|
-
form.set("file", content);
|
|
138
|
-
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/upload`, {
|
|
115
|
+
form.set("filename", reportFilename);
|
|
116
|
+
form.set("file", createUploadBlob(content), reportFilename);
|
|
117
|
+
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/upload`, {
|
|
139
118
|
body: form,
|
|
140
119
|
headers: {
|
|
141
120
|
"Content-Type": "multipart/form-data",
|
|
142
121
|
},
|
|
122
|
+
...(signal ? { signal } : {}),
|
|
143
123
|
});
|
|
144
|
-
return
|
|
124
|
+
return createReportFileUrl(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), reportUuid, reportFilename);
|
|
145
125
|
}
|
|
146
126
|
}
|
|
147
127
|
_AllureServiceClient_client = new WeakMap(), _AllureServiceClient_url = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/service",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Allure Service API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"lint:fix": "oxlint --import-plugin --fix src test features stories"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@allurereport/core-api": "3.
|
|
34
|
-
"@allurereport/plugin-api": "3.
|
|
33
|
+
"@allurereport/core-api": "3.7.0",
|
|
34
|
+
"@allurereport/plugin-api": "3.7.0",
|
|
35
35
|
"axios": "^1.15.0",
|
|
36
36
|
"open": "^10.1.0"
|
|
37
37
|
},
|