ng-talkback 21.0.17 → 21.0.18
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
package/lib-prod/tape.backend.js
CHANGED
|
@@ -1,75 +1,69 @@
|
|
|
1
|
-
import MediaType from
|
|
2
|
-
import TapeRenderer from
|
|
3
|
-
import ContentEncoding from
|
|
4
|
-
import * as URL from
|
|
5
|
-
import * as querystring from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
24
|
-
host: this.options.host
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
static async fromStore(raw, options) {
|
|
28
|
-
return TapeRenderer.fromStore(raw, options);
|
|
29
|
-
}
|
|
30
|
-
cleanupHeaders() {
|
|
31
|
-
const newHeaders = { ...this.req.headers };
|
|
32
|
-
this.options.ignoreHeaders.forEach((h) => delete newHeaders[h]);
|
|
33
|
-
this.req = {
|
|
34
|
-
...this.req,
|
|
35
|
-
headers: newHeaders
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
cleanupQueryParams() {
|
|
39
|
-
if (this.queryParamsToIgnore.length === 0) {
|
|
40
|
-
return;
|
|
1
|
+
import MediaType from './utils/media-type.backend';
|
|
2
|
+
import TapeRenderer from './tape-renderer.backend';
|
|
3
|
+
import ContentEncoding from './utils/content-encoding.backend';
|
|
4
|
+
import * as URL from 'url';
|
|
5
|
+
import * as querystring from 'querystring';
|
|
6
|
+
// const URL = require('url')
|
|
7
|
+
// const querystring = require('querystring')
|
|
8
|
+
export class Tape {
|
|
9
|
+
constructor(req, options) {
|
|
10
|
+
this.new = false;
|
|
11
|
+
this.used = false;
|
|
12
|
+
this.req = { ...req };
|
|
13
|
+
this.options = options;
|
|
14
|
+
// This needs to happen before we erase headers since we could lose information
|
|
15
|
+
this.normalizeBody();
|
|
16
|
+
this.cleanupHeaders();
|
|
17
|
+
this.queryParamsToIgnore = this.options.ignoreQueryParams;
|
|
18
|
+
this.cleanupQueryParams();
|
|
19
|
+
this.meta = {
|
|
20
|
+
createdAt: new Date(),
|
|
21
|
+
host: this.options.host
|
|
22
|
+
};
|
|
41
23
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return;
|
|
24
|
+
static async fromStore(raw, options) {
|
|
25
|
+
return TapeRenderer.fromStore(raw, options);
|
|
45
26
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
url.query = null;
|
|
54
|
-
url.search = null;
|
|
27
|
+
cleanupHeaders() {
|
|
28
|
+
const newHeaders = { ...this.req.headers };
|
|
29
|
+
this.options.ignoreHeaders.forEach(h => delete newHeaders[h]);
|
|
30
|
+
this.req = {
|
|
31
|
+
...this.req,
|
|
32
|
+
headers: newHeaders
|
|
33
|
+
};
|
|
55
34
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
35
|
+
cleanupQueryParams() {
|
|
36
|
+
if (this.queryParamsToIgnore.length === 0) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const url = URL.parse(this.req.url, true);
|
|
40
|
+
if (!url.search) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const query = { ...url.query };
|
|
44
|
+
this.queryParamsToIgnore.forEach(q => delete query[q]);
|
|
45
|
+
const newQuery = querystring.stringify(query);
|
|
46
|
+
if (newQuery) {
|
|
47
|
+
url.query = query;
|
|
48
|
+
url.search = "?" + newQuery;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
url.query = null;
|
|
52
|
+
url.search = null;
|
|
53
|
+
}
|
|
54
|
+
this.req.url = URL.format(url);
|
|
55
|
+
}
|
|
56
|
+
normalizeBody() {
|
|
57
|
+
const mediaType = new MediaType(this.req);
|
|
58
|
+
const contentEncoding = new ContentEncoding(this.req);
|
|
59
|
+
if (contentEncoding.isUncompressed() && mediaType.isJSON() && this.req.body.length > 0) {
|
|
60
|
+
this.req.body = Buffer.from(JSON.stringify(JSON.parse(this.req.body.toString()), null, 2));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async clone() {
|
|
64
|
+
const tapeRenderer = new TapeRenderer(this);
|
|
65
|
+
const raw = await tapeRenderer.render();
|
|
66
|
+
return Tape.fromStore(raw, this.options);
|
|
63
67
|
}
|
|
64
|
-
}
|
|
65
|
-
async clone() {
|
|
66
|
-
const tapeRenderer = new TapeRenderer(this);
|
|
67
|
-
const raw = await tapeRenderer.render();
|
|
68
|
-
return Tape.fromStore(raw, this.options);
|
|
69
|
-
}
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
Tape,
|
|
74
|
-
tape_backend_default as default
|
|
75
|
-
};
|
|
69
|
+
export default Tape;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
const zlib = require(
|
|
2
|
-
import Headers from
|
|
1
|
+
const zlib = require('zlib');
|
|
2
|
+
import Headers from './headers.backend';
|
|
3
3
|
const ALGORITHMS = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
gzip: { compress: zlib.gzipSync, uncompress: zlib.gunzipSync },
|
|
5
|
+
deflate: { compress: zlib.deflateSync, uncompress: zlib.inflateSync }
|
|
6
6
|
};
|
|
7
|
-
class ContentEncoding {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.reqRes = reqRes;
|
|
11
|
-
}
|
|
12
|
-
isUncompressed() {
|
|
13
|
-
const contentEncoding = this.contentEncoding();
|
|
14
|
-
return !contentEncoding || contentEncoding === "identity";
|
|
15
|
-
}
|
|
16
|
-
supportedAlgorithm() {
|
|
17
|
-
const contentEncoding = this.contentEncoding();
|
|
18
|
-
return Object.keys(ALGORITHMS).includes(contentEncoding);
|
|
19
|
-
}
|
|
20
|
-
contentEncoding() {
|
|
21
|
-
return Headers.read(this.reqRes.headers, "content-encoding");
|
|
22
|
-
}
|
|
23
|
-
async uncompressedBody(body) {
|
|
24
|
-
const contentEncoding = this.contentEncoding();
|
|
25
|
-
if (!this.supportedAlgorithm()) {
|
|
26
|
-
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
7
|
+
export default class ContentEncoding {
|
|
8
|
+
constructor(reqRes) {
|
|
9
|
+
this.reqRes = reqRes;
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
isUncompressed() {
|
|
12
|
+
const contentEncoding = this.contentEncoding();
|
|
13
|
+
return !contentEncoding || contentEncoding === "identity";
|
|
14
|
+
}
|
|
15
|
+
supportedAlgorithm() {
|
|
16
|
+
const contentEncoding = this.contentEncoding();
|
|
17
|
+
return Object.keys(ALGORITHMS).includes(contentEncoding);
|
|
18
|
+
}
|
|
19
|
+
contentEncoding() {
|
|
20
|
+
return Headers.read(this.reqRes.headers, "content-encoding");
|
|
21
|
+
}
|
|
22
|
+
async uncompressedBody(body) {
|
|
23
|
+
const contentEncoding = this.contentEncoding();
|
|
24
|
+
if (!this.supportedAlgorithm()) {
|
|
25
|
+
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
26
|
+
}
|
|
27
|
+
return ALGORITHMS[contentEncoding].uncompress(body);
|
|
28
|
+
}
|
|
29
|
+
async compressedBody(body) {
|
|
30
|
+
const contentEncoding = this.contentEncoding();
|
|
31
|
+
if (!this.supportedAlgorithm()) {
|
|
32
|
+
throw new Error(`Unsupported content-encoding ${contentEncoding}`);
|
|
33
|
+
}
|
|
34
|
+
return ALGORITHMS[contentEncoding].compress(body);
|
|
34
35
|
}
|
|
35
|
-
return ALGORITHMS[contentEncoding].compress(body);
|
|
36
|
-
}
|
|
37
36
|
}
|
|
38
|
-
export {
|
|
39
|
-
ContentEncoding as default
|
|
40
|
-
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
class Headers {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export default class Headers {
|
|
2
|
+
static read(headers, headerName) {
|
|
3
|
+
const value = headers[headerName];
|
|
4
|
+
if (Array.isArray(value)) {
|
|
5
|
+
return value[0];
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
static write(headers, headerName, value, type) {
|
|
12
|
+
headers[headerName] = type === "req" ? value : [value];
|
|
8
13
|
}
|
|
9
|
-
}
|
|
10
|
-
static write(headers, headerName, value, type) {
|
|
11
|
-
headers[headerName] = type === "req" ? value : [value];
|
|
12
|
-
}
|
|
13
14
|
}
|
|
14
|
-
export {
|
|
15
|
-
Headers as default
|
|
16
|
-
};
|
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
import { ___NS__merge } from
|
|
2
|
-
import Headers from
|
|
3
|
-
const contentTypeParser = require(
|
|
1
|
+
import { ___NS__merge } from 'tnp-core/lib-prod';
|
|
2
|
+
import Headers from './headers.backend';
|
|
3
|
+
const contentTypeParser = require('content-type');
|
|
4
4
|
const equals = (to) => (contentType) => to == contentType;
|
|
5
|
-
const jsonTypes = [
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export const jsonTypes = [
|
|
6
|
+
equals("application/json"),
|
|
7
|
+
(contentType) => contentType.startsWith("application/") && contentType.endsWith("+json")
|
|
8
8
|
];
|
|
9
9
|
const humanReadableContentTypes = [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
equals("application/javascript"),
|
|
11
|
+
equals("text/css"),
|
|
12
|
+
equals("text/html"),
|
|
13
|
+
equals("text/javascript"),
|
|
14
|
+
equals("text/plain"),
|
|
15
|
+
...jsonTypes
|
|
16
16
|
];
|
|
17
|
-
class MediaType {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.htmlReqRes = htmlReqRes;
|
|
21
|
-
}
|
|
22
|
-
isHumanReadable() {
|
|
23
|
-
const contentType = this.contentType();
|
|
24
|
-
if (!contentType) {
|
|
25
|
-
return false;
|
|
17
|
+
export default class MediaType {
|
|
18
|
+
constructor(htmlReqRes) {
|
|
19
|
+
this.htmlReqRes = htmlReqRes;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
isHumanReadable() {
|
|
22
|
+
const contentType = this.contentType();
|
|
23
|
+
if (!contentType) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return humanReadableContentTypes.some(comparator => comparator(contentType));
|
|
33
27
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
isJSON() {
|
|
29
|
+
const contentType = this.contentType();
|
|
30
|
+
if (!contentType) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const result = jsonTypes.some(comparator => comparator('application/json'));
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
contentType() {
|
|
37
|
+
const contentTypeHeader = Headers.read(this.headers(), "content-type");
|
|
38
|
+
if (!contentTypeHeader) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const parsedContentType = contentTypeParser.parse(contentTypeHeader);
|
|
42
|
+
return parsedContentType.type;
|
|
43
|
+
}
|
|
44
|
+
headers() {
|
|
45
|
+
return ___NS__merge(this.htmlReqRes.headers, {
|
|
46
|
+
'content-type': 'application/json'
|
|
47
|
+
});
|
|
41
48
|
}
|
|
42
|
-
const parsedContentType = contentTypeParser.parse(contentTypeHeader);
|
|
43
|
-
return parsedContentType.type;
|
|
44
|
-
}
|
|
45
|
-
headers() {
|
|
46
|
-
return ___NS__merge(this.htmlReqRes.headers, {
|
|
47
|
-
"content-type": "application/json"
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
49
|
}
|
|
51
|
-
export {
|
|
52
|
-
MediaType as default,
|
|
53
|
-
jsonTypes
|
|
54
|
-
};
|
package/package.json
CHANGED
package/websql/package.json
CHANGED