@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
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
- [![Build Status](https://apm-ci.elastic.co/job/apm-agent-rum/job/elastic-synthetics/job/master/badge/icon)](https://apm-ci.elastic.co/job/apm-agent-rum/job/elastic-synthetics/job/master/)
2
- # Experimental Synthetics Agent
1
+ [![ci](https://github.com/elastic/synthetics/actions/workflows/ci.yml/badge.svg)](https://github.com/elastic/synthetics/actions/workflows/ci.yml)
2
+ [![e2e](https://github.com/elastic/synthetics/actions/workflows/e2e.yml/badge.svg)](https://github.com/elastic/synthetics/actions/workflows/e2e.yml)
3
+
4
+ # Synthetics Agent
3
5
 
4
6
  Synthetic Monitoring with Real Browsers.
5
- **Please note this is an unsupported experimental project. Expect things to break and change!**
6
7
 
7
8
  ## Usage
8
9
 
@@ -20,7 +21,7 @@ npx @elastic/synthetics [options] [dir] [files] file
20
21
 
21
22
  ## Documentation
22
23
 
23
- - [Introduction](https://www.elastic.co/guide/en/observability/current/synthetic-monitoring.html)
24
+ - [Introduction](https://www.elastic.co/guide/en/observability/current/monitor-uptime-synthetics.html#monitoring-synthetics)
24
25
  - [CLI Options](https://www.elastic.co/guide/en/observability/current/synthetics-command-reference.html#elastic-synthetics-command)
25
26
  - [Syntax](https://www.elastic.co/guide/en/observability/current/synthetics-create-test.html#synthetics-syntax)
26
27
  - [Creating a Journey](https://www.elastic.co/guide/en/observability/current/synthetics-create-test.html#synthetics-create-journey)
package/dist/cli.js CHANGED
@@ -24,184 +24,158 @@
24
24
  * THE SOFTWARE.
25
25
  *
26
26
  */
27
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
- if (k2 === undefined) k2 = k;
29
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
43
- __setModuleDefault(result, mod);
44
- return result;
45
- };
46
- var __importDefault = (this && this.__importDefault) || function (mod) {
47
- return (mod && mod.__esModule) ? mod : { "default": mod };
48
- };
49
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
+ const commander_1 = require("commander");
50
29
  const process_1 = require("process");
51
- const path_1 = require("path");
52
- const deepmerge_1 = __importDefault(require("deepmerge"));
30
+ const reporters_1 = require("./reporters");
31
+ const options_1 = require("./options");
32
+ const loader_1 = require("./loader");
33
+ const _1 = require("./");
53
34
  const core_1 = require("./core");
54
- const logger_1 = require("./core/logger");
55
- const parse_args_1 = __importStar(require("./parse_args"));
35
+ const monitor_1 = require("./dsl/monitor");
36
+ const push_1 = require("./push");
37
+ const locations_1 = require("./locations");
38
+ const path_1 = require("path");
39
+ const generator_1 = require("./generator");
56
40
  const helpers_1 = require("./helpers");
57
- const _1 = require("./");
58
- const config_1 = require("./config");
59
- const resolvedCwd = process_1.cwd();
60
- /**
61
- * Set debug based on DEBUG ENV and -d flags
62
- * namespace - synthetics
63
- */
64
- const namespace = 'synthetics';
65
- if (process.env.DEBUG === namespace || Boolean(parse_args_1.options.debug)) {
66
- process.env.DEBUG = '1';
67
- }
68
- const loadInlineScript = source => {
69
- const scriptFn = new Function('step', 'page', 'browser', 'params', source);
70
- core_1.journey('inline', async ({ page, browser, params }) => {
71
- scriptFn.apply(null, [core_1.step, page, browser, params]);
72
- });
73
- };
74
- async function readStdin() {
75
- const chunks = [];
76
- process_1.stdin.resume();
77
- process_1.stdin.setEncoding('utf-8');
78
- for await (const chunk of process_1.stdin) {
79
- chunks.push(chunk);
80
- }
81
- return chunks.join();
82
- }
83
- function requireSuites(suites) {
84
- for (const suite of suites) {
85
- require(suite);
86
- }
87
- }
88
- /**
89
- * Handle both directory and files that are passed through TTY
90
- * and add them to suites
91
- */
92
- async function prepareSuites(inputs) {
93
- const suites = new Set();
94
- const addSuite = absPath => {
95
- logger_1.log(`Processing file: ${absPath}`);
96
- suites.add(require.resolve(absPath));
97
- };
98
- /**
99
- * Match all files inside the directory with the
100
- * .journey.{mjs|cjs|js|ts) extensions
101
- */
102
- const pattern = parse_args_1.options.pattern
103
- ? new RegExp(parse_args_1.options.pattern, 'i')
104
- : /.+\.journey\.([mc]js|[jt]s?)$/;
105
- /**
106
- * Ignore node_modules by default when running suites
107
- */
108
- const ignored = /node_modules/i;
109
- for (const input of inputs) {
110
- const absPath = path_1.resolve(resolvedCwd, input);
41
+ const public_locations_1 = require("./locations/public-locations");
42
+ const monitor_2 = require("./push/monitor");
43
+ /* eslint-disable-next-line @typescript-eslint/no-var-requires */
44
+ const { name, version } = require('../package.json');
45
+ const { params, pattern, tags, match, playwrightOpts } = (0, options_1.getCommonCommandOpts)();
46
+ commander_1.program
47
+ .name(`npx ${name}`)
48
+ .usage('[options] [dir] [files] file')
49
+ .option('-c, --config <path>', 'configuration path (default: synthetics.config.js)')
50
+ .addOption(pattern)
51
+ .addOption(tags)
52
+ .addOption(match)
53
+ .addOption(params)
54
+ .addOption(new commander_1.Option('--reporter <value>', `output reporter format`).choices(Object.keys(reporters_1.reporters)))
55
+ .option('--inline', 'Run inline journeys from heartbeat')
56
+ .option('-r, --require <modules...>', 'module(s) to preload')
57
+ .option('--sandbox', 'enable chromium sandboxing')
58
+ .option('--rich-events', 'Mimics a heartbeat run')
59
+ .option('--capability <features...>', 'Enable capabilities through feature flags')
60
+ .addOption(new commander_1.Option('--screenshots [flag]', 'take screenshots at end of each step')
61
+ .choices(['on', 'off', 'only-on-failure'])
62
+ .default('on'))
63
+ .option('--dry-run', "don't actually execute anything, report only registered journeys")
64
+ .option('--outfd <fd>', 'specify a file descriptor for logs. Default is stdout', parseInt)
65
+ .option('--ws-endpoint <endpoint>', 'Browser WebSocket endpoint to connect to')
66
+ .option('--pause-on-error', 'pause on error until a keypress is made in the console. Useful during development')
67
+ .option('--ignore-https-errors', 'ignores any HTTPS errors in sites being tested, including ones related to unrecognized certs or signatures. This can be insecure!')
68
+ .option('--quiet-exit-code', 'always return 0 as an exit code status, regardless of test pass / fail. Only return > 0 exit codes on internal errors where the suite could not be run')
69
+ .option('--throttling <config>', 'JSON object to throttle network conditions for download and upload throughput in megabits/second and latency in milliseconds. Ex: { "download": 10, "upload": 5, "latency": 200 }.', options_1.parseThrottling)
70
+ .option('--no-throttling', 'Turns off default network throttling.', options_1.parseThrottling)
71
+ .addOption(playwrightOpts)
72
+ .version(version)
73
+ .description('Run synthetic tests')
74
+ .action(async (cliArgs) => {
75
+ const tearDown = await (0, loader_1.globalSetup)(cliArgs, commander_1.program.args);
76
+ try {
77
+ const options = (0, options_1.normalizeOptions)(cliArgs);
78
+ const results = await (0, _1.run)(options);
111
79
  /**
112
- * Validate for package.json file before running
113
- * the suites
80
+ * Exit with error status if any journey fails
114
81
  */
115
- helpers_1.findPkgJsonByTraversing(absPath, resolvedCwd);
116
- if (helpers_1.isDirectory(absPath)) {
117
- await helpers_1.totalist(absPath, (rel, abs) => {
118
- if (pattern.test(rel) && !ignored.test(rel)) {
119
- addSuite(abs);
82
+ if (!options.quietExitCode) {
83
+ for (const result of Object.values(results)) {
84
+ if (result.status === 'failed') {
85
+ process.exit(1);
120
86
  }
121
- });
122
- }
123
- else {
124
- addSuite(absPath);
87
+ }
125
88
  }
126
89
  }
127
- return suites.values();
128
- }
129
- (async () => {
130
- if (parse_args_1.options.inline) {
131
- const source = await readStdin();
132
- loadInlineScript(source);
90
+ catch (e) {
91
+ console.error(e);
92
+ process.exit(1);
133
93
  }
134
- else {
135
- /**
136
- * Preload modules before running the suites
137
- */
138
- const modules = [].concat(parse_args_1.options.require || []).filter(Boolean);
139
- for (const name of modules) {
140
- if (helpers_1.isDepInstalled(name)) {
141
- require(name);
142
- }
143
- else {
144
- throw new Error(`cannot find module '${name}'`);
145
- }
146
- }
147
- /**
148
- * Transform `.ts` files out of the box by invoking
149
- * the `ts-node` via `transpile-only` mode that compiles
150
- * TS files without doing any extensive type checks
151
- */
152
- /* eslint-disable-next-line @typescript-eslint/no-var-requires */
153
- require('ts-node').register({
154
- transpileOnly: true,
155
- compilerOptions: {
156
- esModuleInterop: true,
157
- allowJs: true,
158
- target: 'es2018',
159
- },
94
+ finally {
95
+ tearDown();
96
+ }
97
+ });
98
+ // Push command
99
+ commander_1.program
100
+ .command('push')
101
+ .description('Push all journeys in the current directory to create monitors within the Kibana monitor management UI')
102
+ .addOption(new commander_1.Option('--auth <auth>', 'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).')
103
+ .env('SYNTHETICS_API_KEY')
104
+ .makeOptionMandatory(true))
105
+ .option('--schedule <time-in-minutes>', "schedule in minutes for the pushed monitors. Setting `10`, for example, configures monitors which don't have an interval defined to run every 10 minutes.", parseInt)
106
+ .addOption(new commander_1.Option('--locations <locations...>', 'default list of locations from which your monitors will run.').choices(monitor_1.SyntheticsLocations))
107
+ .option('--private-locations <locations...>', 'default list of private locations from which your monitors will run.')
108
+ .option('--url <url>', 'Kibana URL to upload the monitors')
109
+ .option('--id <id>', 'project id that will be used for logically grouping monitors')
110
+ .option('--space <space>', 'the target Kibana spaces for the pushed monitors — spaces help you organise pushed monitors.')
111
+ .option('-y, --yes', 'skip all questions and run non-interactively')
112
+ .addOption(pattern)
113
+ .addOption(tags)
114
+ .addOption(match)
115
+ .addOption(params)
116
+ .addOption(playwrightOpts)
117
+ .action(async (cmdOpts) => {
118
+ const workDir = (0, process_1.cwd)();
119
+ const tearDown = await (0, loader_1.globalSetup)({ inline: false, ...commander_1.program.opts() }, [
120
+ workDir,
121
+ ]);
122
+ try {
123
+ const settings = await (0, push_1.loadSettings)();
124
+ const options = (0, options_1.normalizeOptions)({
125
+ ...commander_1.program.opts(),
126
+ ...settings,
127
+ ...cmdOpts,
160
128
  });
161
- /**
162
- * Handle piped files by reading the STDIN
163
- * ex: ls example/suites/*.js | npx @elastic/synthetics
164
- */
165
- const files = parse_args_1.default.args.length > 0
166
- ? parse_args_1.default.args
167
- : (await readStdin()).split('\n').filter(Boolean);
168
- const suites = await prepareSuites(files);
169
- requireSuites(suites);
129
+ (0, push_1.validateSettings)(options);
130
+ await (0, push_1.catchIncorrectSettings)(settings, options);
131
+ const monitors = core_1.runner.buildMonitors(options);
132
+ if (options.throttling == null) {
133
+ (0, push_1.warnIfThrottled)(monitors);
134
+ }
135
+ monitors.push(...(await (0, monitor_2.createLightweightMonitors)(workDir, options)));
136
+ await (0, push_1.push)(monitors, options);
137
+ }
138
+ catch (e) {
139
+ e && console.error(e);
140
+ process.exit(1);
141
+ }
142
+ finally {
143
+ tearDown();
144
+ }
145
+ });
146
+ // Init command
147
+ commander_1.program
148
+ .command('init [dir]')
149
+ .description('Initialize Elastic synthetics project')
150
+ .action(async (dir = '') => {
151
+ try {
152
+ const generator = await new generator_1.Generator((0, path_1.resolve)(process.cwd(), dir));
153
+ await generator.setup();
154
+ }
155
+ catch (e) {
156
+ e && (0, helpers_1.error)(e);
157
+ process.exit(1);
170
158
  }
171
- /**
172
- * Use the NODE_ENV variable to control the environment
173
- */
174
- const environment = process.env['NODE_ENV'] || 'development';
175
- /**
176
- * Validate and handle configs
177
- */
178
- const config = config_1.readConfig(environment, parse_args_1.options.config);
179
- const params = deepmerge_1.default(config.params, parse_args_1.options.suiteParams || {}, parse_args_1.options.params || {});
180
- const playwrightOptions = deepmerge_1.default(config.playwrightOptions, {
181
- headless: parse_args_1.options.headless,
182
- chromiumSandbox: parse_args_1.options.sandbox,
183
- });
184
- /**
185
- * use JSON reporter if json flag is enabled
186
- */
187
- const reporter = parse_args_1.options.json ? 'json' : parse_args_1.options.reporter;
188
- const results = await _1.run({
189
- params: Object.freeze(params),
190
- environment,
191
- reporter,
192
- playwrightOptions,
193
- ...parse_args_1.options,
194
- });
195
- /**
196
- * Exit with error status if any journey fails
197
- */
198
- for (const result of Object.values(results)) {
199
- if (result.status === 'failed') {
200
- process.exit(1);
159
+ });
160
+ // Locations command
161
+ commander_1.program
162
+ .command('locations')
163
+ .description(`List all locations to run the synthetics monitors. Pass optional '--url' and '--auth' to list private locations.`)
164
+ .option('--url <url>', 'Kibana URL to fetch all public and private locations')
165
+ .option('--auth <auth>', 'API key used for Kibana authentication(https://www.elastic.co/guide/en/kibana/master/api-keys.html).')
166
+ .action(async (cmdOpts) => {
167
+ try {
168
+ let locations = Object.keys(public_locations_1.LocationsMap);
169
+ if (cmdOpts.auth && cmdOpts.url) {
170
+ const allLocations = await (0, locations_1.getLocations)(cmdOpts);
171
+ locations = (0, locations_1.formatLocations)(allLocations);
201
172
  }
173
+ (0, locations_1.renderLocations)(locations);
174
+ }
175
+ catch (e) {
176
+ e && (0, helpers_1.error)(e);
177
+ process.exit(1);
202
178
  }
203
- })().catch(e => {
204
- console.error(e);
205
- process.exit(1);
206
179
  });
180
+ commander_1.program.parse(process.argv);
207
181
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAqC;AACrC,+BAA+B;AAC/B,0DAA8B;AAC9B,iCAAuC;AACvC,0CAAoC;AACpC,2DAAgD;AAChD,uCAKmB;AACnB,yBAAyB;AACzB,qCAAsC;AAEtC,MAAM,WAAW,GAAG,aAAG,EAAE,CAAC;AAC1B;;;GAGG;AACH,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/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,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -22,11 +22,16 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { BrowserContextOptions, LaunchOptions } from 'playwright-chromium';
26
- import { Protocol } from 'playwright-chromium/types/protocol';
25
+ import { BrowserContextOptions, LaunchOptions, CDPSession, ChromiumBrowser, ChromiumBrowserContext, Page, APIRequestContext } from 'playwright-chromium';
27
26
  import { Step } from './dsl';
28
- import { reporters } from './reporters';
27
+ import { BuiltInReporterName, ReporterInstance } from './reporters';
28
+ import { MonitorConfig } from './dsl/monitor';
29
29
  export declare type VoidCallback = () => void;
30
+ export declare type Location = {
31
+ file: string;
32
+ line: number;
33
+ column: number;
34
+ };
30
35
  export declare type Params = Record<string, any>;
31
36
  export declare type HooksArgs = {
32
37
  env: string;
@@ -34,7 +39,19 @@ export declare type HooksArgs = {
34
39
  };
35
40
  export declare type HooksCallback = (args: HooksArgs) => void;
36
41
  export declare type StatusValue = 'succeeded' | 'failed' | 'skipped';
37
- export declare type Reporters = keyof typeof reporters;
42
+ export declare type NetworkConditions = {
43
+ offline: boolean;
44
+ downloadThroughput: number;
45
+ uploadThroughput: number;
46
+ latency: number;
47
+ };
48
+ export declare type Driver = {
49
+ browser: ChromiumBrowser;
50
+ context: ChromiumBrowserContext;
51
+ page: Page;
52
+ client: CDPSession;
53
+ request: APIRequestContext;
54
+ };
38
55
  export declare type TraceOutput = {
39
56
  name: string;
40
57
  type: string;
@@ -65,26 +82,61 @@ export declare type BrowserInfo = {
65
82
  name: string;
66
83
  version: string;
67
84
  };
85
+ export declare type Screenshot = {
86
+ timestamp: number;
87
+ step: Step;
88
+ data: string;
89
+ };
90
+ export declare type SecurityDetails = {
91
+ issuer?: string;
92
+ protocol?: string;
93
+ subjectName?: string;
94
+ validFrom?: number;
95
+ validTo?: number;
96
+ };
97
+ export declare type Request = {
98
+ method: string;
99
+ url: string;
100
+ headers: Record<string, string>;
101
+ bytes?: number;
102
+ body?: {
103
+ bytes: number;
104
+ };
105
+ referrer?: string;
106
+ };
107
+ export declare type Response = {
108
+ url?: string;
109
+ status: number;
110
+ statusText?: string;
111
+ mimeType?: string;
112
+ headers: Record<string, string>;
113
+ bytes?: number;
114
+ body?: {
115
+ bytes: number;
116
+ };
117
+ transferSize?: number;
118
+ redirectURL?: string;
119
+ securityDetails?: SecurityDetails;
120
+ remoteIPAddress?: string;
121
+ remotePort?: number;
122
+ fromServiceWorker?: boolean;
123
+ };
68
124
  export declare type NetworkInfo = {
69
125
  url: string;
70
126
  browser: BrowserInfo;
71
- method: string;
72
127
  type: string;
73
- request: Protocol.Network.Request;
74
- response?: Protocol.Network.Response;
128
+ request: Request;
129
+ response: Response;
75
130
  isNavigationRequest: boolean;
76
131
  requestSentTime: number;
77
132
  loadEndTime: number;
78
133
  responseReceivedTime: number;
79
- status: number;
80
134
  resourceSize: number;
81
135
  transferSize: number;
82
- timings?: {
136
+ timings: {
83
137
  blocked: number;
84
- queueing: number;
85
138
  dns: number;
86
139
  ssl: number;
87
- proxy: number;
88
140
  connect: number;
89
141
  send: number;
90
142
  wait: number;
@@ -92,9 +144,11 @@ export declare type NetworkInfo = {
92
144
  total: number;
93
145
  };
94
146
  } & DefaultPluginOutput;
147
+ export declare type PageMetrics = Record<string, number>;
95
148
  export declare type BrowserMessage = {
96
149
  text: string;
97
150
  type: string;
151
+ error?: Error;
98
152
  } & DefaultPluginOutput;
99
153
  export declare type PluginOutput = {
100
154
  filmstrips?: Array<Filmstrip>;
@@ -104,40 +158,110 @@ export declare type PluginOutput = {
104
158
  metrics?: PerfMetrics;
105
159
  };
106
160
  export declare type ScreenshotOptions = 'on' | 'off' | 'only-on-failure';
107
- export declare type CliArgs = {
108
- capability?: Array<string>;
109
- config?: string;
110
- outfd?: number;
111
- headless?: boolean;
161
+ export declare type ThrottlingOptions = {
162
+ download?: number;
163
+ upload?: number;
164
+ latency?: number;
165
+ };
166
+ declare type BaseArgs = {
167
+ params?: Params;
112
168
  screenshots?: ScreenshotOptions;
113
- ssblocks?: boolean;
114
- metrics?: boolean;
115
- filmstrips?: boolean;
116
- trace?: boolean;
117
169
  dryRun?: boolean;
118
- network?: boolean;
119
- pauseOnError?: boolean;
120
- reporter?: Reporters;
170
+ match?: string;
171
+ tags?: Array<string>;
172
+ outfd?: number;
121
173
  wsEndpoint?: string;
174
+ pauseOnError?: boolean;
175
+ ignoreHttpsErrors?: boolean;
176
+ playwrightOptions?: PlaywrightOptions;
177
+ quietExitCode?: boolean;
178
+ throttling?: MonitorConfig['throttling'];
179
+ schedule?: MonitorConfig['schedule'];
180
+ locations?: MonitorConfig['locations'];
181
+ privateLocations?: MonitorConfig['privateLocations'];
182
+ };
183
+ export declare type CliArgs = BaseArgs & {
184
+ config?: string;
185
+ reporter?: BuiltInReporterName;
186
+ pattern?: string;
187
+ inline?: boolean;
188
+ require?: Array<string>;
122
189
  sandbox?: boolean;
123
- json?: boolean;
190
+ richEvents?: boolean;
191
+ capability?: Array<string>;
192
+ ignoreHttpsErrors?: boolean;
193
+ };
194
+ export declare type RunOptions = BaseArgs & {
195
+ metrics?: boolean;
196
+ ssblocks?: boolean;
197
+ network?: boolean;
198
+ trace?: boolean;
199
+ filmstrips?: boolean;
200
+ environment?: string;
201
+ playwrightOptions?: PlaywrightOptions;
202
+ networkConditions?: NetworkConditions;
203
+ reporter?: BuiltInReporterName | ReporterInstance;
204
+ };
205
+ export declare type PushOptions = Partial<ProjectSettings> & {
206
+ auth: string;
207
+ schedule?: MonitorConfig['schedule'];
208
+ locations?: MonitorConfig['locations'];
209
+ privateLocations?: MonitorConfig['privateLocations'];
210
+ yes?: boolean;
124
211
  pattern?: string;
125
- inline: boolean;
126
212
  match?: string;
127
213
  tags?: Array<string>;
128
- require: Array<string>;
129
- debug?: boolean;
130
- /**
131
- * @deprecated use `params` instead
132
- */
133
- suiteParams?: Params;
134
- params?: Params;
135
- richEvents?: boolean;
136
214
  };
137
- export declare type PlaywrightOptions = LaunchOptions & BrowserContextOptions;
215
+ export declare type ProjectSettings = {
216
+ id: string;
217
+ url: string;
218
+ space: string;
219
+ };
220
+ export declare type PlaywrightOptions = LaunchOptions & BrowserContextOptions & {
221
+ testIdAttribute?: string;
222
+ actionTimeout?: number;
223
+ navigationTimeout?: number;
224
+ };
138
225
  export declare type SyntheticsConfig = {
139
226
  params?: Params;
140
227
  playwrightOptions?: PlaywrightOptions;
228
+ monitor?: MonitorConfig;
229
+ project?: ProjectSettings;
230
+ };
231
+ /** Runner Payload types */
232
+ export declare type JourneyResult = {
233
+ status: StatusValue;
234
+ error?: Error;
235
+ networkinfo?: PluginOutput['networkinfo'];
236
+ browserconsole?: PluginOutput['browserconsole'];
237
+ };
238
+ export declare type StepResult = {
239
+ status: StatusValue;
240
+ url?: string;
241
+ error?: Error;
242
+ pagemetrics?: PageMetrics;
243
+ filmstrips?: PluginOutput['filmstrips'];
244
+ metrics?: PluginOutput['metrics'];
245
+ traces?: PluginOutput['traces'];
246
+ };
247
+ /** Reporter and Runner contract */
248
+ export declare type StartEvent = {
249
+ numJourneys: number;
250
+ networkConditions?: NetworkConditions;
251
+ };
252
+ export declare type JourneyStartResult = {
253
+ timestamp: number;
254
+ params?: Params;
255
+ };
256
+ export declare type JourneyEndResult = JourneyStartResult & JourneyResult & {
257
+ start: number;
258
+ end: number;
259
+ options: RunOptions;
260
+ timestamp: number;
261
+ };
262
+ export declare type StepEndResult = StepResult & {
263
+ start: number;
264
+ end: number;
141
265
  };
142
266
  export {};
143
267
  //# sourceMappingURL=common_types.d.ts.map