@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,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Generator = exports.CONFIG_PATH = exports.REGULAR_FILES_PATH = void 0;
4
+ /**
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2020-present, Elastic NV
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in
17
+ * all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ * THE SOFTWARE.
26
+ *
27
+ */
28
+ const child_process_1 = require("child_process");
29
+ const fs_1 = require("fs");
30
+ const promises_1 = require("fs/promises");
31
+ const colors_1 = require("kleur/colors");
32
+ const path_1 = require("path");
33
+ // @ts-ignore-next-line: has no exported member 'Input'
34
+ const enquirer_1 = require("enquirer");
35
+ const helpers_1 = require("../helpers");
36
+ const utils_1 = require("./utils");
37
+ const locations_1 = require("../locations");
38
+ const monitor_1 = require("../dsl/monitor");
39
+ // Templates that are required for setting up new synthetics project
40
+ const templateDir = (0, path_1.join)(__dirname, '..', '..', 'templates');
41
+ // exported for testing
42
+ exports.REGULAR_FILES_PATH = [
43
+ 'journeys/example.journey.ts',
44
+ 'journeys/advanced-example-helpers.ts',
45
+ 'journeys/advanced-example.journey.ts',
46
+ 'lightweight/heartbeat.yml',
47
+ '.github/workflows/run-synthetics.yml',
48
+ 'README.md',
49
+ ];
50
+ exports.CONFIG_PATH = 'synthetics.config.ts';
51
+ class Generator {
52
+ projectDir;
53
+ pkgManager = 'npm';
54
+ constructor(projectDir) {
55
+ this.projectDir = projectDir;
56
+ }
57
+ async directory() {
58
+ (0, helpers_1.progress)(`Initializing Synthetics project in '${(0, path_1.relative)(process.cwd(), this.projectDir) || '.'}'`);
59
+ if (!(0, fs_1.existsSync)(this.projectDir)) {
60
+ await (0, promises_1.mkdir)(this.projectDir);
61
+ }
62
+ }
63
+ async questions() {
64
+ if (process.env.TEST_QUESTIONS) {
65
+ return JSON.parse(process.env.TEST_QUESTIONS);
66
+ }
67
+ const { onCloud } = await (0, enquirer_1.prompt)({
68
+ type: 'confirm',
69
+ name: 'onCloud',
70
+ initial: 'y',
71
+ message: 'Do you use Elastic Cloud',
72
+ });
73
+ const url = await new enquirer_1.Input({
74
+ header: onCloud
75
+ ? (0, colors_1.yellow)('Get cloud.id from your deployment https://www.elastic.co/guide/en/cloud/current/ec-cloud-id.html')
76
+ : '',
77
+ message: onCloud
78
+ ? 'What is your cloud.id'
79
+ : 'What is the url of your Kibana instance',
80
+ name: 'url',
81
+ required: true,
82
+ result(value) {
83
+ return onCloud ? (0, utils_1.cloudIDToKibanaURL)(value) : value;
84
+ },
85
+ }).run();
86
+ const auth = await new enquirer_1.Input({
87
+ name: 'auth',
88
+ header: (0, colors_1.yellow)(`Generate API key from Kibana ${(0, helpers_1.getMonitorManagementURL)(url)}`),
89
+ required: true,
90
+ message: 'What is your API key',
91
+ }).run();
92
+ const allLocations = await (0, locations_1.getLocations)({ url, auth });
93
+ const locChoices = (0, locations_1.formatLocations)(allLocations);
94
+ if (locChoices.length === 0) {
95
+ throw 'Follow the docs to set up your first private locations - https://www.elastic.co/guide/en/observability/current/uptime-set-up-choose-agent.html#private-locations';
96
+ }
97
+ const monitorQues = [
98
+ {
99
+ type: 'select',
100
+ name: 'locations',
101
+ hint: '(Use <space> to select, <return> to submit)',
102
+ message: 'Select the locations where you want to run monitors',
103
+ choices: locChoices,
104
+ multiple: true,
105
+ validate(value) {
106
+ return value.length === 0 ? `Select at least one option.` : true;
107
+ },
108
+ },
109
+ {
110
+ type: 'select',
111
+ name: 'schedule',
112
+ message: 'Set default schedule in minutes for all monitors',
113
+ initial: 3,
114
+ choices: monitor_1.ALLOWED_SCHEDULES.map(String),
115
+ required: true,
116
+ result(value) {
117
+ return Number(value);
118
+ },
119
+ },
120
+ {
121
+ type: 'input',
122
+ name: 'id',
123
+ message: 'Choose project id to logically group monitors',
124
+ initial: (0, path_1.basename)(this.projectDir),
125
+ },
126
+ {
127
+ type: 'input',
128
+ name: 'space',
129
+ message: 'Choose the target Kibana space',
130
+ initial: 'default',
131
+ },
132
+ ];
133
+ // Split and group private and public locations from the answered list.
134
+ const answers = await (0, enquirer_1.prompt)(monitorQues);
135
+ const { locations, privateLocations } = (0, locations_1.groupLocations)(answers.locations);
136
+ return { ...answers, url, locations, privateLocations };
137
+ }
138
+ async files(answers) {
139
+ const fileMap = new Map();
140
+ // Setup Synthetics config file
141
+ fileMap.set(exports.CONFIG_PATH, (0, utils_1.replaceTemplates)(await (0, promises_1.readFile)((0, path_1.join)(templateDir, exports.CONFIG_PATH), 'utf-8'), answers));
142
+ // Setup non-templated files
143
+ Promise.all(exports.REGULAR_FILES_PATH.map(async (file) => {
144
+ fileMap.set(file, await (0, promises_1.readFile)((0, path_1.join)(templateDir, file), 'utf-8'));
145
+ })).catch(e => {
146
+ throw e;
147
+ });
148
+ // Create files
149
+ for (const [relativePath, content] of fileMap) {
150
+ await this.createFile(relativePath, content);
151
+ }
152
+ }
153
+ async createFile(relativePath, content, override = false) {
154
+ const absolutePath = (0, path_1.join)(this.projectDir, relativePath);
155
+ if (!override && (0, fs_1.existsSync)(absolutePath)) {
156
+ const { override } = await (0, enquirer_1.prompt)({
157
+ type: 'confirm',
158
+ name: 'override',
159
+ message: `File ${relativePath} already exists. Override it?`,
160
+ initial: false,
161
+ });
162
+ if (!override)
163
+ return;
164
+ }
165
+ (0, helpers_1.progress)(`Writing ${(0, path_1.relative)(process.cwd(), absolutePath)}.`);
166
+ await (0, promises_1.mkdir)((0, path_1.dirname)(absolutePath), { recursive: true });
167
+ await (0, promises_1.writeFile)(absolutePath, content, 'utf-8');
168
+ }
169
+ async package() {
170
+ this.pkgManager = await (0, utils_1.getPackageManager)(this.projectDir);
171
+ const commands = new Map();
172
+ commands.set(`Setting up project using ${this.pkgManager == 'yarn' ? 'Yarn' : 'NPM'}`, this.pkgManager == 'yarn' ? 'yarn init -y' : 'npm init -y');
173
+ const pkgName = '@elastic/synthetics';
174
+ commands.set(`Installing @elastic/synthetics library`, this.pkgManager == 'yarn'
175
+ ? `yarn add -dev ${pkgName} --silent`
176
+ : `npm i -d ${pkgName} --quiet`);
177
+ // Execute commands
178
+ for (const [name, command] of commands) {
179
+ (0, helpers_1.progress)(`${name}...`);
180
+ (0, child_process_1.execSync)(command, {
181
+ stdio: 'inherit',
182
+ cwd: this.projectDir,
183
+ });
184
+ }
185
+ }
186
+ async patchPkgJSON() {
187
+ const filename = 'package.json';
188
+ const pkgJSON = JSON.parse(await (0, promises_1.readFile)((0, path_1.join)(this.projectDir, filename), 'utf-8'));
189
+ if (!pkgJSON.scripts) {
190
+ pkgJSON.scripts = {};
191
+ }
192
+ // Add test command
193
+ if (!pkgJSON.scripts.test) {
194
+ pkgJSON.scripts.test = 'npx @elastic/synthetics journeys';
195
+ }
196
+ // Add push command
197
+ if (!pkgJSON.scripts.push) {
198
+ pkgJSON.scripts.push = 'npx @elastic/synthetics push';
199
+ }
200
+ await this.createFile(filename, JSON.stringify(pkgJSON, null, 2) + '\n', true);
201
+ }
202
+ async patchGitIgnore() {
203
+ const gitIgnorePath = (0, path_1.join)(this.projectDir, '.gitignore');
204
+ let gitIgnore = '';
205
+ if ((0, fs_1.existsSync)(gitIgnorePath)) {
206
+ const contents = await (0, promises_1.readFile)(gitIgnorePath, 'utf-8');
207
+ gitIgnore += contents.trimEnd() + '\n';
208
+ }
209
+ if (!gitIgnore.includes('node_modules')) {
210
+ gitIgnore += 'node_modules/\n';
211
+ }
212
+ if (!gitIgnore.includes('.synthetics')) {
213
+ gitIgnore += '.synthetics/\n';
214
+ }
215
+ await (0, promises_1.writeFile)(gitIgnorePath, gitIgnore, 'utf-8');
216
+ }
217
+ banner() {
218
+ (0, helpers_1.write)((0, colors_1.bold)(`
219
+ All set, you can run below commands inside: ${this.projectDir}:
220
+
221
+ Run synthetic tests: ${(0, colors_1.cyan)((0, utils_1.runCommand)(this.pkgManager, 'test'))}
222
+
223
+ Push monitors to Kibana: ${(0, colors_1.cyan)('SYNTHETICS_API_KEY=<value> ' + (0, utils_1.runCommand)(this.pkgManager, 'push'))}
224
+
225
+ ${(0, colors_1.yellow)('Make sure to configure the SYNTHETICS_API_KEY before pushing monitors to Kibana.')}
226
+
227
+ Visit https://www.elastic.co/guide/en/observability/current/synthetic-run-tests.html to learn more.
228
+ `));
229
+ }
230
+ async setup() {
231
+ await this.directory();
232
+ const answers = await this.questions();
233
+ await this.package();
234
+ await this.files(answers);
235
+ await this.patchPkgJSON();
236
+ await this.patchGitIgnore();
237
+ this.banner();
238
+ }
239
+ }
240
+ exports.Generator = Generator;
241
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAC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AC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1B,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF;AAjPD,8BAiPC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * MIT License
4
3
  *
