@elastic/synthetics 1.0.0-beta.25 → 1.0.0-beta.28

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 (126) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +56 -8
  3. package/dist/cli.js.map +1 -1
  4. package/dist/common_types.d.ts +59 -5
  5. package/dist/common_types.d.ts.map +1 -1
  6. package/dist/core/gatherer.d.ts +2 -2
  7. package/dist/core/gatherer.d.ts.map +1 -1
  8. package/dist/core/gatherer.js +2 -2
  9. package/dist/core/gatherer.js.map +1 -1
  10. package/dist/core/index.d.ts +4 -0
  11. package/dist/core/index.d.ts.map +1 -1
  12. package/dist/core/index.js +15 -1
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/core/runner.d.ts +10 -58
  15. package/dist/core/runner.d.ts.map +1 -1
  16. package/dist/core/runner.js +92 -49
  17. package/dist/core/runner.js.map +1 -1
  18. package/dist/dsl/journey.d.ts +3 -0
  19. package/dist/dsl/journey.d.ts.map +1 -1
  20. package/dist/dsl/journey.js +15 -0
  21. package/dist/dsl/journey.js.map +1 -1
  22. package/dist/{reporters/reporter.d.ts → dsl/locations.d.ts} +12 -8
  23. package/dist/dsl/locations.d.ts.map +1 -0
  24. package/dist/dsl/locations.js +41 -0
  25. package/dist/dsl/locations.js.map +1 -0
  26. package/dist/dsl/monitor.d.ts +65 -0
  27. package/dist/dsl/monitor.d.ts.map +1 -0
  28. package/dist/dsl/monitor.js +63 -0
  29. package/dist/dsl/monitor.js.map +1 -0
  30. package/dist/generator/index.d.ts +21 -0
  31. package/dist/generator/index.d.ts.map +1 -0
  32. package/dist/generator/index.js +169 -0
  33. package/dist/generator/index.js.map +1 -0
  34. package/{src/reporters/reporter.ts → dist/generator/utils.d.ts} +4 -11
  35. package/dist/generator/utils.d.ts.map +1 -0
  36. package/dist/generator/utils.js +57 -0
  37. package/dist/generator/utils.js.map +1 -0
  38. package/dist/helpers.d.ts +12 -6
  39. package/dist/helpers.d.ts.map +1 -1
  40. package/dist/helpers.js +33 -43
  41. package/dist/helpers.js.map +1 -1
  42. package/dist/index.d.ts +2 -7
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +4 -3
  45. package/dist/index.js.map +1 -1
  46. package/dist/loader.js +4 -4
  47. package/dist/loader.js.map +1 -1
  48. package/dist/options.d.ts +7 -0
  49. package/dist/options.d.ts.map +1 -1
  50. package/dist/options.js +66 -12
  51. package/dist/options.js.map +1 -1
  52. package/dist/plugins/performance.d.ts +1 -16
  53. package/dist/plugins/performance.d.ts.map +1 -1
  54. package/dist/plugins/performance.js.map +1 -1
  55. package/dist/plugins/plugin-manager.d.ts +1 -1
  56. package/dist/push/bundler.d.ts +34 -0
  57. package/dist/push/bundler.d.ts.map +1 -0
  58. package/dist/push/bundler.js +119 -0
  59. package/dist/push/bundler.js.map +1 -0
  60. package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
  61. package/dist/push/index.d.ts.map +1 -0
  62. package/dist/push/index.js +58 -0
  63. package/dist/push/index.js.map +1 -0
  64. package/dist/push/monitor.d.ts +32 -0
  65. package/dist/push/monitor.d.ts.map +1 -0
  66. package/dist/push/monitor.js +62 -0
  67. package/dist/push/monitor.js.map +1 -0
  68. package/dist/push/plugin.d.ts +33 -0
  69. package/dist/push/plugin.d.ts.map +1 -0
  70. package/dist/push/plugin.js +123 -0
  71. package/dist/push/plugin.js.map +1 -0
  72. package/dist/push/request.d.ts +43 -0
  73. package/dist/push/request.d.ts.map +1 -0
  74. package/dist/push/request.js +89 -0
  75. package/dist/push/request.js.map +1 -0
  76. package/dist/reporters/base.d.ts +14 -6
  77. package/dist/reporters/base.d.ts.map +1 -1
  78. package/dist/reporters/base.js +45 -47
  79. package/dist/reporters/base.js.map +1 -1
  80. package/dist/reporters/index.d.ts +18 -8
  81. package/dist/reporters/index.d.ts.map +1 -1
  82. package/dist/reporters/index.js.map +1 -1
  83. package/dist/reporters/json.d.ts +7 -3
  84. package/dist/reporters/json.d.ts.map +1 -1
  85. package/dist/reporters/json.js +118 -118
  86. package/dist/reporters/json.js.map +1 -1
  87. package/dist/reporters/junit.d.ts +7 -1
  88. package/dist/reporters/junit.d.ts.map +1 -1
  89. package/dist/reporters/junit.js +91 -86
  90. package/dist/reporters/junit.js.map +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +17 -11
  93. package/src/cli.ts +91 -14
  94. package/src/common_types.ts +69 -5
  95. package/src/core/gatherer.ts +4 -4
  96. package/src/core/index.ts +15 -0
  97. package/src/core/runner.ts +93 -113
  98. package/src/dsl/journey.ts +18 -0
  99. package/src/dsl/locations.ts +38 -0
  100. package/src/dsl/monitor.ts +87 -0
  101. package/src/generator/index.ts +212 -0
  102. package/src/generator/utils.ts +54 -0
  103. package/src/helpers.ts +36 -52
  104. package/src/index.ts +9 -1
  105. package/src/loader.ts +4 -4
  106. package/src/options.ts +72 -15
  107. package/src/plugins/performance.ts +1 -17
  108. package/src/push/bundler.ts +99 -0
  109. package/src/push/index.ts +63 -0
  110. package/src/push/monitor.ts +68 -0
  111. package/src/push/plugin.ts +113 -0
  112. package/src/push/request.ts +116 -0
  113. package/src/reporters/base.ts +57 -56
  114. package/src/reporters/index.ts +26 -3
  115. package/src/reporters/json.ts +153 -145
  116. package/src/reporters/junit.ts +98 -93
  117. package/templates/.github/workflows/run-synthetics.yml +28 -0
  118. package/templates/README.md +21 -0
  119. package/templates/journeys/advanced-example-helpers.ts +54 -0
  120. package/templates/journeys/advanced-example.journey.ts +43 -0
  121. package/templates/journeys/example.journey.ts +18 -0
  122. package/templates/synthetics.config.ts +26 -0
  123. package/CHANGELOG.md +0 -348
  124. package/NOTICE.txt +0 -221
  125. package/dist/reporters/reporter.d.ts.map +0 -1
  126. package/dist/reporters/reporter.js.map +0 -1
