@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.30

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 (189) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +99 -162
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +156 -34
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/config.d.ts +2 -5
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +5 -5
  9. package/dist/config.js.map +1 -1
  10. package/dist/core/browser-service.js +5 -5
  11. package/dist/core/browser-service.js.map +1 -1
  12. package/dist/core/gatherer.d.ts +4 -8
  13. package/dist/core/gatherer.d.ts.map +1 -1
  14. package/dist/core/gatherer.js +46 -14
  15. package/dist/core/gatherer.js.map +1 -1
  16. package/dist/core/index.d.ts +5 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/core/index.js +23 -11
  19. package/dist/core/index.js.map +1 -1
  20. package/dist/core/logger.d.ts +0 -1
  21. package/dist/core/logger.d.ts.map +1 -1
  22. package/dist/core/logger.js +3 -16
  23. package/dist/core/logger.js.map +1 -1
  24. package/dist/core/runner.d.ts +21 -65
  25. package/dist/core/runner.d.ts.map +1 -1
  26. package/dist/core/runner.js +211 -93
  27. package/dist/core/runner.js.map +1 -1
  28. package/dist/dsl/journey.d.ts +7 -3
  29. package/dist/dsl/journey.d.ts.map +1 -1
  30. package/dist/dsl/journey.js +22 -6
  31. package/dist/dsl/journey.js.map +1 -1
  32. package/{src/reporters/reporter.ts → dist/dsl/locations.d.ts} +12 -10
  33. package/dist/dsl/locations.d.ts.map +1 -0
  34. package/dist/dsl/locations.js +41 -0
  35. package/dist/dsl/locations.js.map +1 -0
  36. package/dist/dsl/monitor.d.ts +65 -0
  37. package/dist/dsl/monitor.d.ts.map +1 -0
  38. package/dist/dsl/monitor.js +63 -0
  39. package/dist/dsl/monitor.js.map +1 -0
  40. package/dist/dsl/step.d.ts +3 -2
  41. package/dist/dsl/step.d.ts.map +1 -1
  42. package/dist/dsl/step.js +2 -1
  43. package/dist/dsl/step.js.map +1 -1
  44. package/dist/formatter/javascript.d.ts +98 -0
  45. package/dist/formatter/javascript.d.ts.map +1 -0
  46. package/dist/formatter/javascript.js +295 -0
  47. package/dist/formatter/javascript.js.map +1 -0
  48. package/dist/generator/index.d.ts +21 -0
  49. package/dist/generator/index.d.ts.map +1 -0
  50. package/dist/generator/index.js +169 -0
  51. package/dist/generator/index.js.map +1 -0
  52. package/dist/{reporters/reporter.d.ts → generator/utils.d.ts} +4 -9
  53. package/dist/generator/utils.d.ts.map +1 -0
  54. package/dist/generator/utils.js +57 -0
  55. package/dist/generator/utils.js.map +1 -0
  56. package/dist/helpers.d.ts +20 -1
  57. package/dist/helpers.d.ts.map +1 -1
  58. package/dist/helpers.js +98 -18
  59. package/dist/helpers.js.map +1 -1
  60. package/dist/index.d.ts +5 -6
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +5 -26
  63. package/dist/index.js.map +1 -1
  64. package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
  65. package/dist/loader.d.ts.map +1 -0
  66. package/dist/loader.js +144 -0
  67. package/dist/loader.js.map +1 -0
  68. package/dist/options.d.ts +34 -0
  69. package/dist/options.d.ts.map +1 -0
  70. package/dist/options.js +162 -0
  71. package/dist/options.js.map +1 -0
  72. package/dist/plugins/browser-console.d.ts +5 -4
  73. package/dist/plugins/browser-console.d.ts.map +1 -1
  74. package/dist/plugins/browser-console.js +27 -8
  75. package/dist/plugins/browser-console.js.map +1 -1
  76. package/dist/plugins/network.d.ts +20 -33
  77. package/dist/plugins/network.d.ts.map +1 -1
  78. package/dist/plugins/network.js +173 -214
  79. package/dist/plugins/network.js.map +1 -1
  80. package/dist/plugins/performance.d.ts +4 -19
  81. package/dist/plugins/performance.d.ts.map +1 -1
  82. package/dist/plugins/performance.js +5 -5
  83. package/dist/plugins/performance.js.map +1 -1
  84. package/dist/plugins/plugin-manager.d.ts +9 -5
  85. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  86. package/dist/plugins/plugin-manager.js +44 -29
  87. package/dist/plugins/plugin-manager.js.map +1 -1
  88. package/dist/plugins/tracing.d.ts +6 -6
  89. package/dist/plugins/tracing.d.ts.map +1 -1
  90. package/dist/plugins/tracing.js +8 -7
  91. package/dist/plugins/tracing.js.map +1 -1
  92. package/dist/push/bundler.d.ts +34 -0
  93. package/dist/push/bundler.d.ts.map +1 -0
  94. package/dist/push/bundler.js +114 -0
  95. package/dist/push/bundler.js.map +1 -0
  96. package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
  97. package/dist/push/index.d.ts.map +1 -0
  98. package/dist/push/index.js +55 -0
  99. package/dist/push/index.js.map +1 -0
  100. package/dist/push/monitor.d.ts +32 -0
  101. package/dist/push/monitor.d.ts.map +1 -0
  102. package/dist/push/monitor.js +62 -0
  103. package/dist/push/monitor.js.map +1 -0
  104. package/dist/push/plugin.d.ts +33 -0
  105. package/dist/push/plugin.d.ts.map +1 -0
  106. package/dist/push/plugin.js +124 -0
  107. package/dist/push/plugin.js.map +1 -0
  108. package/dist/push/request.d.ts +42 -0
  109. package/dist/push/request.d.ts.map +1 -0
  110. package/dist/push/request.js +84 -0
  111. package/dist/push/request.js.map +1 -0
  112. package/dist/reporters/base.d.ts +14 -6
  113. package/dist/reporters/base.d.ts.map +1 -1
  114. package/dist/reporters/base.js +54 -48
  115. package/dist/reporters/base.js.map +1 -1
  116. package/dist/reporters/index.d.ts +18 -8
  117. package/dist/reporters/index.d.ts.map +1 -1
  118. package/dist/reporters/index.js.map +1 -1
  119. package/dist/reporters/json.d.ts +18 -67
  120. package/dist/reporters/json.d.ts.map +1 -1
  121. package/dist/reporters/json.js +153 -175
  122. package/dist/reporters/json.js.map +1 -1
  123. package/dist/reporters/junit.d.ts +7 -1
  124. package/dist/reporters/junit.d.ts.map +1 -1
  125. package/dist/reporters/junit.js +94 -89
  126. package/dist/reporters/junit.js.map +1 -1
  127. package/dist/sdk/lh-trace-processor.d.ts +35 -9
  128. package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
  129. package/dist/sdk/lh-trace-processor.js +114 -53
  130. package/dist/sdk/lh-trace-processor.js.map +1 -1
  131. package/dist/sdk/trace-metrics.d.ts +4 -4
  132. package/dist/sdk/trace-metrics.d.ts.map +1 -1
  133. package/dist/sdk/trace-metrics.js +5 -6
  134. package/dist/sdk/trace-metrics.js.map +1 -1
  135. package/dist/sdk/trace-processor.d.ts +11 -3
  136. package/dist/sdk/trace-processor.d.ts.map +1 -1
  137. package/dist/sdk/trace-processor.js +17 -9
  138. package/dist/sdk/trace-processor.js.map +1 -1
  139. package/dist/tsconfig.tsbuildinfo +1 -1888
  140. package/package.json +31 -19
  141. package/src/cli.ts +187 -154
  142. package/src/common_types.ts +188 -34
  143. package/src/config.ts +2 -5
  144. package/src/core/gatherer.ts +55 -27
  145. package/src/core/index.ts +36 -15
  146. package/src/core/logger.ts +1 -12
  147. package/src/core/runner.ts +216 -152
  148. package/src/dsl/journey.ts +29 -5
  149. package/src/dsl/locations.ts +38 -0
  150. package/src/dsl/monitor.ts +87 -0
  151. package/src/dsl/step.ts +9 -2
  152. package/src/formatter/javascript.ts +367 -0
  153. package/src/generator/index.ts +212 -0
  154. package/src/generator/utils.ts +54 -0
  155. package/src/helpers.ts +106 -10
  156. package/src/index.ts +21 -22
  157. package/src/loader.ts +162 -0
  158. package/src/options.ts +173 -0
  159. package/src/plugins/browser-console.ts +30 -8
  160. package/src/plugins/network.ts +208 -267
  161. package/src/plugins/performance.ts +6 -22
  162. package/src/plugins/plugin-manager.ts +49 -31
  163. package/src/plugins/tracing.ts +8 -9
  164. package/src/push/bundler.ts +95 -0
  165. package/src/push/index.ts +59 -0
  166. package/src/push/monitor.ts +68 -0
  167. package/src/push/plugin.ts +114 -0
  168. package/src/push/request.ts +111 -0
  169. package/src/reporters/base.ts +63 -52
  170. package/src/reporters/index.ts +26 -3
  171. package/src/reporters/json.ts +203 -206
  172. package/src/reporters/junit.ts +98 -93
  173. package/src/sdk/lh-trace-processor.ts +132 -68
  174. package/src/sdk/trace-metrics.ts +10 -6
  175. package/src/sdk/trace-processor.ts +28 -13
  176. package/templates/.github/workflows/run-synthetics.yml +26 -0
  177. package/templates/README.md +21 -0
  178. package/templates/journeys/advanced-example-helpers.ts +54 -0
  179. package/templates/journeys/advanced-example.journey.ts +43 -0
  180. package/templates/journeys/example.journey.ts +18 -0
  181. package/templates/synthetics.config.ts +26 -0
  182. package/CHANGELOG.md +0 -102
  183. package/NOTICE.txt +0 -221
  184. package/dist/parse_args.d.ts.map +0 -1
  185. package/dist/parse_args.js +0 -89
  186. package/dist/parse_args.js.map +0 -1
  187. package/dist/reporters/reporter.d.ts.map +0 -1
  188. package/dist/reporters/reporter.js.map +0 -1
  189. package/src/parse_args.ts +0 -127
