@empiricalrun/playwright-utils 0.70.0 → 0.70.2
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/CHANGELOG.md +25 -0
- package/README.md +6 -3
- package/dist/api-worker-client.d.ts +2 -0
- package/dist/api-worker-client.d.ts.map +1 -1
- package/dist/api-worker-client.js +4 -0
- package/dist/generated/api-worker-openapi.d.ts +391 -11
- package/dist/generated/api-worker-openapi.d.ts.map +1 -1
- package/dist/inbox-client.d.ts +5 -0
- package/dist/inbox-client.d.ts.map +1 -1
- package/dist/inbox-client.js +1 -0
- package/dist/reporter/empirical-reporter.js +1 -1
- package/dist/reporter/presigned-upload.d.ts +1 -3
- package/dist/reporter/presigned-upload.d.ts.map +1 -1
- package/dist/reporter/presigned-upload.js +2 -2
- package/dist/reporter/uploader.d.ts +11 -15
- package/dist/reporter/uploader.d.ts.map +1 -1
- package/dist/reporter/uploader.js +49 -101
- package/package.json +4 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/docs/auth.md +0 -116
- package/docs/email.md +0 -97
- package/docs/fixtures.md +0 -106
- package/docs/kv.md +0 -90
- package/docs/video-labels.md +0 -36
package/dist/inbox-client.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ type Link = {
|
|
|
5
5
|
href?: string;
|
|
6
6
|
};
|
|
7
7
|
export type InboxEmail = {
|
|
8
|
+
/**
|
|
9
|
+
* The sender in the email's From header, e.g. `noreply@acme.com`. Falls back
|
|
10
|
+
* to the envelope sender when the email had no From header.
|
|
11
|
+
*/
|
|
12
|
+
from?: string;
|
|
8
13
|
messageId?: string;
|
|
9
14
|
subject?: string;
|
|
10
15
|
text?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox-client.d.ts","sourceRoot":"","sources":["../src/inbox-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,IAAI,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAKF,KAAK,kBAAkB,GAAG;IACxB,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,YAAY,IAAI,EAAE,kBAAkB,EAGnC;IAEK,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,UAAU,CAAC,CAOrB;YAEa,cAAc;IAgD5B,OAAO,CAAC,YAAY;
|
|
1
|
+
{"version":3,"file":"inbox-client.d.ts","sourceRoot":"","sources":["../src/inbox-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,IAAI,GAAG;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAKF,KAAK,kBAAkB,GAAG;IACxB,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,YAAY,IAAI,EAAE,kBAAkB,EAGnC;IAEK,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,UAAU,CAAC,CAOrB;YAEa,cAAc;IAgD5B,OAAO,CAAC,YAAY;CAWrB"}
|
package/dist/inbox-client.js
CHANGED
|
@@ -55,6 +55,7 @@ class InboxClient {
|
|
|
55
55
|
}
|
|
56
56
|
parseMessage(message) {
|
|
57
57
|
return {
|
|
58
|
+
from: message.header_from_address || message.from_address || undefined,
|
|
58
59
|
messageId: message.message_id || undefined,
|
|
59
60
|
subject: message.subject || undefined,
|
|
60
61
|
text: message.text_body || undefined,
|
|
@@ -260,7 +260,7 @@ class EmpiricalReporter {
|
|
|
260
260
|
}
|
|
261
261
|
if (jsonExists) {
|
|
262
262
|
logger_1.logger.debug("[Empirical Reporter] Patching summary.json with attachment URLs");
|
|
263
|
-
await (0, util_1.updateSummaryJsonAttachmentPaths)(jsonFilePath, this._outputDirs, `${this._uploader.
|
|
263
|
+
await (0, util_1.updateSummaryJsonAttachmentPaths)(jsonFilePath, this._outputDirs, `${await this._uploader.reportUrlPrefix()}/data`);
|
|
264
264
|
summaryJsonUrl = await this._uploader.uploadFile(jsonFilePath, "summary.json");
|
|
265
265
|
this._piSandboxLog(`[Empirical Reporter] summary.json URL: ${summaryJsonUrl}`);
|
|
266
266
|
}
|
|
@@ -5,11 +5,9 @@ export type PresignedUploadFile = {
|
|
|
5
5
|
reportPath: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function directoryUploadFiles(sourceDir: string, reportDir: string): PresignedUploadFile[];
|
|
8
|
-
export declare function uploadPresigned({ client, runId,
|
|
8
|
+
export declare function uploadPresigned({ client, runId, files, }: {
|
|
9
9
|
client: ApiWorkerClient;
|
|
10
10
|
runId: string;
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
destinationDir: string;
|
|
13
11
|
files: PresignedUploadFile[];
|
|
14
12
|
}): Promise<FileMap>;
|
|
15
13
|
//# sourceMappingURL=presigned-upload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presigned-upload.d.ts","sourceRoot":"","sources":["../../src/reporter/presigned-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,2BAA2B,CAAC;AAOzE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AASF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,mBAAmB,EAAE,CAUvB;AA8CD,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"presigned-upload.d.ts","sourceRoot":"","sources":["../../src/reporter/presigned-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,2BAA2B,CAAC;AAOzE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AASF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,mBAAmB,EAAE,CAUvB;AA8CD,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,KAAK,EACL,KAAK,GACN,EAAE;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B,GAAG,OAAO,CAAC,OAAO,CAAC,CAwCnB"}
|
|
@@ -58,7 +58,7 @@ async function putFile(uploadUrl, filePath, size, headers) {
|
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
async function uploadPresigned({ client, runId,
|
|
61
|
+
async function uploadPresigned({ client, runId, files, }) {
|
|
62
62
|
const urls = {};
|
|
63
63
|
for (let i = 0; i < files.length; i += MAX_FILES_PER_REQUEST) {
|
|
64
64
|
const batch = await Promise.all(files.slice(i, i + MAX_FILES_PER_REQUEST).map(async (file) => {
|
|
@@ -89,7 +89,7 @@ async function uploadPresigned({ client, runId, baseUrl, destinationDir, files,
|
|
|
89
89
|
"x-amz-storage-class": file.storageClass,
|
|
90
90
|
}),
|
|
91
91
|
});
|
|
92
|
-
urls[file.filePath] =
|
|
92
|
+
urls[file.filePath] = signed.url;
|
|
93
93
|
}));
|
|
94
94
|
}
|
|
95
95
|
return urls;
|
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import { StorageCredentials, UploadStorageClass } from "@empiricalrun/r2-uploader";
|
|
2
2
|
import { ApiWorkerClient } from "../api-worker-client";
|
|
3
|
-
type
|
|
4
|
-
provider: "
|
|
3
|
+
export type UploadTarget = {
|
|
4
|
+
provider: "presigned";
|
|
5
5
|
client: ApiWorkerClient;
|
|
6
|
+
} | {
|
|
7
|
+
provider: "bucket";
|
|
8
|
+
credentials: StorageCredentials;
|
|
9
|
+
uploadBucket: string;
|
|
10
|
+
baseUrl: string;
|
|
6
11
|
};
|
|
7
|
-
export type UploaderCredentials = StorageCredentials | PresignedCredentials;
|
|
8
12
|
export interface UploaderConfig {
|
|
9
13
|
projectSlug: string;
|
|
10
14
|
runId: string;
|
|
11
|
-
|
|
12
|
-
uploadBucket: string;
|
|
13
|
-
credentials: UploaderCredentials;
|
|
15
|
+
target: UploadTarget;
|
|
14
16
|
}
|
|
15
17
|
export declare class Uploader {
|
|
16
|
-
private
|
|
17
|
-
private _uploadBucket;
|
|
18
|
+
private _target;
|
|
18
19
|
private _runId;
|
|
19
20
|
private _destinationDir;
|
|
20
|
-
private
|
|
21
|
+
private _reportBaseUrl;
|
|
21
22
|
constructor(config: UploaderConfig);
|
|
22
|
-
private static _getR2Credentials;
|
|
23
|
-
private static _getS3Credentials;
|
|
24
|
-
static getCredentialsFromEnv(enableS3: boolean): StorageCredentials | null;
|
|
25
23
|
get isEnabled(): boolean;
|
|
26
|
-
get baseUrl(): string;
|
|
27
24
|
get destinationDir(): string;
|
|
28
|
-
|
|
25
|
+
reportUrlPrefix(): Promise<string>;
|
|
29
26
|
private _presignedTask;
|
|
30
27
|
uploadFile(filePath: string, destinationPath: string, storageClass?: UploadStorageClass): Promise<string | null>;
|
|
31
28
|
uploadDirectory(sourceDir: string, destinationPrefix: string): Promise<void>;
|
|
@@ -33,5 +30,4 @@ export declare class Uploader {
|
|
|
33
30
|
}
|
|
34
31
|
export declare function getUploader(): Uploader | null;
|
|
35
32
|
export declare function createUploader(): Uploader | null;
|
|
36
|
-
export {};
|
|
37
33
|
//# sourceMappingURL=uploader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../src/reporter/uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,EAElB,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AASvD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GAClD;IACE,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,kBAAkB,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,qBAAa,QAAQ;IACnB,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAgC;IAEtD,YAAY,MAAM,EAAE,cAAc,EAQjC;IAED,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B;IAEK,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CASvC;IAED,OAAO,CAAC,cAAc;IAchB,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,kBAAkB,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0CxB;IAEK,eAAe,CACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAqBf;IAEK,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBpC;CACF;AAID,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CAM7C;AAED,wBAAgB,cAAc,IAAI,QAAQ,GAAG,IAAI,CAiDhD"}
|
|
@@ -7,77 +7,43 @@ exports.Uploader = void 0;
|
|
|
7
7
|
exports.getUploader = getUploader;
|
|
8
8
|
exports.createUploader = createUploader;
|
|
9
9
|
const r2_uploader_1 = require("@empiricalrun/r2-uploader");
|
|
10
|
+
const report_storage_1 = require("@empiricalrun/r2-uploader/report-storage");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const api_worker_client_1 = require("../api-worker-client");
|
|
12
13
|
const local_run_id_1 = require("../local-run-id");
|
|
13
14
|
const logger_1 = require("../logger");
|
|
14
15
|
const presigned_upload_1 = require("./presigned-upload");
|
|
15
|
-
const R2_REPORTS_BASE_URL = "https://reports-r2.empirical.run";
|
|
16
|
-
const R2_REPORTS_BUCKET = "test-report";
|
|
17
16
|
class Uploader {
|
|
18
|
-
|
|
19
|
-
_uploadBucket;
|
|
17
|
+
_target;
|
|
20
18
|
_runId;
|
|
21
19
|
_destinationDir;
|
|
22
|
-
|
|
20
|
+
_reportBaseUrl = null;
|
|
23
21
|
constructor(config) {
|
|
24
|
-
this.
|
|
25
|
-
this._uploadBucket = config.uploadBucket;
|
|
22
|
+
this._target = config.target;
|
|
26
23
|
this._runId = config.runId;
|
|
27
|
-
this._destinationDir =
|
|
28
|
-
this.
|
|
29
|
-
logger_1.logger.debug(`[Uploader] Initialized with destination: ${this._destinationDir}, provider: ${this._credentials.provider}`);
|
|
30
|
-
}
|
|
31
|
-
static _getR2Credentials() {
|
|
32
|
-
if (process.env.R2_ACCOUNT_ID &&
|
|
33
|
-
process.env.R2_ACCESS_KEY_ID &&
|
|
34
|
-
process.env.R2_SECRET_ACCESS_KEY) {
|
|
35
|
-
return {
|
|
36
|
-
provider: "r2",
|
|
37
|
-
accountId: process.env.R2_ACCOUNT_ID,
|
|
38
|
-
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
39
|
-
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
static _getS3Credentials() {
|
|
45
|
-
if (process.env.S3_REGION && process.env.S3_UPLOAD_BUCKET) {
|
|
46
|
-
return {
|
|
47
|
-
provider: "s3-iam",
|
|
48
|
-
region: process.env.S3_REGION,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
static getCredentialsFromEnv(enableS3) {
|
|
54
|
-
if (enableS3) {
|
|
55
|
-
return Uploader._getS3Credentials();
|
|
56
|
-
}
|
|
57
|
-
return Uploader._getR2Credentials();
|
|
24
|
+
this._destinationDir = (0, report_storage_1.reportRunPrefix)(config.projectSlug, config.runId);
|
|
25
|
+
logger_1.logger.debug(`[Uploader] Initialized with destination: ${this._destinationDir}, target: ${this._target.provider}`);
|
|
58
26
|
}
|
|
59
27
|
get isEnabled() {
|
|
60
28
|
return true;
|
|
61
29
|
}
|
|
62
|
-
get baseUrl() {
|
|
63
|
-
return this._baseUrl;
|
|
64
|
-
}
|
|
65
30
|
get destinationDir() {
|
|
66
31
|
return this._destinationDir;
|
|
67
32
|
}
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
async reportUrlPrefix() {
|
|
34
|
+
const target = this._target;
|
|
35
|
+
if (target.provider === "bucket") {
|
|
36
|
+
return `${target.baseUrl}/${this._destinationDir}`;
|
|
37
|
+
}
|
|
38
|
+
this._reportBaseUrl ??= target.client
|
|
39
|
+
.getTestReportStorage()
|
|
40
|
+
.then((storage) => storage.base_url);
|
|
41
|
+
return `${await this._reportBaseUrl}/${this._destinationDir}`;
|
|
70
42
|
}
|
|
71
|
-
_presignedTask(
|
|
43
|
+
_presignedTask(client, files) {
|
|
72
44
|
return async () => {
|
|
73
45
|
try {
|
|
74
|
-
return await (0, presigned_upload_1.uploadPresigned)({
|
|
75
|
-
client: credentials.client,
|
|
76
|
-
runId: this._runId,
|
|
77
|
-
baseUrl: this._baseUrl,
|
|
78
|
-
destinationDir: this._destinationDir,
|
|
79
|
-
files,
|
|
80
|
-
});
|
|
46
|
+
return await (0, presigned_upload_1.uploadPresigned)({ client, runId: this._runId, files });
|
|
81
47
|
}
|
|
82
48
|
catch (error) {
|
|
83
49
|
logger_1.logger.error("[Uploader] Error uploading files", error);
|
|
@@ -86,9 +52,10 @@ class Uploader {
|
|
|
86
52
|
};
|
|
87
53
|
}
|
|
88
54
|
async uploadFile(filePath, destinationPath, storageClass) {
|
|
55
|
+
const target = this._target;
|
|
89
56
|
try {
|
|
90
|
-
if (
|
|
91
|
-
const result = await (0, r2_uploader_1.sendTaskToQueue)(this._presignedTask(
|
|
57
|
+
if (target.provider === "presigned") {
|
|
58
|
+
const result = await (0, r2_uploader_1.sendTaskToQueue)(this._presignedTask(target.client, [
|
|
92
59
|
{ filePath, reportPath: destinationPath },
|
|
93
60
|
]));
|
|
94
61
|
return (result && result[filePath]) || null;
|
|
@@ -99,11 +66,11 @@ class Uploader {
|
|
|
99
66
|
sourceDir,
|
|
100
67
|
fileList: [filePath],
|
|
101
68
|
destinationDir: path_1.default.dirname(fullDestinationPath),
|
|
102
|
-
uploadBucket:
|
|
103
|
-
baseUrl:
|
|
104
|
-
credentials:
|
|
105
|
-
storageClass:
|
|
106
|
-
|
|
69
|
+
uploadBucket: target.uploadBucket,
|
|
70
|
+
baseUrl: target.baseUrl,
|
|
71
|
+
credentials: target.credentials,
|
|
72
|
+
storageClass: target.credentials.provider === "s3" ||
|
|
73
|
+
target.credentials.provider === "s3-iam"
|
|
107
74
|
? storageClass
|
|
108
75
|
: undefined,
|
|
109
76
|
});
|
|
@@ -120,17 +87,17 @@ class Uploader {
|
|
|
120
87
|
}
|
|
121
88
|
}
|
|
122
89
|
async uploadDirectory(sourceDir, destinationPrefix) {
|
|
123
|
-
|
|
124
|
-
|
|
90
|
+
const target = this._target;
|
|
91
|
+
if (target.provider === "presigned") {
|
|
92
|
+
await (0, r2_uploader_1.sendTaskToQueue)(this._presignedTask(target.client, (0, presigned_upload_1.directoryUploadFiles)(sourceDir, destinationPrefix)));
|
|
125
93
|
return;
|
|
126
94
|
}
|
|
127
|
-
const fullDestinationDir = path_1.default.join(this._destinationDir, destinationPrefix);
|
|
128
95
|
const uploadTask = (0, r2_uploader_1.createUploadTask)({
|
|
129
96
|
sourceDir,
|
|
130
|
-
destinationDir:
|
|
131
|
-
uploadBucket:
|
|
132
|
-
baseUrl:
|
|
133
|
-
credentials:
|
|
97
|
+
destinationDir: path_1.default.join(this._destinationDir, destinationPrefix),
|
|
98
|
+
uploadBucket: target.uploadBucket,
|
|
99
|
+
baseUrl: target.baseUrl,
|
|
100
|
+
credentials: target.credentials,
|
|
134
101
|
});
|
|
135
102
|
await (0, r2_uploader_1.sendTaskToQueue)(uploadTask);
|
|
136
103
|
}
|
|
@@ -180,46 +147,29 @@ function createUploader() {
|
|
|
180
147
|
logger_1.logger.debug(`[Uploader] REPORT_STORAGE_BACKEND must be "s3" or "r2" (got ${backend ?? "unset"})`);
|
|
181
148
|
return null;
|
|
182
149
|
}
|
|
183
|
-
if (backend === "r2"
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const enableS3 = backend === "s3";
|
|
187
|
-
const credentials = Uploader.getCredentialsFromEnv(enableS3);
|
|
188
|
-
if (!credentials) {
|
|
189
|
-
const storageType = enableS3 ? "S3" : "R2";
|
|
190
|
-
logger_1.logger.debug(`[Uploader] ${storageType} credentials not found`);
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
let baseUrl;
|
|
194
|
-
let uploadBucket;
|
|
195
|
-
if (enableS3) {
|
|
196
|
-
const region = process.env.S3_REGION;
|
|
197
|
-
const bucket = process.env.S3_UPLOAD_BUCKET;
|
|
198
|
-
if (!region || !bucket) {
|
|
199
|
-
logger_1.logger.debug("[Uploader] S3_REGION or S3_UPLOAD_BUCKET not configured");
|
|
150
|
+
if (backend === "r2") {
|
|
151
|
+
if (process.env.REPORT_UPLOAD_PRESIGNED !== "true") {
|
|
152
|
+
logger_1.logger.debug("[Uploader] R2 reports upload only through presigned URLs");
|
|
200
153
|
return null;
|
|
201
154
|
}
|
|
202
|
-
|
|
203
|
-
process.env.REPORTS_BASE_URL?.replace(/\/+$/, "") ||
|
|
204
|
-
`https://${bucket}.s3.${region}.amazonaws.com`;
|
|
205
|
-
uploadBucket = bucket;
|
|
155
|
+
return createPresignedUploader(process.env.PROJECT_NAME, runId);
|
|
206
156
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
baseUrl = R2_REPORTS_BASE_URL;
|
|
215
|
-
uploadBucket = bucket;
|
|
157
|
+
const region = process.env.S3_REGION;
|
|
158
|
+
const bucket = process.env.S3_UPLOAD_BUCKET;
|
|
159
|
+
const baseUrl = process.env.REPORTS_BASE_URL?.replace(/\/+$/, "");
|
|
160
|
+
if (!region || !bucket || !baseUrl) {
|
|
161
|
+
logger_1.logger.debug("[Uploader] S3_REGION, S3_UPLOAD_BUCKET and REPORTS_BASE_URL must be set");
|
|
162
|
+
return null;
|
|
216
163
|
}
|
|
217
164
|
return new Uploader({
|
|
218
165
|
projectSlug: process.env.PROJECT_NAME,
|
|
219
166
|
runId,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
167
|
+
target: {
|
|
168
|
+
provider: "bucket",
|
|
169
|
+
credentials: { provider: "s3-iam", region },
|
|
170
|
+
uploadBucket: bucket,
|
|
171
|
+
baseUrl,
|
|
172
|
+
},
|
|
223
173
|
});
|
|
224
174
|
}
|
|
225
175
|
function createPresignedUploader(projectSlug, runId) {
|
|
@@ -230,8 +180,6 @@ function createPresignedUploader(projectSlug, runId) {
|
|
|
230
180
|
return new Uploader({
|
|
231
181
|
projectSlug,
|
|
232
182
|
runId,
|
|
233
|
-
|
|
234
|
-
uploadBucket: R2_REPORTS_BUCKET,
|
|
235
|
-
credentials: { provider: "r2-presigned", client: new api_worker_client_1.ApiWorkerClient() },
|
|
183
|
+
target: { provider: "presigned", client: new api_worker_client_1.ApiWorkerClient() },
|
|
236
184
|
});
|
|
237
185
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empiricalrun/playwright-utils",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.2",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22"
|
|
6
6
|
},
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"playwright-core": "1.65.1",
|
|
51
51
|
"serve-handler": "^6.1.6",
|
|
52
52
|
"typescript": "7.0.2",
|
|
53
|
-
"@empiricalrun/shared-types": "0.28.
|
|
53
|
+
"@empiricalrun/shared-types": "0.28.3"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@modelcontextprotocol/client": "2.4.0",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
|
64
64
|
"ts-morph": "^28.0.0",
|
|
65
65
|
"@empiricalrun/cua": "^0.6.0",
|
|
66
|
-
"@empiricalrun/r2-uploader": "^0.11.
|
|
67
|
-
"@empiricalrun/reporter": "^0.30.
|
|
66
|
+
"@empiricalrun/r2-uploader": "^0.11.8",
|
|
67
|
+
"@empiricalrun/reporter": "^0.30.6"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"dev": "pnpm gen:api-worker-openapi && tsc --build --watch",
|