@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,37 @@
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 { CommonOptions, TransformOptions } from 'esbuild';
26
+ export declare function commonOptions(): CommonOptions;
27
+ /**
28
+ * Transform the given code using esbuild and save the corresponding
29
+ * map file in memory to be retrived later.
30
+ */
31
+ export declare function transform(code: string, filename: string, options?: TransformOptions): import("esbuild").TransformResult;
32
+ /**
33
+ * Install the pirates hook to transform the code on the fly
34
+ * for all of the imported files.
35
+ */
36
+ export declare function installTransform(): () => void;
37
+ //# sourceMappingURL=transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/core/transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAGL,aAAa,EACb,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA6CjB,wBAAgB,aAAa,IAAI,aAAa,CAiB7C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB,qCAuC/B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,eAY/B"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.installTransform = exports.transform = exports.commonOptions = void 0;
31
+ const pirates_1 = require("pirates");
32
+ const esbuild_1 = require("esbuild");
33
+ const path_1 = __importDefault(require("path"));
34
+ const source_map_support_1 = __importDefault(require("source-map-support"));
35
+ // Cache that holds the sourcemap content for each file
36
+ const sourceMaps = new Map();
37
+ // Register the source-map-support library to resolve the sourcemaps
38
+ // for the files that are transpiled by esbuild
39
+ /**
40
+ * Register the source-map-support library to resolve the sourcemaps
41
+ * for the files that are transpiled by esbuild and cache the sourcemaps
42
+ * for each file.
43
+ *
44
+ * Caching the sourcemap file is important, as it is used by the Synthetics agent
45
+ * to resolve the stack traces of journey, monitor and step functions.
46
+ */
47
+ source_map_support_1.default.install({
48
+ environment: 'node',
49
+ handleUncaughtExceptions: false,
50
+ retrieveSourceMap(source) {
51
+ if (!sourceMaps.has(source))
52
+ return null;
53
+ return {
54
+ map: JSON.parse(sourceMaps.get(source)),
55
+ url: source,
56
+ };
57
+ },
58
+ });
59
+ /**
60
+ * Default list of files and corresponding loaders we support
61
+ * while pushing project based monitors
62
+ */
63
+ const LOADERS = {
64
+ '.ts': 'ts',
65
+ '.js': 'js',
66
+ '.mjs': 'js',
67
+ '.cjs': 'js',
68
+ };
69
+ const getLoader = (filename) => {
70
+ const ext = path_1.default.extname(filename);
71
+ return LOADERS[ext] || 'default';
72
+ };
73
+ function commonOptions() {
74
+ /**
75
+ * We are not minifying the code as we want it to be in sync with previous
76
+ * transformation phase and introduce it later.
77
+ */
78
+ return {
79
+ minify: false,
80
+ minifyIdentifiers: false,
81
+ minifySyntax: false,
82
+ minifyWhitespace: false,
83
+ sourcemap: 'both',
84
+ sourcesContent: false,
85
+ platform: 'node',
86
+ logLevel: 'silent',
87
+ format: 'cjs',
88
+ target: `node${process.version.slice(1)}`,
89
+ };
90
+ }
91
+ exports.commonOptions = commonOptions;
92
+ /**
93
+ * Transform the given code using esbuild and save the corresponding
94
+ * map file in memory to be retrived later.
95
+ */
96
+ function transform(code, filename, options = {}) {
97
+ const result = (0, esbuild_1.transformSync)(code, {
98
+ ...commonOptions(),
99
+ sourcefile: filename,
100
+ loader: getLoader(filename),
101
+ /**
102
+ * Add this only for the transformation phase, using it on
103
+ * bundling phase would disable tree shaking and uncessary bloat
104
+ *
105
+ * Ensures backwards compatability with tsc's implicit strict behaviour
106
+ */
107
+ tsconfigRaw: {
108
+ compilerOptions: {
109
+ alwaysStrict: true,
110
+ },
111
+ },
112
+ ...options,
113
+ });
114
+ const warnings = result.warnings;
115
+ if (warnings && warnings.length > 0) {
116
+ for (const warning of warnings) {
117
+ console.log(warning.location);
118
+ console.log(warning.text);
119
+ }
120
+ }
121
+ /**
122
+ * Cache the sourcemap contents in memory, so we can look it up
123
+ * later when we try to resolve the sourcemap for a given file.
124
+ *
125
+ * Every time the synthetics agent is started, we register the source-map-support
126
+ * library to resolve the sourcemaps for the files that are transpiled by esbuild.
127
+ */
128
+ if (result.map) {
129
+ sourceMaps.set(filename, result.map);
130
+ }
131
+ return result;
132
+ }
133
+ exports.transform = transform;
134
+ /**
135
+ * Install the pirates hook to transform the code on the fly
136
+ * for all of the imported files.
137
+ */
138
+ function installTransform() {
139
+ const revertPirates = (0, pirates_1.addHook)((source, filename) => {
140
+ const { code } = transform(source, filename);
141
+ return code;
142
+ }, { exts: ['.ts', '.js', '.mjs', '.cjs'] });
143
+ return () => {
144
+ revertPirates();
145
+ };
146
+ }
147
+ exports.installTransform = installTransform;
148
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/core/transform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,qCAAkC;AAClC,qCAKiB;AACjB,gDAAwB;AACxB,4EAAkD;AAElD,uDAAuD;AACvD,MAAM,UAAU,GAAwB,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(function(o, m, k, k2) {
27
27
  if (k2 === undefined) k2 = k;
28
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
29
33
  }) : (function(o, m, k, k2) {
30
34
  if (k2 === undefined) k2 = k;
31
35
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dsl/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;AAEH,4CAA0B;AAC1B,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dsl/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;AAEH,4CAA0B;AAC1B,yCAAuB"}
@@ -22,9 +22,10 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { Browser, Page, BrowserContext, CDPSession } from 'playwright-chromium';
25
+ import { Browser, Page, BrowserContext, CDPSession, APIRequestContext } from 'playwright-chromium';
26
26
  import { Step } from './step';
27
- import { VoidCallback, HooksCallback, Params } from '../common_types';
27
+ import { VoidCallback, HooksCallback, Params, Location } from '../common_types';
28
+ import { Monitor, MonitorConfig } from './monitor';
28
29
  export declare type JourneyOptions = {
29
30
  name: string;
30
31
  id?: string;
@@ -38,17 +39,21 @@ export declare type JourneyCallback = (options: {
38
39
  browser: Browser;
39
40
  client: CDPSession;
40
41
  params: Params;
42
+ request: APIRequestContext;
41
43
  }) => void;
42
44
  export declare class Journey {
43
45
  name: string;
44
46
  id?: string;
45
47
  tags?: string[];
46
48
  callback: JourneyCallback;
49
+ location?: Location;
47
50
  steps: Step[];
48
51
  hooks: Hooks;
49
- constructor(options: JourneyOptions, callback: JourneyCallback);
50
- addStep(name: string, callback: VoidCallback): Step;
52
+ monitor: Monitor;
53
+ constructor(options: JourneyOptions, callback: JourneyCallback, location?: Location);
54
+ addStep(name: string, callback: VoidCallback, location?: Location): Step;
51
55
  addHook(type: HookType, callback: HooksCallback): void;
56
+ updateMonitor(config: MonitorConfig): void;
52
57
  /**
53
58
  * Matches journeys based on the provided args. Proitize tags over match
54
59
  * - tags pattern that matches only tags
@@ -1 +1 @@
1
- {"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["../../src/dsl/journey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEhF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtE,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,aAAK,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AACnC,oBAAY,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AAC3D,oBAAY,eAAe,GAAG,CAAC,OAAO,EAAE;IACtC,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAK,IAAI,CAAC;AAEX,qBAAa,OAAO;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,E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EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,iBAAiB,CAAC;CAC5B,KAAK,IAAI,CAAC;AAEX,qBAAa,OAAO;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,KAAK,EAAE,KAAK,CAA6B;IACzC,OAAO,EAAE,OAAO,CAAC;gBAGf,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,QAAQ;IAUrB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,QAAQ;IAMjE,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa;IAI/C,aAAa,CAAC,MAAM,EAAE,aAAa;IAgBnC;;;;OAIG;IACH,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;IAUxD,SAAS,CAAC,OAAO,KAAA;CAIlB"}
@@ -25,7 +25,11 @@
25
25
  */
26
26
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
27
  if (k2 === undefined) k2 = k;
28
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
29
33
  }) : (function(o, m, k, k2) {
30
34
  if (k2 === undefined) k2 = k;
31
35
  o[k2] = m[k];
@@ -46,23 +50,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
46
50
  exports.Journey = void 0;
47
51
  const micromatch_1 = __importStar(require("micromatch"));
48
52
  const step_1 = require("./step");
53
+ const monitor_1 = require("./monitor");
49
54
  class Journey {
50
- constructor(options, callback) {
51
- this.steps = [];
52
- this.hooks = { before: [], after: [] };
55
+ name;
56
+ id;
57
+ tags;
58
+ callback;
59
+ location;
60
+ steps = [];
61
+ hooks = { before: [], after: [] };
62
+ monitor;
63
+ constructor(options, callback, location) {
53
64
  this.name = options.name;
54
- this.id = options.id;
65
+ this.id = options.id || options.name;
55
66
  this.tags = options.tags;
56
67
  this.callback = callback;
68
+ this.location = location;
69
+ this.updateMonitor({});
57
70
  }
58
- addStep(name, callback) {
59
- const step = new step_1.Step(name, this.steps.length + 1, callback);
71
+ addStep(name, callback, location) {
72
+ const step = new step_1.Step(name, this.steps.length + 1, callback, location);
60
73
  this.steps.push(step);
61
74
  return step;
62
75
  }
63
76
  addHook(type, callback) {
64
77
  this.hooks[type].push(callback);
65
78
  }
79
+ updateMonitor(config) {
80
+ /**
81
+ * Use defaults values from journey for monitor object (id, name and tags)
82
+ */
83
+ this.monitor = new monitor_1.Monitor({
84
+ name: this.name,
85
+ id: this.id,
86
+ type: 'browser',
87
+ tags: this.tags ?? [],
88
+ ...config,
89
+ });
90
+ this.monitor.setSource(this.location);
91
+ this.monitor.setContent(this.callback.toString());
92
+ this.monitor.setFilter({ match: this.name });
93
+ }
66
94
  /**
67
95
  * Matches journeys based on the provided args. Proitize tags over match
68
96
  * - tags pattern that matches only tags
@@ -73,12 +101,12 @@ class Journey {
73
101
  return this.tagsMatch(tagsPattern);
74
102
  }
75
103
  if (matchPattern) {
76
- return micromatch_1.isMatch(this.name, matchPattern) || this.tagsMatch(matchPattern);
104
+ return (0, micromatch_1.isMatch)(this.name, matchPattern) || this.tagsMatch(matchPattern);
77
105
  }
78
106
  return true;
79
107
  }
80
108
  tagsMatch(pattern) {
81
- const matchess = micromatch_1.default(this.tags || ['*'], pattern);
109
+ const matchess = (0, micromatch_1.default)(this.tags || ['*'], pattern);
82
110
  return matchess.length > 0;
83
111
  }
84
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"journey.js","sourceRoot":"","sources":["../../src/dsl/journey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;;;;;;;AAGH,yDAAiD;AACjD,iCAA8B;AAmB9B,MAAa,OAAO;IAQlB,YAAY,OAAuB,EAAE,QAAyB;QAH9D,UAAK,GAAW,EAAE,CAAC;QACnB,UAAK,GAAU,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QAGvC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,OAAO,CAAC,IAAY,EAAE,QAAsB;QAC1C,MAAM,IAAI,GAAG,IAAI,WAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,IAAc,EAAE,QAAuB;QAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,YAAoB,EAAE,WAA0B;QACtD,IAAI,WAAW,EAAE;YACf,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;SACpC;QACD,IAAI,YAAY,EAAE;YAChB,OAAO,oBAAO,CAAC,I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IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF;AApED,0BAoEC"}
@@ -0,0 +1,83 @@
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 { ThrottlingOptions, Location, ScreenshotOptions, Params, PlaywrightOptions } from '../common_types';
26
+ import { LocationsMap } from '../locations/public-locations';
27
+ export declare type SyntheticsLocationsType = keyof typeof LocationsMap;
28
+ export declare const SyntheticsLocations: ("japan" | "india" | "singapore" | "australia_east" | "united_kingdom" | "germany" | "canada_east" | "brazil" | "us_east" | "us_west")[];
29
+ export declare const ALLOWED_SCHEDULES: readonly [1, 3, 5, 10, 15, 30, 60];
30
+ export declare type MonitorConfig = {
31
+ id?: string;
32
+ name?: string;
33
+ type?: string;
34
+ tags?: string[];
35
+ schedule?: typeof ALLOWED_SCHEDULES[number];
36
+ enabled?: boolean;
37
+ locations?: SyntheticsLocationsType[];
38
+ privateLocations?: string[];
39
+ throttling?: boolean | ThrottlingOptions;
40
+ screenshot?: ScreenshotOptions;
41
+ params?: Params;
42
+ playwrightOptions?: PlaywrightOptions;
43
+ };
44
+ declare type MonitorFilter = {
45
+ match: string;
46
+ tags?: string[];
47
+ };
48
+ export declare class Monitor {
49
+ config: MonitorConfig;
50
+ content?: string;
51
+ source?: Location;
52
+ filter: MonitorFilter;
53
+ constructor(config?: MonitorConfig);
54
+ /**
55
+ * Treat the creation time config with `monitor.use` as source of truth by
56
+ * merging the values coming from CLI and Synthetics config file
57
+ */
58
+ update(globalOpts?: MonitorConfig): void;
59
+ get type(): string;
60
+ setSource(source: Location): void;
61
+ /**
62
+ * The underlying journey code of the monitor
63
+ */
64
+ setContent(content?: string): void;
65
+ /**
66
+ * If journey files are colocated within the same file during
67
+ * push command, when we invoke synthetics from HB we rely on
68
+ * this filter for running that specific journey alone instead of
69
+ * all journeys on the file
70
+ */
71
+ setFilter(filter: MonitorFilter): void;
72
+ /**
73
+ * Hash is used to identify if the monitor has changed since the last time
74
+ * it was pushed to Kibana. Change is based on three factors:
75
+ * - Monitor configuration
76
+ * - Code changes
77
+ * - File path changes
78
+ */
79
+ hash(): string;
80
+ validate(): void;
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/dsl/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,MAAM,EACN,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,C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iBT"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /**
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2020-present, Elastic NV
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ * THE SOFTWARE.
24
+ *
25
+ */
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.Monitor = exports.ALLOWED_SCHEDULES = exports.SyntheticsLocations = void 0;
31
+ const crypto_1 = require("crypto");
32
+ const deepmerge_1 = __importDefault(require("deepmerge"));
33
+ const colors_1 = require("kleur/colors");
34
+ const helpers_1 = require("../helpers");
35
+ const public_locations_1 = require("../locations/public-locations");
36
+ exports.SyntheticsLocations = Object.keys(public_locations_1.LocationsMap);
37
+ exports.ALLOWED_SCHEDULES = [1, 3, 5, 10, 15, 30, 60];
38
+ class Monitor {
39
+ config;
40
+ content;
41
+ source;
42
+ filter;
43
+ constructor(config = {}) {
44
+ this.config = config;
45
+ }
46
+ /**
47
+ * Treat the creation time config with `monitor.use` as source of truth by
48
+ * merging the values coming from CLI and Synthetics config file
49
+ */
50
+ update(globalOpts = {}) {
51
+ this.config = (0, deepmerge_1.default)(globalOpts, this.config, {
52
+ arrayMerge(target, source) {
53
+ return [...new Set(source)];
54
+ },
55
+ });
56
+ }
57
+ get type() {
58
+ return this.config.type;
59
+ }
60
+ setSource(source) {
61
+ this.source = source;
62
+ }
63
+ /**
64
+ * The underlying journey code of the monitor
65
+ */
66
+ setContent(content = '') {
67
+ this.content = content;
68
+ }
69
+ /**
70
+ * If journey files are colocated within the same file during
71
+ * push command, when we invoke synthetics from HB we rely on
72
+ * this filter for running that specific journey alone instead of
73
+ * all journeys on the file
74
+ */
75
+ setFilter(filter) {
76
+ this.filter = filter;
77
+ }
78
+ /**
79
+ * Hash is used to identify if the monitor has changed since the last time
80
+ * it was pushed to Kibana. Change is based on three factors:
81
+ * - Monitor configuration
82
+ * - Code changes
83
+ * - File path changes
84
+ */
85
+ hash() {
86
+ const hash = (0, crypto_1.createHash)('sha256');
87
+ return hash
88
+ .update(JSON.stringify(this.config))
89
+ .update(this.content || '')
90
+ .update(this.source?.file || '')
91
+ .digest('base64');
92
+ }
93
+ validate() {
94
+ const schedule = this.config.schedule;
95
+ if (exports.ALLOWED_SCHEDULES.includes(schedule)) {
96
+ return;
97
+ }
98
+ const { config, source } = this;
99
+ let outer = (0, colors_1.bold)(`Invalid schedule: ${schedule}, allowed values are ${exports.ALLOWED_SCHEDULES.join(',')}\n`);
100
+ if (source) {
101
+ const inner = `* ${config.id} - ${source.file}:${source.line}:${source.column}\n`;
102
+ outer += (0, helpers_1.indent)(inner);
103
+ }
104
+ throw (0, colors_1.red)(outer);
105
+ }
106
+ }
107
+ exports.Monitor = Monitor;
108
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.js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C;QAClC,OAAO,IAAI;aACR,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACnC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;aAC1B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;aAC/B,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtC,IAAI,yBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACxC,OAAO;SACR;QACD,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAChC,IAAI,KAAK,GAAG,IAAA,aAAI,EACd,qBAAqB,QAAQ,wBAAwB,yBAAiB,CAAC,IAAI,CACzE,GAAG,CACJ,IAAI,CACN,CAAC;QACF,IAAI,MAAM,EAAE;YACV,MAAM,KAAK,GAAG,KAAK,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;YAClF,KAAK,IAAI,IAAA,gBAAM,EAAC,KAAK,CAAC,CAAC;SACxB;QACD,MAAM,IAAA,YAAG,EAAC,KAAK,CAAC,CAAC;IACnB,CAAC;CACF;AA3ED,0BA2EC"}
@@ -22,11 +22,12 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { VoidCallback } from '../common_types';
25
+ import { Location, VoidCallback } from '../common_types';
26
26
  export declare class Step {
27
27
  name: string;
28
28
  index: number;
29
29
  callback: VoidCallback;
30
- constructor(name: string, index: number, callback: VoidCallback);
30
+ location?: Location;
31
+ constructor(name: string, index: number, callback: VoidCallback, location: Location);
31
32
  }
32
33
  //# sourceMappingURL=step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,qBAAa,IAAI;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;gBAEX,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY;CAKhE"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,qBAAa,IAAI;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAGlB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ;CAOrB"}
package/dist/dsl/step.js CHANGED
@@ -26,10 +26,15 @@
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.Step = void 0;
28
28
  class Step {
29
- constructor(name, index, callback) {
29
+ name;
30
+ index;
31
+ callback;
32
+ location;
33
+ constructor(name, index, callback, location) {
30
34
  this.name = name;
31
35
  this.index = index;
32
36
  this.callback = callback;
37
+ this.location = location;
33
38
  }
34
39
  }
35
40
  exports.Step = Step;
@@ -1 +1 @@
1
- {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,MAAa,IAAI;IAKf,YAAY,IAAY,EAAE,KAAa,EAAE,QAAsB;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAVD,oBAUC"}
1
+ {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/dsl/step.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,MAAa,IAAI;IACf,IAAI,CAAS;IACb,KAAK,CAAS;IACd,QAAQ,CAAe;IACvB,QAAQ,CAAY;IAEpB,YACE,IAAY,EACZ,KAAa,EACb,QAAsB,EACtB,QAAkB;QAElB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAjBD,oBAiBC"}