@@ -30,55 +30,70 @@ class PluginManager {
30
30
  constructor(driver) {
31
31
  this.driver = driver;
32
32
  this.plugins = new Map();
33
+ this.PLUGIN_TYPES = [
34
+ 'network',
35
+ 'trace',
36
+ 'performance',
37
+ 'browserconsole',
38
+ ];
33
39
  }
34
- async start(type, options) {
40
+ register(type, options) {
35
41
  let instance;
36
42
  switch (type) {
37
43
  case 'network':
38
- instance = new _1.NetworkManager();
39
- await instance.start(this.driver.client);
44
+ instance = new _1.NetworkManager(this.driver);
40
45
  break;
41
46
  case 'trace':
42
- instance = new _1.Tracing(options);
43
- await instance.start(this.driver.client);
47
+ instance = new _1.Tracing(this.driver, options);
44
48
  break;
45
49
  case 'performance':
46
- instance = new _1.PerformanceManager(this.driver.client);
47
- instance.start();
50
+ instance = new _1.PerformanceManager(this.driver);
48
51
  break;
49
52
  case 'browserconsole':
50
- instance = new _1.BrowserConsole(this.driver.page);
51
- instance.start();
53
+ instance = new _1.BrowserConsole(this.driver);
52
54
  break;
53
55
  }
54
- this.plugins.set(instance.constructor.name, instance);
56
+ instance && this.plugins.set(type, instance);
55
57
  return instance;
56
58
  }
57
- get(Type) {
58
- return this.plugins.get(Type.name);
59
+ registerAll(options) {
60
+ for (const type of this.PLUGIN_TYPES) {
61
+ this.register(type, options);
62
+ }
63
+ }
64
+ unregisterAll() {
65
+ for (const type of this.PLUGIN_TYPES) {
66
+ this.plugins.delete(type);
67
+ }
68
+ }
69
+ async stop(type) {
70
+ const instance = this.plugins.get(type);
71
+ if (instance) {
72
+ return await instance.stop();
73
+ }
74
+ return {};
75
+ }
76
+ async start(type) {
77
+ const instance = this.plugins.get(type);
78
+ instance && (await instance.start());
79
+ return instance;
80
+ }
81
+ get(type) {
82
+ return this.plugins.get(type);
59
83
  }
60
84
  onStep(step) {
61
- this.get(_1.BrowserConsole) && (this.get(_1.BrowserConsole)._currentStep = step);
62
- this.get(_1.NetworkManager) && (this.get(_1.NetworkManager)._currentStep = step);
85
+ this.get('browserconsole')._currentStep = step;
86
+ this.get('network')._currentStep = step;
63
87
  }
64
88
  async output() {
65
89
  const data = {};
66
- try {
67
- for (const [, plugin] of this.plugins) {
68
- if (plugin instanceof _1.NetworkManager) {
69
- data.networkinfo = plugin.stop();
70
- }
71
- else if (plugin instanceof _1.Tracing) {
72
- const result = await plugin.stop(this.driver.client);
73
- Object.assign(data, { ...result });
74
- }
75
- else if (plugin instanceof _1.BrowserConsole) {
76
- data.browserconsole = plugin.stop();
77
- }
90
+ for (const [, plugin] of this.plugins) {
91
+ if (plugin instanceof _1.NetworkManager) {
92
+ data.networkinfo = await plugin.stop();
93
+ }
94
+ else if (plugin instanceof _1.BrowserConsole) {
95
+ data.browserconsole = plugin.stop();
78
96
  }
79
- }
80
- catch (e) {
81
- console.error('Error capturing data', e.message);
82
97
  }
83
98
  return data;
84
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../../src/plugins/plugin-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAGH,yBAMY;AAQZ,MAAa,aAAa;IAGxB,YAAoB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AAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,QAAQ,IAAI,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,GAAG,CAAC,IAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,IAAU;QACd,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAoB,CAAC,YAAY,GAAG,IAAI,CAAC;QAClE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAoB,CAAC,YAAY,GAAG,IAAI,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,GAAiB,EAAE,CAAC;QAC9B,KAAK,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;YACrC,IAAI,MAAM,YAAY,iBAAc,EAAE;gBACpC,IAAI,CAAC,WAAW,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;aACxC;iBAAM,IAAI,MAAM,YAAY,iBAAc,EAAE;gBAC3C,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;aACrC;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5ED,sCA4EC"}
@@ -22,8 +22,7 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { CDPSession } from 'playwright-chromium';
26
- import { PluginOutput } from '../common_types';
25
+ import { Driver, PluginOutput } from '../common_types';
27
26
  export declare type TraceOptions = {
28
27
  filmstrips?: boolean;
29
28
  trace?: boolean;
@@ -33,9 +32,10 @@ export declare type TraceOptions = {
33
32
  * https://chromedevtools.github.io/devtools-protocol/tot/Tracing/
34
33
  */
35
34
  export declare class Tracing {
36
- options: TraceOptions;
37
- constructor(options: TraceOptions);
38
- start(client: CDPSession): Promise<void>;
39
- stop(client: CDPSession): Promise<Partial<PluginOutput>>;
35
+ private driver;
36
+ private options;
37
+ constructor(driver: Driver, options: TraceOptions);
38
+ start(): Promise<void>;
39
+ stop(): Promise<Partial<PluginOutput>>;
40
40
  }
41
41
  //# sourceMappingURL=tracing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/plugins/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,oBAAY,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,qBAAa,OAAO;IACC,OAAO,EAAE,YAAY;gBAArB,OAAO,EAAE,YAAY;IAElC,KAAK,CAAC,MAAM,EAAE,UAAU;IAmCxB,IAAI,CAAC,MAAM,EAAE,UAAU;CAyB9B"}
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../src/plugins/tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIvD,oBAAY,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;gBAA/B,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,YAAY;IAE3D,KAAK;IAkCL,IAAI;CA0BX"}
@@ -32,10 +32,11 @@ const trace_processor_1 = require("../sdk/trace-processor");
32
32
  * https://chromedevtools.github.io/devtools-protocol/tot/Tracing/
33
33
  */
34
34
  class Tracing {
35
- constructor(options) {
35
+ constructor(driver, options) {
36
+ this.driver = driver;
36
37
  this.options = options;
37
38
  }
38
- async start(client) {
39
+ async start() {
39
40
  const includedCategories = [
40
41
  // exclude all default categories
41
42
  '-*',
@@ -56,20 +57,20 @@ class Tracing {
56
57
  // Includes FCP, LCP, Main thread frames, process, etc.
57
58
  'devtools.timeline', 'disabled-by-default-devtools.timeline');
58
59
  }
59
- await client.send('Tracing.start', {
60
+ await this.driver.client.send('Tracing.start', {
60
61
  /**
61
62
  * Using `ReportEvents` makes gathering trace events
62
63
  * much faster as opposed to using `ReturnAsStream` mode
63
64
  */
64
65
  transferMode: 'ReportEvents',
65
- traceConfig: {
66
- includedCategories,
67
- },
66
+ categories: includedCategories.join(','),
67
+ options: 'sampling-frequency=10000', // 1000 is default
68
68
  });
69
69
  }
70
- async stop(client) {
70
+ async stop() {
71
71
  const events = [];
72
72
  const collectListener = payload => events.push(...payload.value);
73
+ const { client } = this.driver;
73
74
  client.on('Tracing.dataCollected', collectListener);
74
75
  const [traceEvents] = await Promise.all([
75
76
  new Promise(resolve => client.once('Tracing.tracingComplete', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../src/plugins/tracing.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,wDAAkD;AAClD,4DAAoE;AAOpE;;;GAGG;AACH,MAAa,OAAO;IAClB,YAAmB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,KAAK,CAAC,MAAkB;QAC5B,MAAM,kBAAkB,GAAG;YACzB,iCAAiC;YACjC,IAAI;SACL,CAAC;QACF,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3B,6EAA6E;YAC7E,kBAAkB,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;SACpE;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE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AM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAC/B,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;QAEpD,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACtC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CACpB,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;gBAC1C,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,eAAe,CAAC,CAAC;gBACrD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CACH;YACD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;SAC3B,CAAC,CAAC;QACH,MAAM,MAAM,GAA0B,EAAE,CAAC;QACzC,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3B,MAAM,CAAC,UAAU,GAAG,0BAAU,CAAC,OAAO,CAAC,WAAgC,CAAC,CAAC;SAC1E;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACtB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;gBACpB,GAAG,gCAAc,CAAC,YAAY,CAAC,WAAgC,CAAC;aACjE,CAAC,CAAC;SACJ;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/DD,0BA+DC"}
@@ -0,0 +1,34 @@
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
+ export declare class Bundler {
26
+ moduleMap: Map<string, string>;
27
+ constructor();
28
+ prepare(absPath: string): Promise<void>;
29
+ zip(outputPath: string): Promise<unknown>;
30
+ build(entry: string, output: string): Promise<string>;
31
+ encode(outputPath: string): Promise<string>;
32
+ cleanup(outputPath: string): Promise<void>;
33
+ }
34
+ //# sourceMappingURL=bundler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/push/bundler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAaH,qBAAa,OAAO;IAClB,SAAS,sBAA6B;;IAGhC,OAAO,CAAC,OAAO,EAAE,MAAM;IAqBvB,GAAG,CAAC,UAAU,EAAE,MAAM;IAiBtB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQnC,MAAM,CAAC,UAAU,EAAE,MAAM;IAIzB,OAAO,CAAC,UAAU,EAAE,MAAM;CAIjC"}
@@ -0,0 +1,114 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
34
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
35
+ }) : function(o, v) {
36
+ o["default"] = v;
37
+ });
38
+ var __importStar = (this && this.__importStar) || function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.Bundler = void 0;
50
+ const path_1 = __importDefault(require("path"));
51
+ const promises_1 = require("fs/promises");
52
+ const fs_1 = require("fs");
53
+ const esbuild = __importStar(require("esbuild"));
54
+ const archiver_1 = __importDefault(require("archiver"));
55
+ const plugin_1 = require("./plugin");
56
+ function relativeToCwd(entry) {
57
+ return path_1.default.relative(process.cwd(), entry);
58
+ }
59
+ class Bundler {
60
+ constructor() {
61
+ this.moduleMap = new Map();
62
+ }
63
+ async prepare(absPath) {
64
+ const addToMap = (data) => {
65
+ this.moduleMap.set(data.path, data.contents);
66
+ };
67
+ const options = {
68
+ ...(0, plugin_1.commonOptions)(),
69
+ ...{
70
+ entryPoints: {
71
+ [absPath]: absPath,
72
+ },
73
+ plugins: [(0, plugin_1.MultiAssetPlugin)(addToMap)],
74
+ },
75
+ };
76
+ const result = await esbuild.build(options);
77
+ if (result.errors.length > 0) {
78
+ throw result.errors;
79
+ }
80
+ this.moduleMap.set(absPath, result.outputFiles[0].text);
81
+ }
82
+ async zip(outputPath) {
83
+ return new Promise((fulfill, reject) => {
84
+ const output = (0, fs_1.createWriteStream)(outputPath);
85
+ const archive = (0, archiver_1.default)('zip', {
86
+ zlib: { level: 9 },
87
+ });
88
+ archive.on('error', err => reject(err));
89
+ output.on('close', fulfill);
90
+ archive.pipe(output);
91
+ for (const [path, content] of this.moduleMap.entries()) {
92
+ const relativePath = relativeToCwd(path);
93
+ archive.append(content, { name: relativePath });
94
+ }
95
+ archive.finalize();
96
+ });
97
+ }
98
+ async build(entry, output) {
99
+ await this.prepare(entry);
100
+ await this.zip(output);
101
+ const data = await this.encode(output);
102
+ await this.cleanup(output);
103
+ return data;
104
+ }
105
+ async encode(outputPath) {
106
+ return await (0, promises_1.readFile)(outputPath, 'base64');
107
+ }
108
+ async cleanup(outputPath) {
109
+ this.moduleMap = new Map();
110
+ await (0, promises_1.unlink)(outputPath);
111
+ }
112
+ }
113
+ exports.Bundler = Bundler;
114
+ //# sourceMappingURL=bundler.js.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AC9B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,MAAM,IAAA,iBAAM,EAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;CACF;AA1DD,0BA0DC"}
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * MIT License
4
3
  *
@@ -23,5 +22,7 @@
23
22
  * THE SOFTWARE.
24
23
  *
25
24
  */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- //# sourceMappingURL=reporter.js.map
25
+ import { Monitor } from '../dsl/monitor';
26
+ import { PushOptions } from '../common_types';
27
+ export declare function push(monitors: Monitor[], options: PushOptions): Promise<void>;
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/push/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AASH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,wBAAsB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,iBAqBnE"}
@@ -0,0 +1,55 @@
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.push = void 0;
28
+ const request_1 = require("./request");
29
+ const monitor_1 = require("./monitor");
30
+ const helpers_1 = require("../helpers");
31
+ async function push(monitors, options) {
32
+ (0, helpers_1.progress)(`preparing all monitors`);
33
+ const schemas = await (0, monitor_1.buildMonitorSchema)(monitors);
34
+ try {
35
+ (0, helpers_1.progress)(`creating all monitors`);
36
+ const { body, statusCode } = await (0, request_1.createMonitors)(schemas, options);
37
+ if (statusCode === 404) {
38
+ throw (0, request_1.formatNotFoundError)(await body.text());
39
+ }
40
+ if (!(0, request_1.ok)(statusCode)) {
41
+ const { error, message } = await body.json();
42
+ throw (0, request_1.formatAPIError)(statusCode, error, message);
43
+ }
44
+ const { failedMonitors } = await body.json();
45
+ if (failedMonitors.length > 0) {
46
+ throw (0, request_1.formatFailedMonitors)(failedMonitors);
47
+ }
48
+ (0, helpers_1.done)('Pushed');
49
+ }
50
+ catch (e) {
51
+ (0, helpers_1.error)(e);
52
+ }
53
+ }
54
+ exports.push = push;
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/push/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,uCAMmB;AAGnB,uCAA+C;AAC/C,wCAAmD;AAE5C,KAAK,UAAU,IAAI,CAAC,QAAmB,EAAE,OAAoB;IAClE,IAAA,kBAAQ,EAAC,wBAAwB,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,IAAA,4BAAkB,EAAC,QAAQ,CAAC,CAAC;IACnD,IAAI;QACF,IAAA,kBAAQ,EAAC,uBAAuB,CAAC,CAAC;QAClC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,wBAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpE,IAAI,UAAU,KAAK,GAAG,EAAE;YACtB,MAAM,IAAA,6BAAmB,EAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;SAC9C;QACD,IAAI,CAAC,IAAA,YAAE,EAAC,UAAU,CAAC,EAAE;YACnB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC7C,MAAM,IAAA,wBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;SAClD;QACD,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7C,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,MAAM,IAAA,8BAAoB,EAAC,cAAc,CAAC,CAAC;SAC5C;QACD,IAAA,cAAI,EAAC,QAAQ,CAAC,CAAC;KAChB;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,eAAK,EAAC,CAAC,CAAC,CAAC;KACV;AACH,CAAC;AArBD,oBAqBC"}
@@ -0,0 +1,32 @@
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 { Monitor, MonitorConfig } from '../dsl/monitor';
26
+ export declare type MonitorSchema = Omit<MonitorConfig, 'locations'> & {
27
+ content: string;
28
+ locations: string[];
29
+ filter: Monitor['filter'];
30
+ };
31
+ export declare function buildMonitorSchema(monitors: Monitor[]): Promise<MonitorSchema[]>;
32
+ //# sourceMappingURL=monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExD,oBAAY,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC3B,CAAC;AAMF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,4BAyB3D"}
@@ -0,0 +1,62 @@
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.buildMonitorSchema = void 0;
28
+ const promises_1 = require("fs/promises");
29
+ const path_1 = require("path");
30
+ const bundler_1 = require("./bundler");
31
+ const helpers_1 = require("../helpers");
32
+ const locations_1 = require("../dsl/locations");
33
+ function translateLocation(locations) {
34
+ return locations.map(loc => locations_1.LocationsMap[loc]).filter(Boolean);
35
+ }
36
+ async function buildMonitorSchema(monitors) {
37
+ if (monitors.length == 0) {
38
+ throw new Error('No Monitors found');
39
+ }
40
+ /**
41
+ * Set up the bundle artifacts path which can be used to
42
+ * create the bundles required for uploading journeys
43
+ */
44
+ const bundlePath = (0, path_1.join)(helpers_1.CACHE_PATH, 'bundles');
45
+ await (0, promises_1.mkdir)(bundlePath, { recursive: true });
46
+ const bundler = new bundler_1.Bundler();
47
+ const schemas = [];
48
+ for (const monitor of monitors) {
49
+ const { source, config, filter } = monitor;
50
+ const outPath = (0, path_1.join)(bundlePath, config.name + '.zip');
51
+ const content = await bundler.build(source.file, outPath);
52
+ schemas.push({
53
+ ...config,
54
+ content,
55
+ locations: translateLocation(config.locations),
56
+ filter: filter,
57
+ });
58
+ }
59
+ return schemas;
60
+ }
61
+ exports.buildMonitorSchema = buildMonitorSchema;
62
+ //# sourceMappingURL=monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../src/push/monitor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,0CAAoC;AACpC,+BAA4B;AAC5B,uCAAoC;AACpC,wCAAwC;AACxC,gDAAgD;AAShD,SAAS,iBAAiB,CAAC,SAAqC;IAC9D,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,wBAAY,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC;AAEM,KAAK,UAAU,kBAAkB,CAAC,QAAmB;IAC1D,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACtC;IACD;;;OAGG;IACH,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,oBAAU,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,IAAA,gBAAK,EAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAC3C,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,UAAU,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;QACvD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC;YACX,GAAG,MAAM;YACT,OAAO;YACP,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC;YAC9C,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;KACJ;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAzBD,gDAyBC"}
@@ -0,0 +1,33 @@
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 * as esbuild from 'esbuild';
26
+ export declare function commonOptions(): esbuild.BuildOptions;
27
+ export declare type PluginData = {
28
+ path: string;
29
+ contents: string;
30
+ };
31
+ export declare type PluginCallback = (data: PluginData) => void;
32
+ export declare function MultiAssetPlugin(callback: PluginCallback): esbuild.Plugin;
33
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/push/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,wBAAgB,aAAa,IAAI,OAAO,CAAC,YAAY,CAapD;AAED,oBAAY,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,oBAAY,cAAc,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAExD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CA+DzE"}