@flakiness/sdk 1.0.0 → 1.0.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/lib/browser.js CHANGED
@@ -4,140 +4,6 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // node_modules/.pnpm/@flakiness+flakiness-report@0.22.0/node_modules/@flakiness/flakiness-report/lib/flakinessReport.js
8
- var FlakinessReport;
9
- ((FlakinessReport22) => {
10
- FlakinessReport22.CATEGORY_PLAYWRIGHT = "playwright";
11
- FlakinessReport22.CATEGORY_PYTEST = "pytest";
12
- FlakinessReport22.CATEGORY_JUNIT = "junit";
13
- })(FlakinessReport || (FlakinessReport = {}));
14
-
15
- // node_modules/.pnpm/@flakiness+flakiness-report@0.22.0/node_modules/@flakiness/flakiness-report/lib/schema.js
16
- import z from "zod/v4";
17
- var Schema;
18
- ((Schema2) => {
19
- Schema2.CommitId = z.string().min(40).max(40);
20
- Schema2.AttachmentId = z.string().min(1).max(1024);
21
- Schema2.UnixTimestampMS = z.number().min(0);
22
- Schema2.DurationMS = z.number().min(0);
23
- Schema2.Number1Based = z.number();
24
- Schema2.GitFilePath = z.string().min(0);
25
- Schema2.Location = z.object({
26
- file: Schema2.GitFilePath,
27
- line: Schema2.Number1Based,
28
- // Note: Locations for file suites are (0, 0).
29
- column: Schema2.Number1Based
30
- });
31
- Schema2.TestStatus = z.enum(["passed", "failed", "timedOut", "skipped", "interrupted"]);
32
- Schema2.Environment = z.object({
33
- name: z.string().min(1).max(512),
34
- systemData: z.object({
35
- osName: z.string().optional(),
36
- osVersion: z.string().optional(),
37
- osArch: z.string().optional()
38
- }).optional(),
39
- metadata: z.any().optional(),
40
- userSuppliedData: z.any().optional()
41
- });
42
- Schema2.STDIOEntry = z.union([
43
- z.object({ text: z.string() }),
44
- z.object({ buffer: z.string() })
45
- ]);
46
- Schema2.ReportError = z.object({
47
- location: Schema2.Location.optional(),
48
- message: z.string().optional(),
49
- stack: z.string().optional(),
50
- snippet: z.string().optional(),
51
- value: z.string().optional()
52
- });
53
- Schema2.SuiteType = z.enum(["file", "anonymous suite", "suite"]);
54
- Schema2.TestStep = z.object({
55
- title: z.string(),
56
- duration: Schema2.DurationMS.optional(),
57
- location: Schema2.Location.optional(),
58
- snippet: z.string().optional(),
59
- error: Schema2.ReportError.optional(),
60
- get steps() {
61
- return z.array(Schema2.TestStep).optional();
62
- }
63
- });
64
- Schema2.Attachment = z.object({
65
- name: z.string(),
66
- contentType: z.string(),
67
- id: Schema2.AttachmentId
68
- });
69
- Schema2.Annotation = z.object({
70
- type: z.string(),
71
- description: z.string().optional(),
72
- location: Schema2.Location.optional()
73
- });
74
- Schema2.RunAttempt = z.object({
75
- // Index of the environment in the environments array (must be >= 0).
76
- environmentIdx: z.number().min(0).optional(),
77
- expectedStatus: Schema2.TestStatus.optional(),
78
- status: Schema2.TestStatus.optional(),
79
- startTimestamp: Schema2.UnixTimestampMS,
80
- duration: Schema2.DurationMS.optional(),
81
- timeout: Schema2.DurationMS.optional(),
82
- annotations: z.array(Schema2.Annotation).optional(),
83
- errors: z.array(Schema2.ReportError).optional(),
84
- parallelIndex: z.number().optional(),
85
- steps: z.array(Schema2.TestStep).optional(),
86
- stdout: z.array(Schema2.STDIOEntry).optional(),
87
- stderr: z.array(Schema2.STDIOEntry).optional(),
88
- attachments: z.array(Schema2.Attachment).optional()
89
- });
90
- Schema2.Suite = z.object({
91
- type: Schema2.SuiteType,
92
- title: z.string(),
93
- location: Schema2.Location.optional(),
94
- get suites() {
95
- return z.array(Schema2.Suite).optional();
96
- },
97
- get tests() {
98
- return z.array(Schema2.Test).optional();
99
- }
100
- });
101
- Schema2.Test = z.object({
102
- title: z.string(),
103
- location: Schema2.Location.optional(),
104
- tags: z.array(z.string()).optional(),
105
- attempts: z.array(Schema2.RunAttempt)
106
- });
107
- Schema2.SystemUtilizationSample = z.object({
108
- dts: Schema2.DurationMS,
109
- // Must be between 0 and 100 (inclusive). Can be a rational number.
110
- cpuUtilization: z.number().min(0).max(100),
111
- // Must be between 0 and 100 (inclusive). Can be a rational number.
112
- memoryUtilization: z.number().min(0).max(100)
113
- });
114
- Schema2.SystemUtilization = z.object({
115
- totalMemoryBytes: z.number().min(0),
116
- startTimestamp: Schema2.UnixTimestampMS,
117
- samples: z.array(Schema2.SystemUtilizationSample)
118
- });
119
- Schema2.UtilizationTelemetry = z.tuple([Schema2.DurationMS, z.number().min(0).max(100)]);
120
- Schema2.Report = z.object({
121
- category: z.string().min(1).max(100),
122
- commitId: Schema2.CommitId,
123
- relatedCommitIds: z.array(Schema2.CommitId).optional(),
124
- configPath: Schema2.GitFilePath.optional(),
125
- url: z.string().optional(),
126
- environments: z.array(Schema2.Environment).min(1),
127
- suites: z.array(Schema2.Suite).optional(),
128
- tests: z.array(Schema2.Test).optional(),
129
- unattributedErrors: z.array(Schema2.ReportError).optional(),
130
- startTimestamp: Schema2.UnixTimestampMS,
131
- duration: Schema2.DurationMS,
132
- systemUtilization: z.optional(Schema2.SystemUtilization),
133
- cpuCount: z.number().min(0).optional(),
134
- cpuAvg: z.array(Schema2.UtilizationTelemetry).optional(),
135
- cpuMax: z.array(Schema2.UtilizationTelemetry).optional(),
136
- ram: z.array(Schema2.UtilizationTelemetry).optional(),
137
- ramBytes: z.number().min(0).optional()
138
- });
139
- })(Schema || (Schema = {}));
140
-
141
7
  // src/reportUtilsBrowser.ts
