@elastic/synthetics 1.0.0-beta.8 → 1.0.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.
Files changed (220) hide show
  1. package/README.md +5 -4
  2. package/dist/cli.js +139 -165
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +158 -34
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/config.d.ts +1 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +7 -6
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/browser-service.d.ts +1 -1
  11. package/dist/core/browser-service.d.ts.map +1 -1
  12. package/dist/core/browser-service.js +7 -6
  13. package/dist/core/browser-service.js.map +1 -1
  14. package/dist/core/expect.d.ts +25 -25
  15. package/dist/core/expect.d.ts.map +1 -1
  16. package/dist/core/expect.js.map +1 -1
  17. package/dist/core/gatherer.d.ts +5 -8
  18. package/dist/core/gatherer.d.ts.map +1 -1
  19. package/dist/core/gatherer.js +75 -17
  20. package/dist/core/gatherer.js.map +1 -1
  21. package/dist/core/index.d.ts +5 -1
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js +23 -11
  24. package/dist/core/index.js.map +1 -1
  25. package/dist/core/logger.d.ts +0 -1
  26. package/dist/core/logger.d.ts.map +1 -1
  27. package/dist/core/logger.js +10 -17
  28. package/dist/core/logger.js.map +1 -1
  29. package/dist/core/runner.d.ts +12 -63
  30. package/dist/core/runner.d.ts.map +1 -1
  31. package/dist/core/runner.js +159 -92
  32. package/dist/core/runner.js.map +1 -1
  33. package/dist/core/transform.d.ts +37 -0
  34. package/dist/core/transform.d.ts.map +1 -0
  35. package/dist/core/transform.js +148 -0
  36. package/dist/core/transform.js.map +1 -0
  37. package/dist/dsl/index.js +5 -1
  38. package/dist/dsl/index.js.map +1 -1
  39. package/dist/dsl/journey.d.ts +9 -7
  40. package/dist/dsl/journey.d.ts.map +1 -1
  41. package/dist/dsl/journey.js +32 -39
  42. package/dist/dsl/journey.js.map +1 -1
  43. package/dist/dsl/monitor.d.ts +93 -0
  44. package/dist/dsl/monitor.d.ts.map +1 -0
  45. package/dist/dsl/monitor.js +110 -0
  46. package/dist/dsl/monitor.js.map +1 -0
  47. package/dist/dsl/step.d.ts +3 -2
  48. package/dist/dsl/step.d.ts.map +1 -1
  49. package/dist/dsl/step.js +6 -1
  50. package/dist/dsl/step.js.map +1 -1
  51. package/dist/formatter/javascript.d.ts +115 -0
  52. package/dist/formatter/javascript.d.ts.map +1 -0
  53. package/dist/formatter/javascript.js +331 -0
  54. package/dist/formatter/javascript.js.map +1 -0
  55. package/dist/generator/index.d.ts +24 -0
  56. package/dist/generator/index.d.ts.map +1 -0
  57. package/dist/generator/index.js +241 -0
  58. package/dist/generator/index.js.map +1 -0
  59. package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
  60. package/dist/generator/utils.d.ts.map +1 -0
  61. package/dist/generator/utils.js +84 -0
  62. package/dist/generator/utils.js.map +1 -0
  63. package/dist/helpers.d.ts +36 -9
  64. package/dist/helpers.d.ts.map +1 -1
  65. package/dist/helpers.js +170 -24
  66. package/dist/helpers.js.map +1 -1
  67. package/dist/index.d.ts +5 -7
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +5 -26
  70. package/dist/index.js.map +1 -1
  71. package/dist/loader.d.ts +34 -0
  72. package/dist/loader.d.ts.map +1 -0
  73. package/dist/loader.js +153 -0
  74. package/dist/loader.js.map +1 -0
  75. package/dist/locations/index.d.ts +45 -0
  76. package/dist/locations/index.d.ts.map +1 -0
  77. package/dist/locations/index.js +83 -0
  78. package/dist/locations/index.js.map +1 -0
  79. package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
  80. package/dist/locations/public-locations.d.ts.map +1 -0
  81. package/dist/locations/public-locations.js +41 -0
  82. package/dist/locations/public-locations.js.map +1 -0
  83. package/dist/options.d.ts +42 -0
  84. package/dist/options.d.ts.map +1 -0
  85. package/dist/options.js +146 -0
  86. package/dist/options.js.map +1 -0
  87. package/dist/plugins/browser-console.d.ts +5 -4
  88. package/dist/plugins/browser-console.d.ts.map +1 -1
  89. package/dist/plugins/browser-console.js +47 -24
  90. package/dist/plugins/browser-console.js.map +1 -1
  91. package/dist/plugins/index.js +5 -1
  92. package/dist/plugins/index.js.map +1 -1
  93. package/dist/plugins/network.d.ts +24 -31
  94. package/dist/plugins/network.d.ts.map +1 -1
  95. package/dist/plugins/network.js +226 -229
  96. package/dist/plugins/network.js.map +1 -1
  97. package/dist/plugins/performance.d.ts +4 -19
  98. package/dist/plugins/performance.d.ts.map +1 -1
  99. package/dist/plugins/performance.js +6 -5
  100. package/dist/plugins/performance.js.map +1 -1
  101. package/dist/plugins/plugin-manager.d.ts +9 -5
  102. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  103. package/dist/plugins/plugin-manager.js +46 -30
  104. package/dist/plugins/plugin-manager.js.map +1 -1
  105. package/dist/plugins/tracing.d.ts +6 -6
  106. package/dist/plugins/tracing.d.ts.map +1 -1
  107. package/dist/plugins/tracing.js +13 -7
  108. package/dist/plugins/tracing.js.map +1 -1
  109. package/dist/push/bundler.d.ts +35 -0
  110. package/dist/push/bundler.d.ts.map +1 -0
  111. package/dist/push/bundler.js +131 -0
  112. package/dist/push/bundler.js.map +1 -0
  113. package/dist/push/index.d.ts +10 -0
  114. package/dist/push/index.d.ts.map +1 -0
  115. package/dist/push/index.js +235 -0
  116. package/dist/push/index.js.map +1 -0
  117. package/dist/push/kibana_api.d.ts +56 -0
  118. package/dist/push/kibana_api.d.ts.map +1 -0
  119. package/dist/push/kibana_api.js +135 -0
  120. package/dist/push/kibana_api.js.map +1 -0
  121. package/dist/push/monitor.d.ts +55 -0
  122. package/dist/push/monitor.d.ts.map +1 -0
  123. package/dist/push/monitor.js +268 -0
  124. package/dist/push/monitor.js.map +1 -0
  125. package/dist/{parse_args.d.ts → push/plugin.d.ts} +9 -6
  126. package/dist/push/plugin.d.ts.map +1 -0
  127. package/dist/push/plugin.js +66 -0
  128. package/dist/push/plugin.js.map +1 -0
  129. package/dist/push/request.d.ts +45 -0
  130. package/dist/push/request.d.ts.map +1 -0
  131. package/dist/push/request.js +109 -0
  132. package/dist/push/request.js.map +1 -0
  133. package/dist/push/utils.d.ts +31 -0
  134. package/dist/push/utils.d.ts.map +1 -0
  135. package/dist/push/utils.js +64 -0
  136. package/dist/push/utils.js.map +1 -0
  137. package/dist/reporters/base.d.ts +14 -6
  138. package/dist/reporters/base.d.ts.map +1 -1
  139. package/dist/reporters/base.js +58 -50
  140. package/dist/reporters/base.js.map +1 -1
  141. package/dist/reporters/index.d.ts +18 -8
  142. package/dist/reporters/index.d.ts.map +1 -1
  143. package/dist/reporters/index.js.map +1 -1
  144. package/dist/reporters/json.d.ts +17 -62
  145. package/dist/reporters/json.d.ts.map +1 -1
  146. package/dist/reporters/json.js +147 -177
  147. package/dist/reporters/json.js.map +1 -1
  148. package/dist/reporters/junit.d.ts +7 -1
  149. package/dist/reporters/junit.d.ts.map +1 -1
  150. package/dist/reporters/junit.js +90 -95
  151. package/dist/reporters/junit.js.map +1 -1
  152. package/dist/sdk/lh-trace-processor.d.ts +35 -9
  153. package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
  154. package/dist/sdk/lh-trace-processor.js +114 -53
  155. package/dist/sdk/lh-trace-processor.js.map +1 -1
  156. package/dist/sdk/trace-metrics.d.ts +4 -4
  157. package/dist/sdk/trace-metrics.d.ts.map +1 -1
  158. package/dist/sdk/trace-metrics.js +3 -4
  159. package/dist/sdk/trace-metrics.js.map +1 -1
  160. package/dist/sdk/trace-processor.d.ts +11 -3
  161. package/dist/sdk/trace-processor.d.ts.map +1 -1
  162. package/dist/sdk/trace-processor.js +17 -9
  163. package/dist/sdk/trace-processor.js.map +1 -1
  164. package/package.json +38 -30
  165. package/src/cli.ts +223 -158
  166. package/src/common_types.ts +191 -34
  167. package/src/config.ts +1 -1
  168. package/src/core/expect.ts +58 -24
  169. package/src/core/gatherer.ts +92 -25
  170. package/src/core/index.ts +36 -15
  171. package/src/core/logger.ts +8 -12
  172. package/src/core/runner.ts +158 -148
  173. package/src/core/transform.ts +160 -0
  174. package/src/dsl/journey.ts +41 -21
  175. package/src/dsl/monitor.ts +152 -0
  176. package/src/dsl/step.ts +9 -2
  177. package/src/formatter/javascript.ts +414 -0
  178. package/src/generator/index.ts +308 -0
  179. package/src/generator/utils.ts +84 -0
  180. package/src/helpers.ts +182 -16
  181. package/src/index.ts +21 -22
  182. package/src/loader.ts +171 -0
  183. package/src/locations/index.ts +95 -0
  184. package/src/{reporters/reporter.ts → locations/public-locations.ts} +12 -9
  185. package/src/options.ts +175 -0
  186. package/src/plugins/browser-console.ts +33 -8
  187. package/src/plugins/network.ts +266 -284
  188. package/src/plugins/performance.ts +6 -22
  189. package/src/plugins/plugin-manager.ts +49 -31
  190. package/src/plugins/tracing.ts +11 -9
  191. package/src/push/bundler.ts +112 -0
  192. package/src/push/index.ts +291 -0
  193. package/src/push/kibana_api.ts +191 -0
  194. package/src/push/monitor.ts +307 -0
  195. package/src/push/plugin.ts +66 -0
  196. package/src/push/request.ts +141 -0
  197. package/src/push/utils.ts +77 -0
  198. package/src/reporters/base.ts +63 -52
  199. package/src/reporters/index.ts +26 -3
  200. package/src/reporters/json.ts +181 -201
  201. package/src/reporters/junit.ts +98 -93
  202. package/src/sdk/lh-trace-processor.ts +132 -68
  203. package/src/sdk/trace-metrics.ts +8 -4
  204. package/src/sdk/trace-processor.ts +28 -13
  205. package/templates/.github/workflows/run-synthetics.yml +27 -0
  206. package/templates/README.md +21 -0
  207. package/templates/journeys/advanced-example-helpers.ts +54 -0
  208. package/templates/journeys/advanced-example.journey.ts +43 -0
  209. package/templates/journeys/example.journey.ts +18 -0
  210. package/templates/lightweight/heartbeat.yml +9 -0
  211. package/templates/synthetics.config.ts +35 -0
  212. package/CHANGELOG.md +0 -181
  213. package/NOTICE.txt +0 -221
  214. package/dist/parse_args.d.ts.map +0 -1
  215. package/dist/parse_args.js +0 -98
  216. package/dist/parse_args.js.map +0 -1
  217. package/dist/reporters/reporter.d.ts.map +0 -1
  218. package/dist/reporters/reporter.js.map +0 -1
  219. package/dist/tsconfig.tsbuildinfo +0 -1895
  220. package/src/parse_args.ts +0 -146
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.renderLocations = exports.groupLocations = exports.formatLocations = exports.getLocations = void 0;
28
+ const request_1 = require("../push/request");
29
+ const helpers_1 = require("../helpers");
30
+ const utils_1 = require("../push/utils");
31
+ const PRIVATE_KEYWORD = '(private)';
32
+ async function getLocations(options) {
33
+ const resp = await (0, request_1.sendReqAndHandleError)({
34
+ url: (0, utils_1.generateURL)(options, 'location'),
35
+ method: 'GET',
36
+ auth: options.auth,
37
+ });
38
+ return resp.locations;
39
+ }
40
+ exports.getLocations = getLocations;
41
+ function formatLocations(locations) {
42
+ const formatted = [];
43
+ for (const location of locations) {
44
+ let name = location.label;
45
+ if (location.isServiceManaged) {
46
+ [, name] = name.includes('-') ? name.split('-') : [, name];
47
+ name = name.toLowerCase().trim().split(' ').join('_');
48
+ }
49
+ else {
50
+ name = `${name}${PRIVATE_KEYWORD}`;
51
+ }
52
+ formatted.push(name);
53
+ }
54
+ return formatted;
55
+ }
56
+ exports.formatLocations = formatLocations;
57
+ function groupLocations(locations) {
58
+ const grouped = { locations: [], privateLocations: [] };
59
+ for (const loc of locations) {
60
+ if (loc.includes(PRIVATE_KEYWORD)) {
61
+ grouped.privateLocations.push(loc.replace(PRIVATE_KEYWORD, ''));
62
+ }
63
+ else {
64
+ grouped.locations.push(loc);
65
+ }
66
+ }
67
+ return grouped;
68
+ }
69
+ exports.groupLocations = groupLocations;
70
+ function renderLocations(locations) {
71
+ let outer = 'Available locations: \n';
72
+ let inner = '';
73
+ for (const location of locations) {
74
+ inner += `* ${location}\n`;
75
+ }
76
+ outer += (0, helpers_1.indent)(inner);
77
+ outer += `\nSet default location for monitors via
78
+ - Synthetics config file 'monitors.locations' | 'monitors.privateLocations' field
79
+ - Monitor API 'monitor.use({ locations: ["japan"], privateLocations: ["custom-location"] }')`;
80
+ (0, helpers_1.write)(outer);
81
+ }
82
+ exports.renderLocations = renderLocations;
83
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/locations/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,6CAAwD;AACxD,wCAA2C;AAC3C,yCAA4C;AAiB5C,MAAM,eAAe,GAAG,WAAW,CAAC;AAE7B,KAAK,UAAU,YAAY,CAAC,OAA2B;IAC5D,MAAM,IAAI,GAAG,MAAM,IAAA,+BAAqB,E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C,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC7B;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAVD,wCAUC;AAED,SAAgB,eAAe,CAAC,SAAwB;IACtD,IAAI,KAAK,GAAG,yBAAyB,CAAC;IACtC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,KAAK,IAAI,KAAK,QAAQ,IAAI,CAAC;KAC5B;IACD,KAAK,IAAI,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC;IACvB,KAAK,IAAI;;+FAEoF,CAAC;IAE9F,IAAA,eAAK,EAAC,KAAK,CAAC,CAAC;AACf,CAAC;AAZD,0CAYC"}
@@ -22,12 +22,16 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import Runner from '../core/runner';
26
- export declare type ReporterOptions = {
27
- fd?: number;
28
- colors?: boolean;
25
+ export declare const LocationsMap: {
26
+ japan: string;
27
+ india: string;
28
+ singapore: string;
29
+ australia_east: string;
30
+ united_kingdom: string;
31
+ germany: string;
32
+ canada_east: string;
33
+ brazil: string;
34
+ us_east: string;
35
+ us_west: string;
29
36
  };
30
- export default interface Reporter {
31
- new (runner: Runner, options: ReporterOptions): any;
32
- }
33
- //# sourceMappingURL=reporter.d.ts.map
37
+ //# sourceMappingURL=public-locations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-locations.d.ts","sourceRoot":"","sources":["../../src/locations/public-locations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,eAAO,MAAM,YAAY;;;;;;;;;;;CAWxB,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.LocationsMap = void 0;
28
+ // DO NOT EDIT - UPDATE WITH `npm run build:locations`
29
+ exports.LocationsMap = {
30
+ japan: 'asia-northeast1-a',
31
+ india: 'asia-south1-a',
32
+ singapore: 'asia-southeast1-a',
33
+ australia_east: 'australia-southeast1-a',
34
+ united_kingdom: 'europe-west2-a',
35
+ germany: 'europe-west3-a',
36
+ canada_east: 'northamerica-northeast1-a',
37
+ brazil: 'southamerica-east1-a',
38
+ us_east: 'us-east4-a',
39
+ us_west: 'us-west1-a',
40
+ };
41
+ //# sourceMappingURL=public-locations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public-locations.js","sourceRoot":"","sources":["../../src/locations/public-locations.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,sDAAsD;AACzC,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,mBAAmB;IAC1B,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,mBAAmB;IAC9B,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,gBAAgB;IAChC,OAAO,EAAE,gBAAgB;IACzB,WAAW,EAAE,2BAA2B;IACxC,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,YAAY;CACtB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2020-present, Elastic NV
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ */
25
+ import type { CliArgs, RunOptions } from './common_types';
26
+ export declare function normalizeOptions(cliArgs: CliArgs): RunOptions;
27
+ /**
28
+ * Parses the throttling CLI settings with `{download: 5, upload: 3, latency:
29
+ * 20}` format
30
+ *
31
+ * Since throttling is disabled for now, we warn the users if throttling/nothrottling
32
+ * flag is passed to the CLI
33
+ */
34
+ export declare function parseThrottling(): void;
35
+ export declare function getCommonCommandOpts(): {
36
+ params: import("commander").Option;
37
+ playwrightOpts: import("commander").Option;
38
+ pattern: import("commander").Option;
39
+ tags: import("commander").Option;
40
+ match: import("commander").Option;
41
+ };
42
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG1D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAwF7D;AAWD;;;;;;GAMG;AACH,wBAAgB,eAAe,SAE9B;AAED,wBAAgB,oBAAoB;;;;;;EAiCnC"}
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.getCommonCommandOpts = exports.parseThrottling = exports.normalizeOptions = void 0;
31
+ const deepmerge_1 = __importDefault(require("deepmerge"));
32
+ const commander_1 = require("commander");
33
+ const config_1 = require("./config");
34
+ const helpers_1 = require("./helpers");
35
+ function normalizeOptions(cliArgs) {
36
+ const options = {
37
+ ...cliArgs,
38
+ environment: process.env['NODE_ENV'] || 'development',
39
+ };
40
+ /**
41
+ * Group all events that can be consumed by heartbeat and
42
+ * eventually by the Synthetics UI.
43
+ */
44
+ if (cliArgs.richEvents) {
45
+ options.reporter = cliArgs.reporter ?? 'json';
46
+ options.ssblocks = true;
47
+ options.network = true;
48
+ options.trace = true;
49
+ options.quietExitCode = true;
50
+ }
51
+ if (cliArgs.capability) {
52
+ const supportedCapabilities = [
53
+ 'trace',
54
+ 'network',
55
+ 'filmstrips',
56
+ 'metrics',
57
+ 'ssblocks',
58
+ ];
59
+ /**
60
+ * trace - record chrome trace events(LCP, FCP, CLS, etc.) for all journeys
61
+ * network - capture network information for all journeys
62
+ * filmstrips - record detailed filmstrips for all journeys
63
+ * metrics - capture performance metrics (DOM Nodes, Heap size, etc.) for each step
64
+ * ssblocks - Dedupes the screenshots in to blocks to save storage space
65
+ */
66
+ for (const flag of cliArgs.capability) {
67
+ if (supportedCapabilities.includes(flag)) {
68
+ options[flag] = true;
69
+ }
70
+ else {
71
+ console.warn(`Missing capability "${flag}", current supported capabilities are ${supportedCapabilities.join(', ')}`);
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Validate and read synthetics config file
77
+ * based on the environment
78
+ */
79
+ const config = cliArgs.config || !cliArgs.inline
80
+ ? (0, config_1.readConfig)(options.environment, cliArgs.config)
81
+ : {};
82
+ /**
83
+ * Order of preference for options that are used while running are
84
+ * 1. Local options configured via Runner API
85
+ * 2. CLI flags
86
+ * 3. Configuration file
87
+ */
88
+ options.params = Object.freeze((0, deepmerge_1.default)(config.params, cliArgs.params || {}));
89
+ /**
90
+ * Merge playwright options from CLI and Synthetics config
91
+ * and prefer individual options over other option
92
+ */
93
+ const playwrightOpts = (0, deepmerge_1.default)(config.playwrightOptions, cliArgs.playwrightOptions || {});
94
+ options.playwrightOptions = {
95
+ ...playwrightOpts,
96
+ chromiumSandbox: cliArgs.sandbox ?? playwrightOpts?.chromiumSandbox,
97
+ ignoreHTTPSErrors: cliArgs.ignoreHttpsErrors ?? playwrightOpts?.ignoreHTTPSErrors,
98
+ };
99
+ /**
100
+ * Get the default monitor config from synthetics.config.ts file
101
+ */
102
+ const monitor = config.monitor;
103
+ options.schedule = cliArgs.schedule ?? monitor?.schedule;
104
+ options.locations = cliArgs.locations ?? monitor?.locations;
105
+ options.privateLocations =
106
+ cliArgs.privateLocations ?? monitor?.privateLocations;
107
+ return options;
108
+ }
109
+ exports.normalizeOptions = normalizeOptions;
110
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
111
+ function toObject(value) {
112
+ const defaulVal = {};
113
+ if (typeof value === 'boolean') {
114
+ return defaulVal;
115
+ }
116
+ return value || defaulVal;
117
+ }
118
+ /**
119
+ * Parses the throttling CLI settings with `{download: 5, upload: 3, latency:
120
+ * 20}` format
121
+ *
122
+ * Since throttling is disabled for now, we warn the users if throttling/nothrottling
123
+ * flag is passed to the CLI
124
+ */
125
+ function parseThrottling() {
126
+ (0, helpers_1.warn)(helpers_1.THROTTLING_WARNING_MSG);
127
+ }
128
+ exports.parseThrottling = parseThrottling;
129
+ function getCommonCommandOpts() {
130
+ const params = (0, commander_1.createOption)('-p, --params <jsonstring>', 'JSON object that gets injected to all journeys');
131
+ params.argParser(JSON.parse);
132
+ const playwrightOpts = (0, commander_1.createOption)('--playwright-options <jsonstring>', 'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file.');
133
+ playwrightOpts.argParser(JSON.parse);
134
+ const pattern = (0, commander_1.createOption)('--pattern <pattern>', 'RegExp pattern to match journey/monitor files that are different from the default (ex: /*.journey.(ts|js)$/)');
135
+ const tags = (0, commander_1.createOption)('--tags <name...>', 'run/push tests with a tag that matches the glob');
136
+ const match = (0, commander_1.createOption)('--match <name>', 'run/push tests with a name or tags that matches the glob');
137
+ return {
138
+ params,
139
+ playwrightOpts,
140
+ pattern,
141
+ tags,
142
+ match,
143
+ };
144
+ }
145
+ exports.getCommonCommandOpts = getCommonCommandOpts;
146
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,0DAA8B;AAC9B,yCAAyC;AACzC,qCAAsC;AAEtC,uCAAyD;AAEzD,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,OAAO,GAAe;QAC1B,GAAG,OAAO;QACV,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,aAAa;KACtD,CAAC;IACF;;;OAGG;IACH,IAAI,OAAO,CAAC,UAAU,EAAE;QACtB,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC;QAC9C,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;QACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACvB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;QACrB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;KAC9B;IAED,IAAI,OAAO,CAAC,UAAU,EAAE;QACtB,MAAM,qBAAqB,GAAG;YAC5B,OAAO;YACP,SAAS;YACT,YAAY;YACZ,SAAS;YACT,UAAU;SACX,CAAC;QACF;;;;;;WAMG;QACH,KAAK,MAAM,IAAI,IAAI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O,EAAE,gBAAgB,CAAC;IAExD,OAAO,OAAO,CAAC;AACjB,CAAC;AAxFD,4CAwFC;AAED,gEAAgE;AAChE,SAAS,QAAQ,CAAC,KAAoC;IACpD,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QAC9B,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,KAAK,IAAI,SAAS,CAAC;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe;IAC7B,IAAA,cAAI,EAAC,gCAAsB,CAAC,CAAC;AAC/B,CAAC;AAFD,0CAEC;AAED,SAAgB,oBAAoB;IAClC,MAAM,MAAM,GAAG,IAAA,wBAAY,EACzB,2BAA2B,EAC3B,gDAAgD,CACjD,CAAC;IACF,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE7B,MAAM,cAAc,GAAG,IAAA,wBAAY,EACjC,mCAAmC,EACnC,kKAAkK,CACnK,CAAC;IACF,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,IAAA,wBAAY,EAC1B,qBAAqB,EACrB,8GAA8G,CAC/G,CAAC;IACF,MAAM,IAAI,GAAG,IAAA,wBAAY,EACvB,kBAAkB,EAClB,iDAAiD,CAClD,CAAC;IACF,MAAM,KAAK,GAAG,IAAA,wBAAY,EACxB,gBAAgB,EAChB,0DAA0D,CAC3D,CAAC;IAEF,OAAO;QACL,MAAM;QACN,cAAc;QACd,OAAO;QACP,IAAI;QACJ,KAAK;KACN,CAAC;AACJ,CAAC;AAjCD,oDAiCC"}
@@ -22,15 +22,16 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { Page } from 'playwright-chromium';
26
- import { BrowserMessage } from '../common_types';
25
+ import { BrowserMessage, Driver } from '../common_types';
27
26
  import { Step } from '../dsl';
28
27
  export declare class BrowserConsole {
29
- private page;
28
+ private driver;
30
29
  private messages;
31
30
  _currentStep: Partial<Step>;
31
+ constructor(driver: Driver);
32
32
  private consoleEventListener;
33
- constructor(page: Page);
33
+ private pageErrorEventListener;
34
+ private enforceMessagesLimit;
34
35
  start(): void;
35
36
  stop(): BrowserMessage[];
36
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"browser-console.d.ts","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B,qBAAa,cAAc;IAuBb,OAAO,CAAC,IAAI;IAtBxB,OAAO,CAAC,QAAQ,CAAwB;IACxC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAQ;IAEnC,OAAO,CAAC,oBAAoB,CAiB1B;gBAEkB,IAAI,EAAE,IAAI;IAE9B,KAAK;IAIL,IAAI;CAIL"}
1
+ {"version":3,"file":"browser-console.d.ts","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B,qBAAa,cAAc;IAIb,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,QAAQ,CAAwB;IACxC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAQ;gBAEf,MAAM,EAAE,MAAM;IAElC,OAAO,CAAC,oBAAoB,CAgB1B;IAEF,OAAO,CAAC,sBAAsB,CAc5B;IAEF,OAAO,CAAC,oBAAoB;IAM5B,KAAK;IAML,IAAI;CAML"}
@@ -25,37 +25,60 @@
25
25
  */
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.BrowserConsole = void 0;
28
+ const logger_1 = require("../core/logger");
28
29
  const helpers_1 = require("../helpers");
29
30
  const defaultMessageLimit = 1000;
30
31
  class BrowserConsole {
31
- constructor(page) {
32
- this.page = page;
33
- this.messages = [];
34
- this._currentStep = null;
35
- this.consoleEventListener = msg => {
36
- if (!this._currentStep) {
37
- return;
38
- }
39
- const type = msg.type();
40
- if (type === 'error' || type === 'warning') {
41
- const { name, index } = this._currentStep;
42
- this.messages.push({
43
- timestamp: helpers_1.getTimestamp(),
44
- text: msg.text(),
45
- type,
46
- step: { name, index },
47
- });
48
- if (this.messages.length > defaultMessageLimit) {
49
- this.messages.splice(0, 1);
50
- }
51
- }
52
- };
32
+ driver;
33
+ messages = [];
34
+ _currentStep = null;
35
+ constructor(driver) {
36
+ this.driver = driver;
37
+ }
38
+ consoleEventListener = msg => {
39
+ if (!this._currentStep) {
40
+ return;
41
+ }
42
+ const type = msg.type();
43
+ if (type === 'error' || type === 'warning') {
44
+ const { name, index } = this._currentStep;
45
+ this.messages.push({
46
+ timestamp: (0, helpers_1.getTimestamp)(),
47
+ text: msg.text(),
48
+ type,
49
+ step: { name, index },
50
+ });
51
+ this.enforceMessagesLimit();
52
+ }
53
+ };
54
+ pageErrorEventListener = (error) => {
55
+ if (!this._currentStep) {
56
+ return;
57
+ }
58
+ const { name, index } = this._currentStep;
59
+ this.messages.push({
60
+ timestamp: (0, helpers_1.getTimestamp)(),
61
+ text: error.message,
62
+ type: 'error',
63
+ step: { name, index },
64
+ error,
65
+ });
66
+ this.enforceMessagesLimit();
67
+ };
68
+ enforceMessagesLimit() {
69
+ if (this.messages.length > defaultMessageLimit) {
70
+ this.messages.splice(0, 1);
71
+ }
53
72
  }
54
73
  start() {
55
- this.page.on('console', this.consoleEventListener);
74
+ (0, logger_1.log)(`Plugins: started collecting console events`);
75
+ this.driver.page.on('console', this.consoleEventListener);
76
+ this.driver.page.on('pageerror', this.pageErrorEventListener);
56
77
  }
57
78
  stop() {
58
- this.page.off('console', this.consoleEventListener);
79
+ this.driver.page.off('console', this.consoleEventListener);
80
+ this.driver.page.off('pageerror', this.pageErrorEventListener);
81
+ (0, logger_1.log)(`Plugins: stopped collecting console events`);
59
82
  return this.messages;
60
83
  }
61
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"browser-console.js","sourceRoot":"","sources":["../../src/plugins/browser-console.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAKH,wCAA0C;AAE1C,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAa,cAAc;IAuBzB,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;QAtBtB,aAAQ,GAAqB,EAAE,CAAC;QACxC,iBAAY,GAAkB,IAAI,CAAC;QAE3B,yBAAoB,GAAG,GAAG,CAAC,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,OAAO;aACR;YACD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,SAAS,EAAE;gBAC1C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;gBAC1C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACjB,SAAS,EAAE,sBAAY,EAAE;oBACzB,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;oBAChB,IAAI;oBACJ,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;iBACtB,CAAC,CAAC;gBACH,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,mBAAmB,EAAE;oBAC9C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;iBAC5B;aACF;QACH,CAAC,CAAC;IAE+B,CAAC;IAElC,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS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E,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACjB,SAAS,EAAE,IAAA,sBAAY,GAAE;YACzB,IAAI,EAAE,KAAK,CAAC,OAAO;YACnB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACrB,KAAK;SACN,CAAC,CAAC;QAEH,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC,CAAC;IAEM,oBAAoB;QAC1B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,mBAAmB,EAAE;YAC9C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC5B;IACH,CAAC;IAED,KAAK;QACH,IAAA,YAAG,EAAC,4CAA4C,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC/D,IAAA,YAAG,EAAC,4CAA4C,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA1DD,wCA0DC"}
@@ -25,7 +25,11 @@
25
25
  */
26
26
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
27
  if (k2 === undefined) k2 = k;
28
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
29
33
  }) : (function(o, m, k, k2) {
30
34
  if (k2 === undefined) k2 = k;
31
35
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;AAEH,mDAAiC;AACjC,4CAA0B;AAC1B,gDAA8B;AAC9B,4CAA0B;AAC1B,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;AAEH,mDAAiC;AACjC,4CAA0B;AAC1B,gDAA8B;AAC9B,4CAA0B;AAC1B,oDAAkC"}
@@ -22,45 +22,38 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { CDPSession } from 'playwright-chromium';
26
- import { Protocol } from 'playwright-chromium/types/protocol';
27
- import { NetworkInfo } from '../common_types';
25
+ import { NetworkInfo, Driver } from '../common_types';
28
26
  import { Step } from '../dsl';
27
+ /**
28
+ * Used as a key in each Network Request to identify the
29
+ * associated request across distinct lifecycle events
30
+ */
31
+ export declare const NETWORK_ENTRY_SUMBOL: unique symbol;
29
32
  export declare class NetworkManager {
33
+ private driver;
30
34
  private _browser;
31
- private _InflightRequestMap;
35
+ private _barrierPromises;
32
36
  results: Array<NetworkInfo>;
33
37
  _currentStep: Partial<Step>;
34
- start(client: CDPSession): Promise<void>;
35
- _findNetworkRecord(requestId: string): NetworkInfo;
36
- _onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload): void;
37
- _onRequestWillBeSentExtraInfo(event: Protocol.Network.requestWillBeSentExtraInfoPayload): void;
38
- _onDataReceived(event: Protocol.Network.dataReceivedPayload): void;
39
- _onResponseReceived(event: Protocol.Network.responseReceivedPayload): void;
40
- _onLoadingFinished(event: Protocol.Network.loadingFinishedPayload): void;
41
- _onLoadingFailed(event: Protocol.Network.loadingFailedPayload): void;
42
- _requestCompleted(requestId: string, endTime: number, encodedDataLength?: number): void;
38
+ constructor(driver: Driver);
43
39
  /**
44
- * Account for missing response received event and also adjust the
45
- * response received event based on when first byte event was recorded
40
+ * Adds a protection barrier aganist all asynchronous extract operations from
41
+ * request/response object that are happening during page lifecycle, If the
42
+ * page is closed during the extraction, the barrier enforces those operations
43
+ * to not result in exception
46
44
  */
47
- getResponseReceivedTime(timing: Protocol.Network.Response['timing'], responseReceivedTime: number): number;
45
+ private _addBarrier;
46
+ start(): Promise<void>;
47
+ private _findNetworkEntry;
48
+ private _onRequest;
49
+ private _onResponse;
50
+ private _onRequestCompleted;
48
51
  /**
49
- * The timing calculations are based on the chrome devtools frontend
50
- * https://github.com/ChromeDevTools/devtools-frontend/blob/7f5478d8ceb7586f23f4073ab5c2085dac1ec26a/front_end/network/RequestTimingView.js#L98-L193
52
+ * Calculates the total time for the network request based on the ResourceTiming
53
+ * data from Playwright. Fallbacks to the event timings if ResourceTiming data
54
+ * is not available.
51
55
  */
52
- calculateTimings(record: NetworkInfo): {
53
- blocked: number;
54
- queueing: number;
55
- dns: number;
56
- ssl: number;
57
- proxy: number;
58
- connect: number;
59
- send: number;
60
- wait: number;
61
- receive: number;
62
- total: number;
63
- };
64
- stop(): NetworkInfo[];
56
+ private _calcTotalTime;
57
+ stop(): Promise<NetworkInfo[]>;
65
58
  }
66
59
  //# sourceMappingURL=network.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/plugins/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,q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