@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.
- package/README.md +2 -2
- package/dist/cli.js +56 -8
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +59 -5
- package/dist/common_types.d.ts.map +1 -1
- package/dist/core/gatherer.d.ts +2 -2
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +2 -2
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +15 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/runner.d.ts +10 -58
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +92 -49
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/journey.d.ts +3 -0
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +15 -0
- package/dist/dsl/journey.js.map +1 -1
- package/dist/{reporters/reporter.d.ts → dsl/locations.d.ts} +12 -8
- package/dist/dsl/locations.d.ts.map +1 -0
- package/dist/dsl/locations.js +41 -0
- package/dist/dsl/locations.js.map +1 -0
- package/dist/dsl/monitor.d.ts +65 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +63 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/generator/index.d.ts +21 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +169 -0
- package/dist/generator/index.js.map +1 -0
- package/{src/reporters/reporter.ts → dist/generator/utils.d.ts} +4 -11
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +57 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +12 -6
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +33 -43
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/loader.js +4 -4
- package/dist/loader.js.map +1 -1
- package/dist/options.d.ts +7 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +66 -12
- package/dist/options.js.map +1 -1
- package/dist/plugins/performance.d.ts +1 -16
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +119 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/{reporters/reporter.js → push/index.d.ts} +4 -3
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +58 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +32 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +62 -0
- package/dist/push/monitor.js.map +1 -0
- package/dist/push/plugin.d.ts +33 -0
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +123 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +43 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +89 -0
- package/dist/push/request.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +45 -47
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +7 -3
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +118 -118
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +91 -86
- package/dist/reporters/junit.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -11
- package/src/cli.ts +91 -14
- package/src/common_types.ts +69 -5
- package/src/core/gatherer.ts +4 -4
- package/src/core/index.ts +15 -0
- package/src/core/runner.ts +93 -113
- package/src/dsl/journey.ts +18 -0
- package/src/dsl/locations.ts +38 -0
- package/src/dsl/monitor.ts +87 -0
- package/src/generator/index.ts +212 -0
- package/src/generator/utils.ts +54 -0
- package/src/helpers.ts +36 -52
- package/src/index.ts +9 -1
- package/src/loader.ts +4 -4
- package/src/options.ts +72 -15
- package/src/plugins/performance.ts +1 -17
- package/src/push/bundler.ts +99 -0
- package/src/push/index.ts +63 -0
- package/src/push/monitor.ts +68 -0
- package/src/push/plugin.ts +113 -0
- package/src/push/request.ts +116 -0
- package/src/reporters/base.ts +57 -56
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +153 -145
- package/src/reporters/junit.ts +98 -93
- package/templates/.github/workflows/run-synthetics.yml +28 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/synthetics.config.ts +26 -0
- package/CHANGELOG.md +0 -348
- package/NOTICE.txt +0 -221
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
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.MultiAssetPlugin = exports.commonOptions = void 0;
|
|
50
|
+
const path_1 = __importDefault(require("path"));
|
|
51
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
52
|
+
const esbuild = __importStar(require("esbuild"));
|
|
53
|
+
function commonOptions() {
|
|
54
|
+
return {
|
|
55
|
+
bundle: true,
|
|
56
|
+
external: ['node_modules', '@elastic/synthetics'],
|
|
57
|
+
minify: false,
|
|
58
|
+
platform: 'node',
|
|
59
|
+
format: 'esm',
|
|
60
|
+
write: false,
|
|
61
|
+
outExtension: {
|
|
62
|
+
'.js': '.js',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.commonOptions = commonOptions;
|
|
67
|
+
function MultiAssetPlugin(callback) {
|
|
68
|
+
const isBare = (str) => {
|
|
69
|
+
if (str.startsWith('/') || str.startsWith('./') || str.startsWith('../')) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
name: 'esbuild-multiasset-plugin',
|
|
76
|
+
setup(build) {
|
|
77
|
+
build.onResolve({ filter: /.*?/ }, async (args) => {
|
|
78
|
+
// External and other packages need be marked external to
|
|
79
|
+
// be removed from the bundle
|
|
80
|
+
if (build.initialOptions.external?.includes(args.path) ||
|
|
81
|
+
!isBare(args.path)) {
|
|
82
|
+
return {
|
|
83
|
+
external: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (args.kind === 'entry-point') {
|
|
87
|
+
return {
|
|
88
|
+
path: args.path,
|
|
89
|
+
namespace: 'asset',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// If the modules are resolved locally, then
|
|
93
|
+
// use the imported path to get full path
|
|
94
|
+
const entryPath = path_1.default.join(path_1.default.dirname(args.importer), args.path) +
|
|
95
|
+
path_1.default.extname(args.importer);
|
|
96
|
+
// Spin off another build to copy over the imported modules without bundling
|
|
97
|
+
const result = await esbuild.build({
|
|
98
|
+
...commonOptions(),
|
|
99
|
+
entryPoints: {
|
|
100
|
+
[entryPath]: entryPath,
|
|
101
|
+
},
|
|
102
|
+
bundle: false,
|
|
103
|
+
external: [],
|
|
104
|
+
});
|
|
105
|
+
callback({
|
|
106
|
+
path: entryPath,
|
|
107
|
+
contents: result.outputFiles[0].text,
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
errors: result.errors,
|
|
111
|
+
external: true,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
build.onLoad({ filter: /.*?/, namespace: 'asset' }, async (args) => {
|
|
115
|
+
const contents = await promises_1.default.readFile(args.path, 'utf-8');
|
|
116
|
+
callback({ path: args.path, contents });
|
|
117
|
+
return { contents };
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
exports.MultiAssetPlugin = MultiAssetPlugin;
|
|
123
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/push/plugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,2DAA6B;AAC7B,iDAAmC;AAEnC,SAAgB,aAAa;IAC3B,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,CAAC,cAAc,EAAE,qBAAqB,CAAC;QACjD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,KAAK;QACZ,YAAY,EAAE;YACZ,KAAK,EAAE,KAAK;SACb;KACF,CAAC;AACJ,CAAC;AAZD,sCA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BACb,QAAQ,EAAE,EAAE;iBACb,CAAC,CAAC;gBAEH,QAAQ,CAAC;oBACP,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI;iBACrC,CAAC,CAAC;gBAEH,OAAO;oBACL,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,QAAQ,EAAE,IAAI;iBACf,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE;gBAC/D,MAAM,QAAQ,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACvD,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACxC,OAAO,EAAE,QAAQ,EAAE,CAAC;YACtB,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AA/DD,4CA+DC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 { PushOptions } from '../common_types';
|
|
26
|
+
import { MonitorSchema } from './monitor';
|
|
27
|
+
export declare type APISchema = {
|
|
28
|
+
project: string;
|
|
29
|
+
keep_stale: boolean;
|
|
30
|
+
monitors: MonitorSchema[];
|
|
31
|
+
};
|
|
32
|
+
export declare function ok(statusCode: number): boolean;
|
|
33
|
+
export declare function createMonitors(monitors: MonitorSchema[], options: PushOptions): Promise<import("undici/types/dispatcher").ResponseData>;
|
|
34
|
+
export declare type APIMonitorError = {
|
|
35
|
+
id?: string;
|
|
36
|
+
reason: string;
|
|
37
|
+
details: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function formatNotFoundError(message: string): string;
|
|
40
|
+
export declare function formatAPIError(statuCode: number, error: string, message: string): string;
|
|
41
|
+
export declare function formatFailedMonitors(errors: APIMonitorError[]): string;
|
|
42
|
+
export declare function formatStaleMonitors(): string;
|
|
43
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/push/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAK1C,oBAAY,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,aAAa,EAAE,CAAC;CAC3B,CAAC;AAQF,wBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,WAEpC;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,EAAE,WAAW,2DAkBrB;AAED,oBAAY,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAIlD;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,UAShB;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,UAU7D;AAED,wBAAgB,mBAAmB,WAKlC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
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.formatStaleMonitors = exports.formatFailedMonitors = exports.formatAPIError = exports.formatNotFoundError = exports.createMonitors = exports.ok = void 0;
|
|
28
|
+
const colors_1 = require("kleur/colors");
|
|
29
|
+
const undici_1 = require("undici");
|
|
30
|
+
const helpers_1 = require("../helpers");
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
32
|
+
const { version } = require('../../package.json');
|
|
33
|
+
function getAPIUrl(options) {
|
|
34
|
+
return (options.url + `/s/${options.space}/api/synthetics/service/project/monitors`);
|
|
35
|
+
}
|
|
36
|
+
function ok(statusCode) {
|
|
37
|
+
return statusCode >= 200 && statusCode <= 299;
|
|
38
|
+
}
|
|
39
|
+
exports.ok = ok;
|
|
40
|
+
async function createMonitors(monitors, options) {
|
|
41
|
+
const schema = {
|
|
42
|
+
project: options.project,
|
|
43
|
+
keep_stale: !options.delete,
|
|
44
|
+
monitors,
|
|
45
|
+
};
|
|
46
|
+
return await (0, undici_1.request)(getAPIUrl(options), {
|
|
47
|
+
method: 'PUT',
|
|
48
|
+
body: JSON.stringify(schema),
|
|
49
|
+
headers: {
|
|
50
|
+
authorization: `ApiKey ${options.auth}`,
|
|
51
|
+
'content-type': 'application/json',
|
|
52
|
+
'user-agent': `Elastic/Synthetics ${version}`,
|
|
53
|
+
'kbn-xsrf': 'true',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
exports.createMonitors = createMonitors;
|
|
58
|
+
function formatNotFoundError(message) {
|
|
59
|
+
return (0, colors_1.bold)(`${helpers_1.symbols['failed']} Please check your kibana url and try again - 404:${message}`);
|
|
60
|
+
}
|
|
61
|
+
exports.formatNotFoundError = formatNotFoundError;
|
|
62
|
+
function formatAPIError(statuCode, error, message) {
|
|
63
|
+
let outer = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
64
|
+
let inner = (0, colors_1.bold)(`${helpers_1.symbols['failed']} monitor creation failed - ${statuCode}:${error}\n`);
|
|
65
|
+
inner += (0, helpers_1.indent)(message, ' ');
|
|
66
|
+
outer += (0, helpers_1.indent)(inner);
|
|
67
|
+
return outer;
|
|
68
|
+
}
|
|
69
|
+
exports.formatAPIError = formatAPIError;
|
|
70
|
+
function formatFailedMonitors(errors) {
|
|
71
|
+
let outer = (0, colors_1.bold)(`${helpers_1.symbols['failed']} Error\n`);
|
|
72
|
+
for (const error of errors) {
|
|
73
|
+
const monitorId = error.id ? `: monitor(${error.id})` : '';
|
|
74
|
+
let inner = (0, colors_1.bold)(`> ${error.reason}${monitorId}\n`);
|
|
75
|
+
inner += (0, helpers_1.indent)(error.details, ' ');
|
|
76
|
+
outer += (0, helpers_1.indent)(inner) + '\n';
|
|
77
|
+
outer += '\n';
|
|
78
|
+
}
|
|
79
|
+
return outer;
|
|
80
|
+
}
|
|
81
|
+
exports.formatFailedMonitors = formatFailedMonitors;
|
|
82
|
+
function formatStaleMonitors() {
|
|
83
|
+
let outer = (0, colors_1.bold)((0, colors_1.yellow)(`${helpers_1.symbols['warning']} Found stale monitors\n`));
|
|
84
|
+
const inner = (0, colors_1.gray)(`Pass --delete to remove all the stale monitors.`);
|
|
85
|
+
outer += (0, helpers_1.indent)(inner, ' ');
|
|
86
|
+
return outer;
|
|
87
|
+
}
|
|
88
|
+
exports.formatStaleMonitors = formatStaleMonitors;
|
|
89
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/push/request.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,yCAAkD;AAClD,mCAAiC;AAEjC,wCAA6C;AAG7C,uDAAuD;AACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAQlD,SAAS,SAAS,CAAC,OAAoB;IACrC,OAAO,CACL,OAAO,CAAC,GAAG,GAAG,MAAM,OAAO,CAAC,KAAK,0CAA0C,CAC5E,CAAC;AACJ,CAAC;AAED,SAAgB,EAAE,CAAC,UAAkB;IACnC,OAAO,UAAU,IAAI,GAAG,IAAI,UAAU,IAAI,GAAG,CAAC;AAChD,CAAC;AAFD,gBAEC;AAEM,KAAK,UAAU,cAAc,CAClC,QAAyB,EACzB,OAAoB;IAEpB,MAAM,MAAM,GAAc;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,CAAC,OAAO,CAAC,MAAM;QAC3B,QAAQ;KACT,CAAC;IAEF,OAAO,MAAM,IAAA,gBAAO,EAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACvC,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAC5B,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,IAAI,EAAE;YACvC,cAAc,EAAE,kBAAkB;YAClC,YAAY,EAAE,sBAAsB,OAAO,EAAE;YAC7C,UAAU,EAAE,MAAM;SACnB;KACF,CAAC,CAAC;AACL,CAAC;AApBD,wCAoBC;AAQD,SAAgB,mBAAmB,CAAC,OAAe;IACjD,OAAO,IAAA,aAAI,EACT,GAAG,iBAAO,C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AS,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,IAAA,aAAI,EAAC,iDAAiD,CAAC,CAAC;IACtE,KAAK,IAAI,IAAA,gBAAM,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC;AACf,CAAC;AALD,kDAKC"}
|
package/dist/reporters/base.d.ts
CHANGED
|
@@ -23,14 +23,22 @@
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
import SonicBoom from 'sonic-boom';
|
|
26
|
-
import
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
import { Reporter, ReporterOptions } from '.';
|
|
27
|
+
import { JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
28
|
+
import { Journey, Step } from '../dsl';
|
|
29
|
+
export default class BaseReporter implements Reporter {
|
|
30
30
|
stream: SonicBoom;
|
|
31
31
|
fd: number;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
metrics: {
|
|
33
|
+
succeeded: number;
|
|
34
|
+
failed: number;
|
|
35
|
+
skipped: number;
|
|
36
|
+
};
|
|
37
|
+
constructor(options?: ReporterOptions);
|
|
38
|
+
onJourneyStart(journey: Journey, {}: JourneyStartResult): void;
|
|
39
|
+
onStepEnd(journey: Journey, step: Step, result: StepEndResult): void;
|
|
40
|
+
onJourneyEnd(journey: Journey, { error }: JourneyEndResult): void;
|
|
41
|
+
onEnd(): void;
|
|
34
42
|
write(message: any): void;
|
|
35
43
|
}
|
|
36
44
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,SAAS,MAAM,YAAY,CAAC;AASnC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAyBvC,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,QAAQ;IACnD,MAAM,EAAE,SAAS,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO;;;;MAIL;gBAEU,OAAO,GAAE,eAAoB;IAUzC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,kBAAkB;IAIvD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa;IAW7D,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,gBAAgB;IAY1D,KAAK;IAwBL,KAAK,CAAC,OAAO,KAAA;CAMd"}
|
package/dist/reporters/base.js
CHANGED
|
@@ -52,8 +52,12 @@ function renderDuration(durationMs) {
|
|
|
52
52
|
return parseInt(durationMs);
|
|
53
53
|
}
|
|
54
54
|
class BaseReporter {
|
|
55
|
-
constructor(
|
|
56
|
-
this.
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this.metrics = {
|
|
57
|
+
succeeded: 0,
|
|
58
|
+
failed: 0,
|
|
59
|
+
skipped: 0,
|
|
60
|
+
};
|
|
57
61
|
this.fd = options.fd || process.stdout.fd;
|
|
58
62
|
/**
|
|
59
63
|
* minLength is set to 1 byte to make sure we flush the
|
|
@@ -61,54 +65,48 @@ class BaseReporter {
|
|
|
61
65
|
* before destroying the pipe with underlying file descriptor
|
|
62
66
|
*/
|
|
63
67
|
this.stream = new sonic_boom_1.default({ fd: this.fd, sync: true, minLength: 1 });
|
|
64
|
-
// flushSync is used here to make sure all the data from the underlying
|
|
65
|
-
// SonicBoom stream buffer is completely written to the fd before closing
|
|
66
|
-
// the process
|
|
67
|
-
this.runner.on('end', () => this.stream.flushSync());
|
|
68
|
-
this._registerListeners();
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const total = failed + succeeded + skipped;
|
|
99
|
-
let message = '\n';
|
|
100
|
-
if (total === 0) {
|
|
101
|
-
message = 'No tests found!';
|
|
102
|
-
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
103
|
-
this.write(message);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
message += succeeded > 0 ? (0, colors_1.green)(` ${succeeded} passed`) : '';
|
|
107
|
-
message += failed > 0 ? (0, colors_1.red)(` ${failed} failed`) : '';
|
|
108
|
-
message += skipped > 0 ? (0, colors_1.cyan)(` ${skipped} skipped`) : '';
|
|
69
|
+
onJourneyStart(journey, {}) {
|
|
70
|
+
this.write(`\nJourney: ${journey.name}`);
|
|
71
|
+
}
|
|
72
|
+
onStepEnd(journey, step, result) {
|
|
73
|
+
const { status, end, start, error } = result;
|
|
74
|
+
const message = `${helpers_1.symbols[status]} Step: '${step.name}' ${status} (${renderDuration((end - start) * 1000)} ms)`;
|
|
75
|
+
this.write((0, helpers_1.indent)(message));
|
|
76
|
+
error && this.write(renderError(error));
|
|
77
|
+
this.metrics[status]++;
|
|
78
|
+
}
|
|
79
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
80
|
+
onJourneyEnd(journey, { error }) {
|
|
81
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
82
|
+
const total = failed + succeeded + skipped;
|
|
83
|
+
/**
|
|
84
|
+
* Render the error on the terminal only when no steps could
|
|
85
|
+
* be executed which means the error happened in one of the hooks
|
|
86
|
+
*/
|
|
87
|
+
if (total === 0 && error) {
|
|
88
|
+
this.write(renderError(error));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onEnd() {
|
|
92
|
+
const { failed, succeeded, skipped } = this.metrics;
|
|
93
|
+
const total = failed + succeeded + skipped;
|
|
94
|
+
let message = '\n';
|
|
95
|
+
if (total === 0) {
|
|
96
|
+
message = 'No tests found!';
|
|
109
97
|
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
110
98
|
this.write(message);
|
|
111
|
-
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
message += succeeded > 0 ? (0, colors_1.green)(` ${succeeded} passed`) : '';
|
|
102
|
+
message += failed > 0 ? (0, colors_1.red)(` ${failed} failed`) : '';
|
|
103
|
+
message += skipped > 0 ? (0, colors_1.cyan)(` ${skipped} skipped`) : '';
|
|
104
|
+
message += ` (${renderDuration((0, helpers_1.now)())} ms) \n`;
|
|
105
|
+
this.write(message);
|
|
106
|
+
// flushSync is used here to make sure all the data from the underlying
|
|
107
|
+
// SonicBoom stream buffer is completely written to the fd before closing
|
|
108
|
+
// the process
|
|
109
|
+
this.stream.flushSync();
|
|
112
110
|
}
|
|
113
111
|
write(message) {
|
|
114
112
|
if (typeof message == 'object') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/reporters/base.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;AAEH,4DAAmC;AACnC,yCAAgD;
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources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
|
|
24
24
|
*/
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
import { Journey, Step } from '../dsl';
|
|
26
|
+
import { StartEvent, JourneyEndResult, JourneyStartResult, StepEndResult } from '../common_types';
|
|
27
|
+
export declare type ReporterOptions = {
|
|
28
|
+
fd?: number;
|
|
29
|
+
colors?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare type BuiltInReporterName = 'default' | 'json' | 'junit';
|
|
32
|
+
export declare type ReporterInstance = new (opts: ReporterOptions) => Reporter;
|
|
30
33
|
export declare const reporters: {
|
|
31
|
-
|
|
32
|
-
json: typeof JSONReporter;
|
|
33
|
-
junit: typeof JUnitReporter;
|
|
34
|
+
[key in BuiltInReporterName]: ReporterInstance;
|
|
34
35
|
};
|
|
36
|
+
export interface Reporter {
|
|
37
|
+
onStart?(params: StartEvent): void;
|
|
38
|
+
onJourneyRegister?(journey: Journey): void;
|
|
39
|
+
onJourneyStart?(journey: Journey, result: JourneyStartResult): void;
|
|
40
|
+
onStepStart?(journey: Journey, step: Step): void;
|
|
41
|
+
onStepEnd?(journey: Journey, step: Step, result: StepEndResult): void;
|
|
42
|
+
onJourneyEnd?(journey: Journey, result: JourneyEndResult): void | Promise<void>;
|
|
43
|
+
onEnd?(): void | Promise<void>;
|
|
44
|
+
}
|
|
35
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAEzB,oBAAY,eAAe,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAChE,oBAAY,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAC/D,oBAAY,gBAAgB,GAAG,KAAK,IAAI,EAAE,eAAe,KAAK,QAAQ,CAAC;AACvE,eAAO,MAAM,SAAS,EAAE;KACrB,GAAG,IAAI,mBAAmB,GAAG,gBAAgB;CAK/C,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,iBAAiB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpE,WAAW,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACjD,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IACtE,YAAY,CAAC,CACX,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,GACvB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;;;AAEH,kDAAkC;AAClC,kDAAkC;AAClC,oDAAoC;AAYvB,QAAA,SAAS,GAElB;IACF,OAAO,EAAE,cAAY;IACrB,IAAI,EAAE,cAAY;IAClB,KAAK,EAAE,eAAa;CACrB,CAAC"}
|
package/dist/reporters/json.d.ts
CHANGED
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
/// <reference types="node" />
|
|
26
26
|
import BaseReporter from './base';
|
|
27
27
|
import { Journey, Step } from '../dsl';
|
|
28
|
-
import { NetworkInfo, NetworkConditions, TraceOutput, StatusValue, PerfMetrics, Params, Screenshot } from '../common_types';
|
|
29
|
-
import { PageMetrics } from '../plugins';
|
|
28
|
+
import { NetworkInfo, NetworkConditions, TraceOutput, StatusValue, PerfMetrics, Params, Screenshot, StartEvent, JourneyStartResult, StepEndResult, JourneyEndResult, PageMetrics } from '../common_types';
|
|
30
29
|
declare type OutputType = 'synthetics/metadata' | 'journey/register' | 'journey/start' | 'screenshot/block' | 'step/screenshot_ref' | 'step/screenshot' | 'step/metrics' | 'step/filmstrips' | 'step/end' | 'journey/network_info' | 'journey/browserconsole' | 'journey/end';
|
|
31
30
|
declare type Payload = {
|
|
32
31
|
source?: string;
|
|
@@ -116,7 +115,12 @@ export declare function getScreenshotBlocks(screenshot: Buffer): Promise<{
|
|
|
116
115
|
*/
|
|
117
116
|
export declare function gatherScreenshots(screenshotsPath: string, callback: (data: Screenshot) => Promise<void>): Promise<void>;
|
|
118
117
|
export default class JSONReporter extends BaseReporter {
|
|
119
|
-
|
|
118
|
+
onStart(params: StartEvent): void;
|
|
119
|
+
onJourneyRegister(journey: Journey): void;
|
|
120
|
+
onJourneyStart(journey: Journey, { timestamp, params }: JourneyStartResult): void;
|
|
121
|
+
onStepEnd(journey: Journey, step: Step, { start, end, error, url, status, pagemetrics, traces, metrics, filmstrips, }: StepEndResult): void;
|
|
122
|
+
onJourneyEnd(journey: Journey, { timestamp, start, end, networkinfo, browserconsole, status, error, options, }: JourneyEndResult): Promise<void>;
|
|
123
|
+
onEnd(): void;
|
|
120
124
|
writeScreenshotBlocks(journey: Journey, screenshot: Screenshot): Promise<void>;
|
|
121
125
|
writeMetrics(journey: Journey, step: Step, type: string, events: Array<TraceOutput> | PerfMetrics): void;
|
|
122
126
|
writeJSON({ _id, journey, type, timestamp, step, root_fields, error, payload, blob, blob_mime, url, }: OutputFields): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,MAAM,EACN,UAAU,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EACL,WAAW,EAEX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,aAAK,UAAU,GACX,qBAAqB,GACrB,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,qBAAqB,GACrB,iBAAiB,GACjB,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,sBAAsB,GACtB,wBAAwB,GACxB,aAAa,CAAC;AAElB,aAAK,OA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