@allurereport/service 3.6.2 → 3.8.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 +128 -0
- package/dist/model.d.ts +36 -0
- package/dist/service.d.ts +7 -24
- package/dist/service.js +38 -59
- package/dist/utils/token.d.ts +4 -0
- package/dist/utils/token.js +22 -0
- package/package.json +4 -4
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,128 @@
|
|
|
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
|
+
import { parseServiceToken } from "./utils/token.js";
|
|
17
|
+
const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
|
|
18
|
+
const UPLOAD_CONTENT_TYPE = "application/octet-stream";
|
|
19
|
+
const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
|
|
20
|
+
const createReportFileUrl = (reportUrl, reportFilename) => {
|
|
21
|
+
const fileUrl = new URL(reportUrl);
|
|
22
|
+
fileUrl.pathname = joinPosix(fileUrl.pathname, reportFilename);
|
|
23
|
+
fileUrl.search = "";
|
|
24
|
+
fileUrl.hash = "";
|
|
25
|
+
return fileUrl.toString();
|
|
26
|
+
};
|
|
27
|
+
const createFallbackReportUrl = (baseUrl, reportUuid) => {
|
|
28
|
+
const reportUrl = new URL(`${baseUrl}/`);
|
|
29
|
+
reportUrl.pathname = joinPosix(reportUrl.pathname, reportUuid);
|
|
30
|
+
return reportUrl;
|
|
31
|
+
};
|
|
32
|
+
export class AllureLegacyServiceClient {
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.config = config;
|
|
35
|
+
_AllureLegacyServiceClient_client.set(this, void 0);
|
|
36
|
+
_AllureLegacyServiceClient_url.set(this, void 0);
|
|
37
|
+
_AllureLegacyServiceClient_reportUrl.set(this, void 0);
|
|
38
|
+
if (!config?.accessToken) {
|
|
39
|
+
throw new Error("Allure service access token is required");
|
|
40
|
+
}
|
|
41
|
+
const { accessToken, url } = parseServiceToken(config.accessToken);
|
|
42
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_url, url.replace(/\/$/, ""), "f");
|
|
43
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), accessToken), "f");
|
|
44
|
+
}
|
|
45
|
+
async downloadHistory(payload) {
|
|
46
|
+
const { branch, limit } = payload ?? {};
|
|
47
|
+
const { history } = await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").get("/projects/history", {
|
|
48
|
+
params: {
|
|
49
|
+
limit: limit ? encodeURIComponent(limit) : undefined,
|
|
50
|
+
branch: branch ? encodeURIComponent(branch) : undefined,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
return history;
|
|
54
|
+
}
|
|
55
|
+
async createReport(payload) {
|
|
56
|
+
const { reportName, reportUuid, branch } = payload;
|
|
57
|
+
const { url } = await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post("/reports", {
|
|
58
|
+
body: {
|
|
59
|
+
reportName,
|
|
60
|
+
reportUuid,
|
|
61
|
+
branch,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
__classPrivateFieldSet(this, _AllureLegacyServiceClient_reportUrl, new URL(url), "f");
|
|
65
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_reportUrl, "f");
|
|
66
|
+
}
|
|
67
|
+
async completeReport(payload) {
|
|
68
|
+
const { reportUuid, historyPoint } = payload;
|
|
69
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/complete`, {
|
|
70
|
+
body: {
|
|
71
|
+
historyPoint,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async deleteReport(payload) {
|
|
76
|
+
const { reportUuid, pluginId = "" } = payload;
|
|
77
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/delete`, {
|
|
78
|
+
body: {
|
|
79
|
+
pluginId,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async addReportAsset(payload) {
|
|
84
|
+
const { filename, file, filepath, signal } = payload;
|
|
85
|
+
if (!file && !filepath) {
|
|
86
|
+
throw new Error("File or filepath is required");
|
|
87
|
+
}
|
|
88
|
+
let content = file;
|
|
89
|
+
if (!content) {
|
|
90
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
91
|
+
}
|
|
92
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
93
|
+
throw new Error(`Asset size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
94
|
+
}
|
|
95
|
+
const form = new FormData();
|
|
96
|
+
form.set("filename", filename);
|
|
97
|
+
form.set("file", createUploadBlob(content), filename);
|
|
98
|
+
return __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post("/assets/upload", {
|
|
99
|
+
body: form,
|
|
100
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
101
|
+
...(signal ? { signal } : {}),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async addReportFile(payload) {
|
|
105
|
+
const { reportUuid, filename, file, filepath, pluginId, signal } = payload;
|
|
106
|
+
const reportFilename = pluginId ? joinPosix(pluginId, filename) : filename;
|
|
107
|
+
if (!file && !filepath) {
|
|
108
|
+
throw new Error("File or filepath is required");
|
|
109
|
+
}
|
|
110
|
+
let content = file;
|
|
111
|
+
if (!content) {
|
|
112
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
113
|
+
}
|
|
114
|
+
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
115
|
+
throw new Error(`Report file size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
116
|
+
}
|
|
117
|
+
const form = new FormData();
|
|
118
|
+
form.set("filename", reportFilename);
|
|
119
|
+
form.set("file", createUploadBlob(content), reportFilename);
|
|
120
|
+
await __classPrivateFieldGet(this, _AllureLegacyServiceClient_client, "f").post(`/reports/${reportUuid}/upload`, {
|
|
121
|
+
body: form,
|
|
122
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
123
|
+
...(signal ? { signal } : {}),
|
|
124
|
+
});
|
|
125
|
+
return createReportFileUrl(__classPrivateFieldGet(this, _AllureLegacyServiceClient_reportUrl, "f") ?? createFallbackReportUrl(__classPrivateFieldGet(this, _AllureLegacyServiceClient_url, "f"), reportUuid), reportFilename);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_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
|
@@ -13,7 +13,12 @@ var _AllureServiceClient_client, _AllureServiceClient_url;
|
|
|
13
13
|
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
|
+
import { parseServiceToken } from "./utils/token.js";
|
|
16
17
|
const ASSET_MAX_FILE_SIZE = 200 * 1024 * 1024;
|
|
18
|
+
const UPLOAD_CONTENT_TYPE = "application/octet-stream";
|
|
19
|
+
const createUploadBlob = (content) => new Blob([content], { type: UPLOAD_CONTENT_TYPE });
|
|
20
|
+
const createReportUrl = (baseUrl, reportUuid) => `${baseUrl}/${reportUuid}`;
|
|
21
|
+
const createReportFileUrl = (baseUrl, reportUuid, reportFilename) => `${baseUrl}/${joinPosix(reportUuid, reportFilename)}`;
|
|
17
22
|
export class AllureServiceClient {
|
|
18
23
|
constructor(config) {
|
|
19
24
|
this.config = config;
|
|
@@ -22,126 +27,100 @@ export class AllureServiceClient {
|
|
|
22
27
|
if (!config?.accessToken) {
|
|
23
28
|
throw new Error("Allure service access token is required");
|
|
24
29
|
}
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
throw new Error("Invalid access token");
|
|
28
|
-
}
|
|
29
|
-
__classPrivateFieldSet(this, _AllureServiceClient_url, baseUrl, "f");
|
|
30
|
+
const { url } = parseServiceToken(config.accessToken);
|
|
31
|
+
__classPrivateFieldSet(this, _AllureServiceClient_url, url.replace(/\/$/, ""), "f");
|
|
30
32
|
__classPrivateFieldSet(this, _AllureServiceClient_client, createServiceHttpClient(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), config.accessToken), "f");
|
|
31
33
|
}
|
|
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,
|
|
34
|
+
async downloadHistory(payload) {
|
|
35
|
+
const { repo, branch, limit } = payload ?? {};
|
|
36
|
+
const { history } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").get("/api/history", {
|
|
37
|
+
params: {
|
|
38
|
+
limit: limit ? encodeURIComponent(limit) : undefined,
|
|
39
|
+
repo: repo ? encodeURIComponent(repo) : undefined,
|
|
40
|
+
branch: branch ? encodeURIComponent(branch) : undefined,
|
|
53
41
|
},
|
|
54
42
|
});
|
|
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
43
|
return history;
|
|
74
44
|
}
|
|
75
45
|
async createReport(payload) {
|
|
76
|
-
const { reportName, reportUuid, branch } = payload;
|
|
77
|
-
|
|
46
|
+
const { reportName, reportUuid, repo, branch } = payload;
|
|
47
|
+
const { url } = await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/api/reports", {
|
|
78
48
|
body: {
|
|
79
49
|
reportName,
|
|
80
50
|
reportUuid,
|
|
51
|
+
repo,
|
|
81
52
|
branch,
|
|
82
53
|
},
|
|
83
54
|
});
|
|
55
|
+
return new URL(url, __classPrivateFieldGet(this, _AllureServiceClient_url, "f"));
|
|
84
56
|
}
|
|
85
57
|
async completeReport(payload) {
|
|
86
58
|
const { reportUuid, historyPoint } = payload;
|
|
87
|
-
|
|
59
|
+
const completedHistoryPoint = {
|
|
60
|
+
...historyPoint,
|
|
61
|
+
url: createReportUrl(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), reportUuid),
|
|
62
|
+
};
|
|
63
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/complete`, {
|
|
88
64
|
body: {
|
|
89
|
-
historyPoint,
|
|
65
|
+
historyPoint: completedHistoryPoint,
|
|
90
66
|
},
|
|
91
67
|
});
|
|
92
68
|
}
|
|
93
69
|
async deleteReport(payload) {
|
|
94
70
|
const { reportUuid, pluginId = "" } = payload;
|
|
95
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/delete`, {
|
|
71
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/delete`, {
|
|
96
72
|
body: {
|
|
97
73
|
pluginId,
|
|
98
74
|
},
|
|
99
75
|
});
|
|
100
76
|
}
|
|
101
77
|
async addReportAsset(payload) {
|
|
102
|
-
const { filename, file, filepath } = payload;
|
|
78
|
+
const { filename, file, filepath, signal } = payload;
|
|
103
79
|
if (!file && !filepath) {
|
|
104
80
|
throw new Error("File or filepath is required");
|
|
105
81
|
}
|
|
106
82
|
let content = file;
|
|
107
83
|
if (!content) {
|
|
108
|
-
content = await readFile(filepath);
|
|
84
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
109
85
|
}
|
|
110
86
|
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
111
87
|
throw new Error(`Asset size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
112
88
|
}
|
|
113
89
|
const form = new FormData();
|
|
114
90
|
form.set("filename", filename);
|
|
115
|
-
form.set("file", content);
|
|
116
|
-
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/assets/upload", {
|
|
91
|
+
form.set("file", createUploadBlob(content), filename);
|
|
92
|
+
return __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post("/api/assets/upload", {
|
|
117
93
|
body: form,
|
|
118
94
|
headers: {
|
|
119
95
|
"Content-Type": "multipart/form-data",
|
|
120
96
|
},
|
|
97
|
+
...(signal ? { signal } : {}),
|
|
121
98
|
});
|
|
122
99
|
}
|
|
123
100
|
async addReportFile(payload) {
|
|
124
|
-
const { reportUuid, filename, file, filepath, pluginId } = payload;
|
|
101
|
+
const { reportUuid, filename, file, filepath, pluginId, signal } = payload;
|
|
102
|
+
const reportFilename = pluginId ? joinPosix(pluginId, filename) : filename;
|
|
125
103
|
if (!file && !filepath) {
|
|
126
104
|
throw new Error("File or filepath is required");
|
|
127
105
|
}
|
|
128
106
|
let content = file;
|
|
129
107
|
if (!content) {
|
|
130
|
-
content = await readFile(filepath);
|
|
108
|
+
content = signal ? await readFile(filepath, { signal }) : await readFile(filepath);
|
|
131
109
|
}
|
|
132
110
|
if (content.length > ASSET_MAX_FILE_SIZE) {
|
|
133
111
|
throw new Error(`Report file size exceeds the maximum allowed size of ${ASSET_MAX_FILE_SIZE / (1024 * 1024)}MB`);
|
|
134
112
|
}
|
|
135
113
|
const form = new FormData();
|
|
136
|
-
form.set("filename",
|
|
137
|
-
form.set("file", content);
|
|
138
|
-
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/reports/${reportUuid}/upload`, {
|
|
114
|
+
form.set("filename", reportFilename);
|
|
115
|
+
form.set("file", createUploadBlob(content), reportFilename);
|
|
116
|
+
await __classPrivateFieldGet(this, _AllureServiceClient_client, "f").post(`/api/reports/${reportUuid}/upload`, {
|
|
139
117
|
body: form,
|
|
140
118
|
headers: {
|
|
141
119
|
"Content-Type": "multipart/form-data",
|
|
142
120
|
},
|
|
121
|
+
...(signal ? { signal } : {}),
|
|
143
122
|
});
|
|
144
|
-
return
|
|
123
|
+
return createReportFileUrl(__classPrivateFieldGet(this, _AllureServiceClient_url, "f"), reportUuid, reportFilename);
|
|
145
124
|
}
|
|
146
125
|
}
|
|
147
126
|
_AllureServiceClient_client = new WeakMap(), _AllureServiceClient_url = new WeakMap();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const parseServiceToken = (token) => {
|
|
2
|
+
try {
|
|
3
|
+
const encodedPayload = token.split(".")[1];
|
|
4
|
+
if (!encodedPayload) {
|
|
5
|
+
throw new Error("missing payload");
|
|
6
|
+
}
|
|
7
|
+
const payload = JSON.parse(Buffer.from(encodedPayload, "base64url").toString("utf-8"));
|
|
8
|
+
if (!payload.accessToken) {
|
|
9
|
+
throw new Error("missing access token");
|
|
10
|
+
}
|
|
11
|
+
if (!payload.url) {
|
|
12
|
+
throw new Error("missing url");
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
accessToken: payload.accessToken,
|
|
16
|
+
url: payload.url,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error("Allure service access token is invalid");
|
|
21
|
+
}
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/service",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Allure Service API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -30,9 +30,9 @@
|
|
|
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.
|
|
35
|
-
"axios": "^1.15.
|
|
33
|
+
"@allurereport/core-api": "3.8.0",
|
|
34
|
+
"@allurereport/plugin-api": "3.8.0",
|
|
35
|
+
"axios": "^1.15.2",
|
|
36
36
|
"open": "^10.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|