checkly 5.6.0 → 6.0.0-prerelease-541d8e1

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 (113) hide show
  1. package/dist/commands/baseCommand.d.ts +1 -1
  2. package/dist/commands/baseCommand.js +3 -3
  3. package/dist/commands/baseCommand.js.map +1 -1
  4. package/dist/commands/deploy.js +37 -18
  5. package/dist/commands/deploy.js.map +1 -1
  6. package/dist/commands/import/plan.js +54 -27
  7. package/dist/commands/import/plan.js.map +1 -1
  8. package/dist/commands/test.js +84 -53
  9. package/dist/commands/test.js.map +1 -1
  10. package/dist/commands/trigger.d.ts +0 -1
  11. package/dist/commands/trigger.js +4 -6
  12. package/dist/commands/trigger.js.map +1 -1
  13. package/dist/constructs/api-check-bundle.d.ts +57 -0
  14. package/dist/constructs/api-check-bundle.js +34 -0
  15. package/dist/constructs/api-check-bundle.js.map +1 -0
  16. package/dist/constructs/api-check.d.ts +14 -20
  17. package/dist/constructs/api-check.js +86 -83
  18. package/dist/constructs/api-check.js.map +1 -1
  19. package/dist/constructs/browser-check-bundle.d.ts +58 -0
  20. package/dist/constructs/browser-check-bundle.js +31 -0
  21. package/dist/constructs/browser-check-bundle.js.map +1 -0
  22. package/dist/constructs/browser-check.d.ts +10 -22
  23. package/dist/constructs/browser-check.js +54 -67
  24. package/dist/constructs/browser-check.js.map +1 -1
  25. package/dist/constructs/check-group-codegen.d.ts +6 -5
  26. package/dist/constructs/check-group-codegen.js +14 -7
  27. package/dist/constructs/check-group-codegen.js.map +1 -1
  28. package/dist/constructs/check-group-ref.d.ts +14 -0
  29. package/dist/constructs/check-group-ref.js +37 -0
  30. package/dist/constructs/check-group-ref.js.map +1 -0
  31. package/dist/constructs/check-group-v1.d.ts +294 -0
  32. package/dist/constructs/check-group-v1.js +271 -0
  33. package/dist/constructs/check-group-v1.js.map +1 -0
  34. package/dist/constructs/check-group-v2.d.ts +120 -0
  35. package/dist/constructs/check-group-v2.js +87 -0
  36. package/dist/constructs/check-group-v2.js.map +1 -0
  37. package/dist/constructs/check-group.d.ts +4 -175
  38. package/dist/constructs/check-group.js +8 -246
  39. package/dist/constructs/check-group.js.map +1 -1
  40. package/dist/constructs/check.d.ts +2 -2
  41. package/dist/constructs/construct-diagnostics.d.ts +33 -0
  42. package/dist/constructs/construct-diagnostics.js +101 -0
  43. package/dist/constructs/construct-diagnostics.js.map +1 -0
  44. package/dist/constructs/construct.d.ts +35 -1
  45. package/dist/constructs/construct.js +48 -1
  46. package/dist/constructs/construct.js.map +1 -1
  47. package/dist/constructs/dashboard-bundle.d.ts +11 -0
  48. package/dist/constructs/dashboard-bundle.js +19 -0
  49. package/dist/constructs/dashboard-bundle.js.map +1 -0
  50. package/dist/constructs/dashboard.d.ts +26 -22
  51. package/dist/constructs/dashboard.js +39 -46
  52. package/dist/constructs/dashboard.js.map +1 -1
  53. package/dist/constructs/diagnostics.d.ts +36 -0
  54. package/dist/constructs/diagnostics.js +69 -0
  55. package/dist/constructs/diagnostics.js.map +1 -0
  56. package/dist/constructs/index.d.ts +1 -0
  57. package/dist/constructs/index.js +1 -0
  58. package/dist/constructs/index.js.map +1 -1
  59. package/dist/constructs/multi-step-check-bundle.d.ts +46 -0
  60. package/dist/constructs/multi-step-check-bundle.js +25 -0
  61. package/dist/constructs/multi-step-check-bundle.js.map +1 -0
  62. package/dist/constructs/multi-step-check.d.ts +9 -11
  63. package/dist/constructs/multi-step-check.js +50 -65
  64. package/dist/constructs/multi-step-check.js.map +1 -1
  65. package/dist/constructs/playwright-check-bundle.d.ts +49 -0
  66. package/dist/constructs/playwright-check-bundle.js +28 -0
  67. package/dist/constructs/playwright-check-bundle.js.map +1 -0
  68. package/dist/constructs/playwright-check.d.ts +9 -15
  69. package/dist/constructs/playwright-check.js +37 -33
  70. package/dist/constructs/playwright-check.js.map +1 -1
  71. package/dist/constructs/private-location.d.ts +2 -0
  72. package/dist/constructs/private-location.js +7 -5
  73. package/dist/constructs/private-location.js.map +1 -1
  74. package/dist/constructs/project-bundle.d.ts +30 -0
  75. package/dist/constructs/project-bundle.js +44 -0
  76. package/dist/constructs/project-bundle.js.map +1 -0
  77. package/dist/constructs/project.d.ts +41 -18
  78. package/dist/constructs/project.js +72 -31
  79. package/dist/constructs/project.js.map +1 -1
  80. package/dist/reporters/util.d.ts +0 -1
  81. package/dist/reporters/util.js +1 -5
  82. package/dist/reporters/util.js.map +1 -1
  83. package/dist/rest/projects.d.ts +2 -0
  84. package/dist/rest/projects.js.map +1 -1
  85. package/dist/rest/test-sessions.d.ts +2 -1
  86. package/dist/rest/test-sessions.js.map +1 -1
  87. package/dist/services/check-parser/package-files/json-source-file.js +2 -1
  88. package/dist/services/check-parser/package-files/json-source-file.js.map +1 -1
  89. package/dist/services/check-parser/package-files/loader.d.ts +2 -2
  90. package/dist/services/check-parser/package-files/loader.js +2 -2
  91. package/dist/services/check-parser/package-files/loader.js.map +1 -1
  92. package/dist/services/check-parser/package-files/resolver.d.ts +8 -8
  93. package/dist/services/check-parser/package-files/resolver.js +34 -32
  94. package/dist/services/check-parser/package-files/resolver.js.map +1 -1
  95. package/dist/services/check-parser/package-files/source-file.d.ts +1 -1
  96. package/dist/services/check-parser/package-files/source-file.js +5 -4
  97. package/dist/services/check-parser/package-files/source-file.js.map +1 -1
  98. package/dist/services/check-parser/parser.d.ts +3 -3
  99. package/dist/services/check-parser/parser.js +22 -23
  100. package/dist/services/check-parser/parser.js.map +1 -1
  101. package/dist/services/checkly-config-codegen.js +0 -3
  102. package/dist/services/checkly-config-codegen.js.map +1 -1
  103. package/dist/services/checkly-config-loader.d.ts +0 -1
  104. package/dist/services/checkly-config-loader.js.map +1 -1
  105. package/dist/services/project-parser.d.ts +4 -2
  106. package/dist/services/project-parser.js +109 -67
  107. package/dist/services/project-parser.js.map +1 -1
  108. package/dist/services/test-runner.d.ts +6 -4
  109. package/dist/services/test-runner.js +33 -22
  110. package/dist/services/test-runner.js.map +1 -1
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/oclif.manifest.json +3 -3
  113. package/package.json +1 -1