package/dist/options.js CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.normalizeOptions = void 0;
30
+ exports.parseThrottling = exports.normalizeOptions = void 0;
31
31
  const deepmerge_1 = __importDefault(require("deepmerge"));
32
32
  const config_1 = require("./config");
33
33
  const helpers_1 = require("./helpers");
@@ -86,23 +86,77 @@ function normalizeOptions(cliArgs) {
86
86
  const config = cliArgs.config || !cliArgs.inline
87
87
  ? (0, config_1.readConfig)(options.environment, cliArgs.config)
88
88
  : {};
89
+ /**
90
+ * Order of preference for options that are used while running are
91
+ * 1. Local options configured via Runner API
92
+ * 2. CLI flags
93
+ * 3. Configuration file
94
+ */
89
95
  options.params = Object.freeze((0, deepmerge_1.default)(config.params, cliArgs.params || {}));
90
96
  /**
91
- * Favor playwright options passed via cli to inline playwright options
97
+ * Merge playwright options from CLI and Synthetics config
98
+ * and prefer individual options over other option
92
99
  */
93
- options.playwrightOptions = deepmerge_1.default.all([
94
- config.playwrightOptions || {},
95
- cliArgs.playwrightOptions || {},
96
- {
97
- headless: cliArgs.headless,
98
- chromiumSandbox: cliArgs.sandbox,
99
- ignoreHTTPSErrors: cliArgs.ignoreHttpsErrors,
100
- },
101
- ]);
100
+ const playwrightOpts = (0, deepmerge_1.default)(config.playwrightOptions, cliArgs.playwrightOptions || {});
101
+ options.playwrightOptions = {
102
+ ...playwrightOpts,
103
+ headless: cliArgs.headless,
104
+ chromiumSandbox: cliArgs.sandbox ?? playwrightOpts?.chromiumSandbox,
105
+ ignoreHTTPSErrors: cliArgs.ignoreHttpsErrors ?? playwrightOpts?.ignoreHTTPSErrors,
106
+ };
107
+ /**
108
+ * Get the default monitor config from synthetics.config.ts file
109
+ */
110
+ const monitor = config.monitor;
102
111
  if (cliArgs.throttling) {
103
- options.networkConditions = (0, helpers_1.parseNetworkConditions)(cliArgs.throttling);
112
+ const throttleConfig = deepmerge_1.default.all([
113
+ helpers_1.DEFAULT_THROTTLING_OPTIONS,
114
+ monitor?.throttling || {},
115
+ cliArgs.throttling,
116
+ ]);
117
+ options.throttling = throttleConfig;
118
+ options.networkConditions = (0, helpers_1.getNetworkConditions)(throttleConfig);
104
119
  }
120
+ else {
121
+ /**
122
+ * Do not apply throttling when `--no-throttling` flag is passed
123
+ */
124
+ options.throttling = {};
125
+ }
126
+ options.schedule = cliArgs.schedule ?? monitor?.schedule;
127
+ options.locations = cliArgs.locations ?? monitor?.locations;
105
128
  return options;
106
129
  }
