bruniai 0.1.16 → 0.1.17
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/report.d.ts +23 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +57 -0
- package/dist/report.js.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { compareUrls } from "./compare-urls.js";
|
|
8
8
|
export { compareImageToUrl } from "./compare-image-to-url.js";
|
|
9
|
+
export { sendReport } from "./report.js";
|
|
10
|
+
export type { SendReportInput } from "./report.js";
|
|
9
11
|
export type { CompareImageToUrlInput, CompareImageToUrlOutput, CompareUrlsInput, CompareUrlsOutput, ComparisonImages, } from "./types.js";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CompareUrlsOutput } from "./types.js";
|
|
2
|
+
/** Comparison mode matching the reporter's ComparisonMode type. */
|
|
3
|
+
type ComparisonMode = "url-to-url" | "image-to-url" | "image-to-image";
|
|
4
|
+
export interface SendReportInput {
|
|
5
|
+
result: CompareUrlsOutput;
|
|
6
|
+
page: string;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
previewUrl: string;
|
|
9
|
+
bruniToken: string;
|
|
10
|
+
bruniApiUrl?: string;
|
|
11
|
+
comparisonMode?: ComparisonMode;
|
|
12
|
+
prNumber?: string;
|
|
13
|
+
repository?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Send a comparison result to the Bruni reporting API and return the report URL.
|
|
17
|
+
*
|
|
18
|
+
* @param input - Report input containing the comparison result and metadata
|
|
19
|
+
* @returns Report URL if the report was successfully sent, null otherwise
|
|
20
|
+
*/
|
|
21
|
+
export declare function sendReport(input: SendReportInput): Promise<string | null>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,mEAAmE;AACnE,KAAK,cAAc,GAAG,YAAY,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAsBvE,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwExB"}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
async function importSourceModule(relativePath) {
|
|
2
|
+
return (await import(new URL(relativePath, import.meta.url).href));
|
|
3
|
+
}
|
|
4
|
+
async function loadReporterModule() {
|
|
5
|
+
if (import.meta.url.includes("/packages/bruniai/src/")) {
|
|
6
|
+
try {
|
|
7
|
+
return await import("../../../dist/reporter/index.js");
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return await importSourceModule("../../../src/reporter/index.ts");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return await import("./runtime/reporter/index.js");
|
|
14
|
+
}
|
|
15
|
+
const DEFAULT_BRUNI_API_URL = "https://bruniai-app.vercel.app/api/tests";
|
|
16
|
+
/**
|
|
17
|
+
* Send a comparison result to the Bruni reporting API and return the report URL.
|
|
18
|
+
*
|
|
19
|
+
* @param input - Report input containing the comparison result and metadata
|
|
20
|
+
* @returns Report URL if the report was successfully sent, null otherwise
|
|
21
|
+
*/
|
|
22
|
+
export async function sendReport(input) {
|
|
23
|
+
const { result, page, baseUrl, previewUrl, bruniToken, bruniApiUrl = DEFAULT_BRUNI_API_URL, comparisonMode = "url-to-url", prNumber = "", repository = "", } = input;
|
|
24
|
+
const { BruniReporter, parseMultiPageAnalysisResults, encodeImageCompressed } = await loadReporterModule();
|
|
25
|
+
const reporter = new BruniReporter(bruniToken, bruniApiUrl);
|
|
26
|
+
const imageRefs = {
|
|
27
|
+
base_screenshot: await encodeImageCompressed(result.images.base_screenshot, "WEBP", 1200, 60),
|
|
28
|
+
pr_screenshot: await encodeImageCompressed(result.images.preview_screenshot, "WEBP", 1200, 60),
|
|
29
|
+
diff_image: await encodeImageCompressed(result.images.diff_image, "WEBP", 1200, 70),
|
|
30
|
+
};
|
|
31
|
+
const multiPageReport = parseMultiPageAnalysisResults(prNumber, repository, [
|
|
32
|
+
{
|
|
33
|
+
page_path: page,
|
|
34
|
+
base_url: baseUrl,
|
|
35
|
+
pr_url: previewUrl,
|
|
36
|
+
visual_analysis: result.visual_analysis,
|
|
37
|
+
sections_analysis: result.sections_analysis,
|
|
38
|
+
image_refs: imageRefs,
|
|
39
|
+
},
|
|
40
|
+
], comparisonMode);
|
|
41
|
+
const apiResponse = await reporter.sendMultiPageReport(multiPageReport);
|
|
42
|
+
if (apiResponse && apiResponse.length > 0) {
|
|
43
|
+
const firstResponse = apiResponse[0];
|
|
44
|
+
if (firstResponse.test && typeof firstResponse.test === "object") {
|
|
45
|
+
const testObj = firstResponse.test;
|
|
46
|
+
const reportId = testObj.id;
|
|
47
|
+
if (reportId) {
|
|
48
|
+
const baseApiUrl = bruniApiUrl
|
|
49
|
+
.replace("/api/tests", "")
|
|
50
|
+
.replace(/\/$/, "");
|
|
51
|
+
return `${baseApiUrl}/test/${reportId}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAOA,KAAK,UAAU,kBAAkB,CAAI,YAAoB;IACvD,OAAO,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAM,CAAC;AAC1E,CAAC;AAED,KAAK,UAAU,kBAAkB;IAC/B,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,iCAAiC,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,kBAAkB,CAC7B,gCAAgC,CACjC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;AACrD,CAAC;AAcD,MAAM,qBAAqB,GAAG,0CAA0C,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,KAAsB;IAEtB,MAAM,EACJ,MAAM,EACN,IAAI,EACJ,OAAO,EACP,UAAU,EACV,UAAU,EACV,WAAW,GAAG,qBAAqB,EACnC,cAAc,GAAG,YAAY,EAC7B,QAAQ,GAAG,EAAE,EACb,UAAU,GAAG,EAAE,GAChB,GAAG,KAAK,CAAC;IAEV,MAAM,EAAE,aAAa,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,GAC3E,MAAM,kBAAkB,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,UAAU,EAAE,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AAE,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bruniai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI-powered visual regression testing tool - core comparison library",
|
|
6
6
|
"author": "Joao Garin",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@sparticuz/chromium": "^138.0.2",
|
|
26
|
-
"@browserbasehq/stagehand": "^3.
|
|
26
|
+
"@browserbasehq/stagehand": "^3.2.1",
|
|
27
27
|
"dotenv": "^16.0.0",
|
|
28
28
|
"pixelmatch": "^7.1.0",
|
|
29
|
-
"playwright": "^1.
|
|
29
|
+
"playwright": "^1.59.1",
|
|
30
30
|
"pngjs": "^7.0.0",
|
|
31
31
|
"sharp": "^0.34.5",
|
|
32
32
|
"uuid": "^10.0.0",
|
|
33
|
-
"zod": "^3.
|
|
33
|
+
"zod": "^3.25.76"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.11.24",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"typescript": "^5.5.4"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@browserbasehq/stagehand": "^3.
|
|
44
|
+
"@browserbasehq/stagehand": "^3.2.1"
|
|
45
45
|
}
|
|
46
46
|
}
|