ng-talkback 21.0.17 → 21.0.19
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.js +26 -14
- package/lib-prod/env/env.angular-node-app.js +66 -130
- package/lib-prod/env/env.docs-webapp.js +66 -130
- package/lib-prod/env/env.electron-app.js +66 -130
- package/lib-prod/env/env.mobile-app.js +66 -130
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +66 -130
- package/lib-prod/env/env.vscode-plugin.js +66 -130
- package/lib-prod/env/index.js +6 -6
- package/lib-prod/es6.backend.js +2 -5
- package/lib-prod/features/error-rate.backend.js +20 -24
- package/lib-prod/features/latency.backend.js +25 -27
- package/lib-prod/index._auto-generated_.js +5 -0
- package/lib-prod/index.js +12 -14
- package/lib-prod/logger.backend.js +17 -21
- package/lib-prod/migrations/index.js +2 -1
- package/lib-prod/migrations/migrations_index._auto-generated_.js +3 -0
- package/lib-prod/options.backend.js +75 -85
- package/lib-prod/package.json +1 -1
- package/lib-prod/request-handler.backend.js +131 -125
- package/lib-prod/server.backend.js +76 -79
- package/lib-prod/summary.backend.js +16 -21
- package/lib-prod/talkback-factory.backend.js +15 -18
- package/lib-prod/tape-matcher.backend.js +84 -88
- package/lib-prod/tape-renderer.backend.js +90 -89
- package/lib-prod/tape-store.backend.js +85 -87
- package/lib-prod/tape.backend.js +64 -70
- package/lib-prod/types.backend.js +1 -0
- package/lib-prod/utils/content-encoding.backend.js +31 -35
- package/lib-prod/utils/headers.backend.js +12 -14
- package/lib-prod/utils/media-type.backend.js +41 -46
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
|
@@ -1,130 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
ENV_VSCODE_PLUGIN_BUILD_ELECTRON_SHOW_DEV_TOOLS,
|
|
68
|
-
ENV_VSCODE_PLUGIN_BUILD_GEN_ONLY_CLIENT_CODE,
|
|
69
|
-
ENV_VSCODE_PLUGIN_BUILD_OVERRIDE_OUTPUT_PATH,
|
|
70
|
-
ENV_VSCODE_PLUGIN_BUILD_PROD,
|
|
71
|
-
ENV_VSCODE_PLUGIN_BUILD_PWA_DISABLE_SERVICE_WORKER,
|
|
72
|
-
ENV_VSCODE_PLUGIN_BUILD_PWA_NAME,
|
|
73
|
-
ENV_VSCODE_PLUGIN_BUILD_PWA_SHORT_NAME,
|
|
74
|
-
ENV_VSCODE_PLUGIN_BUILD_PWA_START_URL,
|
|
75
|
-
ENV_VSCODE_PLUGIN_BUILD_SSR,
|
|
76
|
-
ENV_VSCODE_PLUGIN_BUILD_WATCH,
|
|
77
|
-
ENV_VSCODE_PLUGIN_BUILD_WEBSQL,
|
|
78
|
-
ENV_VSCODE_PLUGIN_CONTAINER_END,
|
|
79
|
-
ENV_VSCODE_PLUGIN_CONTAINER_ONLY,
|
|
80
|
-
ENV_VSCODE_PLUGIN_CONTAINER_SKIP,
|
|
81
|
-
ENV_VSCODE_PLUGIN_CONTAINER_SKIP_RELEASED,
|
|
82
|
-
ENV_VSCODE_PLUGIN_CONTAINER_START,
|
|
83
|
-
ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_BEFORE_COPY_HOOK,
|
|
84
|
-
ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_COPY_TO_LOCATIONS,
|
|
85
|
-
ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_COPY_TO_PROJECTS,
|
|
86
|
-
ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_SKIP,
|
|
87
|
-
ENV_VSCODE_PLUGIN_DOCKER_ADDITIONAL_CONTAINER,
|
|
88
|
-
ENV_VSCODE_PLUGIN_DOCKER_SKIP_START_IN_ORDER,
|
|
89
|
-
ENV_VSCODE_PLUGIN_DOCKER_SKIP_USING_MYSQL_DB,
|
|
90
|
-
ENV_VSCODE_PLUGIN_INIT_BRANDING,
|
|
91
|
-
ENV_VSCODE_PLUGIN_INIT_STRUCT,
|
|
92
|
-
ENV_VSCODE_PLUGIN_IS_CI_PROCESS,
|
|
93
|
-
ENV_VSCODE_PLUGIN_LOADING_PRE_ANGULAR_BOOTSTRAP_BACKGROUND,
|
|
94
|
-
ENV_VSCODE_PLUGIN_LOADING_PRE_ANGULAR_BOOTSTRAP_LOADER,
|
|
95
|
-
ENV_VSCODE_PLUGIN_PURPOSE,
|
|
96
|
-
ENV_VSCODE_PLUGIN_RECURSIVE_ACTION,
|
|
97
|
-
ENV_VSCODE_PLUGIN_RELEASE_AUTO_RELEASE_TASK_NAME,
|
|
98
|
-
ENV_VSCODE_PLUGIN_RELEASE_AUTO_RELEASE_USING_CONFIG,
|
|
99
|
-
ENV_VSCODE_PLUGIN_RELEASE_CLI_COMPRESS,
|
|
100
|
-
ENV_VSCODE_PLUGIN_RELEASE_CLI_INCLUDE_NODE_MODULES,
|
|
101
|
-
ENV_VSCODE_PLUGIN_RELEASE_CLI_MINIFY,
|
|
102
|
-
ENV_VSCODE_PLUGIN_RELEASE_CLI_OBSCURE,
|
|
103
|
-
ENV_VSCODE_PLUGIN_RELEASE_CLI_UGLIFY,
|
|
104
|
-
ENV_VSCODE_PLUGIN_RELEASE_ENV_NAME,
|
|
105
|
-
ENV_VSCODE_PLUGIN_RELEASE_ENV_NUMBER,
|
|
106
|
-
ENV_VSCODE_PLUGIN_RELEASE_INSTALL_LOCALLY,
|
|
107
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_COMPRESS,
|
|
108
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_DO_NOT_INCLUDE_LIB_FILES,
|
|
109
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_INCLUDE_SOURCE_MAPS,
|
|
110
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_OBSCURE_FILE_BY_FILE,
|
|
111
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_REMOVE_DTS,
|
|
112
|
-
ENV_VSCODE_PLUGIN_RELEASE_LIB_UGLIFY_FILE_BY_FILE,
|
|
113
|
-
ENV_VSCODE_PLUGIN_RELEASE_NODE_BACKEND_APP_MINIFY,
|
|
114
|
-
ENV_VSCODE_PLUGIN_RELEASE_RELEASE_TYPE,
|
|
115
|
-
ENV_VSCODE_PLUGIN_RELEASE_RELEASE_VERSION_BUMP_TYPE,
|
|
116
|
-
ENV_VSCODE_PLUGIN_RELEASE_REMOVE_RELEASE_OUTPUT_AFTER_LOCAL_INSTALL,
|
|
117
|
-
ENV_VSCODE_PLUGIN_RELEASE_RESOLVED_NEW_VERSION,
|
|
118
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_BUILDING_ARTIFACTS,
|
|
119
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_CODE_CUTTING,
|
|
120
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_DEPLOY,
|
|
121
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_NPM_PUBLISH,
|
|
122
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_RELEASE_QUESTION,
|
|
123
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_RESOLVING_GIT_CHANGES,
|
|
124
|
-
ENV_VSCODE_PLUGIN_RELEASE_SKIP_TAG_GIT_PUSH,
|
|
125
|
-
ENV_VSCODE_PLUGIN_RELEASE_TAON_INSTANCE_IP,
|
|
126
|
-
ENV_VSCODE_PLUGIN_RELEASE_TARGET_ARTIFACT,
|
|
127
|
-
ENV_VSCODE_PLUGIN_WEBSITE_DOMAIN,
|
|
128
|
-
ENV_VSCODE_PLUGIN_WEBSITE_TITLE,
|
|
129
|
-
ENV_VSCODE_PLUGIN_WEBSITE_USE_DOMAIN
|
|
130
|
-
};
|
|
1
|
+
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
2
|
+
export const ENV_VSCODE_PLUGIN_WEBSITE_DOMAIN = 'ng-talkback.example.domain.com';
|
|
3
|
+
export const ENV_VSCODE_PLUGIN_WEBSITE_TITLE = 'Ng Talkback';
|
|
4
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_TARGET_ARTIFACT = 'vscode-plugin';
|
|
5
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_ENV_NAME = '__';
|
|
6
|
+
export const ENV_VSCODE_PLUGIN_CONTAINER_ONLY = undefined;
|
|
7
|
+
export const ENV_VSCODE_PLUGIN_CONTAINER_END = undefined;
|
|
8
|
+
export const ENV_VSCODE_PLUGIN_CONTAINER_START = undefined;
|
|
9
|
+
export const ENV_VSCODE_PLUGIN_CONTAINER_SKIP_RELEASED = undefined;
|
|
10
|
+
export const ENV_VSCODE_PLUGIN_CONTAINER_SKIP = undefined;
|
|
11
|
+
export const ENV_VSCODE_PLUGIN_INIT_BRANDING = undefined;
|
|
12
|
+
export const ENV_VSCODE_PLUGIN_INIT_STRUCT = undefined;
|
|
13
|
+
export const ENV_VSCODE_PLUGIN_BUILD_PWA_DISABLE_SERVICE_WORKER = undefined;
|
|
14
|
+
export const ENV_VSCODE_PLUGIN_BUILD_PWA_NAME = undefined;
|
|
15
|
+
export const ENV_VSCODE_PLUGIN_BUILD_PWA_SHORT_NAME = undefined;
|
|
16
|
+
export const ENV_VSCODE_PLUGIN_BUILD_PWA_START_URL = undefined;
|
|
17
|
+
export const ENV_VSCODE_PLUGIN_BUILD_ELECTRON_SHOW_DEV_TOOLS = undefined;
|
|
18
|
+
export const ENV_VSCODE_PLUGIN_BUILD_SSR = undefined;
|
|
19
|
+
export const ENV_VSCODE_PLUGIN_BUILD_WEBSQL = undefined;
|
|
20
|
+
export const ENV_VSCODE_PLUGIN_BUILD_PROD = undefined;
|
|
21
|
+
export const ENV_VSCODE_PLUGIN_BUILD_OVERRIDE_OUTPUT_PATH = undefined;
|
|
22
|
+
export const ENV_VSCODE_PLUGIN_BUILD_BASE_HREF = undefined;
|
|
23
|
+
export const ENV_VSCODE_PLUGIN_BUILD_WATCH = undefined;
|
|
24
|
+
export const ENV_VSCODE_PLUGIN_BUILD_GEN_ONLY_CLIENT_CODE = undefined;
|
|
25
|
+
export const ENV_VSCODE_PLUGIN_LOADING_PRE_ANGULAR_BOOTSTRAP_LOADER = undefined;
|
|
26
|
+
export const ENV_VSCODE_PLUGIN_LOADING_PRE_ANGULAR_BOOTSTRAP_BACKGROUND = undefined;
|
|
27
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_CLI_MINIFY = undefined;
|
|
28
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_CLI_INCLUDE_NODE_MODULES = undefined;
|
|
29
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_CLI_UGLIFY = undefined;
|
|
30
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_CLI_OBSCURE = undefined;
|
|
31
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_CLI_COMPRESS = undefined;
|
|
32
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_NODE_BACKEND_APP_MINIFY = undefined;
|
|
33
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_REMOVE_DTS = undefined;
|
|
34
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_OBSCURE_FILE_BY_FILE = undefined;
|
|
35
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_UGLIFY_FILE_BY_FILE = undefined;
|
|
36
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_INCLUDE_SOURCE_MAPS = undefined;
|
|
37
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_COMPRESS = undefined;
|
|
38
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_LIB_DO_NOT_INCLUDE_LIB_FILES = undefined;
|
|
39
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_RESOLVED_NEW_VERSION = undefined;
|
|
40
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_RELEASE_VERSION_BUMP_TYPE = undefined;
|
|
41
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_ENV_NUMBER = undefined;
|
|
42
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_INSTALL_LOCALLY = undefined;
|
|
43
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_REMOVE_RELEASE_OUTPUT_AFTER_LOCAL_INSTALL = undefined;
|
|
44
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_RELEASE_TYPE = undefined;
|
|
45
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_AUTO_RELEASE_USING_CONFIG = undefined;
|
|
46
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_AUTO_RELEASE_TASK_NAME = undefined;
|
|
47
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_TAON_INSTANCE_IP = undefined;
|
|
48
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_NPM_PUBLISH = undefined;
|
|
49
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_DEPLOY = undefined;
|
|
50
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_TAG_GIT_PUSH = undefined;
|
|
51
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_RELEASE_QUESTION = undefined;
|
|
52
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_RESOLVING_GIT_CHANGES = undefined;
|
|
53
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_CODE_CUTTING = undefined;
|
|
54
|
+
export const ENV_VSCODE_PLUGIN_RELEASE_SKIP_BUILDING_ARTIFACTS = undefined;
|
|
55
|
+
export const ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_BEFORE_COPY_HOOK = undefined;
|
|
56
|
+
export const ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_COPY_TO_LOCATIONS = undefined;
|
|
57
|
+
export const ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_COPY_TO_PROJECTS = undefined;
|
|
58
|
+
export const ENV_VSCODE_PLUGIN_COPY_TO_MANAGER_SKIP = undefined;
|
|
59
|
+
export const ENV_VSCODE_PLUGIN_WEBSITE_USE_DOMAIN = undefined;
|
|
60
|
+
export const ENV_VSCODE_PLUGIN_PURPOSE = undefined;
|
|
61
|
+
export const ENV_VSCODE_PLUGIN_RECURSIVE_ACTION = undefined;
|
|
62
|
+
export const ENV_VSCODE_PLUGIN_IS_CI_PROCESS = undefined;
|
|
63
|
+
export const ENV_VSCODE_PLUGIN_DOCKER_ADDITIONAL_CONTAINER = undefined;
|
|
64
|
+
export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_START_IN_ORDER = undefined;
|
|
65
|
+
export const ENV_VSCODE_PLUGIN_DOCKER_SKIP_USING_MYSQL_DB = undefined;
|
|
66
|
+
// THIS FILE IS GENERATED - DO NOT MODIFY
|
package/lib-prod/env/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from './env.angular-node-app';
|
|
2
|
+
export * from './env.docs-webapp';
|
|
3
|
+
export * from './env.electron-app';
|
|
4
|
+
export * from './env.mobile-app';
|
|
5
|
+
export * from './env.npm-lib-and-cli-tool';
|
|
6
|
+
export * from './env.vscode-plugin';
|
package/lib-prod/es6.backend.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import OptionsFactory from
|
|
2
|
-
class ErrorRate {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import OptionsFactory from '../options.backend';
|
|
2
|
+
export default class ErrorRate {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
5
|
+
}
|
|
6
|
+
shouldSimulate(req, tape) {
|
|
7
|
+
const globalErrorRate = typeof (this.options.errorRate) === 'number' ? this.options.errorRate : this.options.errorRate(req);
|
|
8
|
+
const errorRate = tape && tape.meta.errorRate !== undefined ? tape.meta.errorRate : globalErrorRate;
|
|
9
|
+
OptionsFactory.validateErrorRate(errorRate);
|
|
10
|
+
const random = Math.random() * 100;
|
|
11
|
+
return random < errorRate;
|
|
12
|
+
}
|
|
13
|
+
simulate(req) {
|
|
14
|
+
this.options.logger.log(`Simulating error for ${req.url}`);
|
|
15
|
+
return {
|
|
16
|
+
status: 503,
|
|
17
|
+
headers: { 'content-type': ['text/plain'] },
|
|
18
|
+
body: Buffer.from("talkback - failure injection")
|
|
19
|
+
};
|
|
20
|
+
}
|
|
22
21
|
}
|
|
23
|
-
export {
|
|
24
|
-
ErrorRate as default
|
|
25
|
-
};
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
import OptionsFactory from
|
|
2
|
-
class Latency {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
this.options = options;
|
|
6
|
-
}
|
|
7
|
-
async simulate(req, tape) {
|
|
8
|
-
const resolved = Promise.resolve();
|
|
9
|
-
const latencyGenerator = tape && tape.meta.latency !== void 0 ? tape.meta.latency : this.options.latency;
|
|
10
|
-
if (!latencyGenerator) {
|
|
11
|
-
return resolved;
|
|
1
|
+
import OptionsFactory from '../options.backend';
|
|
2
|
+
export default class Latency {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
this.options = options;
|
|
12
5
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
async simulate(req, tape) {
|
|
7
|
+
const resolved = Promise.resolve();
|
|
8
|
+
const latencyGenerator = tape && tape.meta.latency !== undefined ? tape.meta.latency : this.options.latency;
|
|
9
|
+
if (!latencyGenerator) {
|
|
10
|
+
return resolved;
|
|
11
|
+
}
|
|
12
|
+
OptionsFactory.validateLatency(latencyGenerator);
|
|
13
|
+
let latency = 0;
|
|
14
|
+
const type = typeof latencyGenerator;
|
|
15
|
+
if (type === "number") {
|
|
16
|
+
latency = latencyGenerator;
|
|
17
|
+
}
|
|
18
|
+
else if (Array.isArray(latencyGenerator)) {
|
|
19
|
+
const high = latencyGenerator[1];
|
|
20
|
+
const low = latencyGenerator[0];
|
|
21
|
+
latency = Math.random() * (high - low) + low;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
latency = latencyGenerator(req);
|
|
25
|
+
}
|
|
26
|
+
return new Promise(r => setTimeout(r, latency));
|
|
24
27
|
}
|
|
25
|
-
return new Promise((r) => setTimeout(r, latency));
|
|
26
|
-
}
|
|
27
28
|
}
|
|
28
|
-
export {
|
|
29
|
-
Latency as default
|
|
30
|
-
};
|
package/lib-prod/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
let a = 2;
|
|
2
2
|
a++;
|
|
3
|
-
|
|
4
|
-
export * from
|
|
5
|
-
|
|
6
|
-
import
|
|
3
|
+
//#region @backend
|
|
4
|
+
export * from './options.backend';
|
|
5
|
+
export * from './tape.backend';
|
|
6
|
+
import TalkbackFactory from './talkback-factory.backend';
|
|
7
|
+
import { DefaultOptions, FallbackMode, RecordMode } from './options.backend';
|
|
7
8
|
const talkbackFn = (options) => {
|
|
8
|
-
|
|
9
|
+
return TalkbackFactory.server(options);
|
|
9
10
|
};
|
|
10
11
|
talkbackFn.Options = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Default: DefaultOptions,
|
|
13
|
+
FallbackMode,
|
|
14
|
+
RecordMode
|
|
14
15
|
};
|
|
15
16
|
talkbackFn.requestHandler = (options) => TalkbackFactory.requestHandler(options);
|
|
16
|
-
const talkback = talkbackFn;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
index_default as default,
|
|
20
|
-
talkback
|
|
21
|
-
};
|
|
17
|
+
export const talkback = talkbackFn;
|
|
18
|
+
export default talkbackFn;
|
|
19
|
+
//#endregion
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
class Logger {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export default class Logger {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.options = options;
|
|
4
|
+
if (this.options.debug) {
|
|
5
|
+
console.debug("DEBUG mode active");
|
|
6
|
+
}
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
log(message) {
|
|
9
|
+
if (!this.options.silent || this.options.debug) {
|
|
10
|
+
console.log(message);
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
debug(message) {
|
|
14
|
+
if (this.options.debug) {
|
|
15
|
+
console.debug(message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
error(message) {
|
|
19
|
+
console.error(message);
|
|
17
20
|
}
|
|
18
|
-
}
|
|
19
|
-
error(message) {
|
|
20
|
-
console.error(message);
|
|
21
|
-
}
|
|
22
21
|
}
|
|
23
|
-
export {
|
|
24
|
-
Logger as default
|
|
25
|
-
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
export * from './migrations_index._auto-generated_';
|
|
@@ -1,95 +1,85 @@
|
|
|
1
|
-
import Logger from
|
|
2
|
-
const RecordMode = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
DISABLED: "DISABLED",
|
|
8
|
-
// If a matching tape exists, return it. Otherwise, don't proxy the request and use `fallbackMode` for the response
|
|
9
|
-
ALL: []
|
|
1
|
+
import Logger from './logger.backend';
|
|
2
|
+
export const RecordMode = {
|
|
3
|
+
NEW: "NEW", // If no tape matches the request, proxy it and save the response to a tape
|
|
4
|
+
OVERWRITE: "OVERWRITE", // Always proxy the request and save the response to a tape, overwriting any existing one
|
|
5
|
+
DISABLED: "DISABLED", // If a matching tape exists, return it. Otherwise, don't proxy the request and use `fallbackMode` for the response
|
|
6
|
+
ALL: []
|
|
10
7
|
};
|
|
11
8
|
RecordMode.ALL = [RecordMode.NEW, RecordMode.OVERWRITE, RecordMode.DISABLED];
|
|
12
|
-
const FallbackMode = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const FallbackMode = {
|
|
10
|
+
NOT_FOUND: "NOT_FOUND",
|
|
11
|
+
PROXY: "PROXY",
|
|
12
|
+
ALL: []
|
|
16
13
|
};
|
|
17
14
|
FallbackMode.ALL = [FallbackMode.NOT_FOUND, FallbackMode.PROXY];
|
|
18
|
-
const DefaultOptions = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
export const DefaultOptions = {
|
|
16
|
+
host: "",
|
|
17
|
+
port: 8080,
|
|
18
|
+
path: "./tapes/",
|
|
19
|
+
record: RecordMode.NEW,
|
|
20
|
+
fallbackMode: FallbackMode.NOT_FOUND,
|
|
21
|
+
name: "unnamed",
|
|
22
|
+
tapeNameGenerator: undefined,
|
|
23
|
+
https: {
|
|
24
|
+
enabled: false,
|
|
25
|
+
keyPath: undefined,
|
|
26
|
+
certPath: undefined
|
|
27
|
+
},
|
|
28
|
+
ignoreHeaders: ["content-length", "host"],
|
|
29
|
+
ignoreQueryParams: [],
|
|
30
|
+
ignoreBody: false,
|
|
31
|
+
bodyMatcher: undefined,
|
|
32
|
+
urlMatcher: undefined,
|
|
33
|
+
requestDecorator: undefined,
|
|
34
|
+
responseDecorator: undefined,
|
|
35
|
+
tapeDecorator: undefined,
|
|
36
|
+
latency: 0,
|
|
37
|
+
errorRate: 0,
|
|
38
|
+
silent: false,
|
|
39
|
+
summary: true,
|
|
40
|
+
debug: false,
|
|
41
|
+
logger: new Logger({})
|
|
45
42
|
};
|
|
46
|
-
class OptionsFactory {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return opts;
|
|
62
|
-
}
|
|
63
|
-
static validateOptions(opts) {
|
|
64
|
-
this.validateRecord(opts.record);
|
|
65
|
-
this.validateFallbackMode(opts.fallbackMode);
|
|
66
|
-
this.validateLatency(opts.latency);
|
|
67
|
-
this.validateErrorRate(opts.errorRate);
|
|
68
|
-
}
|
|
69
|
-
static validateRecord(record) {
|
|
70
|
-
if (typeof record === "string" && !RecordMode.ALL.includes(record)) {
|
|
71
|
-
throw `INVALID OPTION: record has an invalid value of '${record}'`;
|
|
43
|
+
export default class OptionsFactory {
|
|
44
|
+
static prepare(usrOpts = {}) {
|
|
45
|
+
const opts = {
|
|
46
|
+
...DefaultOptions,
|
|
47
|
+
name: usrOpts.host,
|
|
48
|
+
...usrOpts,
|
|
49
|
+
ignoreHeaders: [
|
|
50
|
+
...DefaultOptions.ignoreHeaders,
|
|
51
|
+
...(usrOpts.ignoreHeaders || [])
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
this.logger = new Logger(opts);
|
|
55
|
+
opts.logger = this.logger;
|
|
56
|
+
this.validateOptions(opts);
|
|
57
|
+
return opts;
|
|
72
58
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
static validateOptions(opts) {
|
|
60
|
+
this.validateRecord(opts.record);
|
|
61
|
+
this.validateFallbackMode(opts.fallbackMode);
|
|
62
|
+
this.validateLatency(opts.latency);
|
|
63
|
+
this.validateErrorRate(opts.errorRate);
|
|
77
64
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
static validateRecord(record) {
|
|
66
|
+
if (typeof (record) === "string" && !RecordMode.ALL.includes(record)) {
|
|
67
|
+
throw `INVALID OPTION: record has an invalid value of '${record}'`;
|
|
68
|
+
}
|
|
82
69
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
static validateFallbackMode(fallbackMode) {
|
|
71
|
+
if (typeof (fallbackMode) === "string" && !FallbackMode.ALL.includes(fallbackMode)) {
|
|
72
|
+
throw `INVALID OPTION: fallbackMode has an invalid value of '${fallbackMode}'`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
static validateLatency(latency) {
|
|
76
|
+
if (Array.isArray(latency) && latency.length !== 2) {
|
|
77
|
+
throw `Invalid LATENCY option. If using a range, the array should only have 2 values [min, max]. Current=[${latency}]`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
static validateErrorRate(errorRate) {
|
|
81
|
+
if (typeof (errorRate) !== "function" && (errorRate < 0 || errorRate > 100)) {
|
|
82
|
+
throw `Invalid ERRORRATE option. Value should be between 0 and 100. Current=[${errorRate}]`;
|
|
83
|
+
}
|
|
87
84
|
}
|
|
88
|
-
}
|
|
89
85
|
}
|
|
90
|
-
export {
|
|
91
|
-
DefaultOptions,
|
|
92
|
-
FallbackMode,
|
|
93
|
-
RecordMode,
|
|
94
|
-
OptionsFactory as default
|
|
95
|
-
};
|
package/lib-prod/package.json
CHANGED