107
130
  exports.normalizeOptions = normalizeOptions;
131
+ /**
132
+ * Parses the throttling CLI settings and also
133
+ * adapts to the format to keep the backwards compatability
134
+ * - Accepts old format `<5d/3u/20l>`
135
+ * - Processess new format otherwise `{download: 5, upload: 3, latency: 20}`
136
+ */
137
+ function parseThrottling(value, prev) {
138
+ const THROTTLING_REGEX = /([0-9]{1,}u)|([0-9]{1,}d)|([0-9]{1,}l)/gm;
139
+ if (THROTTLING_REGEX.test(value)) {
140
+ const throttling = {};
141
+ const conditions = value.split('/');
142
+ conditions.forEach(condition => {
143
+ const setting = condition.slice(0, condition.length - 1);
144
+ const token = condition.slice(-1);
145
+ switch (token) {
146
+ case 'd':
147
+ throttling.download = Number(setting);
148
+ break;
149
+ case 'u':
150
+ throttling.upload = Number(setting);
151
+ break;
152
+ case 'l':
153
+ throttling.latency = Number(setting);
154
+ break;
155
+ }
156
+ });
157
+ return throttling;
158
+ }
159
+ return JSON.parse(value || prev);
160
+ }
161
+ exports.parseThrottling = parseThrottling;
108
162
  //# sourceMappingURL=options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,0DAA8B;AAC9B,qCAAsC;AACtC,uCAAmD;AAGnD;;;GAGG;AACH,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,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,KAAK,GAAG;oBACN,UAAU,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;oBACtC,MAAM;gBACR,KAAK,GAAG;oBACN,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;oBACpC,MAAM;gBACR,KAAK,GAAG;oBACN,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;oBACrC,MAAM;aACT;QACH,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;KACnB;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;AACnC,CAAC;AAxBD,0CAwBC"}
@@ -22,22 +22,7 @@
22
22
  * THE SOFTWARE.
23
23
  *
24
24
  */
