checkly 3.1.1 → 4.0.0
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 +42 -110
- package/bin/dev +17 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/constructs.d.ts +1 -0
- package/constructs.js +1 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +228 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/authCommand.d.ts +5 -0
- package/dist/commands/authCommand.js +14 -0
- package/dist/commands/authCommand.js.map +1 -0
- package/dist/commands/baseCommand.d.ts +9 -0
- package/dist/commands/baseCommand.js +21 -0
- package/dist/commands/baseCommand.js.map +1 -0
- package/dist/commands/deploy.d.ts +13 -0
- package/dist/commands/deploy.js +171 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +10 -0
- package/dist/commands/destroy.js +47 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/env/add.d.ts +13 -0
- package/dist/commands/env/add.js +54 -0
- package/dist/commands/env/add.js.map +1 -0
- package/dist/commands/env/ls.d.ts +6 -0
- package/dist/commands/env/ls.js +21 -0
- package/dist/commands/env/ls.js.map +1 -0
- package/dist/commands/env/pull.d.ts +12 -0
- package/dist/commands/env/pull.js +63 -0
- package/dist/commands/env/pull.js.map +1 -0
- package/dist/commands/env/rm.d.ts +12 -0
- package/dist/commands/env/rm.js +56 -0
- package/dist/commands/env/rm.js.map +1 -0
- package/dist/commands/env/update.d.ts +13 -0
- package/dist/commands/env/update.js +54 -0
- package/dist/commands/env/update.js.map +1 -0
- package/dist/commands/login.d.ts +13 -0
- package/dist/commands/login.js +129 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +9 -0
- package/dist/commands/logout.js +40 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/runtimes.d.ts +6 -0
- package/dist/commands/runtimes.js +26 -0
- package/dist/commands/runtimes.js.map +1 -0
- package/dist/commands/switch.d.ts +9 -0
- package/dist/commands/switch.js +59 -0
- package/dist/commands/switch.js.map +1 -0
- package/dist/commands/test.d.ts +36 -0
- package/dist/commands/test.js +247 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.js +16 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -0
- package/dist/constructs/alert-channel-subscription.d.ts +44 -0
- package/dist/constructs/alert-channel-subscription.js +39 -0
- package/dist/constructs/alert-channel-subscription.js.map +1 -0
- package/dist/constructs/alert-channel.d.ts +53 -0
- package/dist/constructs/alert-channel.js +55 -0
- package/dist/constructs/alert-channel.js.map +1 -0
- package/dist/constructs/api-check.d.ts +179 -0
- package/dist/constructs/api-check.js +248 -0
- package/dist/constructs/api-check.js.map +1 -0
- package/dist/constructs/browser-check.d.ts +59 -0
- package/dist/constructs/browser-check.js +102 -0
- package/dist/constructs/browser-check.js.map +1 -0
- package/dist/constructs/check-group.d.ts +116 -0
- package/dist/constructs/check-group.js +113 -0
- package/dist/constructs/check-group.js.map +1 -0
- package/dist/constructs/check.d.ts +111 -0
- package/dist/constructs/check.js +88 -0
- package/dist/constructs/check.js.map +1 -0
- package/dist/constructs/construct.d.ts +17 -0
- package/dist/constructs/construct.js +22 -0
- package/dist/constructs/construct.js.map +1 -0
- package/dist/constructs/email-alert-channel.d.ts +26 -0
- package/dist/constructs/email-alert-channel.js +37 -0
- package/dist/constructs/email-alert-channel.js.map +1 -0
- package/dist/constructs/environment-variable.d.ts +2 -0
- package/dist/constructs/environment-variable.js +3 -0
- package/dist/constructs/environment-variable.js.map +1 -0
- package/dist/constructs/frequency.d.ts +20 -0
- package/dist/constructs/frequency.js +26 -0
- package/dist/constructs/frequency.js.map +1 -0
- package/dist/constructs/http-header.d.ts +2 -0
- package/dist/constructs/http-header.js +3 -0
- package/dist/constructs/http-header.js.map +1 -0
- package/dist/constructs/index.d.ts +15 -0
- package/dist/constructs/index.js +32 -0
- package/dist/constructs/index.js.map +1 -0
- package/dist/constructs/key-value-pair.d.ts +5 -0
- package/dist/constructs/key-value-pair.js +3 -0
- package/dist/constructs/key-value-pair.js.map +1 -0
- package/dist/constructs/opsgenie-alert-channel.d.ts +45 -0
- package/dist/constructs/opsgenie-alert-channel.js +44 -0
- package/dist/constructs/opsgenie-alert-channel.js.map +1 -0
- package/dist/constructs/pagerduty-alert-channel.d.ts +39 -0
- package/dist/constructs/pagerduty-alert-channel.js +42 -0
- package/dist/constructs/pagerduty-alert-channel.js.map +1 -0
- package/dist/constructs/project.d.ts +57 -0
- package/dist/constructs/project.js +100 -0
- package/dist/constructs/project.js.map +1 -0
- package/dist/constructs/query-param.d.ts +2 -0
- package/dist/constructs/query-param.js +3 -0
- package/dist/constructs/query-param.js.map +1 -0
- package/dist/constructs/ref.d.ts +5 -0
- package/dist/constructs/ref.js +13 -0
- package/dist/constructs/ref.js.map +1 -0
- package/dist/constructs/slack-alert-channel.d.ts +26 -0
- package/dist/constructs/slack-alert-channel.js +40 -0
- package/dist/constructs/slack-alert-channel.js.map +1 -0
- package/dist/constructs/sms-alert-channel.d.ts +27 -0
- package/dist/constructs/sms-alert-channel.js +38 -0
- package/dist/constructs/sms-alert-channel.js.map +1 -0
- package/dist/constructs/validator-error.d.ts +2 -0
- package/dist/constructs/validator-error.js +7 -0
- package/dist/constructs/validator-error.js.map +1 -0
- package/dist/constructs/webhook-alert-channel.d.ts +59 -0
- package/dist/constructs/webhook-alert-channel.js +50 -0
- package/dist/constructs/webhook-alert-channel.js.map +1 -0
- package/dist/help/examples.d.ts +6 -0
- package/dist/help/examples.js +22 -0
- package/dist/help/examples.js.map +1 -0
- package/dist/help/help-extension.d.ts +4 -0
- package/dist/help/help-extension.js +41 -0
- package/dist/help/help-extension.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/common-messages.d.ts +5 -0
- package/dist/messages/common-messages.js +9 -0
- package/dist/messages/common-messages.js.map +1 -0
- package/dist/reporters/abstract-list.d.ts +34 -0
- package/dist/reporters/abstract-list.js +122 -0
- package/dist/reporters/abstract-list.js.map +1 -0
- package/dist/reporters/ci.d.ts +12 -0
- package/dist/reporters/ci.js +29 -0
- package/dist/reporters/ci.js.map +1 -0
- package/dist/reporters/dot.d.ts +12 -0
- package/dist/reporters/dot.js +28 -0
- package/dist/reporters/dot.js.map +1 -0
- package/dist/reporters/github.d.ts +33 -0
- package/dist/reporters/github.js +93 -0
- package/dist/reporters/github.js.map +1 -0
- package/dist/reporters/list.d.ts +13 -0
- package/dist/reporters/list.js +57 -0
- package/dist/reporters/list.js.map +1 -0
- package/dist/reporters/reporter.d.ts +14 -0
- package/dist/reporters/reporter.js +23 -0
- package/dist/reporters/reporter.js.map +1 -0
- package/dist/reporters/util.d.ts +15 -0
- package/dist/reporters/util.js +283 -0
- package/dist/reporters/util.js.map +1 -0
- package/dist/rest/accounts.d.ts +12 -0
- package/dist/rest/accounts.js +15 -0
- package/dist/rest/accounts.js.map +1 -0
- package/dist/rest/api.d.ts +27 -0
- package/dist/rest/api.js +90 -0
- package/dist/rest/api.js.map +1 -0
- package/dist/rest/assets.d.ts +13 -0
- package/dist/rest/assets.js +30 -0
- package/dist/rest/assets.js.map +1 -0
- package/dist/rest/environment-variables.d.ts +16 -0
- package/dist/rest/environment-variables.js +25 -0
- package/dist/rest/environment-variables.js.map +1 -0
- package/dist/rest/locations.d.ts +11 -0
- package/dist/rest/locations.js +12 -0
- package/dist/rest/locations.js.map +1 -0
- package/dist/rest/private-locations.d.ts +11 -0
- package/dist/rest/private-locations.js +12 -0
- package/dist/rest/private-locations.js.map +1 -0
- package/dist/rest/projects.d.ts +43 -0
- package/dist/rest/projects.js +24 -0
- package/dist/rest/projects.js.map +1 -0
- package/dist/rest/runtimes.d.ts +15 -0
- package/dist/rest/runtimes.js +15 -0
- package/dist/rest/runtimes.js.map +1 -0
- package/dist/rest/test-sessions.d.ts +26 -0
- package/dist/rest/test-sessions.js +12 -0
- package/dist/rest/test-sessions.js.map +1 -0
- package/dist/rest/users.d.ts +12 -0
- package/dist/rest/users.js +12 -0
- package/dist/rest/users.js.map +1 -0
- package/dist/services/abstract-check-runner.d.ts +50 -0
- package/dist/services/abstract-check-runner.js +151 -0
- package/dist/services/abstract-check-runner.js.map +1 -0
- package/dist/services/check-parser/collector.d.ts +33 -0
- package/dist/services/check-parser/collector.js +48 -0
- package/dist/services/check-parser/collector.js.map +1 -0
- package/dist/services/check-parser/errors.d.ts +8 -0
- package/dist/services/check-parser/errors.js +45 -0
- package/dist/services/check-parser/errors.js.map +1 -0
- package/dist/services/check-parser/parser.d.ts +39 -0
- package/dist/services/check-parser/parser.js +296 -0
- package/dist/services/check-parser/parser.js.map +1 -0
- package/dist/services/checkly-config-loader.d.ts +54 -0
- package/dist/services/checkly-config-loader.js +55 -0
- package/dist/services/checkly-config-loader.js.map +1 -0
- package/dist/services/config.d.ts +24 -0
- package/dist/services/config.js +73 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/project-parser.d.ts +19 -0
- package/dist/services/project-parser.js +87 -0
- package/dist/services/project-parser.js.map +1 -0
- package/dist/services/socket-client.d.ts +4 -0
- package/dist/services/socket-client.js +20 -0
- package/dist/services/socket-client.js.map +1 -0
- package/dist/services/test-filters.d.ts +2 -0
- package/dist/services/test-filters.js +16 -0
- package/dist/services/test-filters.js.map +1 -0
- package/dist/services/test-runner.d.ts +21 -0
- package/dist/services/test-runner.js +50 -0
- package/dist/services/test-runner.js.map +1 -0
- package/dist/services/util.d.ts +29 -0
- package/dist/services/util.js +147 -0
- package/dist/services/util.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/oclif.manifest.json +423 -0
- package/package.json +163 -18
- package/LICENSE +0 -121
- package/dist/checkly.min.js +0 -1
- package/index.js +0 -285
- package/logo.png +0 -0
- package/test.js +0 -183
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const conf_1 = require("conf");
|
|
4
|
+
const dataSchema = {
|
|
5
|
+
accountId: { type: 'string' },
|
|
6
|
+
accountName: { type: 'string' },
|
|
7
|
+
};
|
|
8
|
+
const authSchema = {
|
|
9
|
+
apiKey: { type: 'string' },
|
|
10
|
+
};
|
|
11
|
+
const projectSuffix = process.env.NODE_ENV === 'test' ? 'test' : '';
|
|
12
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
13
|
+
var Env;
|
|
14
|
+
(function (Env) {
|
|
15
|
+
Env["production"] = "production";
|
|
16
|
+
Env["staging"] = "staging";
|
|
17
|
+
Env["development"] = "development";
|
|
18
|
+
Env["test"] = "test";
|
|
19
|
+
})(Env || (Env = {}));
|
|
20
|
+
const config = {
|
|
21
|
+
auth: new conf_1.default({
|
|
22
|
+
configName: 'auth',
|
|
23
|
+
projectSuffix,
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
schema: authSchema,
|
|
26
|
+
}),
|
|
27
|
+
data: new conf_1.default({
|
|
28
|
+
configName: 'config',
|
|
29
|
+
projectSuffix,
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
schema: dataSchema,
|
|
32
|
+
}),
|
|
33
|
+
clear() {
|
|
34
|
+
this.auth.clear();
|
|
35
|
+
this.data.clear();
|
|
36
|
+
},
|
|
37
|
+
getEnv() {
|
|
38
|
+
const environments = ['production', 'staging', 'development', 'test'];
|
|
39
|
+
const env = process.env.NODE_ENV || environments[0];
|
|
40
|
+
if (!(env in Env)) {
|
|
41
|
+
throw new Error('Invalid NODE_ENV');
|
|
42
|
+
}
|
|
43
|
+
return env;
|
|
44
|
+
},
|
|
45
|
+
getApiKey() {
|
|
46
|
+
return process.env.CHECKLY_API_KEY || this.auth.get('apiKey') || '';
|
|
47
|
+
},
|
|
48
|
+
getAccountId() {
|
|
49
|
+
return process.env.CHECKLY_ACCOUNT_ID || this.data.get('accountId') || '';
|
|
50
|
+
},
|
|
51
|
+
hasEnvVarsConfigured() {
|
|
52
|
+
const apiKey = process.env.CHECKLY_API_KEY || '';
|
|
53
|
+
const accoundId = process.env.CHECKLY_ACCOUNT_ID || '';
|
|
54
|
+
return apiKey !== '' || accoundId !== '';
|
|
55
|
+
},
|
|
56
|
+
getMqttUrl() {
|
|
57
|
+
const environments = {
|
|
58
|
+
development: 'wss://events-local.checklyhq.com',
|
|
59
|
+
test: 'wss://events-test.checklyhq.com',
|
|
60
|
+
staging: 'wss://events-test.checklyhq.com',
|
|
61
|
+
production: 'wss://events.checklyhq.com',
|
|
62
|
+
};
|
|
63
|
+
return environments[this.getEnv()];
|
|
64
|
+
},
|
|
65
|
+
hasValidCredentials() {
|
|
66
|
+
if (this.getApiKey() !== '' && this.getAccountId() !== '') {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
exports.default = config;
|
|
73
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/services/config.ts"],"names":[],"mappings":";;AAAA,+BAAuB;AAEvB,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC7B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAChC,CAAA;AAED,MAAM,UAAU,GAAG;IACjB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC3B,CAAA;AAED,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;AAEnE,gDAAgD;AAChD,IAAK,GAKJ;AALD,WAAK,GAAG;IACN,gCAAyB,CAAA;IACzB,0BAAmB,CAAA;IACnB,kCAA2B,CAAA;IAC3B,oBAAa,CAAA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,EAAE,CAAA;IAC1C,CAAC;IAED,UAAU;QACR,MAAM,YAAY,GAAG;YACnB,WAAW,EAAE,kCAAkC;YAC/C,IAAI,EAAE,iCAAiC;YACvC,OAAO,EAAE,iCAAiC;YAC1C,UAAU,EAAE,4BAA4B;SACzC,CAAA;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACpC,CAAC;IAED,mBAAmB;QACjB,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE;YACzD,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Project } from '../constructs';
|
|
2
|
+
import { CheckConfigDefaults } from './checkly-config-loader';
|
|
3
|
+
import type { Runtime } from '../rest/runtimes';
|
|
4
|
+
import type { Construct } from '../constructs/construct';
|
|
5
|
+
type ProjectParseOpts = {
|
|
6
|
+
directory: string;
|
|
7
|
+
projectLogicalId: string;
|
|
8
|
+
projectName: string;
|
|
9
|
+
repoUrl?: string;
|
|
10
|
+
checkMatch?: string;
|
|
11
|
+
browserCheckMatch?: string;
|
|
12
|
+
ignoreDirectoriesMatch?: string[];
|
|
13
|
+
checkDefaults?: CheckConfigDefaults;
|
|
14
|
+
browserCheckDefaults?: CheckConfigDefaults;
|
|
15
|
+
availableRuntimes: Record<string, Runtime>;
|
|
16
|
+
checklyConfigConstructs?: Construct[];
|
|
17
|
+
};
|
|
18
|
+
export declare function parseProject(opts: ProjectParseOpts): Promise<Project>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseProject = void 0;
|
|
4
|
+
const constructs_1 = require("../constructs");
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const glob = require("glob");
|
|
7
|
+
const util_2 = require("./util");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const globPromise = (0, util_1.promisify)(glob);
|
|
10
|
+
const BASE_CHECK_DEFAULTS = {
|
|
11
|
+
runtimeId: '2022.10',
|
|
12
|
+
};
|
|
13
|
+
async function parseProject(opts) {
|
|
14
|
+
const { directory, checkMatch = '**/*.check.{js,ts}', browserCheckMatch, projectLogicalId, projectName, repoUrl, ignoreDirectoriesMatch = [], checkDefaults = {}, browserCheckDefaults = {}, availableRuntimes, checklyConfigConstructs, } = opts;
|
|
15
|
+
const project = new constructs_1.Project(projectLogicalId, {
|
|
16
|
+
name: projectName,
|
|
17
|
+
repoUrl,
|
|
18
|
+
});
|
|
19
|
+
checklyConfigConstructs === null || checklyConfigConstructs === void 0 ? void 0 : checklyConfigConstructs.forEach((construct) => project.addResource(construct.type, construct.logicalId, construct));
|
|
20
|
+
constructs_1.Session.project = project;
|
|
21
|
+
constructs_1.Session.basePath = directory;
|
|
22
|
+
constructs_1.Session.checkDefaults = Object.assign({}, BASE_CHECK_DEFAULTS, checkDefaults);
|
|
23
|
+
constructs_1.Session.browserCheckDefaults = browserCheckDefaults;
|
|
24
|
+
constructs_1.Session.availableRuntimes = availableRuntimes;
|
|
25
|
+
// TODO: Do we really need all of the ** globs, or could we just put node_modules?
|
|
26
|
+
const ignoreDirectories = ['**/node_modules/**', '**/.git/**', ...ignoreDirectoriesMatch];
|
|
27
|
+
await loadAllCheckFiles(directory, checkMatch, ignoreDirectories);
|
|
28
|
+
await loadAllBrowserChecks(directory, browserCheckMatch, ignoreDirectories, project);
|
|
29
|
+
return project;
|
|
30
|
+
}
|
|
31
|
+
exports.parseProject = parseProject;
|
|
32
|
+
async function loadAllCheckFiles(directory, checkFilePattern, ignorePattern) {
|
|
33
|
+
const checkFiles = await findFilesWithPattern(directory, checkFilePattern, ignorePattern);
|
|
34
|
+
for (const checkFile of checkFiles) {
|
|
35
|
+
// setting the checkFilePath is used for filtering by file name on the command line
|
|
36
|
+
constructs_1.Session.checkFileAbsolutePath = checkFile;
|
|
37
|
+
constructs_1.Session.checkFilePath = (0, util_2.pathToPosix)(path.relative(directory, checkFile));
|
|
38
|
+
if (checkFile.endsWith('.js')) {
|
|
39
|
+
await (0, util_2.loadJsFile)(checkFile);
|
|
40
|
+
}
|
|
41
|
+
else if (checkFile.endsWith('.ts')) {
|
|
42
|
+
await (0, util_2.loadTsFile)(checkFile);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('Unable to load check configuration file with unsupported extension. ' +
|
|
46
|
+
`Please use a .js or .ts file instead.\n${checkFile}`);
|
|
47
|
+
}
|
|
48
|
+
constructs_1.Session.checkFilePath = undefined;
|
|
49
|
+
constructs_1.Session.checkFileAbsolutePath = undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function loadAllBrowserChecks(directory, browserCheckFilePattern, ignorePattern, project) {
|
|
53
|
+
if (!browserCheckFilePattern) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const checkFiles = await findFilesWithPattern(directory, browserCheckFilePattern, ignorePattern);
|
|
57
|
+
const preexistingCheckFiles = new Set();
|
|
58
|
+
Object.values(project.data.check).forEach((check) => {
|
|
59
|
+
if (check instanceof constructs_1.BrowserCheck && check.scriptPath) {
|
|
60
|
+
preexistingCheckFiles.add(check.scriptPath);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
for (const checkFile of checkFiles) {
|
|
64
|
+
const relPath = (0, util_2.pathToPosix)(path.relative(directory, checkFile));
|
|
65
|
+
// Don't create an additional check if the checkFile was already added to a check in loadAllCheckFiles.
|
|
66
|
+
if (preexistingCheckFiles.has(relPath)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const browserCheck = new constructs_1.BrowserCheck((0, util_2.pathToPosix)(relPath), {
|
|
70
|
+
name: path.basename(checkFile),
|
|
71
|
+
code: {
|
|
72
|
+
entrypoint: checkFile,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function findFilesWithPattern(directory, pattern, ignorePattern) {
|
|
78
|
+
// The files are sorted to make sure that the processing order is deterministic.
|
|
79
|
+
const files = await globPromise(pattern, {
|
|
80
|
+
nodir: true,
|
|
81
|
+
cwd: directory,
|
|
82
|
+
ignore: ignorePattern,
|
|
83
|
+
absolute: true,
|
|
84
|
+
});
|
|
85
|
+
return files.sort();
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=project-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-parser.js","sourceRoot":"","sources":["../../src/services/project-parser.ts"],"names":[],"mappings":";;;AAAA,8CAA8D;AAC9D,+BAAgC;AAChC,6BAA4B;AAC5B,iCAA4D;AAC5D,6BAA4B;AAM5B,MAAM,WAAW,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,CAAA;AAgBnC,MAAM,mBAAmB,GAAG;IAC1B,SAAS,EAAE,SAAS;CACrB,CAAA;AAEM,KAAK,UAAU,YAAY,CAAE,IAAsB;IACxD,MAAM,EACJ,SAAS,EACT,UAAU,GAAG,oBAAoB,EACjC,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,sBAAsB,GAAG,EAAE,EAC3B,aAAa,GAAG,EAAE,EAClB,oBAAoB,GAAG,EAAE,EACzB,iBAAiB,EACjB,uBAAuB,GACxB,GAAG,IAAI,CAAA;IACR,MAAM,OAAO,GAAG,IAAI,oBAAO,CAAC,gBAAgB,EAAE;QAC5C,IAAI,EAAE,WAAW;QACjB,OAAO;KACR,CAAC,CAAA;IACF,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,OAAO,CAC9B,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CACnF,CAAA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AM,KAAK,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE;QACvC,KAAK,EAAE,IAAI;QACX,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAA;IACF,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocketClient = void 0;
|
|
4
|
+
const mqtt = require("async-mqtt");
|
|
5
|
+
const config_1 = require("../services/config");
|
|
6
|
+
class SocketClient {
|
|
7
|
+
static connect() {
|
|
8
|
+
const url = config_1.default.getMqttUrl();
|
|
9
|
+
const accountId = config_1.default.getAccountId();
|
|
10
|
+
const apiKey = config_1.default.getApiKey();
|
|
11
|
+
const options = {
|
|
12
|
+
reconnectPeriod: 0,
|
|
13
|
+
username: accountId,
|
|
14
|
+
password: apiKey,
|
|
15
|
+
};
|
|
16
|
+
return mqtt.connectAsync(`${url}?authenticationScheme=userApiKey`, options, false);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SocketClient = SocketClient;
|
|
20
|
+
//# sourceMappingURL=socket-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-client.js","sourceRoot":"","sources":["../../src/services/socket-client.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAClC,+CAAuC;AAEvC,MAAa,YAAY;IACvB,MAAM,CAAC,OAAO;QACZ,MAAM,GAAG,GAAG,gBAAM,CAAC,UAAU,EAAG,CAAA;QAChC,MAAM,SAAS,GAAG,gBAAM,CAAC,YAAY,EAAG,CAAA;QACxC,MAAM,MAAM,GAAG,gBAAM,CAAC,SAAS,EAAG,CAAA;QAClC,MAAM,OAAO,GAAG;YACd,eAAe,EAAE,CAAC;YAClB,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE,MAAM;SACjB,CAAA;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,kCAAkC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACpF,CAAC;CACF;AAZD,oCAYC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterByFileNamePattern = exports.filterByCheckNamePattern = void 0;
|
|
4
|
+
function filterByCheckNamePattern(checkNamePattern = '', checkName) {
|
|
5
|
+
const re = new RegExp(checkNamePattern);
|
|
6
|
+
return re.test(checkName);
|
|
7
|
+
}
|
|
8
|
+
exports.filterByCheckNamePattern = filterByCheckNamePattern;
|
|
9
|
+
function filterByFileNamePattern(filePatterns = [], path) {
|
|
10
|
+
return !!filePatterns.find(filePattern => {
|
|
11
|
+
const re = new RegExp(filePattern);
|
|
12
|
+
return re.test(path);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.filterByFileNamePattern = filterByFileNamePattern;
|
|
16
|
+
//# sourceMappingURL=test-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-filters.js","sourceRoot":"","sources":["../../src/services/test-filters.ts"],"names":[],"mappings":";;;AAAA,SAAgB,wBAAwB,CAAE,gBAAgB,GAAG,EAAE,EAAE,SAAiB;IAChF,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IACvC,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC3B,CAAC;AAHD,4DAGC;AAED,SAAgB,uBAAuB,CAAE,eAA8B,EAAE,EAAE,IAAsB;IAC/F,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QACvC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAA;QAClC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAW,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC;AALD,0DAKC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractCheckRunner, { RunLocation, CheckRunId } from './abstract-check-runner';
|
|
2
|
+
import { GitInformation } from './util';
|
|
3
|
+
import { Check } from '../constructs/check';
|
|
4
|
+
import { Project } from '../constructs';
|
|
5
|
+
export default class TestRunner extends AbstractCheckRunner {
|
|
6
|
+
project: Project;
|
|
7
|
+
checkConstructs: Check[];
|
|
8
|
+
location: RunLocation;
|
|
9
|
+
shouldRecord: boolean;
|
|
10
|
+
repoInfo: GitInformation | null;
|
|
11
|
+
environment: string | null;
|
|
12
|
+
constructor(accountId: string, project: Project, checks: Check[], location: RunLocation, timeout: number, verbose: boolean, shouldRecord: boolean, repoInfo: GitInformation | null, environment: string | null);
|
|
13
|
+
scheduleChecks(checkRunSuiteId: string): Promise<{
|
|
14
|
+
testSessionId?: string;
|
|
15
|
+
checks: Array<{
|
|
16
|
+
check: any;
|
|
17
|
+
checkRunId: CheckRunId;
|
|
18
|
+
testSessionId?: string;
|
|
19
|
+
}>;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_1 = require("../rest/api");
|
|
4
|
+
const abstract_check_runner_1 = require("./abstract-check-runner");
|
|
5
|
+
const uuid = require("uuid");
|
|
6
|
+
class TestRunner extends abstract_check_runner_1.default {
|
|
7
|
+
constructor(accountId, project, checks, location, timeout, verbose, shouldRecord, repoInfo, environment) {
|
|
8
|
+
super(accountId, timeout, verbose);
|
|
9
|
+
this.project = project;
|
|
10
|
+
this.checkConstructs = checks;
|
|
11
|
+
this.location = location;
|
|
12
|
+
this.shouldRecord = shouldRecord;
|
|
13
|
+
this.repoInfo = repoInfo;
|
|
14
|
+
this.environment = environment;
|
|
15
|
+
}
|
|
16
|
+
async scheduleChecks(checkRunSuiteId) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const checkRunIdMap = new Map(this.checkConstructs.map((check) => [uuid.v4(), check]));
|
|
19
|
+
const checkRunJobs = Array.from(checkRunIdMap.entries()).map(([checkRunId, check]) => ({
|
|
20
|
+
...check.synthesize(),
|
|
21
|
+
group: check.groupId ? this.project.data['check-group'][check.groupId.ref].synthesize() : undefined,
|
|
22
|
+
groupId: undefined,
|
|
23
|
+
sourceInfo: { checkRunSuiteId, checkRunId },
|
|
24
|
+
logicalId: check.logicalId,
|
|
25
|
+
}));
|
|
26
|
+
try {
|
|
27
|
+
if (!checkRunJobs.length) {
|
|
28
|
+
throw new Error('Unable to find checks to run.');
|
|
29
|
+
}
|
|
30
|
+
const { data } = await api_1.testSessions.run({
|
|
31
|
+
name: this.project.name,
|
|
32
|
+
checkRunJobs,
|
|
33
|
+
project: { logicalId: this.project.logicalId },
|
|
34
|
+
runLocation: this.location,
|
|
35
|
+
repoInfo: this.repoInfo,
|
|
36
|
+
environment: this.environment,
|
|
37
|
+
shouldRecord: this.shouldRecord,
|
|
38
|
+
});
|
|
39
|
+
const { testSessionId, testResultIds } = data;
|
|
40
|
+
const checks = Array.from(checkRunIdMap.entries())
|
|
41
|
+
.map(([checkRunId, check]) => ({ check, checkRunId, testResultId: testResultIds === null || testResultIds === void 0 ? void 0 : testResultIds[check.logicalId] }));
|
|
42
|
+
return { testSessionId, checks };
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
throw new Error((_c = (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : err.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.default = TestRunner;
|
|
50
|
+
//# sourceMappingURL=test-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../../src/services/test-runner.ts"],"names":[],"mappings":";;AAAA,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
5
|
+
commitOwner?: string | null;
|
|
6
|
+
commitMessage?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface CiInformation {
|
|
9
|
+
environment: string | null;
|
|
10
|
+
}
|
|
11
|
+
export declare function walkDirectory(directory: string, ignoreDirectories: Set<string>, callback: (filepath: string) => Promise<void>): Promise<void>;
|
|
12
|
+
export declare function loadJsFile(filepath: string): Promise<any>;
|
|
13
|
+
export declare function loadTsFile(filepath: string): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* @param relPath the path to be converted
|
|
16
|
+
* @param separator this is for testing purposes only so we can reliably replace the separator on Linux / Darwin
|
|
17
|
+
*/
|
|
18
|
+
export declare function pathToPosix(relPath: string, separator?: string): string;
|
|
19
|
+
export declare function splitConfigFilePath(configFile?: string): {
|
|
20
|
+
configDirectory: string;
|
|
21
|
+
configFilenames?: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare function isFileSync(path: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* @param repoUrl default repoURL the user can set in their project config.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getGitInformation(repoUrl?: string): GitInformation | null;
|
|
28
|
+
export declare function getCiInformation(): CiInformation;
|
|
29
|
+
export declare function escapeValue(value: string | undefined): string;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeValue = exports.getCiInformation = exports.getGitInformation = exports.isFileSync = exports.splitConfigFilePath = exports.pathToPosix = exports.loadTsFile = exports.loadJsFile = exports.walkDirectory = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs/promises");
|
|
6
|
+
const fsSync = require("fs");
|
|
7
|
+
const gitRepoInfo = require("git-repo-info");
|
|
8
|
+
// TODO: Remove this in favor of glob? It's unused.
|
|
9
|
+
async function walkDirectory(directory, ignoreDirectories, callback) {
|
|
10
|
+
const files = await fs.readdir(directory);
|
|
11
|
+
for (const file of files.sort()) {
|
|
12
|
+
const filepath = path.join(directory, file);
|
|
13
|
+
const stats = await fs.stat(filepath);
|
|
14
|
+
if (stats.isDirectory() && !ignoreDirectories.has(file)) {
|
|
15
|
+
await walkDirectory(filepath, ignoreDirectories, callback);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
await callback(filepath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.walkDirectory = walkDirectory;
|
|
23
|
+
async function loadJsFile(filepath) {
|
|
24
|
+
try {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
26
|
+
let exported = require(filepath);
|
|
27
|
+
if (exported instanceof Function) {
|
|
28
|
+
exported = await exported();
|
|
29
|
+
}
|
|
30
|
+
return exported;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
throw new Error(`Error loading file ${filepath}\n${err.stack}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.loadJsFile = loadJsFile;
|
|
37
|
+
async function loadTsFile(filepath) {
|
|
38
|
+
try {
|
|
39
|
+
const tsCompiler = await getTsCompiler();
|
|
40
|
+
tsCompiler.enabled(true);
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
42
|
+
let { default: exported } = require(filepath);
|
|
43
|
+
if (exported instanceof Function) {
|
|
44
|
+
exported = await exported();
|
|
45
|
+
}
|
|
46
|
+
tsCompiler.enabled(false); // Re-disable the TS compiler
|
|
47
|
+
return exported;
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
throw new Error(`Error loading file ${filepath}\n${err.stack}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.loadTsFile = loadTsFile;
|
|
54
|
+
// To avoid a dependency on typescript for users with no TS checks, we need to dynamically import ts-node
|
|
55
|
+
let tsCompiler;
|
|
56
|
+
async function getTsCompiler() {
|
|
57
|
+
if (tsCompiler)
|
|
58
|
+
return tsCompiler;
|
|
59
|
+
try {
|
|
60
|
+
const tsNode = await Promise.resolve().then(() => require('ts-node'));
|
|
61
|
+
tsCompiler = tsNode.register({
|
|
62
|
+
compilerOptions: {
|
|
63
|
+
module: 'CommonJS',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'MODULE_NOT_FOUND') {
|
|
69
|
+
throw new Error('Please install "ts-node" and "typescript" to use TypeScript configuration files');
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
return tsCompiler;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param relPath the path to be converted
|
|
77
|
+
* @param separator this is for testing purposes only so we can reliably replace the separator on Linux / Darwin
|
|
78
|
+
*/
|
|
79
|
+
function pathToPosix(relPath, separator) {
|
|
80
|
+
// Windows uses \ rather than / as a path separator.
|
|
81
|
+
// It's important that logical ID's are consistent across platforms, though.
|
|
82
|
+
// Otherwise, checks will be deleted and recreated when `npx checkly deploy` is run on different machines.
|
|
83
|
+
return path.normalize(relPath).split(separator !== null && separator !== void 0 ? separator : path.sep).join(path.posix.sep).replace(/^C:/, '');
|
|
84
|
+
}
|
|
85
|
+
exports.pathToPosix = pathToPosix;
|
|
86
|
+
function splitConfigFilePath(configFile) {
|
|
87
|
+
if (configFile) {
|
|
88
|
+
const cwd = path.resolve(path.dirname(configFile));
|
|
89
|
+
return {
|
|
90
|
+
configDirectory: cwd,
|
|
91
|
+
configFilenames: [path.basename(configFile)],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
configDirectory: process.cwd(),
|
|
96
|
+
configFilenames: undefined,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
exports.splitConfigFilePath = splitConfigFilePath;
|
|
100
|
+
function isFileSync(path) {
|
|
101
|
+
// This helper is useful to test paths inside constructors which cannot be async.
|
|
102
|
+
let result;
|
|
103
|
+
try {
|
|
104
|
+
result = fsSync.existsSync(path);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
throw new Error(`Error parsing the file path: ${path}`);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
exports.isFileSync = isFileSync;
|
|
112
|
+
/**
|
|
113
|
+
* @param repoUrl default repoURL the user can set in their project config.
|
|
114
|
+
*/
|
|
115
|
+
function getGitInformation(repoUrl) {
|
|
116
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
117
|
+
const repositoryInfo = gitRepoInfo();
|
|
118
|
+
if (!process.env.CHECKLY_TEST_REPO_SHA && !repositoryInfo.sha) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// safe way to remove the email address
|
|
122
|
+
const committer = (_b = (((_a = repositoryInfo.committer) === null || _a === void 0 ? void 0 : _a.match(/([^<]+)/)) || [])[1]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
123
|
+
return {
|
|
124
|
+
commitId: (_c = process.env.CHECKLY_TEST_REPO_SHA) !== null && _c !== void 0 ? _c : repositoryInfo.sha,
|
|
125
|
+
repoUrl: (_d = process.env.CHECKLY_TEST_REPO_URL) !== null && _d !== void 0 ? _d : repoUrl,
|
|
126
|
+
branchName: (_e = process.env.CHECKLY_TEST_REPO_BRANCH) !== null && _e !== void 0 ? _e : repositoryInfo.branch,
|
|
127
|
+
commitOwner: (_f = process.env.CHECKLY_TEST_REPO_COMMIT_OWNER) !== null && _f !== void 0 ? _f : committer,
|
|
128
|
+
commitMessage: (_g = process.env.CHECKLY_TEST_REPO_COMMIT_MESSAGE) !== null && _g !== void 0 ? _g : repositoryInfo.commitMessage,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.getGitInformation = getGitInformation;
|
|
132
|
+
function getCiInformation() {
|
|
133
|
+
var _a;
|
|
134
|
+
return {
|
|
135
|
+
environment: (_a = process.env.CHECKLY_TEST_ENVIRONMENT) !== null && _a !== void 0 ? _a : null,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
exports.getCiInformation = getCiInformation;
|
|
139
|
+
function escapeValue(value) {
|
|
140
|
+
return value
|
|
141
|
+
? value
|
|
142
|
+
.replace(/\n/g, '\\n') // combine newlines (unix) into one line
|
|
143
|
+
.replace(/\r/g, '\\r') // combine newlines (windows) into one line
|
|
144
|
+
: '';
|
|
145
|
+
}
|
|
146
|
+
exports.escapeValue = escapeValue;
|
|
147
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/services/util.ts"],"names":[],"mappings":";;;AAAA,6BAA4B;AAC5B,kCAAiC;AACjC,6BAA4B;AAE5B,6CAA4C;AAc5C,mDAAmD;AAC5C,KAAK,UAAU,aAAa,CACjC,SAAiB,EACjB,iBAA8B,EAC9B,QAA6C;IAE7C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QAC3C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACvD,MAAM,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAA;SAC3D;aAAM;YACL,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAA;SACzB;KACF;AACH,CAAC;AAfD,sCAeC;AAEM,KAAK,UAAU,UAAU,CAAE,QAAgB;IAChD,IAAI;QACF,8DAA8D;QAC9D,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAA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