@speedkit/cli 2.9.0 → 2.11.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/CHANGELOG.md +21 -0
- package/README.md +44 -63
- package/dist/commands/build-parameter-query.d.ts +4 -4
- package/dist/commands/build-parameter-query.js +38 -38
- package/dist/commands/build-prewarm-query.d.ts +4 -4
- package/dist/commands/build-prewarm-query.js +33 -34
- package/dist/commands/deploy.d.ts +4 -4
- package/dist/commands/deploy.js +14 -15
- package/dist/commands/find-pops.js +4 -4
- package/dist/commands/generate-pop-config.js +3 -3
- package/dist/commands/login.js +1 -1
- package/dist/commands/pop-prewarm.js +3 -3
- package/dist/commands/prewarm.js +4 -4
- package/dist/commands/wpt-launcher.js +2 -2
- package/dist/helpers/cli-config.d.ts +8 -7
- package/dist/helpers/cli-config.js +50 -44
- package/dist/models/cli-parameters.js +2 -2
- package/dist/services/cli/cli-service.d.ts +4 -4
- package/dist/services/config-api/client.js +1 -1
- package/dist/services/config-api-service.js +1 -1
- package/dist/services/deploy/context/deploy-context.d.ts +1 -4
- package/dist/services/deploy/context/deploy-context.js +6 -7
- package/dist/services/deploy/deploy-service-factory.d.ts +4 -5
- package/dist/services/deploy/deploy-service-factory.js +19 -18
- package/dist/services/integration-api/handler/customer-config-handler.d.ts +3 -3
- package/dist/services/integration-api/handler/customer-config-handler.js +21 -15
- package/dist/services/integration-api/struct/customer-config-file.d.ts +4 -3
- package/dist/services/integration-api/struct/customer-config-file.js +8 -6
- package/dist/services/onboarding/browser/abort-response.js +1 -1
- package/dist/services/onboarding/browser/baqend-response.d.ts +4 -4
- package/dist/services/onboarding/browser/baqend-response.js +33 -25
- package/dist/services/onboarding/browser/origin-response.d.ts +1 -1
- package/dist/services/onboarding/browser/origin-response.js +2 -3
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +4 -4
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +44 -32
- package/dist/services/onboarding/dashboard/athena-service.d.ts +2 -2
- package/dist/services/onboarding/dashboard/athena-service.js +28 -23
- package/dist/services/onboarding/dashboard/index.d.ts +3 -3
- package/dist/services/onboarding/dashboard/index.js +48 -36
- package/dist/services/onboarding/dashboard/param-query-builder.d.ts +2 -2
- package/dist/services/onboarding/dashboard/param-query-builder.js +2 -2
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
- package/dist/services/onboarding/dashboard/request-diff-service.js +32 -28
- package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
- package/dist/services/onboarding/fetch-event-handler.js +72 -62
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +8 -8
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +51 -49
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +3 -3
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +6 -6
- package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +2 -2
- package/dist/services/onboarding/fetch-events/dashboard-request.js +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +7 -7
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +76 -59
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +14 -14
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +6 -6
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +12 -10
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +7 -7
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +4 -4
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +6 -4
- package/dist/services/onboarding/file-events/{fileWatcher.d.ts → file-watcher.d.ts} +9 -8
- package/dist/services/onboarding/file-events/{fileWatcher.js → file-watcher.js} +74 -56
- package/dist/services/onboarding/index.d.ts +3 -3
- package/dist/services/onboarding/onboarding-model.d.ts +36 -34
- package/dist/services/onboarding/onboarding-model.js +19 -19
- package/dist/services/onboarding/onboarding-service-factory.d.ts +6 -6
- package/dist/services/onboarding/onboarding-service-factory.js +80 -75
- package/dist/services/onboarding/onboarding-service.d.ts +7 -7
- package/dist/services/onboarding/onboarding-service.js +54 -48
- package/dist/services/onboarding/request-cache/cache.d.ts +3 -3
- package/dist/services/onboarding/request-cache/cache.js +7 -7
- package/dist/services/onboarding/server-config/index.js +2 -2
- package/dist/services/onboarding/todo-collector.d.ts +1 -1
- package/dist/services/onboarding/todo-collector.js +8 -6
- package/dist/services/prewarm-service.js +2 -2
- package/oclif.manifest.json +9 -9
- package/package.json +24 -23
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SpeedKitInstallContext = void 0;
|
|
4
4
|
const files_1 = require("../../../models/files");
|
|
5
5
|
const IMPORT_PATHS = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"predictive-preloading": "https://www.baqend.com/speed-kit-predictive-preloading/latest/",
|
|
7
|
+
rum: "https://www.baqend.com/rum/latest/",
|
|
8
|
+
"speed-kit": "https://www.baqend.com/speed-kit/latest/",
|
|
9
9
|
};
|
|
10
10
|
class SpeedKitInstallContext {
|
|
11
11
|
customerConfig;
|
|
@@ -22,57 +22,69 @@ class SpeedKitInstallContext {
|
|
|
22
22
|
this.skTemplate = skTemplate;
|
|
23
23
|
this.isLocalRuntime = isLocalRuntime;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
|
|
27
|
+
* downloaded and cached, otherwise the fetcher id returned from cache. The resulting module gets minified afterwards.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
|
|
30
|
+
*/
|
|
31
|
+
async bundleDynamicFetcher() {
|
|
32
|
+
return this.bundler.bundle({
|
|
33
|
+
basePaths: {},
|
|
34
|
+
entryPoints: {
|
|
35
|
+
"dynamicFetcher.js": this.files
|
|
36
|
+
.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
|
|
37
|
+
.getContent(),
|
|
38
|
+
},
|
|
39
|
+
logLevel: "verbose",
|
|
40
|
+
minify: false,
|
|
41
|
+
platform: "browser",
|
|
42
|
+
target: "es6",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
25
45
|
async getSpeedKitInstallJs() {
|
|
26
46
|
const configJs = this.skTemplate.render({
|
|
27
47
|
config: this.getConfigSpeedKit(),
|
|
48
|
+
df: this.files
|
|
49
|
+
.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
|
|
50
|
+
.getContent(),
|
|
51
|
+
domain: this.customerConfig.domain,
|
|
28
52
|
forceInstall: this.customerConfig.forceInstall,
|
|
29
|
-
installPath: this.customerConfig.installPath,
|
|
30
53
|
installParams: this.customerConfig.installParams,
|
|
31
|
-
|
|
32
|
-
df: this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER).getContent(),
|
|
54
|
+
installPath: this.customerConfig.installPath,
|
|
33
55
|
});
|
|
34
56
|
return this.bundler.bundle({
|
|
35
57
|
basePaths: IMPORT_PATHS,
|
|
36
|
-
entryPoints: {
|
|
37
|
-
'rum.js': this.files.getByName(files_1.INTEGRATION_FILES.CONFIG.LOAD_HANDLER).getContent(),
|
|
38
|
-
'config.js': configJs,
|
|
39
|
-
'loader.js': this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.LOADER).getContent(),
|
|
40
|
-
},
|
|
41
|
-
logLevel: 'error',
|
|
42
58
|
define: {
|
|
43
59
|
APP: JSON.stringify(this.customerConfig.app),
|
|
44
60
|
},
|
|
61
|
+
entryPoints: {
|
|
62
|
+
"config.js": configJs,
|
|
63
|
+
"loader.js": this.files
|
|
64
|
+
.getByName(files_1.INTEGRATION_FILES.CUSTOM.LOADER)
|
|
65
|
+
.getContent(),
|
|
66
|
+
"rum.js": this.files
|
|
67
|
+
.getByName(files_1.INTEGRATION_FILES.CONFIG.LOAD_HANDLER)
|
|
68
|
+
.getContent(),
|
|
69
|
+
},
|
|
70
|
+
logLevel: "error",
|
|
45
71
|
});
|
|
46
72
|
}
|
|
47
73
|
getConfigSpeedKit() {
|
|
48
|
-
const configString = this.files
|
|
74
|
+
const configString = this.files
|
|
75
|
+
.getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT)
|
|
76
|
+
.getContent();
|
|
49
77
|
if (!this.isLocalRuntime) {
|
|
50
78
|
return configString;
|
|
51
79
|
}
|
|
52
|
-
if (configString.includes(
|
|
53
|
-
return configString.replace(/delayRacedOrigin:[
|
|
54
|
-
return config.replace(value,
|
|
80
|
+
if (configString.includes("delayRacedOrigin")) {
|
|
81
|
+
return configString.replace(/delayRacedOrigin:[^\d,|](\d*)[^,]*,/, (config, value) => {
|
|
82
|
+
return config.replace(value, "100");
|
|
55
83
|
});
|
|
56
84
|
}
|
|
57
85
|
return configString.replace(/window\.speedKit[^{]*=[^{]*{/, (configOpenTag) => {
|
|
58
86
|
return configOpenTag + `\n delayRacedOrigin: 100,\n`;
|
|
59
87
|
});
|
|
60
88
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
|
|
63
|
-
* downloaded and cached, otherwise the fetcher id returned from cache. The resulting module gets minified afterwards.
|
|
64
|
-
*
|
|
65
|
-
* @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
|
|
66
|
-
*/
|
|
67
|
-
async bundleDynamicFetcher() {
|
|
68
|
-
return this.bundler.bundle({
|
|
69
|
-
basePaths: {},
|
|
70
|
-
entryPoints: { "dynamicFetcher.js": this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER).getContent() },
|
|
71
|
-
target: "es6",
|
|
72
|
-
logLevel: 'verbose',
|
|
73
|
-
minify: false,
|
|
74
|
-
platform: "browser",
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
89
|
}
|
|
78
90
|
exports.SpeedKitInstallContext = SpeedKitInstallContext;
|
|
@@ -5,7 +5,7 @@ export declare class AthenaService {
|
|
|
5
5
|
private cli;
|
|
6
6
|
private lastQueryResult;
|
|
7
7
|
constructor(athena: Athena, cli: CliService);
|
|
8
|
-
executeQuery(queryString: string): Promise<
|
|
8
|
+
executeQuery(queryString: string): Promise<unknown[]>;
|
|
9
|
+
getLastQueryResult(): unknown[];
|
|
9
10
|
private fetchResult;
|
|
10
|
-
getLastQueryResult(): any[];
|
|
11
11
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AthenaService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const cli_1 = require("../../cli");
|
|
5
|
+
const node_util_1 = tslib_1.__importDefault(require("node:util"));
|
|
7
6
|
const safe_1 = require("../../../helpers/safe");
|
|
8
|
-
const
|
|
7
|
+
const cli_1 = require("../../cli");
|
|
8
|
+
const sleep = node_util_1.default.promisify(setTimeout);
|
|
9
9
|
class AthenaService {
|
|
10
10
|
athena;
|
|
11
11
|
cli;
|
|
@@ -18,13 +18,13 @@ class AthenaService {
|
|
|
18
18
|
if (this.lastQueryResult.length > 0) {
|
|
19
19
|
return this.lastQueryResult;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
QueryString: queryString,
|
|
21
|
+
const params = {
|
|
23
22
|
QueryExecutionContext: {
|
|
24
|
-
Database: "rum.pi"
|
|
23
|
+
Database: "rum.pi",
|
|
25
24
|
},
|
|
25
|
+
QueryString: queryString,
|
|
26
26
|
};
|
|
27
|
-
this.cli.startAction(
|
|
27
|
+
this.cli.startAction("[athena-query]: fetch result");
|
|
28
28
|
const result = await (0, safe_1.safe)(this.fetchResult(params));
|
|
29
29
|
if (result.success === true) {
|
|
30
30
|
this.lastQueryResult = result.data;
|
|
@@ -34,37 +34,42 @@ class AthenaService {
|
|
|
34
34
|
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
35
35
|
this.cli.writeError(result.error);
|
|
36
36
|
}
|
|
37
|
+
getLastQueryResult() {
|
|
38
|
+
return this.lastQueryResult;
|
|
39
|
+
}
|
|
37
40
|
async fetchResult(params) {
|
|
38
|
-
|
|
39
|
-
let queryStatus = await this.athena.getQueryExecution({
|
|
40
|
-
|
|
41
|
+
const request = await this.athena.startQueryExecution(params);
|
|
42
|
+
let queryStatus = await this.athena.getQueryExecution({
|
|
43
|
+
QueryExecutionId: request.QueryExecutionId,
|
|
44
|
+
});
|
|
45
|
+
while (queryStatus.QueryExecution.Status.State === "QUEUED" ||
|
|
46
|
+
queryStatus.QueryExecution.Status.State === "RUNNING") {
|
|
41
47
|
await sleep(2000);
|
|
42
|
-
queryStatus = await this.athena.getQueryExecution({
|
|
48
|
+
queryStatus = await this.athena.getQueryExecution({
|
|
49
|
+
QueryExecutionId: request.QueryExecutionId,
|
|
50
|
+
});
|
|
43
51
|
}
|
|
44
52
|
const queryParams = {
|
|
45
53
|
QueryExecutionId: request.QueryExecutionId,
|
|
46
54
|
// MaxResults: 10
|
|
47
55
|
};
|
|
48
|
-
|
|
56
|
+
const queryResult = await this.athena.getQueryResults(queryParams);
|
|
49
57
|
// transform result and return it
|
|
50
|
-
|
|
51
|
-
queryResult.ResultSet.Rows
|
|
52
|
-
|
|
53
|
-
params: recordRow.Data[0].VarCharValue,
|
|
54
|
-
potentialGain: recordRow.Data[1].VarCharValue,
|
|
55
|
-
cachedUrls: recordRow.Data[2].VarCharValue,
|
|
58
|
+
const dataArray = [];
|
|
59
|
+
for (const recordRow of queryResult.ResultSet.Rows) {
|
|
60
|
+
const object = {
|
|
56
61
|
PIs: recordRow.Data[3].VarCharValue,
|
|
62
|
+
cachedUrls: recordRow.Data[2].VarCharValue,
|
|
57
63
|
example1: recordRow.Data[4].VarCharValue,
|
|
58
64
|
example2: recordRow.Data[5].VarCharValue,
|
|
59
|
-
example3: recordRow.Data[6].VarCharValue
|
|
65
|
+
example3: recordRow.Data[6].VarCharValue,
|
|
66
|
+
params: recordRow.Data[0].VarCharValue,
|
|
67
|
+
potentialGain: recordRow.Data[1].VarCharValue,
|
|
60
68
|
};
|
|
61
69
|
// into an array....
|
|
62
70
|
dataArray.push(object);
|
|
63
|
-
}
|
|
71
|
+
}
|
|
64
72
|
return dataArray;
|
|
65
73
|
}
|
|
66
|
-
getLastQueryResult() {
|
|
67
|
-
return this.lastQueryResult;
|
|
68
|
-
}
|
|
69
74
|
}
|
|
70
75
|
exports.AthenaService = AthenaService;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaqendResponse } from "../browser/baqend-response";
|
|
2
1
|
import { Protocol } from "devtools-protocol";
|
|
3
|
-
import { ParamQueryBuilder } from "./param-query-builder";
|
|
4
2
|
import CustomerConfig from "../../integration-api/struct/customer-config";
|
|
3
|
+
import { BaqendResponse } from "../browser/baqend-response";
|
|
4
|
+
import { Cache } from "../request-cache/cache";
|
|
5
5
|
import { AthenaService } from "./athena-service";
|
|
6
|
+
import { ParamQueryBuilder } from "./param-query-builder";
|
|
6
7
|
import { RequestDiffService } from "./request-diff-service";
|
|
7
|
-
import { Cache } from "../request-cache/cache";
|
|
8
8
|
export declare class Dashboard {
|
|
9
9
|
private customerConfig;
|
|
10
10
|
private paramQueryBuilder;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Dashboard = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const baqend_response_1 = require("../browser/baqend-response");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
-
const safe_1 = require("../../../helpers/safe");
|
|
9
5
|
const json2csv_1 = tslib_1.__importDefault(require("json2csv"));
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
8
|
+
const safe_1 = require("../../../helpers/safe");
|
|
9
|
+
const baqend_response_1 = require("../browser/baqend-response");
|
|
10
10
|
class Dashboard {
|
|
11
11
|
customerConfig;
|
|
12
12
|
paramQueryBuilder;
|
|
@@ -22,57 +22,69 @@ class Dashboard {
|
|
|
22
22
|
}
|
|
23
23
|
async getResponse(request) {
|
|
24
24
|
const url = new URL(request.url);
|
|
25
|
-
if (url.pathname ===
|
|
26
|
-
const filePath =
|
|
27
|
-
const content = (0,
|
|
25
|
+
if (url.pathname === "/") {
|
|
26
|
+
const filePath = node_path_1.default.join(__dirname, "./frontend-dist", "index.html");
|
|
27
|
+
const content = (0, node_fs_1.readFileSync)(filePath, { encoding: "utf8" });
|
|
28
28
|
return new baqend_response_1.BaqendResponse(content);
|
|
29
29
|
}
|
|
30
|
-
if (url.pathname.startsWith(
|
|
31
|
-
const filePath =
|
|
32
|
-
const content = (0,
|
|
33
|
-
let contentType =
|
|
34
|
-
if (url.pathname.includes(
|
|
35
|
-
contentType =
|
|
30
|
+
if (url.pathname.startsWith("/assets/")) {
|
|
31
|
+
const filePath = node_path_1.default.join(__dirname, "./frontend-dist", url.pathname);
|
|
32
|
+
const content = (0, node_fs_1.readFileSync)(filePath, { encoding: "utf8" });
|
|
33
|
+
let contentType = "application/javascript; charset=UTF-8";
|
|
34
|
+
if (url.pathname.includes(".css")) {
|
|
35
|
+
contentType = "text/css";
|
|
36
36
|
}
|
|
37
37
|
return new baqend_response_1.BaqendResponse(content, contentType);
|
|
38
38
|
}
|
|
39
|
-
if (url.pathname.startsWith(
|
|
40
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify({ query: this.paramQueryBuilder.getQuery() }),
|
|
39
|
+
if (url.pathname.startsWith("/query/create")) {
|
|
40
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify({ query: this.paramQueryBuilder.getQuery() }), "application/json; charset=UTF-8");
|
|
41
41
|
}
|
|
42
|
-
if (url.pathname.startsWith(
|
|
43
|
-
const postData = request
|
|
42
|
+
if (url.pathname.startsWith("/query/execute")) {
|
|
43
|
+
const { postData } = request;
|
|
44
44
|
const data = JSON.parse(postData);
|
|
45
45
|
const response = await (0, safe_1.safe)(this.athenaClient.executeQuery(data.query));
|
|
46
46
|
if (response.success === true) {
|
|
47
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify(response.data),
|
|
47
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify(response.data), "application/json; charset=UTF-8");
|
|
48
48
|
}
|
|
49
|
-
return new baqend_response_1.BaqendResponse(response.error, null, [{ name:
|
|
49
|
+
return new baqend_response_1.BaqendResponse(response.error, null, [{ name: "x-error", value: response.error }], 500);
|
|
50
50
|
}
|
|
51
|
-
if (url.pathname.startsWith(
|
|
51
|
+
if (url.pathname.startsWith("/query/download")) {
|
|
52
52
|
const result = this.athenaClient.getLastQueryResult();
|
|
53
53
|
result.shift();
|
|
54
|
-
const csv = json2csv_1.default.parse(result, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const csv = json2csv_1.default.parse(result, {
|
|
55
|
+
fields: [
|
|
56
|
+
"params",
|
|
57
|
+
"potentialGain",
|
|
58
|
+
"cachedUrls",
|
|
59
|
+
"PIs",
|
|
60
|
+
"example1",
|
|
61
|
+
"example2",
|
|
62
|
+
"example3",
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
return new baqend_response_1.BaqendResponse(csv, "application/csv", [
|
|
66
|
+
{
|
|
67
|
+
name: "Content-disposition",
|
|
68
|
+
value: `attachment; filename=parameter-${this.customerConfig.app}.csv`,
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
59
71
|
}
|
|
60
|
-
if (url.pathname.startsWith(
|
|
61
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify(this.customerConfig),
|
|
72
|
+
if (url.pathname.startsWith("/api/config")) {
|
|
73
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify(this.customerConfig), "application/json; charset=UTF-8");
|
|
62
74
|
}
|
|
63
|
-
if (url.pathname.startsWith(
|
|
64
|
-
const postData = request
|
|
75
|
+
if (url.pathname.startsWith("/diff")) {
|
|
76
|
+
const { postData } = request;
|
|
65
77
|
const data = JSON.parse(postData);
|
|
66
|
-
return
|
|
78
|
+
return this.requestDiffService.postDiff(data.url, data.params);
|
|
67
79
|
}
|
|
68
|
-
if (url.pathname.startsWith(
|
|
80
|
+
if (url.pathname.startsWith("/cache/get")) {
|
|
69
81
|
const response = [];
|
|
70
|
-
|
|
71
|
-
response.push({
|
|
72
|
-
}
|
|
73
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify(response),
|
|
82
|
+
for (const [url, baqendResponse] of this.cache.getAll()) {
|
|
83
|
+
response.push({ response: baqendResponse, url });
|
|
84
|
+
}
|
|
85
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify(response), "application/json; charset=UTF-8");
|
|
74
86
|
}
|
|
75
|
-
return new baqend_response_1.BaqendResponse(
|
|
87
|
+
return new baqend_response_1.BaqendResponse("Not implemented");
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
exports.Dashboard = Dashboard;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConfigFileInterface } from
|
|
2
|
-
import CustomerConfig from
|
|
1
|
+
import { ConfigFileInterface } from "../../integration-api/integration-api-model";
|
|
2
|
+
import CustomerConfig from "../../integration-api/struct/customer-config";
|
|
3
3
|
export declare class ParamQueryBuilder {
|
|
4
4
|
private customerConfig;
|
|
5
5
|
private speedKitConfigFile;
|
|
@@ -12,8 +12,8 @@ class ParamQueryBuilder {
|
|
|
12
12
|
}
|
|
13
13
|
buildParameterQuery(app, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter) {
|
|
14
14
|
const nowMinusOneMonth = new Date(new Date().setMonth(new Date().getMonth() - 1, new Date().getDate()));
|
|
15
|
-
const monthString = `${nowMinusOneMonth.getMonth() + 1 < 10 ?
|
|
16
|
-
const dateString = `${nowMinusOneMonth.getDate() < 10 ?
|
|
15
|
+
const monthString = `${nowMinusOneMonth.getMonth() + 1 < 10 ? "0" : ""}${nowMinusOneMonth.getMonth() + 1}`;
|
|
16
|
+
const dateString = `${nowMinusOneMonth.getDate() < 10 ? "0" : ""}${nowMinusOneMonth.getDate()}`;
|
|
17
17
|
const date = `${nowMinusOneMonth.getFullYear()}-${monthString}-${dateString}`;
|
|
18
18
|
return `
|
|
19
19
|
with urlWithParams as (
|
|
@@ -4,8 +4,8 @@ export declare class RequestDiffService {
|
|
|
4
4
|
private diffService;
|
|
5
5
|
constructor(diffService: DiffService);
|
|
6
6
|
postDiff(url: string, parametersString: string): Promise<BaqendResponse>;
|
|
7
|
+
private createUrlsForDiff;
|
|
7
8
|
private diffLocal;
|
|
8
9
|
private doOriginVsContentDiff;
|
|
9
10
|
private fetchHtml;
|
|
10
|
-
private createUrlsForDiff;
|
|
11
11
|
}
|
|
@@ -1,59 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequestDiffService = void 0;
|
|
4
|
-
const baqend_response_1 = require("../browser/baqend-response");
|
|
5
4
|
const safe_1 = require("../../../helpers/safe");
|
|
5
|
+
const baqend_response_1 = require("../browser/baqend-response");
|
|
6
6
|
class RequestDiffService {
|
|
7
7
|
diffService;
|
|
8
8
|
constructor(diffService) {
|
|
9
9
|
this.diffService = diffService;
|
|
10
10
|
}
|
|
11
11
|
async postDiff(url, parametersString) {
|
|
12
|
-
const params = parametersString
|
|
12
|
+
const params = parametersString
|
|
13
|
+
.replace("[", "")
|
|
14
|
+
.replace("]", "")
|
|
15
|
+
.split(",")
|
|
16
|
+
.map((param) => {
|
|
13
17
|
return param.trim();
|
|
14
18
|
});
|
|
15
19
|
const { urlWithParam, urlWithoutParam } = this.createUrlsForDiff(url, params);
|
|
16
20
|
const result = await (0, safe_1.safe)(this.diffLocal(urlWithParam, urlWithoutParam));
|
|
17
21
|
if (result.success === true) {
|
|
18
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify({
|
|
22
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify({ isIdentical: result.data, status: "success" }), "application/json; charset=UTF-8");
|
|
19
23
|
}
|
|
20
|
-
return new baqend_response_1.BaqendResponse(JSON.stringify({
|
|
21
|
-
}
|
|
22
|
-
async diffLocal(urlWithParam, urlWithoutParam) {
|
|
23
|
-
const htmlWithParam = await this.fetchHtml(urlWithParam);
|
|
24
|
-
const htmlWithoutParam = await this.fetchHtml(urlWithoutParam);
|
|
25
|
-
const paramsFilePath = await this.diffService.writeContentToTemporalFile('params', htmlWithParam);
|
|
26
|
-
const pureFilePath = await this.diffService.writeContentToTemporalFile('pure', htmlWithoutParam);
|
|
27
|
-
return await this.diffService.executeDiff(paramsFilePath, pureFilePath);
|
|
28
|
-
}
|
|
29
|
-
async doOriginVsContentDiff(url, content) {
|
|
30
|
-
const html = await this.fetchHtml(url);
|
|
31
|
-
const origin = await this.diffService.writeContentToTemporalFile('origin', html);
|
|
32
|
-
const local = await this.diffService.writeContentToTemporalFile('content', content);
|
|
33
|
-
return await this.diffService.executeDiff(local, origin);
|
|
34
|
-
}
|
|
35
|
-
async fetchHtml(url) {
|
|
36
|
-
const response = await fetch(url);
|
|
37
|
-
return await response.text();
|
|
24
|
+
return new baqend_response_1.BaqendResponse(JSON.stringify({ error: result.error, status: "error" }), "application/json; charset=UTF-8", null, 500);
|
|
38
25
|
}
|
|
39
26
|
createUrlsForDiff(urlWithParam, params) {
|
|
40
27
|
const url = new URL(urlWithParam);
|
|
41
|
-
const
|
|
28
|
+
const { searchParams } = url;
|
|
42
29
|
for (const param of params) {
|
|
43
|
-
|
|
30
|
+
searchParams.delete(param);
|
|
44
31
|
}
|
|
45
|
-
url.search =
|
|
32
|
+
url.search = searchParams.toString();
|
|
46
33
|
const urlWithoutParam = url.toString();
|
|
47
|
-
console.log(
|
|
34
|
+
console.log("With-----");
|
|
48
35
|
console.log(urlWithParam);
|
|
49
|
-
console.log(
|
|
36
|
+
console.log("Without-----");
|
|
50
37
|
console.log(urlWithoutParam);
|
|
51
|
-
console.log(
|
|
38
|
+
console.log("-----");
|
|
52
39
|
// TODO: Insert the content
|
|
53
40
|
return {
|
|
54
41
|
urlWithParam,
|
|
55
|
-
urlWithoutParam
|
|
42
|
+
urlWithoutParam,
|
|
56
43
|
};
|
|
57
44
|
}
|
|
45
|
+
async diffLocal(urlWithParam, urlWithoutParam) {
|
|
46
|
+
const htmlWithParam = await this.fetchHtml(urlWithParam);
|
|
47
|
+
const htmlWithoutParam = await this.fetchHtml(urlWithoutParam);
|
|
48
|
+
const paramsFilePath = await this.diffService.writeContentToTemporalFile("params", htmlWithParam);
|
|
49
|
+
const pureFilePath = await this.diffService.writeContentToTemporalFile("pure", htmlWithoutParam);
|
|
50
|
+
return this.diffService.executeDiff(paramsFilePath, pureFilePath);
|
|
51
|
+
}
|
|
52
|
+
async doOriginVsContentDiff(url, content) {
|
|
53
|
+
const html = await this.fetchHtml(url);
|
|
54
|
+
const origin = await this.diffService.writeContentToTemporalFile("origin", html);
|
|
55
|
+
const local = await this.diffService.writeContentToTemporalFile("content", content);
|
|
56
|
+
return this.diffService.executeDiff(local, origin);
|
|
57
|
+
}
|
|
58
|
+
async fetchHtml(url) {
|
|
59
|
+
const response = await fetch(url);
|
|
60
|
+
return response.text();
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
exports.RequestDiffService = RequestDiffService;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { FetchRequestPausedEventHandler } from "./onboarding-model";
|
|
2
|
-
import { Protocol } from "puppeteer-core";
|
|
3
1
|
import { CDPSession, Target } from "puppeteer";
|
|
2
|
+
import { Protocol } from "puppeteer-core";
|
|
4
3
|
import { CliService } from "../cli";
|
|
5
|
-
import CustomerConfig from "../integration-api/struct/customer-config";
|
|
6
4
|
import ConfigApiService from "../config-api/config-api-service";
|
|
5
|
+
import CustomerConfig from "../integration-api/struct/customer-config";
|
|
6
|
+
import { FetchRequestPausedEventHandler } from "./onboarding-model";
|
|
7
7
|
export declare class FetchEventHandler {
|
|
8
8
|
private browserFetchEvents;
|
|
9
9
|
private customerConfig;
|
|
10
10
|
private cli;
|
|
11
11
|
private client?;
|
|
12
12
|
constructor(browserFetchEvents: FetchRequestPausedEventHandler[], customerConfig: CustomerConfig, cli: CliService, client?: ConfigApiService);
|
|
13
|
+
getAuthPattern(): Protocol.Fetch.RequestPattern[];
|
|
13
14
|
handleRequestFetchEvents(target: Target): Promise<void>;
|
|
15
|
+
sendDefaultAuthBehaviour(browserClient: CDPSession, requestId: string): Promise<void>;
|
|
14
16
|
private canHandlePattern;
|
|
15
|
-
private onFetchRequestPaused;
|
|
16
|
-
getAuthPattern(): Protocol.Fetch.RequestPattern[];
|
|
17
17
|
private onFetchAuthRequired;
|
|
18
|
-
|
|
18
|
+
private onFetchRequestPaused;
|
|
19
19
|
}
|