@@ -23,5 +22,8 @@
23
22
  * THE SOFTWARE.
24
23
  *
25
24
  */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- //# sourceMappingURL=reporter.js.map
25
+ export declare function getPackageManager(dir: string): Promise<"yarn" | "npm">;
26
+ export declare function runCommand(pkgManager: string, command: string): string;
27
+ export declare function replaceTemplates(input: string, values: Record<string, any>): string;
28
+ export declare function cloudIDToKibanaURL(id: string): string;
29
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generator/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,2BAKlD;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAK7D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAoB1E;AAED,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,UAmB5C"}
@@ -0,0 +1,84 @@
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.cloudIDToKibanaURL = exports.replaceTemplates = exports.runCommand = exports.getPackageManager = void 0;
28
+ const fs_1 = require("fs");
29
+ const path_1 = require("path");
30
+ async function getPackageManager(dir) {
31
+ if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'yarn.lock'))) {
32
+ return 'yarn';
33
+ }
34
+ return 'npm';
35
+ }
36
+ exports.getPackageManager = getPackageManager;
37
+ function runCommand(pkgManager, command) {
38
+ if (pkgManager === 'yarn') {
39
+ return `yarn ${command}`;
40
+ }
41
+ return `npm run ${command}`;
42
+ }
43
+ exports.runCommand = runCommand;
44
+ function replaceTemplates(input, values) {
45
+ for (const key in values) {
46
+ const finalValue = values[key];
47
+ input = input.replace(new RegExp(`'{{` + key + `}}'`, 'g'), () => {
48
+ if (Array.isArray(finalValue)) {
49
+ return String(finalValue)
50
+ .split(',')
51
+ .filter(Boolean)
52
+ .map(f => `'${f}'`);
53
+ }
54
+ if (typeof finalValue == 'number') {
55
+ return Number(finalValue);
56
+ }
57
+ if (typeof finalValue == 'string') {
58
+ return `'${finalValue}'`;
59
+ }
60
+ return finalValue;
61
+ });
62
+ }
63
+ return input;
64
+ }
65
+ exports.replaceTemplates = replaceTemplates;
66
+ function cloudIDToKibanaURL(id) {
67
+ const ID_SEPARATOR = ':';
68
+ const VALUE_SEPARATOR = '$';
69
+ // Ignore values before the separator
70
+ const index = id.lastIndexOf(ID_SEPARATOR);
71
+ if (index >= 0) {
72
+ id = id.substring(index + 1);
73
+ }
74
+ // Decode the base64 string
75
+ const decoded = Buffer.from(id, 'base64').toString();
76
+ const words = decoded.split(VALUE_SEPARATOR);
77
+ // construct the kibana and ES urls from decoded value
78
+ const [host, port = '443'] = words[0].split(ID_SEPARATOR);
79
+ const [kibanaId, kibanaPort = port] = words[2].split(ID_SEPARATOR);
80
+ const kibanaURL = `https://${kibanaId}.${host}:${kibanaPort}`;
81
+ return kibanaURL;
82
+ }
83
+ exports.cloudIDToKibanaURL = cloudIDToKibanaURL;
84
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/generator/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,2BAAgC;AAChC,+BAA4B;AAErB,KAAK,UAAU,iBAAiB,CAAC,GAAW;IACjD,IAAI,IAAA,eAAU,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE;QACtC,OAAO,MAAM,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AALD,8CAKC;AAED,SAAgB,UAAU,CAAC,UAAkB,EAAE,OAAe;IAC5D,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,OAAO,Q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I,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE7C,sDAAsD;IACtD,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,WAAW,QAAQ,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;IAE9D,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,gDAmBC"}
package/dist/helpers.d.ts CHANGED
@@ -22,18 +22,13 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- /// <reference types="node" />
26
- import fs from 'fs';
27
- import { HooksArgs, HooksCallback } from './common_types';
28
- export declare const readFileAsync: typeof fs.readFile.__promisify__;
29
- export declare const writeFileAsync: typeof fs.writeFile.__promisify__;
30
- export declare const rmdirAsync: typeof fs.rmdir.__promisify__;
31
- export declare const mkdirAsync: typeof fs.mkdir.__promisify__;
25
+ import { HooksArgs, HooksCallback, NetworkConditions, Location, ThrottlingOptions } from './common_types';
32
26
  export declare function noop(): void;
