flakiness 0.149.1 → 0.150.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/lib/cli/cli.js CHANGED
@@ -736,8 +736,232 @@ var Ranges;
736
736
  Ranges2.sequence = sequence;
737
737
  })(Ranges || (Ranges = {}));
738
738
 
739
+ // ../shared/lib/common/typedHttp.js
740
+ var TypedHTTP;
741
+ ((TypedHTTP2) => {
742
+ TypedHTTP2.StatusCodes = {
743
+ Informational: {
744
+ CONTINUE: 100,
745
+ SWITCHING_PROTOCOLS: 101,
746
+ PROCESSING: 102,
747
+ EARLY_HINTS: 103
748
+ },
749
+ Success: {
750
+ OK: 200,
751
+ CREATED: 201,
752
+ ACCEPTED: 202,
753
+ NON_AUTHORITATIVE_INFORMATION: 203,
754
+ NO_CONTENT: 204,
755
+ RESET_CONTENT: 205,
756
+ PARTIAL_CONTENT: 206,
757
+ MULTI_STATUS: 207
758
+ },
759
+ Redirection: {
760
+ MULTIPLE_CHOICES: 300,
761
+ MOVED_PERMANENTLY: 301,
762
+ MOVED_TEMPORARILY: 302,
763
+ SEE_OTHER: 303,
764
+ NOT_MODIFIED: 304,
765
+ USE_PROXY: 305,
766
+ TEMPORARY_REDIRECT: 307,
767
+ PERMANENT_REDIRECT: 308
768
+ },
769
+ ClientErrors: {
770
+ BAD_REQUEST: 400,
771
+ UNAUTHORIZED: 401,
772
+ PAYMENT_REQUIRED: 402,
773
+ FORBIDDEN: 403,
774
+ NOT_FOUND: 404,
775
+ METHOD_NOT_ALLOWED: 405,
776
+ NOT_ACCEPTABLE: 406,
777
+ PROXY_AUTHENTICATION_REQUIRED: 407,
778
+ REQUEST_TIMEOUT: 408,
779
+ CONFLICT: 409,
780
+ GONE: 410,
781
+ LENGTH_REQUIRED: 411,
782
+ PRECONDITION_FAILED: 412,
783
+ REQUEST_TOO_LONG: 413,
784
+ REQUEST_URI_TOO_LONG: 414,
785
+ UNSUPPORTED_MEDIA_TYPE: 415,
786
+ REQUESTED_RANGE_NOT_SATISFIABLE: 416,
787
+ EXPECTATION_FAILED: 417,
788
+ IM_A_TEAPOT: 418,
789
+ INSUFFICIENT_SPACE_ON_RESOURCE: 419,
790
+ METHOD_FAILURE: 420,
791
+ MISDIRECTED_REQUEST: 421,
792
+ UNPROCESSABLE_ENTITY: 422,
793
+ LOCKED: 423,
794
+ FAILED_DEPENDENCY: 424,
795
+ UPGRADE_REQUIRED: 426,
796
+ PRECONDITION_REQUIRED: 428,
797
+ TOO_MANY_REQUESTS: 429,
798
+ REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
799
+ UNAVAILABLE_FOR_LEGAL_REASONS: 451
800
+ },
801
+ ServerErrors: {
802
+ INTERNAL_SERVER_ERROR: 500,
803
+ NOT_IMPLEMENTED: 501,
804
+ BAD_GATEWAY: 502,
805
+ SERVICE_UNAVAILABLE: 503,
806
+ GATEWAY_TIMEOUT: 504,
807
+ HTTP_VERSION_NOT_SUPPORTED: 505,
808
+ INSUFFICIENT_STORAGE: 507,
809
+ NETWORK_AUTHENTICATION_REQUIRED: 511
810
+ }
811
+ };
812
+ const AllErrorCodes = {
813
+ ...TypedHTTP2.StatusCodes.ClientErrors,
814
+ ...TypedHTTP2.StatusCodes.ServerErrors
815
+ };
816
+ class HttpError extends Error {
817
+ constructor(status, message) {
818
+ super(message);
819
+ this.status = status;
820
+ }
821
+ static withCode(code, message) {
822
+ const statusCode = AllErrorCodes[code];
823
+ const defaultMessage = code.split("_").map((word) => word.charAt(0) + word.slice(1).toLowerCase()).join(" ");
824
+ return new HttpError(statusCode, message ?? defaultMessage);
825
+ }
826
+ }
827
+ TypedHTTP2.HttpError = HttpError;
828
+ const allHttpMethods = ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"];
829
+ function isInformationalResponse(response) {
830
+ return response.status >= 100 && response.status < 200;
831
+ }
832
+ TypedHTTP2.isInformationalResponse = isInformationalResponse;
833
+ function isSuccessResponse(response) {
834
+ return response.status >= 200 && response.status < 300;
835
+ }
836
+ TypedHTTP2.isSuccessResponse = isSuccessResponse;
837
+ function isRedirectResponse(response) {
838
+ return response.status >= 300 && response.status < 400;
839
+ }
840
+ TypedHTTP2.isRedirectResponse = isRedirectResponse;
841
+ function isErrorResponse(response) {
842
+ return response.status >= 400 && response.status < 600;
843
+ }
844
+ TypedHTTP2.isErrorResponse = isErrorResponse;
845
+ function info(status) {
846
+ return { status };
847
+ }
848
+ TypedHTTP2.info = info;
849
+ function ok(data, contentType, status) {
850
+ return {
851
+ status: status ?? TypedHTTP2.StatusCodes.Success.OK,
852
+ contentType,
853
+ data
854
+ };
855
+ }
856
+ TypedHTTP2.ok = ok;
857
+ function redirect(url, status = 302) {
858
+ return { status, url };
859
+ }
860
+ TypedHTTP2.redirect = redirect;
861
+ function error(message, status = TypedHTTP2.StatusCodes.ServerErrors.INTERNAL_SERVER_ERROR) {
862
+ return { status, message };
863
+ }
864
+ TypedHTTP2.error = error;
865
+ class Router {
866
+ constructor(_resolveContext) {
867
+ this._resolveContext = _resolveContext;
868
+ }
869
+ static create() {
870
+ return new Router(async (e) => e.ctx);
871
+ }
872
+ rawMethod(method, route) {
873
+ return {
874
+ [method]: {
875
+ method,
876
+ input: route.input,
877
+ etag: route.etag,
878
+ resolveContext: this._resolveContext,
879
+ handler: route.handler
880
+ }
881
+ };
882
+ }
883
+ get(route) {
884
+ return this.rawMethod("GET", {
885
+ ...route,
886
+ handler: (...args) => Promise.resolve(route.handler(...args)).then((result) => TypedHTTP2.ok(result, "application/json"))
887
+ });
888
+ }
889
+ post(route) {
890
+ return this.rawMethod("POST", {
891
+ ...route,
892
+ handler: (...args) => Promise.resolve(route.handler(...args)).then((result) => TypedHTTP2.ok(result, "application/json"))
893
+ });
894
+ }
895
+ use(resolveContext) {
896
+ return new Router(async (options) => {
897
+ const m = await this._resolveContext(options);
898
+ return resolveContext({ ...options, ctx: m });
899
+ });
900
+ }
901
+ }
902
+ TypedHTTP2.Router = Router;
903
+ function createClient(base, fetchCallback) {
904
+ function buildUrl(method, path8, input, options) {
905
+ const url = new URL(path8.join("/"), base);
906
+ const signal = options?.signal;
907
+ let body = void 0;
908
+ if (method === "GET" && input)
909
+ url.searchParams.set("input", JSON.stringify(input));
910
+ else if (method !== "GET" && input)
911
+ body = JSON.stringify(input);
912
+ return {
913
+ url,
914
+ method,
915
+ headers: body ? { "Content-Type": "application/json" } : void 0,
916
+ body,
917
+ signal
918
+ };
919
+ }
920
+ function fetcher(method, path8, input, methodOptions) {
921
+ const options = buildUrl(method, path8, input, methodOptions);
922
+ return fetchCallback(options.url, {
923
+ method: options.method,
924
+ body: options.body,
925
+ headers: options.headers,
926
+ signal: options.signal
927
+ }).then(async (response) => {
928
+ if (response.status >= 200 && response.status < 300) {
929
+ if (response.headers.get("content-type")?.includes("application/json")) {
930
+ const text = await response.text();
931
+ return text.length ? JSON.parse(text) : void 0;
932
+ }
933
+ return await response.arrayBuffer();
934
+ }
935
+ if (response.status >= 400 && response.status < 600) {
936
+ const text = await response.text();
937
+ if (text)
938
+ throw new Error(`HTTP request failed with status ${response.status}: ${text}`);
939
+ else
940
+ throw new Error(`HTTP request failed with status ${response.status}`);
941
+ }
942
+ });
943
+ }
944
+ function createProxy(path8 = []) {
945
+ return new Proxy({}, {
946
+ get(target, prop) {
947
+ if (typeof prop === "symbol")
948
+ return void 0;
949
+ if (allHttpMethods.includes(prop)) {
950
+ const f = fetcher.bind(null, prop, path8);
951
+ f.prepare = buildUrl.bind(null, prop, path8);
952
+ return f;
953
+ }
954
+ const newPath = [...path8, prop];
955
+ return createProxy(newPath);
956
+ }
957
+ });
958
+ }
959
+ return createProxy();
960
+ }
961
+ TypedHTTP2.createClient = createClient;
962
+ })(TypedHTTP || (TypedHTTP = {}));
963
+
739
964
  // src/cli/cli.ts
