@elastic/synthetics 1.0.0-beta.4 → 1.0.0-beta.41

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 +4 -3
  2. package/dist/cli.js +137 -160
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +161 -31
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/config.d.ts +3 -5
  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 +4 -8
  18. package/dist/core/gatherer.d.ts.map +1 -1
  19. package/dist/core/gatherer.js +53 -15
  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 +3 -16
  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 +156 -90
  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 -4
  40. package/dist/dsl/journey.d.ts.map +1 -1
  41. package/dist/dsl/journey.js +37 -9
  42. package/dist/dsl/journey.js.map +1 -1
  43. package/dist/dsl/monitor.d.ts +83 -0
  44. package/dist/dsl/monitor.d.ts.map +1 -0
  45. package/dist/dsl/monitor.js +108 -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 +98 -0
  52. package/dist/formatter/javascript.d.ts.map +1 -0
  53. package/dist/formatter/javascript.js +298 -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 +28 -3
  64. package/dist/helpers.d.ts.map +1 -1
  65. package/dist/helpers.js +152 -20
  66. package/dist/helpers.js.map +1 -1
  67. package/dist/index.d.ts +6 -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 +149 -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 +41 -0
  84. package/dist/options.d.ts.map +1 -0
  85. package/dist/options.js +198 -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 +44 -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 +20 -33
  94. package/dist/plugins/network.d.ts.map +1 -1
  95. package/dist/plugins/network.js +177 -216
  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 +10 -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 +9 -0
  114. package/dist/push/index.d.ts.map +1 -0
  115. package/dist/push/index.js +227 -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 +51 -0
  122. package/dist/push/monitor.d.ts.map +1 -0
  123. package/dist/push/monitor.js +244 -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 +149 -179
  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 +39 -24
  165. package/src/cli.ts +219 -151
  166. package/src/common_types.ts +193 -31
  167. package/src/config.ts +3 -6
  168. package/src/core/expect.ts +58 -24
  169. package/src/core/gatherer.ts +64 -24
  170. package/src/core/index.ts +36 -15
  171. package/src/core/logger.ts +1 -12
  172. package/src/core/runner.ts +151 -136
  173. package/src/core/transform.ts +160 -0
  174. package/src/dsl/journey.ts +39 -6
  175. package/src/dsl/monitor.ts +140 -0
  176. package/src/dsl/step.ts +9 -2
  177. package/src/formatter/javascript.ts +367 -0
  178. package/src/generator/index.ts +308 -0
  179. package/src/generator/utils.ts +84 -0
  180. package/src/helpers.ts +159 -13
  181. package/src/index.ts +22 -22
  182. package/src/loader.ts +167 -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 +227 -0
  186. package/src/plugins/browser-console.ts +30 -8
  187. package/src/plugins/network.ts +208 -267
  188. package/src/plugins/performance.ts +6 -22
  189. package/src/plugins/plugin-manager.ts +49 -31
  190. package/src/plugins/tracing.ts +8 -9
  191. package/src/push/bundler.ts +112 -0
  192. package/src/push/index.ts +282 -0
  193. package/src/push/kibana_api.ts +191 -0
  194. package/src/push/monitor.ts +276 -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 +183 -202
  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 +8 -0
  211. package/templates/synthetics.config.ts +35 -0
  212. package/CHANGELOG.md +0 -131
  213. package/NOTICE.txt +0 -221
  214. package/dist/parse_args.d.ts.map +0 -1
  215. package/dist/parse_args.js +0 -95
  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 -1888
  220. package/src/parse_args.ts +0 -135