142
8
  var reportUtilsBrowser_exports = {};
143
9
  __export(reportUtilsBrowser_exports, {
@@ -305,6 +171,140 @@ function computeTestId(test, suiteId) {
305
171
  });
306
172
  }
307
173
 
174
+ // node_modules/.pnpm/@flakiness+flakiness-report@0.22.0/node_modules/@flakiness/flakiness-report/lib/flakinessReport.js
175
+ var FlakinessReport;
176
+ ((FlakinessReport22) => {
177
+ FlakinessReport22.CATEGORY_PLAYWRIGHT = "playwright";
178
+ FlakinessReport22.CATEGORY_PYTEST = "pytest";
179
+ FlakinessReport22.CATEGORY_JUNIT = "junit";
180
+ })(FlakinessReport || (FlakinessReport = {}));
181
+
182
+ // node_modules/.pnpm/@flakiness+flakiness-report@0.22.0/node_modules/@flakiness/flakiness-report/lib/schema.js
183
+ import z from "zod/v4";
184
+ var Schema;
185
+ ((Schema2) => {
186
+ Schema2.CommitId = z.string().min(40).max(40);
187
+ Schema2.AttachmentId = z.string().min(1).max(1024);
188
+ Schema2.UnixTimestampMS = z.number().min(0);
189
+ Schema2.DurationMS = z.number().min(0);
190
+ Schema2.Number1Based = z.number();
191
+ Schema2.GitFilePath = z.string().min(0);
192
+ Schema2.Location = z.object({
193
+ file: Schema2.GitFilePath,
194
+ line: Schema2.Number1Based,
195
+ // Note: Locations for file suites are (0, 0).
196
+ column: Schema2.Number1Based
197
+ });
198
+ Schema2.TestStatus = z.enum(["passed", "failed", "timedOut", "skipped", "interrupted"]);
199
+ Schema2.Environment = z.object({
200
+ name: z.string().min(1).max(512),
201
+ systemData: z.object({
202
+ osName: z.string().optional(),
203
+ osVersion: z.string().optional(),
204
+ osArch: z.string().optional()
205
+ }).optional(),
206
+ metadata: z.any().optional(),
207
+ userSuppliedData: z.any().optional()
208
+ });
209
+ Schema2.STDIOEntry = z.union([
210
+ z.object({ text: z.string() }),
211
+ z.object({ buffer: z.string() })
212
+ ]);
213
+ Schema2.ReportError = z.object({
214
+ location: Schema2.Location.optional(),
215
+ message: z.string().optional(),
216
+ stack: z.string().optional(),
217
+ snippet: z.string().optional(),
218
+ value: z.string().optional()
219
+ });
220
+ Schema2.SuiteType = z.enum(["file", "anonymous suite", "suite"]);
221
+ Schema2.TestStep = z.object({
222
+ title: z.string(),
223
+ duration: Schema2.DurationMS.optional(),
224
+ location: Schema2.Location.optional(),
225
+ snippet: z.string().optional(),
226
+ error: Schema2.ReportError.optional(),
227
+ get steps() {
228
+ return z.array(Schema2.TestStep).optional();
229
+ }
230
+ });
231
+ Schema2.Attachment = z.object({
232
+ name: z.string(),
233
+ contentType: z.string(),
234
+ id: Schema2.AttachmentId
235
+ });
236
+ Schema2.Annotation = z.object({
237
+ type: z.string(),
238
+ description: z.string().optional(),
239
+ location: Schema2.Location.optional()
240
+ });
241
+ Schema2.RunAttempt = z.object({
242
+ // Index of the environment in the environments array (must be >= 0).
243
+ environmentIdx: z.number().min(0).optional(),
244
+ expectedStatus: Schema2.TestStatus.optional(),
245
+ status: Schema2.TestStatus.optional(),
246
+ startTimestamp: Schema2.UnixTimestampMS,
247
+ duration: Schema2.DurationMS.optional(),
248
+ timeout: Schema2.DurationMS.optional(),
249
+ annotations: z.array(Schema2.Annotation).optional(),
250
+ errors: z.array(Schema2.ReportError).optional(),
251
+ parallelIndex: z.number().optional(),
252
+ steps: z.array(Schema2.TestStep).optional(),
253
+ stdout: z.array(Schema2.STDIOEntry).optional(),
254
+ stderr: z.array(Schema2.STDIOEntry).optional(),
255
+ attachments: z.array(Schema2.Attachment).optional()
256
+ });
257
+ Schema2.Suite = z.object({
258
+ type: Schema2.SuiteType,
259
+ title: z.string(),
260
+ location: Schema2.Location.optional(),
261
+ get suites() {
262
+ return z.array(Schema2.Suite).optional();
263
+ },
264
+ get tests() {
265
+ return z.array(Schema2.Test).optional();
266
+ }
267
+ });
268
+ Schema2.Test = z.object({
269
+ title: z.string(),
270
+ location: Schema2.Location.optional(),
271
+ tags: z.array(z.string()).optional(),
272
+ attempts: z.array(Schema2.RunAttempt)
273
+ });
274
+ Schema2.SystemUtilizationSample = z.object({
275
+ dts: Schema2.DurationMS,
276
+ // Must be between 0 and 100 (inclusive). Can be a rational number.
277
+ cpuUtilization: z.number().min(0).max(100),
278
+ // Must be between 0 and 100 (inclusive). Can be a rational number.
279
+ memoryUtilization: z.number().min(0).max(100)
280
+ });
281
+ Schema2.SystemUtilization = z.object({
282
+ totalMemoryBytes: z.number().min(0),
283
+ startTimestamp: Schema2.UnixTimestampMS,
284
+ samples: z.array(Schema2.SystemUtilizationSample)
285
+ });
286
+ Schema2.UtilizationTelemetry = z.tuple([Schema2.DurationMS, z.number().min(0).max(100)]);
287
+ Schema2.Report = z.object({
288
+ category: z.string().min(1).max(100),
289
+ commitId: Schema2.CommitId,
290
+ relatedCommitIds: z.array(Schema2.CommitId).optional(),
291
+ configPath: Schema2.GitFilePath.optional(),
292
+ url: z.string().optional(),
293
+ environments: z.array(Schema2.Environment).min(1),
294
+ suites: z.array(Schema2.Suite).optional(),
295
+ tests: z.array(Schema2.Test).optional(),
296
+ unattributedErrors: z.array(Schema2.ReportError).optional(),
297
+ startTimestamp: Schema2.UnixTimestampMS,
298
+ duration: Schema2.DurationMS,
299
+ systemUtilization: z.optional(Schema2.SystemUtilization),
300
+ cpuCount: z.number().min(0).optional(),
301
+ cpuAvg: z.array(Schema2.UtilizationTelemetry).optional(),
302
+ cpuMax: z.array(Schema2.UtilizationTelemetry).optional(),
303
+ ram: z.array(Schema2.UtilizationTelemetry).optional(),
304
+ ramBytes: z.number().min(0).optional()
305
+ });
306
+ })(Schema || (Schema = {}));
307
+
308
308
  // src/validateReport.ts