740
- import { TypedHTTP as TypedHTTP2 } from "@flakiness/shared/common/typedHttp.js";
741
965
  import assert2 from "assert";
742
966
  import { Command, Option } from "commander";
743
967
  import fs7 from "fs";
@@ -747,14 +971,15 @@ import path7 from "path";
747
971
  // ../package.json
748
972
  var package_default = {
749
973
  name: "flakiness",
750
- version: "0.149.1",
974
+ version: "0.150.0",
975
+ type: "module",
751
976
  private: true,
752
977
  scripts: {
753
978
  minor: "./version.mjs minor",
754
979
  patch: "./version.mjs patch",
755
980
  dev: "npx kubik --env-file=.env.dev -w $(find . -name build.mts) ./app.mts ./stripe.mts",
756
981
  "dev+billing": "npx kubik --env-file=.env.dev+billing -w $(find . -name build.mts) ./app.mts ./stripe.mts",
757
- prod: "npx kubik --env-file=.env.prodlocal -w ./playwright/build.mts ./cli/build.mts ./server.mts ./web/build.mts ./experimental/build.mts ./landing/build.mts",
982
+ prod: "npx kubik --env-file=.env.prodlocal -w ./cli/build.mts ./server.mts ./web/build.mts ./experimental/build.mts ./landing/build.mts",
758
983
  build: "npx kubik $(find . -name build.mts)",
759
984
  perf: "node --max-old-space-size=10240 --enable-source-maps --env-file=.env.prodlocal experimental/lib/perf_filter.js"
760
985
  },
@@ -764,9 +989,7 @@ var package_default = {
764
989
  author: "Degu Labs, Inc",
765
990
  license: "Fair Source 100",
766
991
  workspaces: [
767
- "./sdk",
768
992
  "./cli",
769
- "./playwright",
770
993
  "./docs",
771
994
  "./landing",
772
995
  "./legal",
@@ -778,6 +1001,7 @@ var package_default = {
778
1001
  "./web"
779
1002
  ],
780
1003
  devDependencies: {
1004
+ "@flakiness/playwright": "^0.150.0",
781
1005
  "@playwright/test": "^1.57.0",
782
1006
  "@types/node": "^22.10.2",
783
1007
  esbuild: "^0.27.0",
@@ -785,6 +1009,9 @@ var package_default = {
785
1009
  kubik: "^0.24.0",
786
1010
  tsx: "^4.19.2",
787
1011
  typescript: "^5.6.2"
1012
+ },
1013
+ dependencies: {
1014
+ "@flakiness/sdk": "^0.150.2"
788
1015
  }
789
1016
  };
790
1017
 
@@ -793,9 +1020,6 @@ import fs2 from "fs/promises";
793
1020
  import os from "os";
794
1021
  import path2 from "path";
795
1022
 
796
- // src/serverapi.ts
797
- import { TypedHTTP } from "@flakiness/shared/common/typedHttp.js";
798
-
799
1023
  // src/utils.ts
800
1024
  import { ReportUtils } from "@flakiness/sdk";
801
1025
  import crypto from "crypto";
@@ -1475,7 +1699,7 @@ async function ensureAccessToken(options) {
1475
1699
  try {
1476
1700
  accessToken = (await session.api.project.getProject.GET({ projectPublicId })).readWriteAccessToken;
1477
1701
  } catch (e) {
1478
- if (e instanceof TypedHTTP2.HttpError && e.status === 404) {
1702
+ if (e instanceof TypedHTTP.HttpError && e.status === 404) {
1479
1703
  } else {
1480
1704
  throw e;
1481
1705
  }
package/package.json CHANGED
@@ -1,16 +1,11 @@
1
1
  {
2
2
  "name": "flakiness",
3
- "version": "0.149.1",
3
+ "version": "0.150.0",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "flakiness": "./lib/cli/cli.js"
7
7
  },
8
8
  "exports": {
9
- "./playwright-json-report": {
10
- "types": "./types/src/playwrightJSONReport.d.ts",
11
- "import": "./lib/playwrightJSONReport.js",
12
- "require": "./lib/playwrightJSONReport.js"
13
- },
14
9
  "./junit": {
15
10
  "types": "./types/src/junit.d.ts",
16
11
  "import": "./lib/junit.js",
@@ -32,12 +27,12 @@
32
27
  "author": "Degu Labs, Inc",
33
28
  "license": "Fair Source 100",
34
29
  "devDependencies": {
35
- "@flakiness/server": "0.149.1",
30
+ "@flakiness/server": "0.150.0",
31
+ "@flakiness/shared": "0.150.0",
36
32
  "@playwright/test": "^1.57.0"
37
33
  },
38
34
  "dependencies": {
39
- "@flakiness/sdk": "0.149.1",
40
- "@flakiness/shared": "0.149.1",
35
+ "@flakiness/sdk": "^0.150.1",
41
36
  "@rgrove/parse-xml": "^4.2.0",
42
37
  "chalk": "^5.6.2",
43
38
  "commander": "^13.1.0",