@@ -1,35 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.ApiCheck = exports.AssertionBuilder = void 0;
27
- const path = __importStar(require("path"));
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
28
8
  const check_1 = require("./check");
29
9
  const project_1 = require("./project");
30
- const util_1 = require("../services/util");
31
- const util_2 = require("../reporters/util");
10
+ const construct_1 = require("./construct");
32
11
  const assertion_1 = require("./internal/assertion");
12
+ const construct_diagnostics_1 = require("./construct-diagnostics");
13
+ const api_check_bundle_1 = require("./api-check-bundle");
33
14
  class AssertionBuilder {
34
15
  static statusCode() {
35
16
  return new assertion_1.NumericAssertionBuilder('STATUS_CODE');
@@ -52,12 +33,6 @@ class AssertionBuilder {
52
33
  }
53
34
  }
54
35
  exports.AssertionBuilder = AssertionBuilder;
55
- function _printWarning(path) {
56
- (0, util_2.printDeprecationWarning)(`API check "${path}" is probably providing a setup ` +
57
- 'or tearDown script using the "localSetupScript" or "localTearDownScript" property. Please update your API checks to ' +
58
- 'reference any setup / tearDown using the "setupScript" and "tearDownScript" properties See the docs at ' +
59
- 'https://checklyhq.com/docs/cli/constructs-reference#apicheck');
60
- }
61
36
  /**
62
37
  * Creates an API Check
63
38
  *
@@ -68,13 +43,11 @@ function _printWarning(path) {
68
43
  class ApiCheck extends check_1.Check {
69
44
  request;
70
45
  localSetupScript;
46
+ setupScript;
71
47
  localTearDownScript;
48
+ tearDownScript;
72
49
  degradedResponseTime;
73
50
  maxResponseTime;
74
- setupScriptDependencies;
75
- tearDownScriptDependencies;
76
- setupScriptPath;
77
- tearDownScriptPath;
78
51
  /**
79
52
  * Constructs the API Check instance
80
53
  *
@@ -85,75 +58,109 @@ class ApiCheck extends check_1.Check {
85
58
  */
86
59
  constructor(logicalId, props) {
87
60
  super(logicalId, props);
88
- if (props.setupScript) {
89
- if ('entrypoint' in props.setupScript) {
90
- const { script, scriptPath, dependencies } = ApiCheck.bundle(props.setupScript.entrypoint, this.runtimeId);
91
- this.localSetupScript = script;
92
- this.setupScriptPath = scriptPath;
93
- this.setupScriptDependencies = dependencies;
61
+ this.setupScript = props.setupScript;
62
+ this.localSetupScript = props.localSetupScript;
63
+ this.tearDownScript = props.tearDownScript;
64
+ this.localTearDownScript = props.localTearDownScript;
65
+ this.request = props.request;
66
+ this.degradedResponseTime = props.degradedResponseTime;
67
+ this.maxResponseTime = props.maxResponseTime;
68
+ project_1.Session.registerConstruct(this);
69
+ this.addSubscriptions();
70
+ this.addPrivateLocationCheckAssignments();
71
+ }
72
+ async validate(diagnostics) {
73
+ if (this.setupScript) {
74
+ if (!(0, construct_1.isEntrypoint)(this.setupScript) && !(0, construct_1.isContent)(this.setupScript)) {
75
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('setupScript', new Error(`Either "entrypoint" or "content" is required.`)));
94
76
  }
95
- else if ('content' in props.setupScript) {
96
- this.localSetupScript = props.setupScript.content;
77
+ else if ((0, construct_1.isEntrypoint)(this.setupScript) && (0, construct_1.isContent)(this.setupScript)) {
78
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('setupScript', new Error(`Provide exactly one of "entrypoint" or "content", but not both.`)));
97
79
  }
98
- else {
99
- throw new Error('Unrecognized type for the "setupScript" property. A "setupScript" should have either a "content" ' +
100
- 'or "entrypoint" property.');
80
+ else if ((0, construct_1.isEntrypoint)(this.setupScript)) {
81
+ const entrypoint = this.resolveContentFilePath(this.setupScript.entrypoint);
82
+ try {
83
+ await promises_1.default.access(entrypoint, promises_1.default.constants.R_OK);
84
+ }
85
+ catch (err) {
86
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('setupScript', new Error(`Unable to access entrypoint file "${entrypoint}": ${err.message}`, { cause: err })));
87
+ }
101
88
  }
102
89
  }
103
- if (props.localSetupScript) {
104
- _printWarning(project_1.Session.checkFilePath);
105
- this.localSetupScript = props.localSetupScript;
90
+ if (this.localSetupScript) {
91
+ diagnostics.add(new construct_diagnostics_1.DeprecatedPropertyDiagnostic('localSetupScript', new Error(`Use "setupScript" instead.`)));
106
92
  }
107
- if (props.tearDownScript) {
108
- if ('entrypoint' in props.tearDownScript) {
109
- const { script, scriptPath, dependencies } = ApiCheck.bundle(props.tearDownScript.entrypoint, this.runtimeId);
110
- this.localTearDownScript = script;
111
- this.tearDownScriptPath = scriptPath;
112
- this.tearDownScriptDependencies = dependencies;
93
+ if (this.tearDownScript) {
94
+ if (!(0, construct_1.isEntrypoint)(this.tearDownScript) && !(0, construct_1.isContent)(this.tearDownScript)) {
95
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('tearDownScript', new Error(`Either "entrypoint" or "content" is required.`)));
113
96
  }
114
- else if ('content' in props.tearDownScript) {
115
- this.localTearDownScript = props.tearDownScript.content;
97
+ else if ((0, construct_1.isEntrypoint)(this.tearDownScript) && (0, construct_1.isContent)(this.tearDownScript)) {
98
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('tearDownScript', new Error(`Provide exactly one of "entrypoint" or "content", but not both.`)));
99
+ }
100
+ else if ((0, construct_1.isEntrypoint)(this.tearDownScript)) {
101
+ const entrypoint = this.resolveContentFilePath(this.tearDownScript.entrypoint);
102
+ try {
103
+ await promises_1.default.access(entrypoint, promises_1.default.constants.R_OK);
104
+ }
105
+ catch (err) {
106
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('tearDownScript', new Error(`Unable to access entrypoint file "${entrypoint}": ${err.message}`, { cause: err })));
107
+ }
116
108
  }
117
109
  }
118
- if (props.localTearDownScript) {
119
- _printWarning(project_1.Session.checkFilePath);
120
- this.localTearDownScript = props.localTearDownScript;
110
+ if (this.localTearDownScript) {
111
+ diagnostics.add(new construct_diagnostics_1.DeprecatedPropertyDiagnostic('localTearDownScript', new Error(`Use "tearDownScript" instead.`)));
121
112
  }
122
- this.request = props.request;
123
- this.degradedResponseTime = props.degradedResponseTime;
124
- this.maxResponseTime = props.maxResponseTime;
125
- project_1.Session.registerConstruct(this);
126
- this.addSubscriptions();
127
- this.addPrivateLocationCheckAssignments();
128
113
  }
129
- static bundle(entrypoint, runtimeId) {
130
- let absoluteEntrypoint = null;
131
- if (path.isAbsolute(entrypoint)) {
132
- absoluteEntrypoint = entrypoint;
114
+ async bundle() {
115
+ const props = {};
116
+ if (this.localSetupScript) {
117
+ props.localSetupScript = this.localSetupScript;
118
+ }
119
+ if (this.setupScript) {
120
+ if ((0, construct_1.isEntrypoint)(this.setupScript)) {
121
+ const { script, scriptPath, dependencies } = await ApiCheck.bundle(this.resolveContentFilePath(this.setupScript.entrypoint), this.runtimeId);
122
+ props.localSetupScript = script;
123
+ props.setupScriptPath = scriptPath;
124
+ props.setupScriptDependencies = dependencies;
125
+ }
126
+ else {
127
+ props.localSetupScript = this.setupScript.content;
128
+ }
129
+ }
130
+ if (this.localTearDownScript) {
131
+ props.localTearDownScript = this.localTearDownScript;
133
132
  }
134
- else {
135
- if (!project_1.Session.checkFileAbsolutePath) {
136
- throw new Error('You cant use relative paths without the checkFileAbsolutePath in session');
133
+ if (this.tearDownScript) {
134
+ if ((0, construct_1.isEntrypoint)(this.tearDownScript)) {
135
+ const { script, scriptPath, dependencies } = await ApiCheck.bundle(this.resolveContentFilePath(this.tearDownScript.entrypoint), this.runtimeId);
136
+ props.localTearDownScript = script;
137
+ props.tearDownScriptPath = scriptPath;
138
+ props.tearDownScriptDependencies = dependencies;
139
+ }
140
+ else {
141
+ props.localTearDownScript = this.tearDownScript.content;
137
142
  }
138
- absoluteEntrypoint = path.join(path.dirname(project_1.Session.checkFileAbsolutePath), entrypoint);
139
143
  }
144
+ return new api_check_bundle_1.ApiCheckBundle(this, props);
145
+ }
146
+ static async bundle(entrypoint, runtimeId) {
140
147
  const runtime = project_1.Session.getRuntime(runtimeId);
141
148
  if (!runtime) {
142
149
  throw new Error(`${runtimeId} is not supported`);
143
150
  }
144
151
  const parser = project_1.Session.getParser(runtime);
145
- const parsed = parser.parse(absoluteEntrypoint);
152
+ const parsed = await parser.parse(entrypoint);
146
153
  // Maybe we can get the parsed deps with the content immediately
147
154
  const deps = [];
148
155
  for (const { filePath, content } of parsed.dependencies) {
149
- deps.push({
150
- path: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, filePath)),
156
+ deps.push(project_1.Session.registerSharedFile({
157
+ path: project_1.Session.relativePosixPath(filePath),
151
158
  content,
152
- });
159
+ }));
153
160
  }
154
161
  return {
155
162
  script: parsed.entrypoint.content,
156
- scriptPath: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, parsed.entrypoint.filePath)),
163
+ scriptPath: project_1.Session.relativePosixPath(parsed.entrypoint.filePath),
157
164
  dependencies: deps,
158
165
  };
159
166
  }
@@ -163,11 +170,7 @@ class ApiCheck extends check_1.Check {
163
170
  checkType: 'API',
164
171
  request: this.request,
165
172
  localSetupScript: this.localSetupScript,
166
- setupScriptPath: this.setupScriptPath,
167
- setupScriptDependencies: this.setupScriptDependencies,
168
173
  localTearDownScript: this.localTearDownScript,
169
- tearDownScriptPath: this.tearDownScriptPath,
170
- tearDownScriptDependencies: this.tearDownScriptDependencies,
171
174
  degradedResponseTime: this.degradedResponseTime,
172
175
  maxResponseTime: this.maxResponseTime,
173
176
  };
@@ -1 +1 @@
1
- {"version":3,"file":"api-check.js","sourceRoot":"","sources":["../../src/constructs/api-check.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,mCAA2C;AAE3C,uCAAmC;AAEnC,2CAA8C;AAC9C,4CAA2D;AAE3D,oDAAmH;AAWnH,MAAa,gBAAgB;IAC3B,MAAM,CAAC,UAAU;QACf,OAAO,IAAI,mCAAuB,CAAkB,aAAa,CAAC,CAAA;IACpE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAE,QAAiB;QAChC,OAAO,IAAI,mCAAuB,CAAkB,WAAW,EAAE,QAAQ,CAAC,CAAA;IAC5E,CAAC;IAED,MAAM,CAAC,OAAO,CAAE,QAAiB,EAAE,KAAc;QAC/C,OAAO,IAAI,mCAAuB,CAAkB,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;IACjF,CAAC;IAED,MAAM,CAAC,QAAQ,CAAE,QAAiB;QAChC,OAAO,IAAI,mCAAuB,CAAkB,WAAW,EAAE,QAAQ,CAAC,CAAA;IAC5E,CAAC;IAED,6CAA6C;IAC7C,MAAM,CAAC,WAAW;QAChB,OAAO,IAAI,mCAAuB,CAAkB,eAAe,CAAC,CAAA;IACtE,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAO,IAAI,mCAAuB,CAAkB,eAAe,CAAC,CAAA;IACtE,CAAC;CACF;AAzBD,4CAyBC;AAED,SAAS,aAAa,CAAE,IAAwB;IAC9C,IAAA,8BAAuB,EAAC,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E,SAAkB;QACzD,MAAM,OAAO,GAAG,iBAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAA;QAClD,CAAC;QACD,MAAM,MAAM,GAAG,iBAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QAC7C,gEAAgE;QAEhE,MAAM,IAAI,GAAoB,EAAE,CAAA;QAChC,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxD,IAAI,CAAC,IAAI,CAAC,iBAAO,CAAC,kBAAkB,CAAC;gBACnC,IAAI,EAAE,iBAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC;gBACzC,OAAO;aACR,CAAC,CAAC,CAAA;QACL,CAAC;QACD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACjC,UAAU,EAAE,iBAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;YACjE,YAAY,EAAE,IAAI;SACnB,CAAA;IACH,CAAC;IAED,UAAU;QACR,OAAO;YACL,GAAG,KAAK,CAAC,UAAU,EAAE;YACrB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAA;IACH,CAAC;CACF;AA9KD,4BA8KC"}
@@ -0,0 +1,58 @@
1
+ import { Snapshot } from '../services/snapshot-service';
2
+ import { BrowserCheck } from './browser-check';
3
+ import { Bundle } from './construct';
4
+ import { SharedFileRef } from './project';
5
+ export interface BrowserCheckBundleProps {
6
+ script: string;
7
+ scriptPath?: string;
8
+ dependencies?: SharedFileRef[];
9
+ rawSnapshots?: {
10
+ absolutePath: string;
11
+ path: string;
12
+ }[];
13
+ }
14
+ export declare class BrowserCheckBundle implements Bundle {
15
+ browserCheck: BrowserCheck;
16
+ script: string;
17
+ scriptPath?: string;
18
+ dependencies?: SharedFileRef[];
19
+ rawSnapshots?: {
20
+ absolutePath: string;
21
+ path: string;
22
+ }[];
23
+ snapshots?: Snapshot[];
24
+ constructor(browserCheck: BrowserCheck, props: BrowserCheckBundleProps);
25
+ synthesize(): {
26
+ script: string;
27
+ scriptPath: string | undefined;
28
+ dependencies: number[] | undefined;
29
+ snapshots: Snapshot[] | undefined;
30
+ checkType: string;
31
+ sslCheckDomain: string | null;
32
+ playwrightConfig: import("./playwright-config").PlaywrightConfig | undefined;
33
+ name: string;
34
+ activated: boolean | undefined;
35
+ muted: boolean | undefined;
36
+ shouldFail: boolean | undefined;
37
+ runtimeId: string | undefined;
38
+ locations: (keyof import("..").Region)[] | undefined;
39
+ privateLocations: undefined;
40
+ tags: string[] | undefined;
41
+ frequency: number | undefined;
42
+ frequencyOffset: number | undefined;
43
+ groupId: import("./ref").Ref | undefined;
44
+ environmentVariables: import("./key-value-pair").default[] | undefined;
45
+ retryStrategy: import("./retry-strategy").RetryStrategy | null | undefined;
46
+ doubleCheck: boolean | undefined;
47
+ alertSettings: import("./alert-escalation-policy").AlertEscalation | undefined;
48
+ useGlobalAlertSettings: boolean | undefined;
49
+ runParallel: boolean | undefined;
50
+ triggerIncident: {
51
+ serviceId: import("./ref").Ref;
52
+ severity: "MINOR" | "MEDIUM" | "MAJOR" | "CRITICAL";
53
+ name: string;
54
+ description: string;
55
+ notifySubscribers: boolean;
56
+ } | undefined;
57
+ };
58
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrowserCheckBundle = void 0;
4
+ class BrowserCheckBundle {
5
+ browserCheck;
6
+ script;
7
+ scriptPath;
8
+ dependencies;
9
+ // For snapshots, we first store `rawSnapshots` with the path to the file.
10
+ // The `snapshots` field is set later (with a `key`) after these are uploaded to storage.
11
+ rawSnapshots;
12
+ snapshots;
13
+ constructor(browserCheck, props) {
14
+ this.browserCheck = browserCheck;
15
+ this.script = props.script;
16
+ this.scriptPath = props.scriptPath;
17
+ this.dependencies = props.dependencies;
18
+ this.rawSnapshots = props.rawSnapshots;
19
+ }
20
+ synthesize() {
21
+ return {
22
+ ...this.browserCheck.synthesize(),
23
+ script: this.script,
24
+ scriptPath: this.scriptPath,
25
+ dependencies: this.dependencies,
26
+ snapshots: this.snapshots,
27
+ };
28
+ }
29
+ }
30
+ exports.BrowserCheckBundle = BrowserCheckBundle;
31
+ //# sourceMappingURL=browser-check-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-check-bundle.js","sourceRoot":"","sources":["../../src/constructs/browser-check-bundle.ts"],"names":[],"mappings":";;;AAYA,MAAa,kBAAkB;IAC7B,YAAY,CAAc;IAC1B,MAAM,CAAQ;IACd,UAAU,CAAS;IACnB,YAAY,CAAkB;IAC9B,0EAA0E;IAC1E,yFAAyF;IACzF,YAAY,CAA2C;IACvD,SAAS,CAAa;IAEtB,YAAa,YAA0B,EAAE,KAA8B;QACrE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;QACtC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;IACxC,CAAC;IAED,UAAU;QACR,OAAO;YACL,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAA;IACH,CAAC;CACF;AA3BD,gDA2BC"}
@@ -1,11 +1,8 @@
1
1
  import { Check, CheckProps } from './check';
2
2
  import { Content, Entrypoint } from './construct';
3
- import { Snapshot } from '../services/snapshot-service';
4
3
  import { PlaywrightConfig } from './playwright-config';
5
- export interface CheckDependency {
6
- path: string;
7
- content: string;
8
- }
4
+ import { Diagnostics } from './diagnostics';
5
+ import { BrowserCheckBundle } from './browser-check-bundle';
9
6
  export interface BrowserCheckProps extends CheckProps {
10
7
  /**
11
8
  * A valid piece of Node.js javascript code describing a browser interaction
@@ -31,16 +28,9 @@ export interface BrowserCheckProps extends CheckProps {
31
28
  * This class make use of the Browser Checks endpoints.
32
29
  */
33
30
  export declare class BrowserCheck extends Check {
34
- script: string;
35
- scriptPath?: string;
36
- dependencies?: Array<CheckDependency>;
37
- sslCheckDomain?: string;
38
- rawSnapshots?: Array<{
39
- absolutePath: string;
40
- path: string;
41
- }>;
42
- snapshots?: Array<Snapshot>;
43
- playwrightConfig?: PlaywrightConfig;
31
+ readonly code: Content | Entrypoint;
32
+ readonly sslCheckDomain?: string;
33
+ readonly playwrightConfig?: PlaywrightConfig;
44
34
  /**
45
35
  * Constructs the Browser Check instance
46
36
  *
@@ -49,25 +39,23 @@ export declare class BrowserCheck extends Check {
49
39
  * {@link https://checklyhq.com/docs/cli/constructs-reference/#browsercheck Read more in the docs}
50
40
  */
51
41
  constructor(logicalId: string, props: BrowserCheckProps);
42
+ validate(diagnostics: Diagnostics): Promise<void>;
52
43
  private static applyDefaultBrowserCheckGroupConfig;
53
44
  private static applyDefaultBrowserCheckConfig;
54
- static bundle(entry: string, runtimeId?: string): {
45
+ static bundle(entry: string, runtimeId?: string): Promise<{
55
46
  script: string;
56
47
  scriptPath: string;
57
- dependencies: CheckDependency[];
48
+ dependencies: number[];
58
49
  snapshots: {
59
50
  absolutePath: string;
60
51
  path: string;
61
52
  }[];
62
- };
53
+ }>;
63
54
  getSourceFile(): string | undefined;
55
+ bundle(): Promise<BrowserCheckBundle>;
64
56
  synthesize(): {
65
57
  checkType: string;
66
- script: string;
67
- scriptPath: string | undefined;
68
- dependencies: CheckDependency[] | undefined;
69
58
  sslCheckDomain: string | null;
70
- snapshots: Snapshot[] | undefined;
71
59
  playwrightConfig: PlaywrightConfig | undefined;
72
60
  name: string;
73
61
  activated: boolean | undefined;
@@ -1,34 +1,18 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.BrowserCheck = void 0;
27
- const path = __importStar(require("path"));
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const node_path_1 = __importDefault(require("node:path"));
28
9
  const check_1 = require("./check");
29
10
  const project_1 = require("./project");
30
11
  const util_1 = require("../services/util");
12
+ const construct_1 = require("./construct");
31
13
  const snapshot_service_1 = require("../services/snapshot-service");
14
+ const construct_diagnostics_1 = require("./construct-diagnostics");
15
+ const browser_check_bundle_1 = require("./browser-check-bundle");
32
16
  /**
33
17
  * Creates a Browser Check
34
18
  *
@@ -37,14 +21,8 @@ const snapshot_service_1 = require("../services/snapshot-service");
37
21
  * This class make use of the Browser Checks endpoints.
38
22
  */
39
23
  class BrowserCheck extends check_1.Check {
40
- script;
41
- scriptPath;
42
- dependencies;
24
+ code;
43
25
  sslCheckDomain;
44
- // For snapshots, we first store `rawSnapshots` with the path to the file.
45
- // The `snapshots` field is set later (with a `key`) after these are uploaded to storage.
46
- rawSnapshots;
47
- snapshots;
48
26
  playwrightConfig;
49
27
  /**
50
28
  * Constructs the Browser Check instance
@@ -59,39 +37,32 @@ class BrowserCheck extends check_1.Check {
59
37
  }
60
38
  BrowserCheck.applyDefaultBrowserCheckConfig(props);
61
39
  super(logicalId, props);
40
+ this.code = props.code;
62
41
  this.sslCheckDomain = props.sslCheckDomain;
63
42
  this.playwrightConfig = props.playwrightConfig;
64
- if ('content' in props.code) {
65
- const script = props.code.content;
66
- this.script = script;
43
+ project_1.Session.registerConstruct(this);
44
+ this.addSubscriptions();
45
+ this.addPrivateLocationCheckAssignments();
46
+ }
47
+ async validate(diagnostics) {
48
+ if (!(0, construct_1.isEntrypoint)(this.code) && !(0, construct_1.isContent)(this.code)) {
49
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('code', new Error(`Either "entrypoint" or "content" is required.`)));
67
50
  }
68
- else if ('entrypoint' in props.code) {
69
- const entrypoint = props.code.entrypoint;
70
- let absoluteEntrypoint = null;
71
- if (path.isAbsolute(entrypoint)) {
72
- absoluteEntrypoint = entrypoint;
73
- }
74
- else {
75
- if (!project_1.Session.checkFileAbsolutePath) {
76
- throw new Error('You cannot use relative paths without the checkFileAbsolutePath in session');
51
+ else if ((0, construct_1.isEntrypoint)(this.code) && (0, construct_1.isContent)(this.code)) {
52
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('code', new Error(`Provide exactly one of "entrypoint" or "content", but not both.`)));
53
+ }
54
+ else if ((0, construct_1.isEntrypoint)(this.code)) {
55
+ const entrypoint = this.resolveContentFilePath(this.code.entrypoint);
56
+ try {
57
+ const stats = await promises_1.default.stat(entrypoint);
58
+ if (stats.size === 0) {
59
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('code', new Error(`The entrypoint file "${entrypoint}" must not be empty.`)));
77
60
  }
78
- absoluteEntrypoint = path.join(path.dirname(project_1.Session.checkFileAbsolutePath), entrypoint);
79
61
  }
80
- const bundle = BrowserCheck.bundle(absoluteEntrypoint, this.runtimeId);
81
- if (!bundle.script) {
82
- throw new Error(`Browser check "${logicalId}" is not allowed to be empty`);
62
+ catch (err) {
63
+ diagnostics.add(new construct_diagnostics_1.InvalidPropertyValueDiagnostic('code', new Error(`Unable to access entrypoint file "${entrypoint}": ${err.message}`, { cause: err })));
83
64
  }
84
- this.script = bundle.script;
85
- this.scriptPath = bundle.scriptPath;
86
- this.dependencies = bundle.dependencies;
87
- this.rawSnapshots = bundle.snapshots;
88
65
  }
89
- else {
90
- throw new Error('Unrecognized type for the "code" property. The "code" property should be a string of JS/TS code.');
91
- }
92
- project_1.Session.registerConstruct(this);
93
- this.addSubscriptions();
94
- this.addPrivateLocationCheckAssignments();
95
66
  }
96
67
  static applyDefaultBrowserCheckGroupConfig(props, groupProps) {
97
68
  let configKey;
@@ -110,40 +81,56 @@ class BrowserCheck extends check_1.Check {
110
81
  props[configKey] = newVal;
111
82
  }
112
83
  }
113
- static bundle(entry, runtimeId) {
84
+ static async bundle(entry, runtimeId) {
114
85
  const runtime = project_1.Session.getRuntime(runtimeId);
115
86
  if (!runtime) {
116
87
  throw new Error(`${runtimeId} is not supported`);
117
88
  }
118
89
  const parser = project_1.Session.getParser(runtime);
119
- const parsed = parser.parse(entry);
90
+ const parsed = await parser.parse(entry);
120
91
  // Maybe we can get the parsed deps with the content immediately
121
92
  const deps = [];
122
93
  for (const { filePath, content } of parsed.dependencies) {
123
- deps.push({
124
- path: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, filePath)),
94
+ deps.push(project_1.Session.registerSharedFile({
95
+ path: (0, util_1.pathToPosix)(node_path_1.default.relative(project_1.Session.basePath, filePath)),
125
96
  content,
126
- });
97
+ }));
127
98
  }
128
99
  return {
129
100
  script: parsed.entrypoint.content,
130
- scriptPath: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, parsed.entrypoint.filePath)),
101
+ scriptPath: project_1.Session.relativePosixPath(parsed.entrypoint.filePath),
131
102
  dependencies: deps,
132
103
  snapshots: (0, snapshot_service_1.detectSnapshots)(project_1.Session.basePath, parsed.entrypoint.filePath),
133
104
  };
134
105
  }
135
106
  getSourceFile() {
136
- return this.__checkFilePath ?? this.scriptPath;
107
+ return this.__checkFilePath;
108
+ }
109
+ async bundle() {
110
+ return new browser_check_bundle_1.BrowserCheckBundle(this, await (async () => {
111
+ if ((0, construct_1.isEntrypoint)(this.code)) {
112
+ const bundle = await BrowserCheck.bundle(this.resolveContentFilePath(this.code.entrypoint), this.runtimeId);
113
+ if (!bundle.script) {
114
+ throw new Error(`The "code" property points to an empty file.`);
115
+ }
116
+ return {
117
+ script: bundle.script,
118
+ scriptPath: bundle.scriptPath,
119
+ dependencies: bundle.dependencies,
120
+ rawSnapshots: bundle.snapshots,
121
+ };
122
+ }
123
+ const script = this.code.content;
124
+ return {
125
+ script,
126
+ };
127
+ })());
137
128
  }
138
129
  synthesize() {
139
130
  return {
140
131
  ...super.synthesize(),
141
132
  checkType: 'BROWSER',
142
- script: this.script,
143
- scriptPath: this.scriptPath,
144
- dependencies: this.dependencies,
145
133
  sslCheckDomain: this.sslCheckDomain || null, // empty string is converted to null
146
- snapshots: this.snapshots,
147
134
  playwrightConfig: this.playwrightConfig,
148
135
  };
149
136
  }