309
309
  import z2 from "zod/v4";
310
310
  function validateReport(report) {
@@ -344,7 +344,6 @@ function visitTests(report, testVisitor) {
344
344
  visitSuite(suite, []);
345
345
  }
346
346
  export {
347
- FlakinessReport,
348
347
  reportUtilsBrowser_exports as ReportUtils
349
348
  };
350
349
  //# sourceMappingURL=browser.js.map
package/lib/index.js CHANGED
@@ -1339,7 +1339,7 @@ var StaticServer = class {
1339
1339
  ".ico": "image/x-icon",
1340
1340
  ".txt": "text/plain"
1341
1341
  };
1342
- constructor(pathPrefix, folderPath, cors) {
1342
+ constructor(pathPrefix, folderPath, cors = []) {
1343
1343
  this._pathPrefix = "/" + pathPrefix.replace(/^\//, "").replace(/\/$/, "");
1344
1344
  this._absoluteFolderPath = path3.resolve(folderPath);
1345
1345
  this._cors = cors;
@@ -1414,9 +1414,10 @@ var StaticServer = class {
1414
1414
  }
1415
1415
  _handleRequest(req, res) {
1416
1416
  const { url, method } = req;
1417
- if (this._cors) {
1417
+ if (this._cors.length && req.headers.origin && this._cors.includes(req.headers.origin)) {
1418
1418
  res.setHeader("Access-Control-Allow-Headers", "*");
1419
- res.setHeader("Access-Control-Allow-Origin", this._cors);
1419
+ res.setHeader("Vary", "Origin");
1420
+ res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
1420
1421
  res.setHeader("Access-Control-Allow-Methods", "*");
1421
1422
  if (req.method === "OPTIONS") {
1422
1423
  res.writeHead(204);
@@ -1468,7 +1469,11 @@ async function showReport(reportFolder) {
1468
1469
  const projectPublicId = config.projectPublicId();
1469
1470
  const reportViewerEndpoint = config.reportViewerUrl();
1470
1471
  const token = randomUUIDBase62();
1471
- const server = new StaticServer(token, reportFolder, reportViewerEndpoint);
1472
+ const server = new StaticServer(token, reportFolder, [
1473
+ reportViewerEndpoint,
1474
+ // trace.playwright.dev is used to load & display Playwright Test traces.
1475
+ "https://trace.playwright.dev"
1476
+ ]);
1472
1477
  await server.start(9373, "127.0.0.1");
1473
1478
  const url = new URL(reportViewerEndpoint);
1474
1479
  url.searchParams.set("port", String(server.port()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flakiness/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,3 +1,2 @@
1
- export { FlakinessReport } from '@flakiness/flakiness-report';
2
1
  export * as ReportUtils from './reportUtilsBrowser.js';
3
2
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../src/showReport.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,iBAqBpD"}
1
+ {"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../src/showReport.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,UAAU,CAAC,YAAY,EAAE,MAAM,iBAyBpD"}
@@ -2,9 +2,9 @@ export declare class StaticServer {
2
2
  private _server;
3
3
  private _absoluteFolderPath;
4
4
  private _pathPrefix;
5
- private _cors?;
5
+ private _cors;
6
6
  private _mimeTypes;
7
- constructor(pathPrefix: string, folderPath: string, cors?: string);
7
+ constructor(pathPrefix: string, folderPath: string, cors?: string[]);
8
8
  port(): number | undefined;
9
9
  address(): string | undefined;
10
10
  private _startServer;
@@ -1 +1 @@
1
- {"version":3,"file":"staticServer.d.ts","sourceRoot":"","sources":["../../src/staticServer.ts"],"names":[],"mappings":"AAQA,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAC,CAAS;IAEvB,OAAO,CAAC,UAAU,CAWhB;gBAEU,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAQjE,IAAI;IAOJ,OAAO,IAAI,MAAM,GAAC,SAAS;YASb,YAAY;IAkBpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB;IAyB7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;CAiEvB"}
1
+ {"version":3,"file":"staticServer.d.ts","sourceRoot":"","sources":["../../src/staticServer.ts"],"names":[],"mappings":"AAQA,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAW;IAExB,OAAO,CAAC,UAAU,CAWhB;gBAEU,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO;IAQvE,IAAI;IAOJ,OAAO,IAAI,MAAM,GAAC,SAAS;YASb,YAAY;IAkBpB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAoB;IAyB7C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;CAkEvB"}