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.
- 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 +237 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/trigger.d.ts +32 -0
- package/dist/commands/trigger.js +173 -0
- package/dist/commands/trigger.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 +128 -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 +34 -0
- package/dist/reporters/github.js +103 -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 +47 -0
- package/dist/rest/test-sessions.js +15 -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 +75 -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/trigger-runner.d.ts +26 -0
- package/dist/services/trigger-runner.js +47 -0
- package/dist/services/trigger-runner.js.map +1 -0
- package/dist/services/util.d.ts +30 -0
- package/dist/services/util.js +157 -0
- package/dist/services/util.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/oclif.manifest.json +527 -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,43 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
export interface Project {
|
|
3
|
+
name: string;
|
|
4
|
+
logicalId: string;
|
|
5
|
+
repoUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
type ProjectResponse = Project & {
|
|
8
|
+
id: string;
|
|
9
|
+
created_at: string;
|
|
10
|
+
};
|
|
11
|
+
export interface Change {
|
|
12
|
+
logicalId: string;
|
|
13
|
+
physicalId?: string;
|
|
14
|
+
type: string;
|
|
15
|
+
action: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ResourceSync {
|
|
18
|
+
logicalId: string;
|
|
19
|
+
physicalId?: string | number;
|
|
20
|
+
type: string;
|
|
21
|
+
member: boolean;
|
|
22
|
+
payload: any;
|
|
23
|
+
}
|
|
24
|
+
export interface ProjectSync {
|
|
25
|
+
project: Project;
|
|
26
|
+
resources: Array<ResourceSync>;
|
|
27
|
+
}
|
|
28
|
+
export interface ProjectDeployResponse {
|
|
29
|
+
project: Project;
|
|
30
|
+
diff: Array<Change>;
|
|
31
|
+
}
|
|
32
|
+
declare class Projects {
|
|
33
|
+
api: AxiosInstance;
|
|
34
|
+
constructor(api: AxiosInstance);
|
|
35
|
+
getAll(): Promise<import("axios").AxiosResponse<ProjectResponse[], any>>;
|
|
36
|
+
get(id: string): Promise<import("axios").AxiosResponse<ProjectResponse, any>>;
|
|
37
|
+
create(project: Project): Promise<import("axios").AxiosResponse<any, any>>;
|
|
38
|
+
deleteProject(logicalId: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
39
|
+
deploy(resources: ProjectSync, { dryRun }?: {
|
|
40
|
+
dryRun?: boolean | undefined;
|
|
41
|
+
}): Promise<import("axios").AxiosResponse<ProjectDeployResponse, any>>;
|
|
42
|
+
}
|
|
43
|
+
export default Projects;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Projects {
|
|
4
|
+
constructor(api) {
|
|
5
|
+
this.api = api;
|
|
6
|
+
}
|
|
7
|
+
getAll() {
|
|
8
|
+
return this.api.get('/next/projects');
|
|
9
|
+
}
|
|
10
|
+
get(id) {
|
|
11
|
+
return this.api.get(`/next/projects/${id}`);
|
|
12
|
+
}
|
|
13
|
+
create(project) {
|
|
14
|
+
return this.api.post('/next/projects', project);
|
|
15
|
+
}
|
|
16
|
+
deleteProject(logicalId) {
|
|
17
|
+
return this.api.delete(`/next/projects/${logicalId}`);
|
|
18
|
+
}
|
|
19
|
+
deploy(resources, { dryRun = false } = {}) {
|
|
20
|
+
return this.api.post(`/next-v2/projects/deploy?dryRun=${dryRun}`, resources);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = Projects;
|
|
24
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/rest/projects.ts"],"names":[],"mappings":";;AAkCA,MAAM,QAAQ;IAEZ,YAAa,GAAkB;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAyB,gBAAgB,CAAC,CAAA;IAC/D,CAAC;IAED,GAAG,CAAE,EAAU;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAkB,kBAAkB,EAAE,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,MAAM,CAAE,OAAgB;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAED,aAAa,CAAE,SAAiB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,SAAS,EAAE,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,CAAE,SAAsB,EAAE,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,EAAE;QACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAClB,mCAAmC,MAAM,EAAE,EAC3C,SAAS,CACV,CAAA;IACH,CAAC;CACF;AAED,kBAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
export interface Runtime {
|
|
3
|
+
name: string;
|
|
4
|
+
stage?: string;
|
|
5
|
+
runtimeEndOfLife?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
dependencies: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
declare class Runtimes {
|
|
10
|
+
api: AxiosInstance;
|
|
11
|
+
constructor(api: AxiosInstance);
|
|
12
|
+
getAll(): Promise<import("axios").AxiosResponse<Runtime[], any>>;
|
|
13
|
+
get(runtimeId: string): Promise<import("axios").AxiosResponse<Runtime, any>>;
|
|
14
|
+
}
|
|
15
|
+
export default Runtimes;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Runtimes {
|
|
4
|
+
constructor(api) {
|
|
5
|
+
this.api = api;
|
|
6
|
+
}
|
|
7
|
+
getAll() {
|
|
8
|
+
return this.api.get('/v1/runtimes');
|
|
9
|
+
}
|
|
10
|
+
get(runtimeId) {
|
|
11
|
+
return this.api.get(`/v1/runtimes/${runtimeId}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = Runtimes;
|
|
15
|
+
//# sourceMappingURL=runtimes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimes.js","sourceRoot":"","sources":["../../src/rest/runtimes.ts"],"names":[],"mappings":";;AAUA,MAAM,QAAQ;IAEZ,YAAa,GAAkB;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAiB,cAAc,CAAC,CAAA;IACrD,CAAC;IAED,GAAG,CAAE,SAAiB;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAU,gBAAgB,SAAS,EAAE,CAAC,CAAA;IAC3D,CAAC;CACF;AAED,kBAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import { GitInformation } from '../services/util';
|
|
3
|
+
type RunTestSessionRequest = {
|
|
4
|
+
name: string;
|
|
5
|
+
checkRunJobs: any[];
|
|
6
|
+
project: {
|
|
7
|
+
logicalId: string;
|
|
8
|
+
};
|
|
9
|
+
runLocation: string | {
|
|
10
|
+
type: 'PUBLIC';
|
|
11
|
+
region: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'PRIVATE';
|
|
14
|
+
slugName: string;
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
repoInfo?: GitInformation | null;
|
|
18
|
+
environment?: string | null;
|
|
19
|
+
shouldRecord: boolean;
|
|
20
|
+
};
|
|
21
|
+
type TriggerTestSessionRequest = {
|
|
22
|
+
name: string;
|
|
23
|
+
runLocation: string | {
|
|
24
|
+
type: 'PUBLIC';
|
|
25
|
+
region: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'PRIVATE';
|
|
28
|
+
slugName: string;
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
shouldRecord: boolean;
|
|
32
|
+
targetTags: string[][];
|
|
33
|
+
checkRunSuiteId: string;
|
|
34
|
+
environmentVariables: Array<{
|
|
35
|
+
key: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}>;
|
|
38
|
+
repoInfo: GitInformation | null;
|
|
39
|
+
environment: string | null;
|
|
40
|
+
};
|
|
41
|
+
declare class TestSessions {
|
|
42
|
+
api: AxiosInstance;
|
|
43
|
+
constructor(api: AxiosInstance);
|
|
44
|
+
run(payload: RunTestSessionRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
45
|
+
trigger(payload: TriggerTestSessionRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
46
|
+
}
|
|
47
|
+
export default TestSessions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class TestSessions {
|
|
4
|
+
constructor(api) {
|
|
5
|
+
this.api = api;
|
|
6
|
+
}
|
|
7
|
+
run(payload) {
|
|
8
|
+
return this.api.post('/next/test-sessions/run', payload);
|
|
9
|
+
}
|
|
10
|
+
trigger(payload) {
|
|
11
|
+
return this.api.post('/next/test-sessions/trigger', payload);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = TestSessions;
|
|
15
|
+
//# sourceMappingURL=test-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-sessions.js","sourceRoot":"","sources":["../../src/rest/test-sessions.ts"],"names":[],"mappings":";;AAwBA,MAAM,YAAY;IAEhB,YAAa,GAAkB;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,GAAG,CAAE,OAA8B;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED,OAAO,CAAE,OAAkC;QACzC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAA;IAC9D,CAAC;CACF;AAED,kBAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
export interface User {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
nickname?: string;
|
|
6
|
+
}
|
|
7
|
+
declare class Users {
|
|
8
|
+
api: AxiosInstance;
|
|
9
|
+
constructor(api: AxiosInstance);
|
|
10
|
+
get(): Promise<import("axios").AxiosResponse<User, any>>;
|
|
11
|
+
}
|
|
12
|
+
export default Users;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Users {
|
|
4
|
+
constructor(api) {
|
|
5
|
+
this.api = api;
|
|
6
|
+
}
|
|
7
|
+
get() {
|
|
8
|
+
return this.api.get('/next/users/me');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.default = Users;
|
|
12
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/rest/users.ts"],"names":[],"mappings":";;AAQA,MAAM,KAAK;IAET,YAAa,GAAkB;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAO,gBAAgB,CAAC,CAAA;IAC7C,CAAC;CACF;AAED,kBAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import PQueue from 'p-queue';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import type { Region } from '..';
|
|
6
|
+
export declare enum Events {
|
|
7
|
+
CHECK_REGISTERED = "CHECK_REGISTERED",
|
|
8
|
+
CHECK_INPROGRESS = "CHECK_INPROGRESS",
|
|
9
|
+
CHECK_FAILED = "CHECK_FAILED",
|
|
10
|
+
CHECK_SUCCESSFUL = "CHECK_SUCCESSFUL",
|
|
11
|
+
CHECK_FINISHED = "CHECK_FINISHED",
|
|
12
|
+
RUN_STARTED = "RUN_STARTED",
|
|
13
|
+
RUN_FINISHED = "RUN_FINISHED",
|
|
14
|
+
ERROR = "ERROR"
|
|
15
|
+
}
|
|
16
|
+
export type PrivateRunLocation = {
|
|
17
|
+
type: 'PRIVATE';
|
|
18
|
+
id: string;
|
|
19
|
+
slugName: string;
|
|
20
|
+
};
|
|
21
|
+
export type PublicRunLocation = {
|
|
22
|
+
type: 'PUBLIC';
|
|
23
|
+
region: keyof Region;
|
|
24
|
+
};
|
|
25
|
+
export type RunLocation = PublicRunLocation | PrivateRunLocation;
|
|
26
|
+
export type CheckRunId = string;
|
|
27
|
+
export default abstract class AbstractCheckRunner extends EventEmitter {
|
|
28
|
+
checks?: Map<CheckRunId, any>;
|
|
29
|
+
timeouts: Map<CheckRunId, NodeJS.Timeout>;
|
|
30
|
+
accountId: string;
|
|
31
|
+
timeout: number;
|
|
32
|
+
verbose: boolean;
|
|
33
|
+
queue: PQueue;
|
|
34
|
+
constructor(accountId: string, timeout: number, verbose: boolean);
|
|
35
|
+
abstract scheduleChecks(checkRunSuiteId: string): Promise<{
|
|
36
|
+
testSessionId?: string;
|
|
37
|
+
checks: Array<{
|
|
38
|
+
check: any;
|
|
39
|
+
checkRunId: CheckRunId;
|
|
40
|
+
testSessionId?: string;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
run(): Promise<void>;
|
|
44
|
+
private configureResultListener;
|
|
45
|
+
private processMessage;
|
|
46
|
+
private allChecksFinished;
|
|
47
|
+
private setAllTimeouts;
|
|
48
|
+
private disableAllTimeouts;
|
|
49
|
+
private disableTimeout;
|
|
50
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Events = void 0;
|
|
4
|
+
const api_1 = require("../rest/api");
|
|
5
|
+
const socket_client_1 = require("./socket-client");
|
|
6
|
+
const p_queue_1 = require("p-queue");
|
|
7
|
+
const uuid = require("uuid");
|
|
8
|
+
const node_events_1 = require("node:events");
|
|
9
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
var Events;
|
|
11
|
+
(function (Events) {
|
|
12
|
+
Events["CHECK_REGISTERED"] = "CHECK_REGISTERED";
|
|
13
|
+
Events["CHECK_INPROGRESS"] = "CHECK_INPROGRESS";
|
|
14
|
+
Events["CHECK_FAILED"] = "CHECK_FAILED";
|
|
15
|
+
Events["CHECK_SUCCESSFUL"] = "CHECK_SUCCESSFUL";
|
|
16
|
+
Events["CHECK_FINISHED"] = "CHECK_FINISHED";
|
|
17
|
+
Events["RUN_STARTED"] = "RUN_STARTED";
|
|
18
|
+
Events["RUN_FINISHED"] = "RUN_FINISHED";
|
|
19
|
+
Events["ERROR"] = "ERROR";
|
|
20
|
+
})(Events = exports.Events || (exports.Events = {}));
|
|
21
|
+
class AbstractCheckRunner extends node_events_1.EventEmitter {
|
|
22
|
+
constructor(accountId, timeout, verbose) {
|
|
23
|
+
super();
|
|
24
|
+
this.timeouts = new Map();
|
|
25
|
+
this.queue = new p_queue_1.default({ autoStart: false, concurrency: 1 });
|
|
26
|
+
this.timeout = timeout;
|
|
27
|
+
this.verbose = verbose;
|
|
28
|
+
this.accountId = accountId;
|
|
29
|
+
}
|
|
30
|
+
async run() {
|
|
31
|
+
let socketClient = null;
|
|
32
|
+
try {
|
|
33
|
+
socketClient = await socket_client_1.SocketClient.connect();
|
|
34
|
+
const checkRunSuiteId = uuid.v4();
|
|
35
|
+
// Configure the socket listener and allChecksFinished listener before starting checks to avoid race conditions
|
|
36
|
+
await this.configureResultListener(checkRunSuiteId, socketClient);
|
|
37
|
+
const { testSessionId, checks } = await this.scheduleChecks(checkRunSuiteId);
|
|
38
|
+
this.checks = new Map(checks.map(({ check, checkRunId }) => [checkRunId, check]));
|
|
39
|
+
// `processMessage()` assumes that `this.timeouts` always has an entry for non-timed-out checks.
|
|
40
|
+
// To ensure that this is the case, we call `setAllTimeouts()` before `queue.start()`.
|
|
41
|
+
// Otherwise, we risk a race condition where check results are received before the timeout is set.
|
|
42
|
+
// This would cause `processMessage()` to mistakenly skip check results and consider the checks timed-out.
|
|
43
|
+
this.setAllTimeouts();
|
|
44
|
+
// `allChecksFinished` should be started before processing check results in `queue.start()`.
|
|
45
|
+
// Otherwise, there could be a race condition causing check results to be missed by `allChecksFinished()`.
|
|
46
|
+
const allChecksFinished = this.allChecksFinished();
|
|
47
|
+
// Start the queue after the test session run rest call is completed to avoid race conditions
|
|
48
|
+
this.queue.start();
|
|
49
|
+
/// / Need to structure the checks depending on how it went
|
|
50
|
+
this.emit(Events.RUN_STARTED, checks, testSessionId);
|
|
51
|
+
await allChecksFinished;
|
|
52
|
+
this.emit(Events.RUN_FINISHED, testSessionId);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
this.disableAllTimeouts();
|
|
56
|
+
this.emit(Events.ERROR, err);
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
if (socketClient) {
|
|
60
|
+
await socketClient.end();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async configureResultListener(checkRunSuiteId, socketClient) {
|
|
65
|
+
socketClient.on('message', (topic, rawMessage) => {
|
|
66
|
+
const message = JSON.parse(rawMessage.toString('utf8'));
|
|
67
|
+
const topicComponents = topic.split('/');
|
|
68
|
+
const checkRunId = topicComponents[4];
|
|
69
|
+
const subtopic = topicComponents[5];
|
|
70
|
+
this.queue.add(() => this.processMessage(checkRunId, subtopic, message));
|
|
71
|
+
});
|
|
72
|
+
await socketClient.subscribe(`account/${this.accountId}/ad-hoc-check-results/${checkRunSuiteId}/+/+`);
|
|
73
|
+
}
|
|
74
|
+
async processMessage(checkRunId, subtopic, message) {
|
|
75
|
+
if (!this.timeouts.has(checkRunId)) {
|
|
76
|
+
// The check has already timed out. We return early to avoid reporting a duplicate result.
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const check = this.checks.get(checkRunId);
|
|
80
|
+
if (subtopic === 'run-start') {
|
|
81
|
+
this.emit(Events.CHECK_INPROGRESS, check);
|
|
82
|
+
}
|
|
83
|
+
else if (subtopic === 'run-end') {
|
|
84
|
+
this.disableTimeout(checkRunId);
|
|
85
|
+
const { result } = message;
|
|
86
|
+
const { region, logPath, checkRunDataPath, playwrightTestTraceFiles, playwrightTestVideoFiles, } = result.assets;
|
|
87
|
+
if (logPath && (this.verbose || result.hasFailures)) {
|
|
88
|
+
result.logs = await api_1.assets.getLogs(region, logPath);
|
|
89
|
+
}
|
|
90
|
+
if (checkRunDataPath && (this.verbose || result.hasFailures)) {
|
|
91
|
+
result.checkRunData = await api_1.assets.getCheckRunData(region, checkRunDataPath);
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
if (result.hasFailures) {
|
|
95
|
+
if (playwrightTestTraceFiles && playwrightTestTraceFiles.length) {
|
|
96
|
+
result.traceFilesUrls = await Promise
|
|
97
|
+
.all(playwrightTestTraceFiles.map((t) => api_1.assets.getAssetsLink(region, t)));
|
|
98
|
+
}
|
|
99
|
+
if (playwrightTestVideoFiles && playwrightTestVideoFiles.length) {
|
|
100
|
+
result.videoFilesUrls = await Promise
|
|
101
|
+
.all(playwrightTestVideoFiles.map((t) => api_1.assets.getAssetsLink(region, t)));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
// TODO: remove the try/catch after deploy endpoint to fetch assets link
|
|
107
|
+
}
|
|
108
|
+
this.emit(Events.CHECK_SUCCESSFUL, checkRunId, check, result);
|
|
109
|
+
this.emit(Events.CHECK_FINISHED, check);
|
|
110
|
+
}
|
|
111
|
+
else if (subtopic === 'error') {
|
|
112
|
+
this.disableTimeout(checkRunId);
|
|
113
|
+
this.emit(Events.CHECK_FAILED, checkRunId, check, message);
|
|
114
|
+
this.emit(Events.CHECK_FINISHED, check);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
allChecksFinished() {
|
|
118
|
+
let finishedCheckCount = 0;
|
|
119
|
+
const numChecks = this.checks.size;
|
|
120
|
+
if (numChecks === 0) {
|
|
121
|
+
return Promise.resolve();
|
|
122
|
+
}
|
|
123
|
+
return new Promise((resolve) => {
|
|
124
|
+
this.on(Events.CHECK_FINISHED, () => {
|
|
125
|
+
finishedCheckCount++;
|
|
126
|
+
if (finishedCheckCount === numChecks)
|
|
127
|
+
resolve();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
setAllTimeouts() {
|
|
132
|
+
Array.from(this.checks.entries()).forEach(([checkRunId, check]) => this.timeouts.set(checkRunId, setTimeout(() => {
|
|
133
|
+
this.timeouts.delete(checkRunId);
|
|
134
|
+
this.emit(Events.CHECK_FAILED, check, `Reached timeout of ${this.timeout} seconds waiting for check result.`);
|
|
135
|
+
this.emit(Events.CHECK_FINISHED, check);
|
|
136
|
+
}, this.timeout * 1000)));
|
|
137
|
+
}
|
|
138
|
+
disableAllTimeouts() {
|
|
139
|
+
if (!this.checks) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
Array.from(this.checks.entries()).forEach(([checkRunId]) => this.disableTimeout(checkRunId));
|
|
143
|
+
}
|
|
144
|
+
disableTimeout(checkRunId) {
|
|
145
|
+
const timeout = this.timeouts.get(checkRunId);
|
|
146
|
+
clearTimeout(timeout);
|
|
147
|
+
this.timeouts.delete(checkRunId);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.default = AbstractCheckRunner;
|
|
151
|
+
//# sourceMappingURL=abstract-check-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-check-runner.js","sourceRoot":"","sources":["../../src/services/abstract-check-runner.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AACpC,mDAA8C;AAC9C,qCAA4B;AAC5B,6BAA4B;AAC5B,6CAA0C;AAI1C,gDAAgD;AAChD,IAAY,MASX;AATD,WAAY,MAAM;IAChB,+CAAqC,CAAA;IACrC,+CAAqC,CA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|
4
|
+
};
|
|
5
|
+
export type ParseError = {
|
|
6
|
+
file: string;
|
|
7
|
+
error: string;
|
|
8
|
+
};
|
|
9
|
+
export declare class Collector {
|
|
10
|
+
entrypoint: string;
|
|
11
|
+
entrypointContent: string;
|
|
12
|
+
missingFiles: string[];
|
|
13
|
+
parseErrors: ParseError[];
|
|
14
|
+
unsupportedNpmDependencies: UnsupportedNpmDependencies[];
|
|
15
|
+
dependencies: Map<string, string>;
|
|
16
|
+
constructor(entrypoint: string, entrypointContent: string);
|
|
17
|
+
hasDependency(path: string): boolean;
|
|
18
|
+
addDependency(path: string, content: string): void;
|
|
19
|
+
addUnsupportedNpmDependencies(file: string, unsupportedDependencies: string[]): void;
|
|
20
|
+
addParsingError(file: string, message: string): void;
|
|
21
|
+
addMissingFile(filePath: string): void;
|
|
22
|
+
validate(): void;
|
|
23
|
+
getItems(): {
|
|
24
|
+
entrypoint: {
|
|
25
|
+
filePath: string;
|
|
26
|
+
content: string;
|
|
27
|
+
};
|
|
28
|
+
dependencies: {
|
|
29
|
+
filePath: string;
|
|
30
|
+
content: string;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Collector = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
class Collector {
|
|
6
|
+
constructor(entrypoint, entrypointContent) {
|
|
7
|
+
this.missingFiles = [];
|
|
8
|
+
this.parseErrors = [];
|
|
9
|
+
this.unsupportedNpmDependencies = [];
|
|
10
|
+
this.dependencies = new Map();
|
|
11
|
+
this.entrypoint = entrypoint;
|
|
12
|
+
this.entrypointContent = entrypointContent;
|
|
13
|
+
}
|
|
14
|
+
hasDependency(path) {
|
|
15
|
+
return this.dependencies.has(path);
|
|
16
|
+
}
|
|
17
|
+
addDependency(path, content) {
|
|
18
|
+
this.dependencies.set(path, content);
|
|
19
|
+
}
|
|
20
|
+
addUnsupportedNpmDependencies(file, unsupportedDependencies) {
|
|
21
|
+
this.unsupportedNpmDependencies.push({ file, unsupportedDependencies });
|
|
22
|
+
}
|
|
23
|
+
addParsingError(file, message) {
|
|
24
|
+
this.parseErrors.push({ file, error: message });
|
|
25
|
+
}
|
|
26
|
+
addMissingFile(filePath) {
|
|
27
|
+
this.missingFiles.push(filePath);
|
|
28
|
+
}
|
|
29
|
+
validate() {
|
|
30
|
+
if (this.missingFiles.length || this.parseErrors.length || this.unsupportedNpmDependencies.length) {
|
|
31
|
+
throw new errors_1.DependencyParseError(this.entrypoint, this.missingFiles, this.unsupportedNpmDependencies, this.parseErrors);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
getItems() {
|
|
35
|
+
return {
|
|
36
|
+
entrypoint: {
|
|
37
|
+
filePath: this.entrypoint,
|
|
38
|
+
content: this.entrypointContent,
|
|
39
|
+
},
|
|
40
|
+
dependencies: Array.from(this.dependencies.entries(), ([key, value]) => ({
|
|
41
|
+
filePath: key,
|
|
42
|
+
content: value,
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.Collector = Collector;
|
|
48
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../../src/services/check-parser/collector.ts"],"names":[],"mappings":";;;AAAA,qCAA+C;AAY/C,MAAa,SAAS;IAQpB,YAAa,UAAkB,EAAE,iBAAyB;QAL1D,iBAAY,GAAa,EAAE,CAAA;QAC3B,gBAAW,GAAiB,EAAE,CAAA;QAC9B,+BAA0B,GAAiC,EAAE,CAAA;QAC7D,iBAAY,GAAG,IAAI,GAAG,EAAkB,CAAA;QAGtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED,aAAa,CAAE,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;CACF;AAxDD,8BAwDC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParseError, UnsupportedNpmDependencies } from './collector';
|
|
2
|
+
export declare class DependencyParseError extends Error {
|
|
3
|
+
entrypoint: string;
|
|
4
|
+
missingFiles: string[];
|
|
5
|
+
unsupportedNpmDependencies: UnsupportedNpmDependencies[];
|
|
6
|
+
parseErrors: ParseError[];
|
|
7
|
+
constructor(entrypoint: string, missingFiles: string[], unsupportedNpmDependencies: UnsupportedNpmDependencies[], parseErrors: ParseError[]);
|
|
8
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DependencyParseError = void 0;
|
|
4
|
+
class DependencyParseError extends Error {
|
|
5
|
+
constructor(entrypoint, missingFiles, unsupportedNpmDependencies, parseErrors) {
|
|
6
|
+
let message = `Encountered an error parsing check files for ${entrypoint}.`;
|
|
7
|
+
if (missingFiles.length) {
|
|
8
|
+
message += '\n\nThe following dependencies weren\'t found:\n';
|
|
9
|
+
for (const missingFile of missingFiles) {
|
|
10
|
+
message += `\t${missingFile}\n`;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (unsupportedNpmDependencies.length) {
|
|
14
|
+
if (unsupportedNpmDependencies.some(d => d.unsupportedDependencies.some(ud => ud === 'checkly/constructs'))) {
|
|
15
|
+
message += '\n\nIt looks like you\'re trying to use checkly/constructs in a browser check file. ' +
|
|
16
|
+
'checkly/constructs should only be used in check files: files ending in .check.ts and .check.js, ' +
|
|
17
|
+
'or the checkMatch pattern set in your configuration. For more information see on the difference between ' +
|
|
18
|
+
'test files and check files, see https://www.checklyhq.com/docs/cli/\n';
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
message += '\n\nThe following NPM dependencies were used, but aren\'t supported in the runtimes.\n';
|
|
22
|
+
message += 'For more information, see https://www.checklyhq.com/docs/runtimes/.\n';
|
|
23
|
+
for (const { file, unsupportedDependencies } of unsupportedNpmDependencies) {
|
|
24
|
+
message += `\t${file} imports unsupported dependencies:\n`;
|
|
25
|
+
for (const unsupportedDependency of unsupportedDependencies) {
|
|
26
|
+
message += `\t\t${unsupportedDependency}\n`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (parseErrors.length) {
|
|
32
|
+
message += '\n\nThe following files couldn\'t be parsed:\n';
|
|
33
|
+
for (const { file, error } of parseErrors) {
|
|
34
|
+
message += `\t${file} - ${error}\n`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
super(message);
|
|
38
|
+
this.entrypoint = entrypoint;
|
|
39
|
+
this.missingFiles = missingFiles;
|
|
40
|
+
this.unsupportedNpmDependencies = unsupportedNpmDependencies;
|
|
41
|
+
this.parseErrors = parseErrors;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.DependencyParseError = DependencyParseError;
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/services/check-parser/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAqB,SAAQ,KAAK;IAK7C,YACE,UAAkB,EAClB,YAAsB,EACtB,0BAAwD,EACxD,WAAyB;QAEzB,IAAI,OAAO,GAAG,gDAAgD,UAAU,GAAG,CAAA;QAC3E,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,OAAO,IAAI,kDAAkD,CAAA;YAC7D,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;gBACtC,OAAO,IAAI,KAAK,WAAW,IAAI,CAAA;aAChC;SACF;QACD,IAAI,0BAA0B,CAAC,MAAM,EAAE;YACrC,IAAI,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,oBAAoB,CAAC,CAAC,EAAE;gBAC3G,OAAO,IAAI,sFAAsF;oBAC/F,kGAAkG;oBAClG,0GAA0G;oBAC1G,uEAAuE,CAAA;aAC1E;iBAAM;gBACL,OAAO,IAAI,wFAAwF,CAAA;gBACnG,OAAO,IAAI,uEAAuE,CAAA;gBAClF,KAAK,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,0BAA0B,EAAE;oBAC1E,OAAO,IAAI,KAAK,IAAI,sCAAsC,CAAA;oBAC1D,KAAK,MAAM,qBAAqB,IAAI,uBAAuB,EAAE;wBAC3D,OAAO,IAAI,OAAO,qBAAqB,IAAI,CAAA;qBAC5C;iBACF;aACF;SACF;QACD,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,OAAO,IAAI,gDAAgD,CAAA;YAC3D,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,WAAW,EAAE;gBACzC,OAAO,IAAI,KAAK,IAAI,MAAM,KAAK,IAAI,CAAA;aACpC;SACF;QACD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAA;QAC5D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CACF;AA/CD,oDA+CC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type Module = {
|
|
2
|
+
localDependencies: Array<string>;
|
|
3
|
+
npmDependencies: Array<string>;
|
|
4
|
+
};
|
|
5
|
+
type SupportedFileExtension = '.js' | '.ts';
|
|
6
|
+
declare const JS_RESOLVE_ORDER: string[];
|
|
7
|
+
declare const TS_RESOLVE_ORDER: string[];
|
|
8
|
+
export declare class Parser {
|
|
9
|
+
supportedModules: Set<string>;
|
|
10
|
+
constructor(supportedNpmModules: Array<string>);
|
|
11
|
+
parse(entrypoint: string): {
|
|
12
|
+
entrypoint: {
|
|
13
|
+
filePath: string;
|
|
14
|
+
content: string;
|
|
15
|
+
};
|
|
16
|
+
dependencies: {
|
|
17
|
+
filePath: string;
|
|
18
|
+
content: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
static readDependency(filePath: string, preferedExtenstion: SupportedFileExtension): {
|
|
22
|
+
filePath: string;
|
|
23
|
+
content: string;
|
|
24
|
+
}[];
|
|
25
|
+
static tryReadFileExt(filePath: string, exts: typeof JS_RESOLVE_ORDER | typeof TS_RESOLVE_ORDER): {
|
|
26
|
+
filePath: string;
|
|
27
|
+
content: string;
|
|
28
|
+
}[];
|
|
29
|
+
static parseDependencies(filePath: string, contents: string): {
|
|
30
|
+
module: Module;
|
|
31
|
+
error?: any;
|
|
32
|
+
};
|
|
33
|
+
static jsNodeVisitor(localDependencies: Set<string>, npmDependencies: Set<string>): any;
|
|
34
|
+
static tsNodeVisitor(tsParser: any, localDependencies: Set<string>, npmDependencies: Set<string>): any;
|
|
35
|
+
static isRequireExpression(node: any): boolean;
|
|
36
|
+
static getRequireStringArg(node: any): string | null;
|
|
37
|
+
static registerDependency(importArg: string | null, localDependencies: Set<string>, npmDependencies: Set<string>): void;
|
|
38
|
+
}
|
|
39
|
+
export {};
|