@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileWatcher = void 0;
|
|
4
4
|
const safe_1 = require("../../../helpers/safe");
|
|
5
|
-
const virtual_file_1 = require("../../integration-api/struct/virtual-file");
|
|
6
5
|
const files_1 = require("../../../models/files");
|
|
6
|
+
const virtual_file_1 = require("../../integration-api/struct/virtual-file");
|
|
7
7
|
/**
|
|
8
8
|
* Add different callbacks that will be executed if a local file is changed.
|
|
9
9
|
*/
|
|
@@ -28,66 +28,88 @@ class FileWatcher {
|
|
|
28
28
|
this.handleGenericConfigFiles(page, installResource);
|
|
29
29
|
this.handleDynamicStyles(page);
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
async clearPageFunction(page) {
|
|
32
|
+
const client = await page.target().createCDPSession();
|
|
33
|
+
const cacheResponse = await client.send("CacheStorage.requestCacheNames", {
|
|
34
|
+
securityOrigin: this.browserContext.domain,
|
|
35
|
+
});
|
|
36
|
+
for (const cache of cacheResponse.caches) {
|
|
37
|
+
if (cache.cacheName.includes("baqend")) {
|
|
38
|
+
await client.send("CacheStorage.deleteCache", {
|
|
39
|
+
cacheId: cache.cacheId,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async clearServiceWorker(page) {
|
|
45
|
+
const client = await page.target().createCDPSession();
|
|
46
|
+
await client.send("ServiceWorker.enable");
|
|
47
|
+
await client.send("ServiceWorker.unregister", {
|
|
48
|
+
scopeURL: `https://${this.customerConfig.domain}`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
handleDynamicStyles(page) {
|
|
52
|
+
if (!this.files.hasFile(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// add watcher that will instantly add changes to current page
|
|
56
|
+
this.files
|
|
57
|
+
.getByName(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES)
|
|
58
|
+
.onChange(async (file) => {
|
|
59
|
+
const result = await (0, safe_1.safe)(this.onChangeDynamicStyleCallback(file, page));
|
|
60
|
+
if (result.success === false) {
|
|
61
|
+
this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
handleGenericConfigFiles(page, installResource) {
|
|
66
|
+
// add watcher to configFiles
|
|
67
|
+
const generalConfigFiles = [
|
|
68
|
+
files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_BLOCKS,
|
|
69
|
+
files_1.INTEGRATION_FILES.CONFIG.DOCUMENT_HANDLER,
|
|
70
|
+
files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
71
|
+
files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
72
|
+
];
|
|
73
|
+
for (const configFile of generalConfigFiles) {
|
|
74
|
+
if (!this.files.hasFile(configFile)) {
|
|
36
75
|
continue;
|
|
37
76
|
}
|
|
38
|
-
const file = this.files.getByName(
|
|
77
|
+
const file = this.files.getByName(configFile);
|
|
39
78
|
if (file.type === virtual_file_1.VirtualFile) {
|
|
40
79
|
continue;
|
|
41
80
|
}
|
|
42
81
|
file.onChange(async (file) => {
|
|
43
|
-
const result = await (0, safe_1.safe)(this.
|
|
82
|
+
const result = await (0, safe_1.safe)(this.onChangeConfigFileCallback(page, installResource, file));
|
|
44
83
|
if (result.success === false) {
|
|
45
84
|
this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
|
|
46
85
|
}
|
|
47
86
|
});
|
|
48
87
|
}
|
|
49
88
|
}
|
|
50
|
-
|
|
51
|
-
// add watcher to
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
89
|
+
handleServiceWorkerDependencies(page, installResource, serviceWorkerReinstallCallback) {
|
|
90
|
+
// add watcher to serviceWorker related files
|
|
91
|
+
const serviceWorkerDependencies = [
|
|
92
|
+
files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT,
|
|
93
|
+
files_1.INTEGRATION_FILES.CONFIG.LOAD_HANDLER,
|
|
94
|
+
files_1.INTEGRATION_FILES.CUSTOM.LOADER,
|
|
95
|
+
files_1.INTEGRATION_FILES.CUSTOM.SW,
|
|
96
|
+
];
|
|
97
|
+
for (const dependency of serviceWorkerDependencies) {
|
|
98
|
+
if (!this.files.hasFile(dependency)) {
|
|
55
99
|
continue;
|
|
56
100
|
}
|
|
57
|
-
const file = this.files.getByName(
|
|
101
|
+
const file = this.files.getByName(dependency);
|
|
58
102
|
if (file.type === virtual_file_1.VirtualFile) {
|
|
59
103
|
continue;
|
|
60
104
|
}
|
|
61
105
|
file.onChange(async (file) => {
|
|
62
|
-
const result = await (0, safe_1.safe)(this.
|
|
106
|
+
const result = await (0, safe_1.safe)(this.onChangeServiceWorkerCallback(file, page, installResource, serviceWorkerReinstallCallback));
|
|
63
107
|
if (result.success === false) {
|
|
64
108
|
this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
|
|
65
109
|
}
|
|
66
110
|
});
|
|
67
111
|
}
|
|
68
112
|
}
|
|
69
|
-
handleDynamicStyles(page) {
|
|
70
|
-
if (!this.files.hasFile(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
// add watcher that will instantly add changes to current page
|
|
74
|
-
this.files.getByName(files_1.INTEGRATION_FILES.CONFIG.DYNAMIC_STYLES).onChange(async (file) => {
|
|
75
|
-
const result = await (0, safe_1.safe)(this.onChangeDynamicStyleCallback(file, page));
|
|
76
|
-
if (result.success === false) {
|
|
77
|
-
this.cli.writeError(`error after fileChange: ${file.name}: ${result.error}`);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async onChangeServiceWorkerCallback(file, page, installResource, serviceWorkerReinstallCallback) {
|
|
82
|
-
this.cli.writeWarning(`changed file: ${file.name} (reinstall serviceWorker)`);
|
|
83
|
-
// clear speed-kit-service-worker-caches and uninstall serviceWorker
|
|
84
|
-
await this.clearPageFunction(page);
|
|
85
|
-
await this.clearServiceWorker(page);
|
|
86
|
-
// rebuild installResource
|
|
87
|
-
await installResource.buildContent();
|
|
88
|
-
// tell puppeteer to reinstall serviceworker on next navigate
|
|
89
|
-
await serviceWorkerReinstallCallback(file);
|
|
90
|
-
}
|
|
91
113
|
async onChangeConfigFileCallback(page, installResource, file) {
|
|
92
114
|
await this.clearPageFunction(page);
|
|
93
115
|
await this.documentHandler.buildDocumentHandler();
|
|
@@ -98,13 +120,7 @@ class FileWatcher {
|
|
|
98
120
|
async onChangeDynamicStyleCallback(file, page) {
|
|
99
121
|
this.cli.writeWarning(`changed file: ${file.name} (update styles on page)`);
|
|
100
122
|
const escapedStyles = encodeURI(file.getContent());
|
|
101
|
-
|
|
102
|
-
const styleElement = document.querySelector('#speed-kit-df-styles');
|
|
103
|
-
if (styleElement) {
|
|
104
|
-
styleElement.textContent = decodeURI(styles);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const evaluateResult = await (0, safe_1.safe)(page.evaluate(`(${updateStyles.toString()})("${escapedStyles}");`));
|
|
123
|
+
const evaluateResult = await (0, safe_1.safe)(page.evaluate(`(${this.updateStyles.toString()})("${escapedStyles}");`));
|
|
108
124
|
if (evaluateResult.success === false) {
|
|
109
125
|
this.cli.writeError(evaluateResult.error);
|
|
110
126
|
}
|
|
@@ -115,19 +131,21 @@ class FileWatcher {
|
|
|
115
131
|
await this.documentHandler.buildDocumentHandler();
|
|
116
132
|
this.cache.clear();
|
|
117
133
|
}
|
|
118
|
-
async
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
async onChangeServiceWorkerCallback(file, page, installResource, serviceWorkerReinstallCallback) {
|
|
135
|
+
this.cli.writeWarning(`changed file: ${file.name} (reinstall serviceWorker)`);
|
|
136
|
+
// clear speed-kit-service-worker-caches and uninstall serviceWorker
|
|
137
|
+
await this.clearPageFunction(page);
|
|
138
|
+
await this.clearServiceWorker(page);
|
|
139
|
+
// rebuild installResource
|
|
140
|
+
await installResource.buildContent();
|
|
141
|
+
// tell puppeteer to reinstall serviceworker on next navigate
|
|
142
|
+
await serviceWorkerReinstallCallback(file);
|
|
126
143
|
}
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
144
|
+
updateStyles(styles) {
|
|
145
|
+
const styleElement = document.querySelector("#speed-kit-df-styles");
|
|
146
|
+
if (styleElement) {
|
|
147
|
+
styleElement.textContent = decodeURI(styles);
|
|
148
|
+
}
|
|
131
149
|
}
|
|
132
150
|
}
|
|
133
151
|
exports.FileWatcher = FileWatcher;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { OnboardingContext } from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export { OnboardingContext } from "./onboarding-model";
|
|
2
|
+
export * from "./onboarding-service";
|
|
3
|
+
export * from "./onboarding-service-factory";
|
|
@@ -1,69 +1,71 @@
|
|
|
1
|
-
import { Protocol } from "puppeteer-core";
|
|
2
1
|
import { CDPSession } from "puppeteer";
|
|
2
|
+
import { Protocol } from "puppeteer-core";
|
|
3
|
+
import { UserCliConfig } from "../../helpers/cli-config";
|
|
3
4
|
import { AbortResponse } from "./browser/abort-response";
|
|
4
5
|
export declare class BrowserContext {
|
|
5
6
|
readonly domain: string;
|
|
6
7
|
readonly chromeFlags?: string[];
|
|
8
|
+
readonly userConfig?: UserCliConfig;
|
|
7
9
|
readonly browserArgs: string[];
|
|
8
10
|
readonly chromePath: string;
|
|
9
11
|
startParameterDashboard: boolean;
|
|
10
|
-
constructor(domain: string, chromeFlags?: string[]);
|
|
12
|
+
constructor(domain: string, chromeFlags?: string[], userConfig?: UserCliConfig);
|
|
11
13
|
}
|
|
12
14
|
export interface FetchRequestPausedEventHandler {
|
|
15
|
+
handle(event: Protocol.Fetch.RequestPausedEvent, client: CDPSession): Promise<AbortResponse | Partial<Protocol.Fetch.FulfillRequestRequest> | void>;
|
|
13
16
|
readonly patterns: Protocol.Fetch.RequestPattern[];
|
|
14
|
-
handle(event: Protocol.Fetch.RequestPausedEvent, client: CDPSession): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse | void>;
|
|
15
17
|
}
|
|
16
18
|
export declare class OnboardingContext {
|
|
17
19
|
readonly customerPath: string;
|
|
18
20
|
readonly configName: string;
|
|
19
21
|
readonly local: boolean;
|
|
20
22
|
readonly verboseLevel?: boolean;
|
|
21
|
-
readonly DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
22
|
-
readonly DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
23
23
|
readonly DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
24
24
|
readonly DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
25
|
+
readonly DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
26
|
+
readonly DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
25
27
|
constructor(customerPath: string, configName: string, local: boolean, verboseLevel?: boolean);
|
|
26
28
|
}
|
|
27
29
|
export type awsCredentials = {
|
|
28
|
-
region: string;
|
|
29
30
|
accessKeyId: string;
|
|
31
|
+
region: string;
|
|
30
32
|
secretAccessKey: string;
|
|
31
33
|
};
|
|
32
34
|
export type SpeedKitServerConfigAuthentication = {
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
password: string;
|
|
36
|
+
type: "basic";
|
|
37
|
+
uri: string;
|
|
38
|
+
user: string;
|
|
37
39
|
};
|
|
38
40
|
export type SpeedKitServerConfigVariation = {
|
|
39
41
|
[key: string]: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
encodePrefixedUrl?: boolean;
|
|
43
|
+
headers?: {
|
|
44
|
+
cookie?: string;
|
|
42
45
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"regex"?: null | string;
|
|
46
|
+
queryParams?: [];
|
|
47
|
+
regex?: null | string;
|
|
48
|
+
urlPrefix?: string;
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
export type SpeedKitServerConfig = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
speedKit: {
|
|
53
|
+
assetRequestRateLimitLowerTTFBLimit: number;
|
|
54
|
+
assetRequestRateLimitUpperTTFBLimit: number;
|
|
55
|
+
assetRequestRateScaleDownFactor: number;
|
|
56
|
+
assetRequestRateScaleUpStep: number;
|
|
57
|
+
assetStreamingRateLimitTimeoutMs: 2000;
|
|
58
|
+
authentications: SpeedKitServerConfigAuthentication[];
|
|
59
|
+
defaultAssetRequestsPerSecond: number;
|
|
60
|
+
globalMaxAssetRequestsPerSecond: number;
|
|
61
|
+
globalMinAssetRequestsPerSecond: number;
|
|
62
|
+
httpAuthPass: null | string;
|
|
63
|
+
httpAuthType: "basic";
|
|
64
|
+
httpAuthURI: null | string;
|
|
65
|
+
httpAuthUser: null | string;
|
|
66
|
+
maxRevalidationWindowSize: number;
|
|
67
|
+
minMaxAge: number;
|
|
68
|
+
streamRateLimit: number;
|
|
69
|
+
variations: SpeedKitServerConfigVariation;
|
|
68
70
|
};
|
|
69
71
|
};
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OnboardingContext = exports.BrowserContext = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const dotenv = tslib_1.__importStar(require("dotenv"));
|
|
6
|
-
dotenv.config();
|
|
7
4
|
const DEFAULT_BROWSER_ARGS = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
"--enable-features=NetworkService",
|
|
6
|
+
"--no-first-run",
|
|
7
|
+
"--disable-infobars",
|
|
11
8
|
];
|
|
12
|
-
if (process.env.SPEED_KIT_EXTENSION_PATH) {
|
|
13
|
-
DEFAULT_BROWSER_ARGS.push(`--load-extension=${process.env.SPEED_KIT_EXTENSION_PATH}`, `--disable-extensions-except=${process.env.SPEED_KIT_EXTENSION_PATH}`);
|
|
14
|
-
}
|
|
15
|
-
if (process.env.CHROME_USER_PROFILE_PATH) {
|
|
16
|
-
DEFAULT_BROWSER_ARGS.push(`--user-data-dir=${process.env.CHROME_USER_PROFILE_PATH}`);
|
|
17
|
-
}
|
|
18
9
|
class BrowserContext {
|
|
19
10
|
domain;
|
|
20
11
|
chromeFlags;
|
|
12
|
+
userConfig;
|
|
21
13
|
browserArgs;
|
|
22
14
|
chromePath;
|
|
23
15
|
startParameterDashboard = false;
|
|
24
|
-
constructor(domain, chromeFlags) {
|
|
16
|
+
constructor(domain, chromeFlags, userConfig) {
|
|
25
17
|
this.domain = domain;
|
|
26
18
|
this.chromeFlags = chromeFlags;
|
|
19
|
+
this.userConfig = userConfig;
|
|
27
20
|
this.domain = domain;
|
|
28
21
|
this.chromeFlags = chromeFlags || [];
|
|
29
|
-
this.chromePath =
|
|
22
|
+
this.chromePath = userConfig.chromePath;
|
|
23
|
+
const browserArgs = DEFAULT_BROWSER_ARGS;
|
|
24
|
+
if (userConfig?.chromeExtensionPaths) {
|
|
25
|
+
browserArgs.push(`--load-extension=${userConfig?.chromeExtensionPaths}`, `--disable-extensions-except=${userConfig?.chromeExtensionPaths}`);
|
|
26
|
+
}
|
|
27
|
+
if (userConfig?.chromeUserProfilePath) {
|
|
28
|
+
browserArgs.push(`--user-data-dir=${userConfig?.chromeUserProfilePath}`);
|
|
29
|
+
}
|
|
30
30
|
this.browserArgs = [
|
|
31
|
-
...
|
|
31
|
+
...browserArgs,
|
|
32
32
|
`--unsafely-treat-insecure-origin-as-secure=${domain}`,
|
|
33
33
|
...this.chromeFlags,
|
|
34
34
|
];
|
|
@@ -40,10 +40,10 @@ class OnboardingContext {
|
|
|
40
40
|
configName;
|
|
41
41
|
local;
|
|
42
42
|
verboseLevel;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
|
|
44
|
+
DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
|
|
45
|
+
DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
|
|
46
|
+
DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
|
|
47
47
|
constructor(customerPath, configName, local, verboseLevel) {
|
|
48
48
|
this.customerPath = customerPath;
|
|
49
49
|
this.configName = configName;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { OnboardingService } from "./onboarding-service";
|
|
2
|
-
import { OnboardingContext } from "./onboarding-model";
|
|
3
1
|
import { UserCliConfig } from "../../helpers/cli-config";
|
|
2
|
+
import { OnboardingContext } from "./onboarding-model";
|
|
3
|
+
import { OnboardingService } from "./onboarding-service";
|
|
4
4
|
export declare class OnboardingServiceFactory {
|
|
5
5
|
private readonly context;
|
|
6
6
|
private cliConfig;
|
|
7
7
|
constructor(context: OnboardingContext, cliConfig: UserCliConfig);
|
|
8
8
|
getService(): Promise<OnboardingService>;
|
|
9
|
-
private getUrlForTest;
|
|
10
9
|
private buildInstallResource;
|
|
11
|
-
private getFetchEventHandler;
|
|
12
|
-
private getIntegrationFiles;
|
|
13
|
-
private getConfigApi;
|
|
14
10
|
private getAthenaClient;
|
|
11
|
+
private getConfigApi;
|
|
15
12
|
private getCredentials;
|
|
13
|
+
private getFetchEventHandler;
|
|
14
|
+
private getIntegrationFiles;
|
|
15
|
+
private getUrlForTest;
|
|
16
16
|
}
|
|
@@ -2,44 +2,44 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OnboardingServiceFactory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const fetch_event_handler_1 = require("./fetch-event-handler");
|
|
10
|
-
const speed_kit_install_html_1 = require("./fetch-events/speed-kit-install-html");
|
|
11
|
-
const customer_domain_document_response_1 = require("./fetch-events/customer-domain-document-response");
|
|
12
|
-
const speed_kit_install_context_1 = require("./config-renderer/speed-kit-install-context");
|
|
13
|
-
const install_speed_kit_js_template_1 = require("./templates/install-speed-kit-js-template");
|
|
5
|
+
const client_athena_1 = require("@aws-sdk/client-athena");
|
|
6
|
+
const vm = tslib_1.__importStar(require("node:vm"));
|
|
7
|
+
const safe_1 = require("../../helpers/safe");
|
|
8
|
+
const files_1 = require("../../models/files");
|
|
14
9
|
const bundler_1 = require("../bundler");
|
|
15
|
-
const speed_kit_install_js_1 = require("./fetch-events/speed-kit-install-js");
|
|
16
|
-
const speed_kit_service_worker_js_1 = require("./fetch-events/speed-kit-service-worker-js");
|
|
17
|
-
const customer_service_worker_js_1 = require("./fetch-events/customer-service-worker-js");
|
|
18
|
-
const fileWatcher_1 = require("./file-events/fileWatcher");
|
|
19
10
|
const cli_1 = require("../cli");
|
|
20
|
-
const install_speed_kit_html_template_1 = require("./templates/install-speed-kit-html-template");
|
|
21
11
|
const config_api_context_1 = tslib_1.__importDefault(require("../config-api/context/config-api-context"));
|
|
22
12
|
const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
|
|
23
|
-
const speed_kit_asset_request_1 = require("./fetch-events/speed-kit-asset-request");
|
|
24
|
-
const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(require("../document-handler-runtime/factory/document-handler-runtime-service-factory"));
|
|
25
|
-
const cache_1 = require("./request-cache/cache");
|
|
26
|
-
const todo_collector_1 = require("./todo-collector");
|
|
27
|
-
const dashboard_request_1 = require("./fetch-events/dashboard-request");
|
|
28
|
-
const dashboard_1 = require("./dashboard");
|
|
29
|
-
const param_query_builder_1 = require("./dashboard/param-query-builder");
|
|
30
|
-
const athena_service_1 = require("./dashboard/athena-service");
|
|
31
|
-
const client_athena_1 = require("@aws-sdk/client-athena");
|
|
32
13
|
const diff_1 = require("../diff");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const vm = tslib_1.__importStar(require("vm"));
|
|
36
|
-
const external_recipe_1 = require("../integration-api/virtual/external-recipe");
|
|
14
|
+
const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(require("../document-handler-runtime/factory/document-handler-runtime-service-factory"));
|
|
15
|
+
const integration_api_context_1 = tslib_1.__importDefault(require("../integration-api/context/integration-api-context"));
|
|
37
16
|
const external_file_reader_1 = require("../integration-api/external/external-file-reader");
|
|
17
|
+
const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
|
|
38
18
|
const virtual_file_1 = require("../integration-api/struct/virtual-file");
|
|
19
|
+
const external_recipe_1 = require("../integration-api/virtual/external-recipe");
|
|
39
20
|
const install_file_recipe_1 = require("./config-renderer/install-file-recipe");
|
|
40
|
-
const
|
|
21
|
+
const speed_kit_install_context_1 = require("./config-renderer/speed-kit-install-context");
|
|
22
|
+
const dashboard_1 = require("./dashboard");
|
|
23
|
+
const athena_service_1 = require("./dashboard/athena-service");
|
|
24
|
+
const param_query_builder_1 = require("./dashboard/param-query-builder");
|
|
25
|
+
const request_diff_service_1 = require("./dashboard/request-diff-service");
|
|
26
|
+
const fetch_event_handler_1 = require("./fetch-event-handler");
|
|
27
|
+
const customer_domain_document_response_1 = require("./fetch-events/customer-domain-document-response");
|
|
28
|
+
const customer_service_worker_js_1 = require("./fetch-events/customer-service-worker-js");
|
|
29
|
+
const dashboard_request_1 = require("./fetch-events/dashboard-request");
|
|
30
|
+
const speed_kit_asset_request_1 = require("./fetch-events/speed-kit-asset-request");
|
|
31
|
+
const speed_kit_install_html_1 = require("./fetch-events/speed-kit-install-html");
|
|
32
|
+
const speed_kit_install_js_1 = require("./fetch-events/speed-kit-install-js");
|
|
41
33
|
const speed_kit_rum_pi_request_1 = require("./fetch-events/speed-kit-rum-pi-request");
|
|
34
|
+
const speed_kit_service_worker_js_1 = require("./fetch-events/speed-kit-service-worker-js");
|
|
35
|
+
const file_watcher_1 = require("./file-events/file-watcher");
|
|
36
|
+
const onboarding_model_1 = require("./onboarding-model");
|
|
37
|
+
const onboarding_service_1 = require("./onboarding-service");
|
|
38
|
+
const cache_1 = require("./request-cache/cache");
|
|
42
39
|
const server_config_1 = require("./server-config");
|
|
40
|
+
const install_speed_kit_html_template_1 = require("./templates/install-speed-kit-html-template");
|
|
41
|
+
const install_speed_kit_js_template_1 = require("./templates/install-speed-kit-js-template");
|
|
42
|
+
const todo_collector_1 = require("./todo-collector");
|
|
43
43
|
class OnboardingServiceFactory {
|
|
44
44
|
context;
|
|
45
45
|
cliConfig;
|
|
@@ -58,30 +58,21 @@ class OnboardingServiceFactory {
|
|
|
58
58
|
customerPath: this.context.customerPath,
|
|
59
59
|
fileDependencies: [],
|
|
60
60
|
requiredFiles: [],
|
|
61
|
-
verboseLevel: this.context.verboseLevel
|
|
61
|
+
verboseLevel: this.context.verboseLevel,
|
|
62
62
|
};
|
|
63
63
|
const documentHandler = await new document_handler_runtime_service_factory_1.default(documentHandlerContext, this.cliConfig, files).buildDocumentHandlerServer();
|
|
64
64
|
const bundler = new bundler_1.BundleServiceFactory().buildService();
|
|
65
65
|
const skTemplate = new install_speed_kit_js_template_1.InstallSpeedKitJsTemplate();
|
|
66
66
|
const speedKitInstallContext = new speed_kit_install_context_1.SpeedKitInstallContext(customerConfig, this.context.configName, files, bundler, skTemplate, this.context.local);
|
|
67
67
|
await this.buildInstallResource(speedKitInstallContext, files, cli);
|
|
68
|
-
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, customerConfig.chromeFlags || []);
|
|
69
|
-
const fileWatcher = new
|
|
68
|
+
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, customerConfig.chromeFlags || [], this.cliConfig);
|
|
69
|
+
const fileWatcher = new file_watcher_1.FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
70
70
|
const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext);
|
|
71
71
|
const fileTodoCollector = new todo_collector_1.TodoCollector(files.getInstallResources());
|
|
72
72
|
return new onboarding_service_1.OnboardingService(browserContext, customerConfig, fetchHandler, fileWatcher, cli, fileTodoCollector);
|
|
73
73
|
}
|
|
74
|
-
async getUrlForTest(customerConfig, cli) {
|
|
75
|
-
let domainToStart = customerConfig.origins[0];
|
|
76
|
-
if (customerConfig.origins.length > 1) {
|
|
77
|
-
domainToStart = await cli.select('select domain to start', customerConfig.origins.map((origin) => {
|
|
78
|
-
return { name: origin, value: origin };
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
return domainToStart;
|
|
82
|
-
}
|
|
83
74
|
async buildInstallResource(speedKitInstallContext, files, cli) {
|
|
84
|
-
cli.startAction(
|
|
75
|
+
cli.startAction("build file install_resource");
|
|
85
76
|
const installResourceFile = new virtual_file_1.VirtualFile(files_1.INTEGRATION_FILES.BUILD.INSTALL, new install_file_recipe_1.InstallFileRecipe(speedKitInstallContext));
|
|
86
77
|
const result = await (0, safe_1.safe)(installResourceFile.buildContent());
|
|
87
78
|
if (result.success === true) {
|
|
@@ -92,6 +83,38 @@ class OnboardingServiceFactory {
|
|
|
92
83
|
cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
93
84
|
cli.writeError(result.error);
|
|
94
85
|
}
|
|
86
|
+
async getAthenaClient(cli) {
|
|
87
|
+
const credentials = await this.getCredentials(cli);
|
|
88
|
+
if (!credentials) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const config = {
|
|
92
|
+
credentials: {
|
|
93
|
+
accessKeyId: credentials?.accessKeyId,
|
|
94
|
+
secretAccessKey: credentials?.secretAccessKey,
|
|
95
|
+
},
|
|
96
|
+
region: "eu-central-1",
|
|
97
|
+
};
|
|
98
|
+
return new athena_service_1.AthenaService(new client_athena_1.Athena(config), cli);
|
|
99
|
+
}
|
|
100
|
+
getConfigApi(app) {
|
|
101
|
+
const configApiContext = new config_api_context_1.default(app);
|
|
102
|
+
return new config_api_service_factory_1.default(configApiContext).getService();
|
|
103
|
+
}
|
|
104
|
+
async getCredentials(cli) {
|
|
105
|
+
cli.startAction("fetch athena credentials");
|
|
106
|
+
const configApiContext = new config_api_context_1.default("onboarding");
|
|
107
|
+
const configApi = new config_api_service_factory_1.default(configApiContext).getService();
|
|
108
|
+
const credentialsResult = await (0, safe_1.safe)(configApi.getModule("credentials"));
|
|
109
|
+
if (credentialsResult.success === true) {
|
|
110
|
+
const context = { module: { exports: { AWS_ATHENA: {} } } };
|
|
111
|
+
vm.runInNewContext(credentialsResult.data, context);
|
|
112
|
+
cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
113
|
+
return context.module.exports.AWS_ATHENA;
|
|
114
|
+
}
|
|
115
|
+
cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
116
|
+
cli.writeError(credentialsResult.error);
|
|
117
|
+
}
|
|
95
118
|
async getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext) {
|
|
96
119
|
const configApi = this.getConfigApi(customerConfig.app);
|
|
97
120
|
const paramQueryBuilder = new param_query_builder_1.ParamQueryBuilder(customerConfig, files.getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT));
|
|
@@ -106,8 +129,7 @@ class OnboardingServiceFactory {
|
|
|
106
129
|
];
|
|
107
130
|
if (this.context.local) {
|
|
108
131
|
const speedKitConfigLoader = new server_config_1.ServerConfig(cli, configApi);
|
|
109
|
-
handlers.push(new speed_kit_asset_request_1.SpeedKitAssetRequest(customerConfig, documentHandler, cache, cli, await speedKitConfigLoader.getServerSpeedKitConfig()));
|
|
110
|
-
handlers.push(new speed_kit_rum_pi_request_1.SpeedKitRumPiRequest(customerConfig, cache, cli));
|
|
132
|
+
handlers.push(new speed_kit_asset_request_1.SpeedKitAssetRequest(customerConfig, documentHandler, cache, cli, await speedKitConfigLoader.getServerSpeedKitConfig()), new speed_kit_rum_pi_request_1.SpeedKitRumPiRequest(customerConfig, cache, cli));
|
|
111
133
|
}
|
|
112
134
|
const athenaClient = await this.getAthenaClient(cli);
|
|
113
135
|
if (athenaClient) {
|
|
@@ -120,50 +142,33 @@ class OnboardingServiceFactory {
|
|
|
120
142
|
const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, []);
|
|
121
143
|
const integrationApi = new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService();
|
|
122
144
|
const externalFileReader = new external_file_reader_1.ExternalFileReader();
|
|
123
|
-
return
|
|
124
|
-
{
|
|
145
|
+
return integrationApi.run([
|
|
146
|
+
{
|
|
147
|
+
name: files_1.INTEGRATION_FILES.CUSTOM.SW,
|
|
148
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SW_PATH, externalFileReader),
|
|
149
|
+
},
|
|
125
150
|
{
|
|
126
151
|
name: files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
127
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DF_PATH, externalFileReader)
|
|
152
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DF_PATH, externalFileReader),
|
|
128
153
|
},
|
|
129
154
|
{
|
|
130
155
|
name: files_1.INTEGRATION_FILES.CUSTOM.LOADER,
|
|
131
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader)
|
|
156
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader),
|
|
132
157
|
},
|
|
133
158
|
{
|
|
134
159
|
name: files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
135
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader)
|
|
160
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader),
|
|
136
161
|
},
|
|
137
162
|
]);
|
|
138
163
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (!credentials) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const config = {
|
|
149
|
-
region: 'eu-central-1',
|
|
150
|
-
credentials: { accessKeyId: credentials?.accessKeyId, secretAccessKey: credentials?.secretAccessKey },
|
|
151
|
-
};
|
|
152
|
-
return new athena_service_1.AthenaService(new client_athena_1.Athena(config), cli);
|
|
153
|
-
}
|
|
154
|
-
async getCredentials(cli) {
|
|
155
|
-
cli.startAction('fetch athena credentials');
|
|
156
|
-
const configApiContext = new config_api_context_1.default('onboarding');
|
|
157
|
-
const configApi = new config_api_service_factory_1.default(configApiContext).getService();
|
|
158
|
-
const credentialsResult = await (0, safe_1.safe)(configApi.getModule('credentials'));
|
|
159
|
-
if (credentialsResult.success === true) {
|
|
160
|
-
const context = { module: { exports: { AWS_ATHENA: {} } } };
|
|
161
|
-
vm.runInNewContext(credentialsResult.data, context);
|
|
162
|
-
cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
163
|
-
return context.module.exports.AWS_ATHENA;
|
|
164
|
+
async getUrlForTest(customerConfig, cli) {
|
|
165
|
+
let domainToStart = customerConfig.origins[0];
|
|
166
|
+
if (customerConfig.origins.length > 1) {
|
|
167
|
+
domainToStart = await cli.select("select domain to start", customerConfig.origins.map((origin) => {
|
|
168
|
+
return { name: origin, value: origin };
|
|
169
|
+
}));
|
|
164
170
|
}
|
|
165
|
-
|
|
166
|
-
cli.writeError(credentialsResult.error);
|
|
171
|
+
return domainToStart;
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
exports.OnboardingServiceFactory = OnboardingServiceFactory;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CliService } from "../cli";
|
|
1
2
|
import CustomerConfig from "../integration-api/struct/customer-config";
|
|
2
|
-
import { BrowserContext } from "./onboarding-model";
|
|
3
3
|
import { FetchEventHandler } from "./fetch-event-handler";
|
|
4
|
-
import { FileWatcher } from "./file-events/
|
|
5
|
-
import {
|
|
4
|
+
import { FileWatcher } from "./file-events/file-watcher";
|
|
5
|
+
import { BrowserContext } from "./onboarding-model";
|
|
6
6
|
import { TodoCollector } from "./todo-collector";
|
|
7
7
|
/**
|
|
8
8
|
* Represents the OnboardingService which is responsible for setting up the browser to test a config using Puppeteer.
|
|
@@ -20,12 +20,12 @@ export declare class OnboardingService {
|
|
|
20
20
|
* prepare puppeteerBrowser, add eventListeners and start
|
|
21
21
|
*/
|
|
22
22
|
run(): Promise<void>;
|
|
23
|
-
private prepareBrowser;
|
|
24
|
-
private preparePage;
|
|
25
23
|
private findPage;
|
|
24
|
+
private navigate;
|
|
25
|
+
private prepareBrowser;
|
|
26
26
|
private prepareCleanState;
|
|
27
|
-
private
|
|
27
|
+
private preparePage;
|
|
28
28
|
private registerFileWatcher;
|
|
29
29
|
private registerReinstallSpeedKitOnNavigate;
|
|
30
|
-
private
|
|
30
|
+
private reinstallSpeedKit;
|
|
31
31
|
}
|