@elastic/synthetics 1.0.0-beta.26 → 1.0.0-beta.27
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 +1 -1
- package/dist/cli.js +19 -11
- package/dist/cli.js.map +1 -1
- package/dist/core/gatherer.js +2 -2
- package/dist/core/gatherer.js.map +1 -1
- package/dist/dsl/locations.d.ts +37 -0
- 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 +3 -2
- package/dist/dsl/monitor.d.ts.map +1 -1
- package/dist/dsl/monitor.js +2 -1
- package/dist/dsl/monitor.js.map +1 -1
- package/dist/generator/index.d.ts +8 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +42 -7
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/utils.d.ts +1 -0
- package/dist/generator/utils.d.ts.map +1 -1
- package/dist/generator/utils.js +14 -1
- package/dist/generator/utils.js.map +1 -1
- package/dist/options.d.ts +0 -5
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +20 -28
- package/dist/options.js.map +1 -1
- package/dist/push/monitor.d.ts.map +1 -1
- package/dist/push/monitor.js +2 -7
- package/dist/push/monitor.js.map +1 -1
- package/dist/push/request.d.ts.map +1 -1
- package/dist/push/request.js +1 -7
- package/dist/push/request.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/src/cli.ts +27 -13
- package/src/core/gatherer.ts +2 -2
- package/src/dsl/locations.ts +38 -0
- package/src/dsl/monitor.ts +6 -2
- package/src/generator/index.ts +53 -11
- package/src/generator/utils.ts +13 -0
- package/src/options.ts +23 -29
- package/src/push/monitor.ts +2 -11
- package/src/push/request.ts +1 -8
- package/templates/synthetics.config.ts +7 -0
package/src/push/monitor.ts
CHANGED
|
@@ -27,11 +27,8 @@ import { mkdir } from 'fs/promises';
|
|
|
27
27
|
import { join } from 'path';
|
|
28
28
|
import { Bundler } from './bundler';
|
|
29
29
|
import { CACHE_PATH } from '../helpers';
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
MonitorConfig,
|
|
33
|
-
SyntheticsLocationsType,
|
|
34
|
-
} from '../dsl/monitor';
|
|
30
|
+
import { LocationsMap } from '../dsl/locations';
|
|
31
|
+
import { Monitor, MonitorConfig } from '../dsl/monitor';
|
|
35
32
|
|
|
36
33
|
export type MonitorSchema = Omit<MonitorConfig, 'locations'> & {
|
|
37
34
|
content: string;
|
|
@@ -39,12 +36,6 @@ export type MonitorSchema = Omit<MonitorConfig, 'locations'> & {
|
|
|
39
36
|
filter: Monitor['filter'];
|
|
40
37
|
};
|
|
41
38
|
|
|
42
|
-
// Internal representation of Locations that would be used when
|
|
43
|
-
// talking to the Kibana API
|
|
44
|
-
const LocationsMap: Record<SyntheticsLocationsType, string> = {
|
|
45
|
-
'US East': 'us-east4-a',
|
|
46
|
-
'EU West': 'europe-west2-a',
|
|
47
|
-
};
|
|
48
39
|
function translateLocation(locations: MonitorConfig['locations']) {
|
|
49
40
|
return locations.map(loc => LocationsMap[loc]).filter(Boolean);
|
|
50
41
|
}
|
package/src/push/request.ts
CHANGED
|
@@ -38,13 +38,6 @@ export type APISchema = {
|
|
|
38
38
|
monitors: MonitorSchema[];
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
function encodeAuth(auth: string) {
|
|
42
|
-
if (auth.includes(':')) {
|
|
43
|
-
return Buffer.from(auth).toString('base64');
|
|
44
|
-
}
|
|
45
|
-
return auth;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
41
|
function getAPIUrl(options: PushOptions) {
|
|
49
42
|
return (
|
|
50
43
|
options.url + `/s/${options.space}/api/synthetics/service/project/monitors`
|
|
@@ -69,7 +62,7 @@ export async function createMonitors(
|
|
|
69
62
|
method: 'PUT',
|
|
70
63
|
body: JSON.stringify(schema),
|
|
71
64
|
headers: {
|
|
72
|
-
authorization: `
|
|
65
|
+
authorization: `ApiKey ${options.auth}`,
|
|
73
66
|
'content-type': 'application/json',
|
|
74
67
|
'user-agent': `Elastic/Synthetics ${version}`,
|
|
75
68
|
'kbn-xsrf': 'true',
|
|
@@ -8,6 +8,13 @@ export default env => {
|
|
|
8
8
|
playwrightOptions: {
|
|
9
9
|
ignoreHTTPSErrors: false,
|
|
10
10
|
},
|
|
11
|
+
/**
|
|
12
|
+
* Configure global monitor settings
|
|
13
|
+
*/
|
|
14
|
+
monitor: {
|
|
15
|
+
schedule: '{{schedule}}',
|
|
16
|
+
locations: ["'{{locations}}'"],
|
|
17
|
+
},
|
|
11
18
|
};
|
|
12
19
|
if (env !== 'development') {
|
|
13
20
|
/**
|