25
- import { Driver } from '../common_types';
26
- export interface PageMetrics {
27
- Timestamp?: number;
28
- Documents?: number;
29
- Frames?: number;
30
- JSEventListeners?: number;
31
- Nodes?: number;
32
- LayoutCount?: number;
33
- RecalcStyleCount?: number;
34
- LayoutDuration?: number;
35
- RecalcStyleDuration?: number;
36
- ScriptDuration?: number;
37
- TaskDuration?: number;
38
- JSHeapUsedSize?: number;
39
- JSHeapTotalSize?: number;
40
- }
25
+ import { Driver, PageMetrics } from '../common_types';
41
26
  export declare class PerformanceManager {
42
27
  private driver;
43
28
  constructor(driver: Driver);
@@ -1 +1 @@
1
- {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/plugins/performance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAkBzC,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAkB;IACjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5B,KAAK;IAIL,IAAI;IAIJ,UAAU;IAKhB,OAAO,CAAC,kBAAkB;CAO3B"}
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/plugins/performance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBtD,qBAAa,kBAAkB;IACjB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5B,KAAK;IAIL,IAAI;IAIJ,UAAU;IAKhB,OAAO,CAAC,kBAAkB;CAO3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sourceRoot":"","sources":["../../src/plugins/performance.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAIH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAS;IACvC,WAAW;IACX,WAAW;IACX,QAAQ;IACR,kBAAkB;IAClB,OAAO;IACP,aAAa;IACb,kBAAkB;IAClB,gBAAgB;IAChB,qBAAqB;IACrB,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;CAClB,CAAC,CAAC;AAkBH,MAAa,kBAAkB;IAC7B,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,KAAK;Q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AAC,oBAAoB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEO,kBAAkB,CAAC,OAAO,GAAG,EAAE;QACrC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;gBAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;SAC3E;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAvBD,gDAuBC"}
@@ -36,7 +36,7 @@ export declare class PluginManager {
36
36
  register(type: PluginType, options: PluginOptions): Plugin;
37
37
  registerAll(options: PluginOptions): void;
38
38
  unregisterAll(): void;
39
- stop(type: PluginType): Promise<void | import("../common_types").NetworkInfo[] | Partial<PluginOutput> | import("../common_types").BrowserMessage[]>;
39
+ stop(type: PluginType): Promise<void | import("../common_types").NetworkInfo[] | import("../common_types").BrowserMessage[] | Partial<PluginOutput>>;
40
40
  start(type: PluginType): Promise<Plugin>;
41
41
  get(type: PluginType): Plugin;
42
42
  onStep(step: Step): void;
@@ -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;IAyBvB,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,119 @@
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
+ try {
77
+ const result = await esbuild.build(options);
78
+ if (result.errors.length > 0) {
79
+ throw result.errors;
80
+ }
81
+ this.moduleMap.set(absPath, result.outputFiles[0].text);
82
+ }
83
+ catch (e) {
84
+ console.error(e);
85
+ }
86
+ }
87
+ async zip(outputPath) {
88
+ return new Promise((fulfill, reject) => {
89
+ const output = (0, fs_1.createWriteStream)(outputPath);
90
+ const archive = (0, archiver_1.default)('zip', {
91
+ zlib: { level: 9 },
92
+ });
93
+ archive.on('error', err => reject(err));
94
+ output.on('close', fulfill);
95
+ archive.pipe(output);
96
+ for (const [path, content] of this.moduleMap.entries()) {
97
+ const relativePath = relativeToCwd(path);
98
+ archive.append(content, { name: relativePath });
99
+ }
100
+ archive.finalize();
101
+ });
102
+ }
103
+ async build(entry, output) {
104
+ await this.prepare(entry);
105
+ await this.zip(output);
106
+ const data = await this.encode(output);
107
+ await this.cleanup(output);
108
+ return data;
109
+ }
110
+ async encode(outputPath) {
111
+ return await (0, promises_1.readFile)(outputPath, 'base64');
112
+ }
113
+ async cleanup(outputPath) {
114
+ this.moduleMap = new Map();
115
+ await (0, promises_1.unlink)(outputPath);
116
+ }
117
+ }
118
+ exports.Bundler = Bundler;
119
+ //# sourceMappingURL=bundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler.js","sourceRoot":"","sources":["../../src/push/bundler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,0CAA+C;AAC/C,2BAAuC;AACvC,iDAAmC;AACnC,wDAAgC;AAChC,qCAAuE;AAEvE,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED,MAAa,OAAO;IAElB;QADA,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvB,CAAC;IAEhB,KAAK,CAAC,OAAO,CAAC,OAAe;QAC3B,MAAM,QAAQ,GAAG,CAAC,IAAgB,EAAE,EAAE;YACpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEF,MAAM,OAAO,GAAyB;YACpC,GAAG,IAAA,sBAAa,GAAE;YAClB,GAAG;gBACD,WAAW,EAAE;oBACX,CAAC,OAAO,CAAC,EAAE,OAAO;iBACnB;gBACD,OAAO,EAAE,CAAC,IAAA,yBAAgB,EAAC,QAAQ,CAAC,CAAC;aACtC;SACF,CAAC;QACF,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBA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,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,OAAO,MAAM,IAAA,mBAAQ,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAkB;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,MAAM,IAAA,iBAAM,EAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;CACF;AA9DD,0BA8DC"}
@@ -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;AAUH,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,iBAwBnE"}
@@ -0,0 +1,58 @@
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 { staleMonitors, failedMonitors } = await body.json();
45
+ if (failedMonitors.length > 0) {
46
+ throw (0, request_1.formatFailedMonitors)(failedMonitors);
47
+ }
48
+ if (staleMonitors.length > 0) {
49
+ (0, helpers_1.write)((0, request_1.formatStaleMonitors)());
50
+ }
51
+ (0, helpers_1.done)('Pushed');
52
+ }
53
+ catch (e) {
54
+ (0, helpers_1.error)(e);
55
+ }
56
+ }
57
+ exports.push = push;
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/push/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,uCAOmB;AAGnB,uCAA+C;AAC/C,wCAA0D;AAEnD,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,aAAa,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5D,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,MAAM,IAAA,8BAAoB,EAAC,cAAc,CAAC,CAAC;SAC5C;QACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,IAAA,eAAK,EAAC,IAAA,6BAAmB,GAAE,CAAC,CAAC;SAC9B;QACD,IAAA,cAAI,EAAC,QAAQ,CAAC,CAAC;KAChB;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,eAAK,EAAC,CAAC,CAAC,CAAC;KACV;AACH,CAAC;AAxBD,oBAwBC"}
@@ -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,CAYpD;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"}