checkly 3.1.1 → 4.0.1

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 (233) hide show
  1. package/README.md +42 -110
  2. package/bin/dev +17 -0
  3. package/bin/run +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/constructs.d.ts +1 -0
  6. package/constructs.js +1 -0
  7. package/dist/auth/index.d.ts +15 -0
  8. package/dist/auth/index.js +228 -0
  9. package/dist/auth/index.js.map +1 -0
  10. package/dist/commands/authCommand.d.ts +5 -0
  11. package/dist/commands/authCommand.js +14 -0
  12. package/dist/commands/authCommand.js.map +1 -0
  13. package/dist/commands/baseCommand.d.ts +9 -0
  14. package/dist/commands/baseCommand.js +21 -0
  15. package/dist/commands/baseCommand.js.map +1 -0
  16. package/dist/commands/deploy.d.ts +13 -0
  17. package/dist/commands/deploy.js +171 -0
  18. package/dist/commands/deploy.js.map +1 -0
  19. package/dist/commands/destroy.d.ts +10 -0
  20. package/dist/commands/destroy.js +47 -0
  21. package/dist/commands/destroy.js.map +1 -0
  22. package/dist/commands/env/add.d.ts +13 -0
  23. package/dist/commands/env/add.js +54 -0
  24. package/dist/commands/env/add.js.map +1 -0
  25. package/dist/commands/env/ls.d.ts +6 -0
  26. package/dist/commands/env/ls.js +21 -0
  27. package/dist/commands/env/ls.js.map +1 -0
  28. package/dist/commands/env/pull.d.ts +12 -0
  29. package/dist/commands/env/pull.js +63 -0
  30. package/dist/commands/env/pull.js.map +1 -0
  31. package/dist/commands/env/rm.d.ts +12 -0
  32. package/dist/commands/env/rm.js +56 -0
  33. package/dist/commands/env/rm.js.map +1 -0
  34. package/dist/commands/env/update.d.ts +13 -0
  35. package/dist/commands/env/update.js +54 -0
  36. package/dist/commands/env/update.js.map +1 -0
  37. package/dist/commands/login.d.ts +13 -0
  38. package/dist/commands/login.js +129 -0
  39. package/dist/commands/login.js.map +1 -0
  40. package/dist/commands/logout.d.ts +9 -0
  41. package/dist/commands/logout.js +40 -0
  42. package/dist/commands/logout.js.map +1 -0
  43. package/dist/commands/runtimes.d.ts +6 -0
  44. package/dist/commands/runtimes.js +26 -0
  45. package/dist/commands/runtimes.js.map +1 -0
  46. package/dist/commands/switch.d.ts +9 -0
  47. package/dist/commands/switch.js +59 -0
  48. package/dist/commands/switch.js.map +1 -0
  49. package/dist/commands/test.d.ts +36 -0
  50. package/dist/commands/test.js +237 -0
  51. package/dist/commands/test.js.map +1 -0
  52. package/dist/commands/trigger.d.ts +32 -0
  53. package/dist/commands/trigger.js +173 -0
  54. package/dist/commands/trigger.js.map +1 -0
  55. package/dist/commands/whoami.d.ts +6 -0
  56. package/dist/commands/whoami.js +16 -0
  57. package/dist/commands/whoami.js.map +1 -0
  58. package/dist/config.d.ts +31 -0
  59. package/dist/config.js +8 -0
  60. package/dist/config.js.map +1 -0
  61. package/dist/constructs/alert-channel-subscription.d.ts +44 -0
  62. package/dist/constructs/alert-channel-subscription.js +39 -0
  63. package/dist/constructs/alert-channel-subscription.js.map +1 -0
  64. package/dist/constructs/alert-channel.d.ts +53 -0
  65. package/dist/constructs/alert-channel.js +55 -0
  66. package/dist/constructs/alert-channel.js.map +1 -0
  67. package/dist/constructs/api-check.d.ts +179 -0
  68. package/dist/constructs/api-check.js +248 -0
  69. package/dist/constructs/api-check.js.map +1 -0
  70. package/dist/constructs/browser-check.d.ts +59 -0
  71. package/dist/constructs/browser-check.js +102 -0
  72. package/dist/constructs/browser-check.js.map +1 -0
  73. package/dist/constructs/check-group.d.ts +116 -0
  74. package/dist/constructs/check-group.js +113 -0
  75. package/dist/constructs/check-group.js.map +1 -0
  76. package/dist/constructs/check.d.ts +111 -0
  77. package/dist/constructs/check.js +88 -0
  78. package/dist/constructs/check.js.map +1 -0
  79. package/dist/constructs/construct.d.ts +17 -0
  80. package/dist/constructs/construct.js +22 -0
  81. package/dist/constructs/construct.js.map +1 -0
  82. package/dist/constructs/email-alert-channel.d.ts +26 -0
  83. package/dist/constructs/email-alert-channel.js +37 -0
  84. package/dist/constructs/email-alert-channel.js.map +1 -0
  85. package/dist/constructs/environment-variable.d.ts +2 -0
  86. package/dist/constructs/environment-variable.js +3 -0
  87. package/dist/constructs/environment-variable.js.map +1 -0
  88. package/dist/constructs/frequency.d.ts +20 -0
  89. package/dist/constructs/frequency.js +26 -0
  90. package/dist/constructs/frequency.js.map +1 -0
  91. package/dist/constructs/http-header.d.ts +2 -0
  92. package/dist/constructs/http-header.js +3 -0
  93. package/dist/constructs/http-header.js.map +1 -0
  94. package/dist/constructs/index.d.ts +15 -0
  95. package/dist/constructs/index.js +32 -0
  96. package/dist/constructs/index.js.map +1 -0
  97. package/dist/constructs/key-value-pair.d.ts +5 -0
  98. package/dist/constructs/key-value-pair.js +3 -0
  99. package/dist/constructs/key-value-pair.js.map +1 -0
  100. package/dist/constructs/opsgenie-alert-channel.d.ts +45 -0
  101. package/dist/constructs/opsgenie-alert-channel.js +44 -0
  102. package/dist/constructs/opsgenie-alert-channel.js.map +1 -0
  103. package/dist/constructs/pagerduty-alert-channel.d.ts +39 -0
  104. package/dist/constructs/pagerduty-alert-channel.js +42 -0
  105. package/dist/constructs/pagerduty-alert-channel.js.map +1 -0
  106. package/dist/constructs/project.d.ts +57 -0
  107. package/dist/constructs/project.js +100 -0
  108. package/dist/constructs/project.js.map +1 -0
  109. package/dist/constructs/query-param.d.ts +2 -0
  110. package/dist/constructs/query-param.js +3 -0
  111. package/dist/constructs/query-param.js.map +1 -0
  112. package/dist/constructs/ref.d.ts +5 -0
  113. package/dist/constructs/ref.js +13 -0
  114. package/dist/constructs/ref.js.map +1 -0
  115. package/dist/constructs/slack-alert-channel.d.ts +26 -0
  116. package/dist/constructs/slack-alert-channel.js +40 -0
  117. package/dist/constructs/slack-alert-channel.js.map +1 -0
  118. package/dist/constructs/sms-alert-channel.d.ts +27 -0
  119. package/dist/constructs/sms-alert-channel.js +38 -0
  120. package/dist/constructs/sms-alert-channel.js.map +1 -0
  121. package/dist/constructs/validator-error.d.ts +2 -0
  122. package/dist/constructs/validator-error.js +7 -0
  123. package/dist/constructs/validator-error.js.map +1 -0
  124. package/dist/constructs/webhook-alert-channel.d.ts +59 -0
  125. package/dist/constructs/webhook-alert-channel.js +50 -0
  126. package/dist/constructs/webhook-alert-channel.js.map +1 -0
  127. package/dist/help/examples.d.ts +6 -0
  128. package/dist/help/examples.js +22 -0
  129. package/dist/help/examples.js.map +1 -0
  130. package/dist/help/help-extension.d.ts +4 -0
  131. package/dist/help/help-extension.js +41 -0
  132. package/dist/help/help-extension.js.map +1 -0
  133. package/dist/index.d.ts +3 -0
  134. package/dist/index.js +7 -0
  135. package/dist/index.js.map +1 -0
  136. package/dist/messages/common-messages.d.ts +5 -0
  137. package/dist/messages/common-messages.js +9 -0
  138. package/dist/messages/common-messages.js.map +1 -0
  139. package/dist/reporters/abstract-list.d.ts +34 -0
  140. package/dist/reporters/abstract-list.js +128 -0
  141. package/dist/reporters/abstract-list.js.map +1 -0
  142. package/dist/reporters/ci.d.ts +12 -0
  143. package/dist/reporters/ci.js +29 -0
  144. package/dist/reporters/ci.js.map +1 -0
  145. package/dist/reporters/dot.d.ts +12 -0
  146. package/dist/reporters/dot.js +28 -0
  147. package/dist/reporters/dot.js.map +1 -0
  148. package/dist/reporters/github.d.ts +34 -0
  149. package/dist/reporters/github.js +103 -0
  150. package/dist/reporters/github.js.map +1 -0
  151. package/dist/reporters/list.d.ts +13 -0
  152. package/dist/reporters/list.js +57 -0
  153. package/dist/reporters/list.js.map +1 -0
  154. package/dist/reporters/reporter.d.ts +14 -0
  155. package/dist/reporters/reporter.js +23 -0
  156. package/dist/reporters/reporter.js.map +1 -0
  157. package/dist/reporters/util.d.ts +15 -0
  158. package/dist/reporters/util.js +283 -0
  159. package/dist/reporters/util.js.map +1 -0
  160. package/dist/rest/accounts.d.ts +12 -0
  161. package/dist/rest/accounts.js +15 -0
  162. package/dist/rest/accounts.js.map +1 -0
  163. package/dist/rest/api.d.ts +27 -0
  164. package/dist/rest/api.js +90 -0
  165. package/dist/rest/api.js.map +1 -0
  166. package/dist/rest/assets.d.ts +13 -0
  167. package/dist/rest/assets.js +30 -0
  168. package/dist/rest/assets.js.map +1 -0
  169. package/dist/rest/environment-variables.d.ts +16 -0
  170. package/dist/rest/environment-variables.js +25 -0
  171. package/dist/rest/environment-variables.js.map +1 -0
  172. package/dist/rest/locations.d.ts +11 -0
  173. package/dist/rest/locations.js +12 -0
  174. package/dist/rest/locations.js.map +1 -0
  175. package/dist/rest/private-locations.d.ts +11 -0
  176. package/dist/rest/private-locations.js +12 -0
  177. package/dist/rest/private-locations.js.map +1 -0
  178. package/dist/rest/projects.d.ts +43 -0
  179. package/dist/rest/projects.js +24 -0
  180. package/dist/rest/projects.js.map +1 -0
  181. package/dist/rest/runtimes.d.ts +15 -0
  182. package/dist/rest/runtimes.js +15 -0
  183. package/dist/rest/runtimes.js.map +1 -0
  184. package/dist/rest/test-sessions.d.ts +47 -0
  185. package/dist/rest/test-sessions.js +15 -0
  186. package/dist/rest/test-sessions.js.map +1 -0
  187. package/dist/rest/users.d.ts +12 -0
  188. package/dist/rest/users.js +12 -0
  189. package/dist/rest/users.js.map +1 -0
  190. package/dist/services/abstract-check-runner.d.ts +50 -0
  191. package/dist/services/abstract-check-runner.js +151 -0
  192. package/dist/services/abstract-check-runner.js.map +1 -0
  193. package/dist/services/check-parser/collector.d.ts +33 -0
  194. package/dist/services/check-parser/collector.js +48 -0
  195. package/dist/services/check-parser/collector.js.map +1 -0
  196. package/dist/services/check-parser/errors.d.ts +8 -0
  197. package/dist/services/check-parser/errors.js +45 -0
  198. package/dist/services/check-parser/errors.js.map +1 -0
  199. package/dist/services/check-parser/parser.d.ts +39 -0
  200. package/dist/services/check-parser/parser.js +296 -0
  201. package/dist/services/check-parser/parser.js.map +1 -0
  202. package/dist/services/checkly-config-loader.d.ts +54 -0
  203. package/dist/services/checkly-config-loader.js +55 -0
  204. package/dist/services/checkly-config-loader.js.map +1 -0
  205. package/dist/services/config.d.ts +24 -0
  206. package/dist/services/config.js +75 -0
  207. package/dist/services/config.js.map +1 -0
  208. package/dist/services/project-parser.d.ts +19 -0
  209. package/dist/services/project-parser.js +87 -0
  210. package/dist/services/project-parser.js.map +1 -0
  211. package/dist/services/socket-client.d.ts +4 -0
  212. package/dist/services/socket-client.js +20 -0
  213. package/dist/services/socket-client.js.map +1 -0
  214. package/dist/services/test-filters.d.ts +2 -0
  215. package/dist/services/test-filters.js +16 -0
  216. package/dist/services/test-filters.js.map +1 -0
  217. package/dist/services/test-runner.d.ts +21 -0
  218. package/dist/services/test-runner.js +50 -0
  219. package/dist/services/test-runner.js.map +1 -0
  220. package/dist/services/trigger-runner.d.ts +26 -0
  221. package/dist/services/trigger-runner.js +47 -0
  222. package/dist/services/trigger-runner.js.map +1 -0
  223. package/dist/services/util.d.ts +30 -0
  224. package/dist/services/util.js +157 -0
  225. package/dist/services/util.js.map +1 -0
  226. package/dist/tsconfig.tsbuildinfo +1 -0
  227. package/oclif.manifest.json +527 -0
  228. package/package.json +163 -18
  229. package/LICENSE +0 -121
  230. package/dist/checkly.min.js +0 -1
  231. package/index.js +0 -285
  232. package/logo.png +0 -0
  233. package/test.js +0 -183
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiCheck = exports.AssertionBuilder = void 0;
4
+ const path = require("path");
5
+ const check_1 = require("./check");
6
+ const project_1 = require("./project");
7
+ const parser_1 = require("../services/check-parser/parser");
8
+ const util_1 = require("../services/util");
9
+ const util_2 = require("../reporters/util");
10
+ // eslint-disable-next-line no-restricted-syntax
11
+ var AssertionSource;
12
+ (function (AssertionSource) {
13
+ AssertionSource["STATUS_CODE"] = "STATUS_CODE";
14
+ AssertionSource["JSON_BODY"] = "JSON_BODY";
15
+ AssertionSource["HEADERS"] = "HEADERS";
16
+ AssertionSource["TEXT_BODY"] = "TEXT_BODY";
17
+ AssertionSource["RESPONSE_TIME"] = "RESPONSE_TIME";
18
+ })(AssertionSource || (AssertionSource = {}));
19
+ // eslint-disable-next-line no-restricted-syntax
20
+ var AssertionComparison;
21
+ (function (AssertionComparison) {
22
+ AssertionComparison["EQUALS"] = "EQUALS";
23
+ AssertionComparison["NOT_EQUALS"] = "NOT_EQUALS";
24
+ AssertionComparison["HAS_KEY"] = "HAS_KEY";
25
+ AssertionComparison["NOT_HAS_KEY"] = "NOT_HAS_KEY";
26
+ AssertionComparison["HAS_VALUE"] = "HAS_VALUE";
27
+ AssertionComparison["NOT_HAS_VALUE"] = "NOT_HAS_VALUE";
28
+ AssertionComparison["IS_EMPTY"] = "IS_EMPTY";
29
+ AssertionComparison["NOT_EMPTY"] = "NOT_EMPTY";
30
+ AssertionComparison["GREATER_THAN"] = "GREATER_THAN";
31
+ AssertionComparison["LESS_THAN"] = "LESS_THAN";
32
+ AssertionComparison["CONTAINS"] = "CONTAINS";
33
+ AssertionComparison["NOT_CONTAINS"] = "NOT_CONTAINS";
34
+ AssertionComparison["IS_NULL"] = "IS_NULL";
35
+ AssertionComparison["NOT_NULL"] = "NOT_NULL";
36
+ })(AssertionComparison || (AssertionComparison = {}));
37
+ class AssertionBuilder {
38
+ static statusCode() {
39
+ return new NumericAssertionBuilder(AssertionSource.STATUS_CODE);
40
+ }
41
+ static jsonBody(property) {
42
+ return new GeneralAssertionBuilder(AssertionSource.JSON_BODY, property);
43
+ }
44
+ static headers(property, regex) {
45
+ return new GeneralAssertionBuilder(AssertionSource.HEADERS, property, regex);
46
+ }
47
+ static textBody(property) {
48
+ return new GeneralAssertionBuilder(AssertionSource.TEXT_BODY, property);
49
+ }
50
+ static responseTme() {
51
+ return new NumericAssertionBuilder(AssertionSource.RESPONSE_TIME);
52
+ }
53
+ }
54
+ exports.AssertionBuilder = AssertionBuilder;
55
+ class NumericAssertionBuilder {
56
+ constructor(source) {
57
+ this.source = source;
58
+ }
59
+ equals(target) {
60
+ return this._toAssertion(AssertionComparison.EQUALS, target);
61
+ }
62
+ notEquals(target) {
63
+ return this._toAssertion(AssertionComparison.NOT_EQUALS, target);
64
+ }
65
+ lessThan(target) {
66
+ return this._toAssertion(AssertionComparison.LESS_THAN, target);
67
+ }
68
+ greaterThan(target) {
69
+ return this._toAssertion(AssertionComparison.GREATER_THAN, target);
70
+ }
71
+ /** @private */
72
+ _toAssertion(comparison, target) {
73
+ return { source: this.source, comparison, property: '', target: target.toString(), regex: null };
74
+ }
75
+ }
76
+ class GeneralAssertionBuilder {
77
+ constructor(source, property, regex) {
78
+ this.source = source;
79
+ this.property = property;
80
+ this.regex = regex;
81
+ }
82
+ equals(target) {
83
+ return this._toAssertion(AssertionComparison.EQUALS, target);
84
+ }
85
+ notEquals(target) {
86
+ return this._toAssertion(AssertionComparison.NOT_EQUALS, target);
87
+ }
88
+ hasKey(target) {
89
+ return this._toAssertion(AssertionComparison.HAS_KEY, target);
90
+ }
91
+ notHasKey(target) {
92
+ return this._toAssertion(AssertionComparison.NOT_HAS_KEY, target);
93
+ }
94
+ hasValue(target) {
95
+ return this._toAssertion(AssertionComparison.HAS_VALUE, target);
96
+ }
97
+ notHasValue(target) {
98
+ return this._toAssertion(AssertionComparison.NOT_HAS_VALUE, target);
99
+ }
100
+ isEmpty() {
101
+ return this._toAssertion(AssertionComparison.IS_EMPTY);
102
+ }
103
+ notEmpty() {
104
+ return this._toAssertion(AssertionComparison.NOT_EMPTY);
105
+ }
106
+ lessThan(target) {
107
+ return this._toAssertion(AssertionComparison.LESS_THAN, target);
108
+ }
109
+ greaterThan(target) {
110
+ return this._toAssertion(AssertionComparison.GREATER_THAN, target);
111
+ }
112
+ contains(target) {
113
+ return this._toAssertion(AssertionComparison.CONTAINS, target);
114
+ }
115
+ notContains(target) {
116
+ return this._toAssertion(AssertionComparison.CONTAINS, target);
117
+ }
118
+ isNull() {
119
+ return this._toAssertion(AssertionComparison.IS_NULL);
120
+ }
121
+ isNotNull() {
122
+ return this._toAssertion(AssertionComparison.NOT_NULL);
123
+ }
124
+ /** @private */
125
+ _toAssertion(comparison, target) {
126
+ var _a, _b, _c;
127
+ return {
128
+ source: this.source,
129
+ comparison,
130
+ property: (_a = this.property) !== null && _a !== void 0 ? _a : '',
131
+ target: (_b = target === null || target === void 0 ? void 0 : target.toString()) !== null && _b !== void 0 ? _b : '',
132
+ regex: (_c = this.regex) !== null && _c !== void 0 ? _c : null,
133
+ };
134
+ }
135
+ }
136
+ function _printWarning(path) {
137
+ (0, util_2.printDeprecationWarning)(`API check "${path}" is probably providing a setup ` +
138
+ 'or tearDown script using the "localSetupScript" or "localTearDownScript" property. Please update your API checks to ' +
139
+ 'reference any setup / tearDown using the "setupScript" and "tearDownScript" properties See the docs at ' +
140
+ 'https://checklyhq.com/docs/cli/constructs-reference#apicheck');
141
+ }
142
+ /**
143
+ * Creates an API Check
144
+ *
145
+ * @remarks
146
+ *
147
+ * This class make use of the API Checks endpoints.
148
+ */
149
+ class ApiCheck extends check_1.Check {
150
+ /**
151
+ * Constructs the API Check instance
152
+ *
153
+ * @param logicalId unique project-scoped resource name identification
154
+ * @param props check configuration properties
155
+ *
156
+ * {@link https://checklyhq.com/docs/cli/constructs/#apicheck Read more in the docs}
157
+ */
158
+ constructor(logicalId, props) {
159
+ super(logicalId, props);
160
+ if (props.setupScript) {
161
+ if ('entrypoint' in props.setupScript) {
162
+ const { script, scriptPath, dependencies } = ApiCheck.bundle(props.setupScript.entrypoint, this.runtimeId);
163
+ this.localSetupScript = script;
164
+ this.setupScriptPath = scriptPath;
165
+ this.setupScriptDependencies = dependencies;
166
+ }
167
+ else if ('content' in props.setupScript) {
168
+ this.localSetupScript = props.setupScript.content;
169
+ }
170
+ else {
171
+ throw new Error('Unrecognized type for the "setupScript" property. A "setupScript" should have either a "content" ' +
172
+ 'or "entrypoint" property.');
173
+ }
174
+ }
175
+ if (props.localSetupScript) {
176
+ _printWarning(project_1.Session.checkFilePath);
177
+ this.localSetupScript = props.localSetupScript;
178
+ }
179
+ if (props.tearDownScript) {
180
+ if ('entrypoint' in props.tearDownScript) {
181
+ const { script, scriptPath, dependencies } = ApiCheck.bundle(props.tearDownScript.entrypoint, this.runtimeId);
182
+ this.localTearDownScript = script;
183
+ this.tearDownScriptPath = scriptPath;
184
+ this.tearDownScriptDependencies = dependencies;
185
+ }
186
+ else if ('content' in props.tearDownScript) {
187
+ this.localTearDownScript = props.tearDownScript.content;
188
+ }
189
+ }
190
+ if (props.localTearDownScript) {
191
+ _printWarning(project_1.Session.checkFilePath);
192
+ this.localTearDownScript = props.localTearDownScript;
193
+ }
194
+ this.request = props.request;
195
+ this.degradedResponseTime = props.degradedResponseTime;
196
+ this.maxResponseTime = props.maxResponseTime;
197
+ project_1.Session.registerConstruct(this);
198
+ this.addSubscriptions();
199
+ }
200
+ static bundle(entrypoint, runtimeId) {
201
+ let absoluteEntrypoint = null;
202
+ if (path.isAbsolute(entrypoint)) {
203
+ absoluteEntrypoint = entrypoint;
204
+ }
205
+ else {
206
+ if (!project_1.Session.checkFileAbsolutePath) {
207
+ throw new Error('You cant use relative paths without the checkFileAbsolutePath in session');
208
+ }
209
+ absoluteEntrypoint = path.join(path.dirname(project_1.Session.checkFileAbsolutePath), entrypoint);
210
+ }
211
+ const runtime = project_1.Session.availableRuntimes[runtimeId];
212
+ if (!runtime) {
213
+ throw new Error(`${runtimeId} is not supported`);
214
+ }
215
+ const parser = new parser_1.Parser(Object.keys(runtime.dependencies));
216
+ const parsed = parser.parse(absoluteEntrypoint);
217
+ // Maybe we can get the parsed deps with the content immediately
218
+ const deps = [];
219
+ for (const { filePath, content } of parsed.dependencies) {
220
+ deps.push({
221
+ path: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, filePath)),
222
+ content,
223
+ });
224
+ }
225
+ return {
226
+ script: parsed.entrypoint.content,
227
+ scriptPath: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, parsed.entrypoint.filePath)),
228
+ dependencies: deps,
229
+ };
230
+ }
231
+ synthesize() {
232
+ return {
233
+ ...super.synthesize(),
234
+ checkType: 'API',
235
+ request: this.request,
236
+ localSetupScript: this.localSetupScript,
237
+ setupScriptPath: this.setupScriptPath,
238
+ setupScriptDependencies: this.setupScriptDependencies,
239
+ localTearDownScript: this.localTearDownScript,
240
+ tearDownScriptPath: this.tearDownScriptPath,
241
+ tearDownScriptDependencies: this.tearDownScriptDependencies,
242
+ degradedResponseTime: this.degradedResponseTime,
243
+ maxResponseTime: this.maxResponseTime,
244
+ };
245
+ }
246
+ }
247
+ exports.ApiCheck = ApiCheck;
248
+ //# sourceMappingURL=api-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-check.js","sourceRoot":"","sources":["../../src/constructs/api-check.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAC5B,mCAA2C;AAE3C,uCAAmC;AAEnC,4DAAwD;AACxD,2CAA8C;AAC9C,4CAA2D;AAG3D,gDAAgD;AAChD,IAAK,eAMJ;AAND,WAAK,eAAe;IAClB,8CAA2B,CAAA;IAC3B,0CAAuB,CAAA;IACvB,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;IACvB,kDAA+B,CAAA;AACjC,CAAC,EANI,eAAe,KAAf,eAAe,QAMnB;AAED,gDAAgD;AAChD,IAAK,mBAeJ;AAfD,WAAK,mBAAmB;IACtB,wCAAiB,CAAA;IACjB,gDAAyB,CAAA;IACzB,0CAAmB,CAAA;IACnB,kDAA2B,CAAA;IAC3B,8CAAuB,CAAA;IACvB,sDAA+B,CAAA;IAC/B,4CAAqB,CAAA;IACrB,8CAAuB,CAAA;IACvB,oDAA6B,CAAA;IAC7B,8CAAuB,CAAA;IACvB,4CAAqB,CAAA;IACrB,oDAA6B,CAAA;IAC7B,0CAAmB,CAAA;IACnB,4CAAqB,CAAA;AACvB,CAAC,EAfI,mBAAmB,KAAnB,mBAAmB,QAevB;AAUD,MAAa,gBAAgB;IAC3B,MAAM,CAAC,UAAU;QACf,OAAO,IAAI,uBAAuB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,CAAC,QAAQ,CAAE,QAAiB;QACh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AAQ,EAAE,OAAO,EAAE,IAAI,MAAM,CAAC,YAAY,EAAE;YACvD,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,IAAA,kBAAW,EAAC,IAAI,CAAC,QAAQ,CAAC,iBAAO,CAAC,QAAS,EAAE,QAAQ,CAAC,CAAC;gBAC7D,OAAO;aACR,CAAC,CAAA;SACH;QACD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACjC,UAAU,EAAE,IAAA,kBAAW,EAAC,IAAI,CAAC,QAAQ,CAAC,iBAAO,CAAC,QAAS,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrF,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,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,0BAA0B,EAAE,IAAI,CAAC,0BAA0B;YAC3D,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAA;IACH,CAAC;CACF;AAlHD,4BAkHC"}
@@ -0,0 +1,59 @@
1
+ import { Check, CheckProps } from './check';
2
+ import { Content, Entrypoint } from './construct';
3
+ export interface CheckDependency {
4
+ path: string;
5
+ content: string;
6
+ }
7
+ export interface BrowserCheckProps extends CheckProps {
8
+ /**
9
+ * A valid piece of Node.js javascript code describing a browser interaction
10
+ * with the Puppeteer or Playwright frameworks.
11
+ */
12
+ code: Content | Entrypoint;
13
+ }
14
+ /**
15
+ * Creates a Browser Check
16
+ *
17
+ * @remarks
18
+ *
19
+ * This class make use of the Browser Checks endpoints.
20
+ */
21
+ export declare class BrowserCheck extends Check {
22
+ script: string;
23
+ scriptPath?: string;
24
+ dependencies?: Array<CheckDependency>;
25
+ /**
26
+ * Constructs the Browser Check instance
27
+ *
28
+ * @param logicalId unique project-scoped resource name identification
29
+ * @param props check configuration properties
30
+ * {@link https://checklyhq.com/docs/cli/constructs/#browsercheck Read more in the docs}
31
+ */
32
+ constructor(logicalId: string, props: BrowserCheckProps);
33
+ private static applyDefaultBrowserCheckConfig;
34
+ static bundle(entry: string, runtimeId: string): {
35
+ script: string;
36
+ scriptPath: string;
37
+ dependencies: CheckDependency[];
38
+ };
39
+ getSourceFile(): string | undefined;
40
+ synthesize(): {
41
+ checkType: string;
42
+ script: string;
43
+ scriptPath: string | undefined;
44
+ dependencies: CheckDependency[] | undefined;
45
+ name: string;
46
+ activated: boolean | undefined;
47
+ muted: boolean | undefined;
48
+ doubleCheck: boolean | undefined;
49
+ shouldFail: boolean | undefined;
50
+ runtimeId: string | undefined;
51
+ locations: (keyof import("..").Region)[] | undefined;
52
+ privateLocations: string[] | undefined;
53
+ tags: string[] | undefined;
54
+ frequency: number | undefined;
55
+ frequencyOffset: number | undefined;
56
+ groupId: import("./ref").Ref | undefined;
57
+ environmentVariables: import("./key-value-pair").default[] | undefined;
58
+ };
59
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrowserCheck = void 0;
4
+ const path = require("path");
5
+ const check_1 = require("./check");
6
+ const project_1 = require("./project");
7
+ const parser_1 = require("../services/check-parser/parser");
8
+ const util_1 = require("../services/util");
9
+ /**
10
+ * Creates a Browser Check
11
+ *
12
+ * @remarks
13
+ *
14
+ * This class make use of the Browser Checks endpoints.
15
+ */
16
+ class BrowserCheck extends check_1.Check {
17
+ /**
18
+ * Constructs the Browser Check instance
19
+ *
20
+ * @param logicalId unique project-scoped resource name identification
21
+ * @param props check configuration properties
22
+ * {@link https://checklyhq.com/docs/cli/constructs/#browsercheck Read more in the docs}
23
+ */
24
+ constructor(logicalId, props) {
25
+ BrowserCheck.applyDefaultBrowserCheckConfig(props);
26
+ super(logicalId, props);
27
+ if ('content' in props.code) {
28
+ const script = props.code.content;
29
+ this.script = script;
30
+ }
31
+ else if ('entrypoint' in props.code) {
32
+ const entrypoint = props.code.entrypoint;
33
+ let absoluteEntrypoint = null;
34
+ if (path.isAbsolute(entrypoint)) {
35
+ absoluteEntrypoint = entrypoint;
36
+ }
37
+ else {
38
+ if (!project_1.Session.checkFileAbsolutePath) {
39
+ throw new Error('You cant use relative paths without the checkFileAbsolutePath in session');
40
+ }
41
+ absoluteEntrypoint = path.join(path.dirname(project_1.Session.checkFileAbsolutePath), entrypoint);
42
+ }
43
+ // runtimeId will always be set by check or browser check defaults so it is safe to use ! operator
44
+ const bundle = BrowserCheck.bundle(absoluteEntrypoint, this.runtimeId);
45
+ this.script = bundle.script;
46
+ this.scriptPath = bundle.scriptPath;
47
+ this.dependencies = bundle.dependencies;
48
+ }
49
+ else {
50
+ throw new Error('Unrecognized type for the "code" property. The "code" property should be a string of JS/TS code.');
51
+ }
52
+ project_1.Session.registerConstruct(this);
53
+ this.addSubscriptions();
54
+ }
55
+ static applyDefaultBrowserCheckConfig(props) {
56
+ var _a;
57
+ if (!project_1.Session.browserCheckDefaults) {
58
+ return;
59
+ }
60
+ let configKey;
61
+ for (configKey in project_1.Session.browserCheckDefaults) {
62
+ const newVal = (_a = props[configKey]) !== null && _a !== void 0 ? _a : project_1.Session.browserCheckDefaults[configKey];
63
+ props[configKey] = newVal;
64
+ }
65
+ }
66
+ static bundle(entry, runtimeId) {
67
+ const runtime = project_1.Session.availableRuntimes[runtimeId];
68
+ if (!runtime) {
69
+ throw new Error(`${runtimeId} is not supported`);
70
+ }
71
+ const parser = new parser_1.Parser(Object.keys(runtime.dependencies));
72
+ const parsed = parser.parse(entry);
73
+ // Maybe we can get the parsed deps with the content immediately
74
+ const deps = [];
75
+ for (const { filePath, content } of parsed.dependencies) {
76
+ deps.push({
77
+ path: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, filePath)),
78
+ content,
79
+ });
80
+ }
81
+ return {
82
+ script: parsed.entrypoint.content,
83
+ scriptPath: (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, parsed.entrypoint.filePath)),
84
+ dependencies: deps,
85
+ };
86
+ }
87
+ getSourceFile() {
88
+ var _a;
89
+ return (_a = this.__checkFilePath) !== null && _a !== void 0 ? _a : this.scriptPath;
90
+ }
91
+ synthesize() {
92
+ return {
93
+ ...super.synthesize(),
94
+ checkType: 'BROWSER',
95
+ script: this.script,
96
+ scriptPath: this.scriptPath,
97
+ dependencies: this.dependencies,
98
+ };
99
+ }
100
+ }
101
+ exports.BrowserCheck = BrowserCheck;
102
+ //# sourceMappingURL=browser-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-check.js","sourceRoot":"","sources":["../../src/constructs/browser-check.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAC5B,mCAA2C;AAC3C,uCAAmC;AACnC,4DAAwD;AAExD,2CAA8C;AAgB9C;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,aAAK;IAKrC;;;;;;OAMG;IACH,YAAa,SAAiB,EAAE,KAAwB;QACtD,YAAY,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAA;QAClD,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QACvB,IAAI,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE;YAC3B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAA;YACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;SACrB;aAAM,IAAI,YAAY,IAAI,KAAK,CAAC,IAAI,EAAE;YACrC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAA;YACxC,IAAI,kBAAkB,GAAG,IAAI,CAAA;YAC7B,IAAI,IAA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;QACpD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAA;SACjD;QACD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAClC,gEAAgE;QAEhE,MAAM,IAAI,GAAsB,EAAE,CAAA;QAClC,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,MAAM,CAAC,YAAY,EAAE;YACvD,IAAI,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,IAAA,kBAAW,EAAC,IAAI,CAAC,QAAQ,CAAC,iBAAO,CAAC,QAAS,EAAE,QAAQ,CAAC,CAAC;gBAC7D,OAAO;aACR,CAAC,CAAA;SACH;QACD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YACjC,UAAU,EAAE,IAAA,kBAAW,EAAC,IAAI,CAAC,QAAQ,CAAC,iBAAO,CAAC,QAAS,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACrF,YAAY,EAAE,IAAI;SACnB,CAAA;IACH,CAAC;IAED,aAAa;;QACX,OAAO,MAAA,IAAI,CAAC,eAAe,mCAAI,IAAI,CAAC,UAAU,CAAA;IAChD,CAAC;IAED,UAAU;QACR,OAAO;YACL,GAAG,KAAK,CAAC,UAAU,EAAE;YACrB,SAAS,EAAE,SAAS;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAA;IACH,CAAC;CACF;AAxFD,oCAwFC"}
@@ -0,0 +1,116 @@
1
+ import { Construct } from './construct';
2
+ import { AlertChannel } from './alert-channel';
3
+ import { EnvironmentVariable } from './environment-variable';
4
+ import { CheckConfigDefaults } from '../services/checkly-config-loader';
5
+ import { ApiCheckDefaultConfig } from './api-check';
6
+ import type { Region } from '..';
7
+ type BrowserCheckConfig = CheckConfigDefaults & {
8
+ /**
9
+ * Glob pattern to include multiple files, i.e. all `.spec.ts` files
10
+ */
11
+ testMatch: string;
12
+ };
13
+ export interface CheckGroupProps {
14
+ /**
15
+ * The name of the check group.
16
+ */
17
+ name: string;
18
+ /**
19
+ * Determines if the checks in the group are running or not.
20
+ */
21
+ activated?: boolean;
22
+ /**
23
+ * Determines if any notifications will be sent out when a check in this group fails and/or recovers.
24
+ */
25
+ muted?: boolean;
26
+ /**
27
+ * Setting this to "true" will trigger a retry when a check fails from the failing region and another,
28
+ * randomly selected region before marking the check as failed.
29
+ */
30
+ doubleCheck?: boolean;
31
+ /**
32
+ * The runtime version, i.e. fixed set of runtime dependencies, used to execute checks in this group.
33
+ */
34
+ runtimeId?: string;
35
+ /**
36
+ * An array of one or more data center locations where to run the checks.
37
+ */
38
+ locations: Array<keyof Region>;
39
+ /**
40
+ * An array of one or more private locations where to run the checks.
41
+ */
42
+ privateLocations?: Array<string>;
43
+ /**
44
+ * Tags for organizing and filtering checks.
45
+ */
46
+ tags?: Array<string>;
47
+ /**
48
+ * Determines how many checks are invoked concurrently when triggering a check group from CI/CD or through the API.
49
+ */
50
+ concurrency?: number;
51
+ environmentVariables?: Array<EnvironmentVariable>;
52
+ /**
53
+ * List of alert channels to be alerted when checks in this group fail or recover.
54
+ */
55
+ alertChannels?: Array<AlertChannel>;
56
+ browserChecks?: BrowserCheckConfig;
57
+ /**
58
+ * A valid piece of Node.js code to run in the setup phase of an API check in this group.
59
+ */
60
+ localSetupScript?: string;
61
+ /**
62
+ * A valid piece of Node.js code to run in the teardown phase of an API check in this group.
63
+ */
64
+ localTearDownScript?: string;
65
+ apiCheckDefaults?: ApiCheckDefaultConfig;
66
+ }
67
+ /**
68
+ * Creates a Check Group
69
+ *
70
+ * @remarks
71
+ *
72
+ * This class make use of the Check Groups endpoints.
73
+ */
74
+ export declare class CheckGroup extends Construct {
75
+ name: string;
76
+ activated?: boolean;
77
+ muted?: boolean;
78
+ doubleCheck?: boolean;
79
+ runtimeId?: string;
80
+ locations: Array<keyof Region>;
81
+ privateLocations?: Array<string>;
82
+ tags?: Array<string>;
83
+ concurrency?: number;
84
+ environmentVariables?: Array<EnvironmentVariable>;
85
+ alertChannels?: Array<AlertChannel>;
86
+ localSetupScript?: string;
87
+ localTearDownScript?: string;
88
+ apiCheckDefaults: ApiCheckDefaultConfig;
89
+ static readonly __checklyType = "check-group";
90
+ /**
91
+ * Constructs the CheckGroup instance
92
+ *
93
+ * @param logicalId unique project-scoped resource name identification
94
+ * @param props CheckGroup configuration properties
95
+ *
96
+ * {@link https://checklyhq.com/docs/cli/constructs/#checkgroup Read more in the docs}
97
+ */
98
+ constructor(logicalId: string, props: CheckGroupProps);
99
+ private __addChecks;
100
+ private __addSubscriptions;
101
+ synthesize(): {
102
+ name: string;
103
+ activated: boolean | undefined;
104
+ muted: boolean | undefined;
105
+ doubleCheck: boolean | undefined;
106
+ tags: string[] | undefined;
107
+ locations: (keyof Region)[];
108
+ privateLocations: string[] | undefined;
109
+ concurrency: number | undefined;
110
+ localSetupScript: string | undefined;
111
+ localTearDownScript: string | undefined;
112
+ apiCheckDefaults: ApiCheckDefaultConfig;
113
+ environmentVariables: import("./key-value-pair").default[] | undefined;
114
+ };
115
+ }
116
+ export {};
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckGroup = void 0;
4
+ const path = require("path");
5
+ const glob = require("glob");
6
+ const ref_1 = require("./ref");
7
+ const project_1 = require("./project");
8
+ const construct_1 = require("./construct");
9
+ const browser_check_1 = require("./browser-check");
10
+ const alert_channel_subscription_1 = require("./alert-channel-subscription");
11
+ const util_1 = require("../services/util");
12
+ const defaultApiCheckDefaults = {
13
+ headers: [],
14
+ queryParameters: [],
15
+ url: '',
16
+ basicAuth: {
17
+ username: '',
18
+ password: '',
19
+ },
20
+ };
21
+ /**
22
+ * Creates a Check Group
23
+ *
24
+ * @remarks
25
+ *
26
+ * This class make use of the Check Groups endpoints.
27
+ */
28
+ class CheckGroup extends construct_1.Construct {
29
+ /**
30
+ * Constructs the CheckGroup instance
31
+ *
32
+ * @param logicalId unique project-scoped resource name identification
33
+ * @param props CheckGroup configuration properties
34
+ *
35
+ * {@link https://checklyhq.com/docs/cli/constructs/#checkgroup Read more in the docs}
36
+ */
37
+ constructor(logicalId, props) {
38
+ var _a, _b, _c;
39
+ super(CheckGroup.__checklyType, logicalId);
40
+ this.name = props.name;
41
+ this.activated = props.activated;
42
+ this.muted = props.muted;
43
+ this.doubleCheck = props.doubleCheck;
44
+ this.tags = props.tags;
45
+ this.runtimeId = props.runtimeId;
46
+ this.locations = props.locations;
47
+ this.privateLocations = props.privateLocations;
48
+ this.concurrency = props.concurrency;
49
+ this.apiCheckDefaults = { ...defaultApiCheckDefaults, ...props.apiCheckDefaults };
50
+ this.environmentVariables = (_a = props.environmentVariables) !== null && _a !== void 0 ? _a : [];
51
+ this.alertChannels = (_b = props.alertChannels) !== null && _b !== void 0 ? _b : [];
52
+ const fileAbsolutePath = project_1.Session.checkFileAbsolutePath;
53
+ if ((_c = props.browserChecks) === null || _c === void 0 ? void 0 : _c.testMatch) {
54
+ this.__addChecks(fileAbsolutePath, props.browserChecks);
55
+ }
56
+ project_1.Session.registerConstruct(this);
57
+ this.__addSubscriptions();
58
+ }
59
+ __addChecks(fileAbsolutePath, browserChecks) {
60
+ const parent = path.dirname(fileAbsolutePath);
61
+ const matched = glob.sync(browserChecks.testMatch, { nodir: true, cwd: parent });
62
+ for (const match of matched) {
63
+ const defaults = {};
64
+ let configKey;
65
+ for (configKey in browserChecks) {
66
+ const newVal = browserChecks[configKey];
67
+ defaults[configKey] = newVal;
68
+ }
69
+ const filepath = path.join(parent, match);
70
+ const props = {
71
+ group: this,
72
+ name: match,
73
+ ...defaults,
74
+ code: {
75
+ entrypoint: filepath,
76
+ },
77
+ };
78
+ const checkLogicalId = (0, util_1.pathToPosix)(path.relative(project_1.Session.basePath, filepath));
79
+ const check = new browser_check_1.BrowserCheck(checkLogicalId, props);
80
+ }
81
+ }
82
+ __addSubscriptions() {
83
+ if (!this.alertChannels) {
84
+ return;
85
+ }
86
+ for (const alertChannel of this.alertChannels) {
87
+ const subscription = new alert_channel_subscription_1.AlertChannelSubscription(`check-group-alert-channel-subscription#${this.logicalId}#${alertChannel.logicalId}`, {
88
+ alertChannelId: ref_1.Ref.from(alertChannel.logicalId),
89
+ groupId: ref_1.Ref.from(this.logicalId),
90
+ activated: true,
91
+ });
92
+ }
93
+ }
94
+ synthesize() {
95
+ return {
96
+ name: this.name,
97
+ activated: this.activated,
98
+ muted: this.muted,
99
+ doubleCheck: this.doubleCheck,
100
+ tags: this.tags,
101
+ locations: this.locations,
102
+ privateLocations: this.privateLocations,
103
+ concurrency: this.concurrency,
104
+ localSetupScript: this.localSetupScript,
105
+ localTearDownScript: this.localTearDownScript,
106
+ apiCheckDefaults: this.apiCheckDefaults,
107
+ environmentVariables: this.environmentVariables,
108
+ };
109
+ }
110
+ }
111
+ exports.CheckGroup = CheckGroup;
112
+ CheckGroup.__checklyType = 'check-group';
113
+ //# sourceMappingURL=check-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-group.js","sourceRoot":"","sources":["../../src/constructs/check-group.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAC5B,6BAA4B;AAC5B,+BAA2B;AAC3B,uCAAmC;AACnC,2CAAuC;AACvC,mDAA8C;AAG9C,6EAAuE;AAGvE,2CAA8C;AAG9C,MAAM,uBAAuB,GAA0B;IACrD,OAAO,EAAE,EAAE;IACX,eAAe,EAAE,EAAE;IACnB,GAAG,EAAE,EAAE;IACP,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACb;CACF,CAAA;AAgED;;;;;;GAMG;AACH,MAAa,U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