@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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +19 -11
  3. package/dist/cli.js.map +1 -1
  4. package/dist/core/gatherer.js +2 -2
  5. package/dist/core/gatherer.js.map +1 -1
  6. package/dist/dsl/locations.d.ts +37 -0
  7. package/dist/dsl/locations.d.ts.map +1 -0
  8. package/dist/dsl/locations.js +41 -0
  9. package/dist/dsl/locations.js.map +1 -0
  10. package/dist/dsl/monitor.d.ts +3 -2
  11. package/dist/dsl/monitor.d.ts.map +1 -1
  12. package/dist/dsl/monitor.js +2 -1
  13. package/dist/dsl/monitor.js.map +1 -1
  14. package/dist/generator/index.d.ts +8 -1
  15. package/dist/generator/index.d.ts.map +1 -1
  16. package/dist/generator/index.js +42 -7
  17. package/dist/generator/index.js.map +1 -1
  18. package/dist/generator/utils.d.ts +1 -0
  19. package/dist/generator/utils.d.ts.map +1 -1
  20. package/dist/generator/utils.js +14 -1
  21. package/dist/generator/utils.js.map +1 -1
  22. package/dist/options.d.ts +0 -5
  23. package/dist/options.d.ts.map +1 -1
  24. package/dist/options.js +20 -28
  25. package/dist/options.js.map +1 -1
  26. package/dist/push/monitor.d.ts.map +1 -1
  27. package/dist/push/monitor.js +2 -7
  28. package/dist/push/monitor.js.map +1 -1
  29. package/dist/push/request.d.ts.map +1 -1
  30. package/dist/push/request.js +1 -7
  31. package/dist/push/request.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +3 -1
  34. package/src/cli.ts +27 -13
  35. package/src/core/gatherer.ts +2 -2
  36. package/src/dsl/locations.ts +38 -0
  37. package/src/dsl/monitor.ts +6 -2
  38. package/src/generator/index.ts +53 -11
  39. package/src/generator/utils.ts +13 -0
  40. package/src/options.ts +23 -29
  41. package/src/push/monitor.ts +2 -11
  42. package/src/push/request.ts +1 -8
  43. package/templates/synthetics.config.ts +7 -0
@@ -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
- Monitor,
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
  }
@@ -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: `Basic ${encodeAuth(options.auth)}`,
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
  /**