33
27
  export declare function indent(lines: string, tab?: string): string;
34
28
  export declare const symbols: {
35
29
  warning: string;
36
30
  skipped: string;
31
+ progress: string;
37
32
  succeeded: string;
38
33
  failed: string;
39
34
  };
@@ -89,11 +84,17 @@ export declare function totalist(dir: string, callback: (relPath: string, absPat
89
84
  export declare function findPWLogsIndexes(msgOrStack: string): [number, number];
90
85
  export declare function rewriteErrorMessage(message: string, start: number): string;
91
86
  export declare function rewriteErrorStack(stack: string, indexes: [number, number]): string;
92
- export declare function formatError(error: Error): {
93
- name: string;
87
+ export declare function formatError(error: Error | any): {
94
88
  message: string;
89
+ name: string;
95
90
  stack: string;
96
91
  };
92
+ /**
93
+ * All the settings that are related to the Synthetics is stored
94
+ * under this directory
95
+ * Examples: Screenshots, Project setup
96
+ */
97
+ export declare const SYNTHETICS_PATH: string;
97
98
  /**
98
99
  * Synthetics cache path that is based on the process id to make sure
99
100
  * each process does not modify the caching layer used by other process
@@ -101,4 +102,30 @@ export declare function formatError(error: Error): {
101
102
  */
102
103
  export declare const CACHE_PATH: string;
103
104
  export declare function getDurationInUs(duration: number): number;
105
+ export declare function megabitsToBytes(megabytes: number): number;
106
+ export declare const DEFAULT_THROTTLING_OPTIONS: ThrottlingOptions;
107
+ /**
108
+ * Transforms the CLI throttling arguments in to format
109
+ * expected by Chrome devtools protocol NetworkConditions
110
+ */
111
+ export declare function getNetworkConditions(throttlingOpts: ThrottlingOptions): NetworkConditions;
112
+ export declare const THROTTLING_WARNING_MSG = "Throttling may not be active when the tests run - see\nhttps://github.com/elastic/synthetics/blob/main/docs/throttling.md for more details";
113
+ export declare function wrapFnWithLocation<A extends unknown[], R>(func: (location: Location, ...args: A) => R): (...args: A) => R;
114
+ export declare function safeNDJSONParse(data: string | string[]): any[];
115
+ export declare function write(message: string, live?: boolean): void;
116
+ export declare function progress(message: string): void;
117
+ export declare function liveProgress(promise: Promise<any>, message: string): Promise<any>;
118
+ export declare function apiProgress(message: string, live?: boolean): void;
119
+ export declare function error(message: string): void;
120
+ export declare function done(message: string): void;
121
+ export declare function warn(message: string): void;
122
+ export declare function removeTrailingSlash(url: string): string;
123
+ export declare function getMonitorManagementURL(url: any): string;
124
+ /**
125
+ * Matches tests based on the provided args. Proitize tags over match
126
+ * - tags pattern that matches only tags
127
+ * - match pattern that matches both name and tags
128
+ */
129
+ export declare function isMatch(tags: Array<string>, name: string, tagsPattern?: Array<string>, matchPattern?: string): boolean;
130
+ export declare function tagsMatch(tags: any, pattern: any): boolean;
104
131
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @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