@@ -0,0 +1,98 @@
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 { JavaScriptLanguageGenerator } from 'playwright-core/lib/server/recorder/javascript';
26
+ export declare type Step = {
27
+ actions: ActionInContext[];
28
+ name?: string;
29
+ };
30
+ export declare type Steps = Step[];
31
+ export declare type ActionInContext = {
32
+ pageAlias: string;
33
+ frameName?: string;
34
+ frameUrl: string;
35
+ isMainFrame: boolean;
36
+ action: Action;
37
+ committed?: boolean;
38
+ modified?: boolean;
39
+ title?: string;
40
+ };
41
+ export declare type Action = {
42
+ name: string;
43
+ selector?: string;
44
+ url?: string;
45
+ key?: string;
46
+ signals: Signal[];
47
+ modifiers?: number;
48
+ button?: 'left' | 'middle' | 'right';
49
+ clickCount?: number;
50
+ text?: string;
51
+ value?: string;
52
+ isAssert?: boolean;
53
+ command?: string;
54
+ files?: string[];
55
+ options?: string[];
56
+ };
57
+ export declare type Signal = {
58
+ name: string;
59
+ url?: string;
60
+ isAsync?: boolean;
61
+ popupAlias?: string;
62
+ downloadAlias?: string;
63
+ dialogAlias?: string;
64
+ };
65
+ export declare class SyntheticsGenerator extends JavaScriptLanguageGenerator {
66
+ private isSuite;
67
+ private previousContext;
68
+ private insideStep;
69
+ constructor(isSuite: boolean);
70
+ /**
71
+ * Generate code for an action.
72
+ * @param actionInContext The action to create code for.
73
+ * @returns the strings generated for the action.
74
+ */
75
+ generateAction(actionInContext: ActionInContext): any;
76
+ isNewStep(actioninContext: ActionInContext): boolean;
77
+ generateStepStart(name: any): any;
78
+ generateStepEnd(): any;
79
+ generateHeader(): any;
80
+ generateFooter(): string;
81
+ /**
82
+ * Generates JavaScript code from a custom set of steps and nested actions.
83
+ *
84
+ * This function makes no assumptions about where steps should be created,
85
+ * and instead follows the step definitions the caller has defined.
86
+ * @param steps IR to use for code generation
87
+ * @returns a list of the code strings outputted by the generator
88
+ */
89
+ generateFromSteps(steps: Steps): string;
90
+ }
91
+ export declare function quote(text: string, char?: string): string;
92
+ /**
93
+ * Generates an appropriate title string based on the action type/data.
94
+ * @param action Playwright action IR
95
+ * @returns title string
96
+ */
97
+ export declare function actionTitle(action: Action): string;
98
+ //# sourceMappingURL=javascript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/formatter/javascript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,2BAA2B,EAE5B,MAAM,gDAAgD,CAAC;AAExD,oBAAY,IAAI,GAAG;I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AC;CACtB,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,2BAA2B;IAItD,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,UAAU,CAAU;gBAER,OAAO,EAAE,OAAO;IAMpC;;;;OAIG;IACH,cAAc,CAAC,eAAe,EAAE,eAAe;IA0F/C,SAAS,CAAC,eAAe,EAAE,eAAe;IAY1C,iBAAiB,CAAC,IAAI,KAAA;IAOtB,eAAe;IAUf,cAAc;IASd,cAAc;IAId;;;;;;;OAOG;IACH,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;CA4BxC;AAGD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAM,UAS7C;AA4DD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,UAgCzC"}
@@ -0,0 +1,298 @@
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.actionTitle = exports.quote = exports.SyntheticsGenerator = void 0;
28
+ const javascript_1 = require("playwright-core/lib/server/recorder/javascript");
29
+ class SyntheticsGenerator extends javascript_1.JavaScriptLanguageGenerator {
30
+ isSuite;
31
+ previousContext;
32
+ insideStep;
33
+ constructor(isSuite) {
34
+ super(true);
35
+ this.isSuite = isSuite;
36
+ this.insideStep = false;
37
+ this.previousContext = undefined;
38
+ }
39
+ /**
40
+ * Generate code for an action.
41
+ * @param actionInContext The action to create code for.
42
+ * @returns the strings generated for the action.
43
+ */
44
+ generateAction(actionInContext) {
45
+ const { action, pageAlias } = actionInContext;
46
+ if (action.name === 'openPage') {
47
+ return '';
48
+ }
49
+ // Don't cleanup page object managed by Synthetics
50
+ const isCleanUp = action.name === 'closePage' && pageAlias === 'page';
51
+ if (isCleanUp) {
52
+ return '';
53
+ }
54
+ const stepIndent = this.insideStep ? 2 : 0;
55
+ const offset = this.isSuite ? 2 + stepIndent : 0 + stepIndent;
56
+ const formatter = new javascript_1.JavaScriptFormatter(offset);
57
+ const subject = actionInContext.isMainFrame
58
+ ? pageAlias
59
+ : actionInContext.frameName
60
+ ? `${pageAlias}.frame(${formatObject({
61
+ name: actionInContext.frameName,
62
+ })})`
63
+ : `${pageAlias}.frame(${formatObject({
64
+ url: actionInContext.frameUrl,
65
+ })})`;
66
+ const signals = toSignalMap(action);
67
+ if (signals.dialog) {
68
+ formatter.add(` ${pageAlias}.once('dialog', dialog => {
69
+ console.log(\`Dialog message: $\{dialog.message()}\`);
70
+ dialog.dismiss().catch(() => {});
71
+ });`);
72
+ }
73
+ const emitPromiseAll = signals.waitForNavigation || signals.popup || signals.download;
74
+ if (emitPromiseAll) {
75
+ // Generate either await Promise.all([]) or
76
+ // const [popup1] = await Promise.all([]).
77
+ let leftHandSide = '';
78
+ if (signals.popup)
79
+ leftHandSide = `const [${signals.popup.popupAlias}] = `;
80
+ else if (signals.download)
81
+ leftHandSide = `const [download] = `;
82
+ formatter.add(`${leftHandSide}await Promise.all([`);
83
+ }
84
+ // Popup signals.
85
+ if (signals.popup)
86
+ formatter.add(`${pageAlias}.waitForEvent('popup'),`);
87
+ // Navigation signal.
88
+ if (signals.waitForNavigation)
89
+ formatter.add(`${pageAlias}.waitForNavigation(/*{ url: ${quote(signals.waitForNavigation.url)} }*/),`);
90
+ // Download signals.
91
+ if (signals.download)
92
+ formatter.add(`${pageAlias}.waitForEvent('download'),`);
93
+ const prefix = signals.popup || signals.waitForNavigation || signals.download
94
+ ? ''
95
+ : 'await ';
96
+ const actionCall = super._generateActionCall(action);
97
+ // Add assertion from Synthetics.
98
+ const isAssert = action.name === 'assert' && action.isAssert;
99
+ if (!isAssert) {
100
+ const suffix = signals.waitForNavigation || emitPromiseAll ? '' : ';';
101
+ formatter.add(`${prefix}${subject}.${actionCall}${suffix}`);
102
+ if (emitPromiseAll) {
103
+ formatter.add(`]);`);
104
+ }
105
+ else if (signals.assertNavigation) {
106
+ formatter.add(` expect(${pageAlias}.url()).toBe(${quote(signals.assertNavigation.url)});`);
107
+ }
108
+ }
109
+ else if (action.command) {
110
+ formatter.add(toAssertCall(pageAlias, action));
111
+ }
112
+ this.previousContext = actionInContext;
113
+ return formatter.format();
114
+ }
115
+ isNewStep(actioninContext) {
116
+ const { action, frameUrl } = actioninContext;
117
+ if (action.name === 'navigate') {
118
+ return true;
119
+ }
120
+ else if (action.name === 'click') {
121
+ return (this.previousContext?.frameUrl === frameUrl && action.signals.length > 0);
122
+ }
123
+ return false;
124
+ }
125
+ generateStepStart(name) {
126
+ this.insideStep = true;
127
+ const formatter = new javascript_1.JavaScriptFormatter(this.isSuite ? 2 : 0);
128
+ formatter.add(`step(${quote(name)}, async () => {`);
129
+ return formatter.format();
130
+ }
131
+ generateStepEnd() {
132
+ if (!this.insideStep) {
133
+ return '';
134
+ }
135
+ this.insideStep = false;
136
+ const formatter = new javascript_1.JavaScriptFormatter(this.isSuite ? 2 : 0);
137
+ formatter.add(`});`);
138
+ return formatter.format();
139
+ }
140
+ generateHeader() {
141
+ const formatter = new javascript_1.JavaScriptFormatter(0);
142
+ formatter.add(`
143
+ const { journey, step, expect } = require('@elastic/synthetics');
144
+
145
+ journey('Recorded journey', async ({ page, context }) => {`);
146
+ return formatter.format();
147
+ }
148
+ generateFooter() {
149
+ return `});`;
150
+ }
151
+ /**
152
+ * Generates JavaScript code from a custom set of steps and nested actions.
153
+ *
154
+ * This function makes no assumptions about where steps should be created,
155
+ * and instead follows the step definitions the caller has defined.
156
+ * @param steps IR to use for code generation
157
+ * @returns a list of the code strings outputted by the generator
158
+ */
159
+ generateFromSteps(steps) {
160
+ const text = [];
161
+ if (this.isSuite) {
162
+ text.push(this.generateHeader());
163
+ }
164
+ for (const step of steps) {
165
+ if (step.actions.length === 0)
166
+ throw Error('Cannot process an empty step');
167
+ text.push(this.generateStepStart(step.name ??
168
+ step.actions[0].title ??
169
+ actionTitle(step.actions[0].action)));
170
+ for (const action of step.actions) {
171
+ const actionText = this.generateAction(action);
172
+ if (actionText.length)
173
+ text.push(actionText);
174
+ }
175
+ text.push(this.generateStepEnd());
176
+ }
177
+ if (this.isSuite) {
178
+ text.push(this.generateFooter());
179
+ }
180
+ return text.filter(s => !!s).join('\n');
181
+ }
182
+ }
183
+ exports.SyntheticsGenerator = SyntheticsGenerator;
184
+ // TODO: Replace once Playwright releases new version
185
+ function quote(text, char = "'") {
186
+ const stringified = JSON.stringify(text);
187
+ const escapedText = stringified
188
+ .substring(1, stringified.length - 1)
189
+ .replace(/\\"/g, '"');
190
+ if (char === "'")
191
+ return char + escapedText.replace(/[']/g, "\\'") + char;
192
+ if (char === '"')
193
+ return char + escapedText.replace(/["]/g, '\\"') + char;
194
+ if (char === '`')
195
+ return char + escapedText.replace(/[`]/g, '`') + char;
196
+ throw new Error('Invalid escape char');
197
+ }
198
+ exports.quote = quote;
199
+ function toSignalMap(action) {
200
+ let waitForNavigation;
201
+ let assertNavigation;
202
+ let popup;
203
+ let download;
204
+ let dialog;
205
+ for (const signal of action.signals) {
206
+ if (signal.name === 'navigation' && signal.isAsync)
207
+ waitForNavigation = signal;
208
+ else if (signal.name === 'navigation' && !signal.isAsync)
209
+ assertNavigation = signal;
210
+ else if (signal.name === 'popup')
211
+ popup = signal;
212
+ else if (signal.name === 'download')
213
+ download = signal;
214
+ else if (signal.name === 'dialog')
215
+ dialog = signal;
216
+ }
217
+ return {
218
+ waitForNavigation,
219
+ assertNavigation,
220
+ popup,
221
+ download,
222
+ dialog,
223
+ };
224
+ }
225
+ function toAssertCall(pageAlias, action) {
226
+ const { command, selector, value } = action;
227
+ switch (command) {
228
+ case 'textContent':
229
+ case 'innerText':
230
+ return `expect(await ${pageAlias}.${command}(${quote(selector)})).toMatch(${quote(value)});`;
231
+ case 'isVisible':
232
+ case 'isHidden':
233
+ case 'isChecked':
234
+ case 'isEditable':
235
+ case 'isEnabled':
236
+ case 'isDisabled':
237
+ return `expect(await ${pageAlias}.${command}(${quote(selector)})).toBeTruthy();`;
238
+ }
239
+ }
240
+ function formatObject(value, indent = ' ') {
241
+ if (typeof value === 'string')
242
+ return quote(value);
243
+ if (Array.isArray(value))
244
+ return `[${value.map(o => formatObject(o)).join(', ')}]`;
245
+ if (typeof value === 'object') {
246
+ const keys = Object.keys(value);
247
+ if (!keys.length)
248
+ return '{}';
249
+ const tokens = [];
250
+ for (const key of keys)
251
+ tokens.push(`${key}: ${formatObject(value[key])}`);
252
+ return `{\n${indent}${tokens.join(`,\n${indent}`)}\n}`;
253
+ }
254
+ return String(value);
255
+ }
256
+ /**
257
+ * Generates an appropriate title string based on the action type/data.
258
+ * @param action Playwright action IR
259
+ * @returns title string
260
+ */
261
+ function actionTitle(action) {
262
+ switch (action.name) {
263
+ case 'openPage':
264
+ return `Open new page`;
265
+ case 'closePage':
266
+ return `Close page`;
267
+ case 'check':
268
+ return `Check ${action.selector}`;
269
+ case 'uncheck':
270
+ return `Uncheck ${action.selector}`;
271
+ case 'click': {
272
+ if (action.clickCount === 1)
273
+ return `Click ${action.selector}`;
274
+ if (action.clickCount === 2)
275
+ return `Double click ${action.selector}`;
276
+ if (action.clickCount === 3)
277
+ return `Triple click ${action.selector}`;
278
+ return `${action.clickCount}× click`;
279
+ }
280
+ case 'fill':
281
+ return `Fill ${action.selector}`;
282
+ case 'setInputFiles':
283
+ if (action.files.length === 0)
284
+ return `Clear selected files`;
285
+ else
286
+ return `Upload ${action.files.join(', ')}`;
287
+ case 'navigate':
288
+ return `Go to ${action.url}`;
289
+ case 'press':
290
+ return (`Press ${action.key}` + (action.modifiers ? ' with modifiers' : ''));
291
+ case 'select':
292
+ return `Select ${action.options.join(', ')}`;
293
+ case 'assert':
294
+ return `Assert ${action.selector} ${action.command}`;
295
+ }
296
+ }
297
+ exports.actionTitle = actionTitle;
298
+ //# sourceMappingURL=javascript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../src/formatter/javascript.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,+EAGwD;AA8CxD,MAAa,mBAAoB,SAAQ,wCAA2B;IAI9C;IAHZ,eAAe,CAAkB;IACjC,UAAU,CAAU;IAE5B,YAAoB,OAAgB;QAClC,KAAK,CAAC,IAAI,CAAC,CAAC;QADM,YAAO,GAAP,OAAO,CAAS;QAElC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,eAAgC;QAC7C,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,CAAC;QAC9C,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9B,OAAO,EAAE,CAAC;SACX;QACD,kDAAkD;QA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;QACnC,KAAK,eAAe;YAClB,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,sBAAsB,CAAC;;gBACxD,OAAO,UAAU,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,SAAS,MAAM,CAAC,GAAG,EAAE,CAAC;QAC/B,KAAK,OAAO;YACV,OAAO,CACL,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CACpE,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;KACxD;AACH,CAAC;AAhCD,kCAgCC"}
@@ -0,0 +1,24 @@
1
+ import type { ProjectSettings } from '../common_types';
2
+ declare type PromptOptions = ProjectSettings & {
3
+ locations: Array<string>;
4
+ privateLocations: Array<string>;
5
+ schedule: number;
6
+ };
7
+ export declare const REGULAR_FILES_PATH: string[];
8
+ export declare const CONFIG_PATH = "synthetics.config.ts";
9
+ export declare class Generator {
10
+ projectDir: string;
11
+ pkgManager: string;
12
+ constructor(projectDir: string);
13
+ directory(): Promise<void>;
14
+ questions(): Promise<any>;
15
+ files(answers: PromptOptions): Promise<void>;
16
+ createFile(relativePath: string, content: string, override?: boolean): Promise<void>;
17
+ package(): Promise<void>;
18
+ patchPkgJSON(): Promise<void>;
19
+ patchGitIgnore(): Promise<void>;
20
+ banner(): void;
21
+ setup(): Promise<void>;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKvD,aAAK,aAAa,GAAG,eAAe,GAAG;IACrC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,eAAO,MAAM,kBAAkB,UAO9B,CAAC;AACF,eAAO,MAAM,WAAW,yBAAyB,CAAC;AAElD,qBAAa,SAAS;IAED,UAAU,EAAE,MAAM;IADrC,UAAU,SAAS;gBACA,UAAU,EAAE,MAAM;IAE/B,SAAS;IAWT,SAAS;IAqFT,KAAK,CAAC,OAAO,EAAE,aAAa;IA2B5B,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,UAAQ;IAkBlE,OAAO;IA0BP,YAAY;IAyBZ,cAAc;IAgBpB,MAAM;IAoBA,KAAK;CASZ"}