@aligent/cdk-prerender-proxy 0.2.4 → 0.2.5-beta
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/lib/handlers/cache-control.ts +7 -20
- package/lib/handlers/error-response.ts +8 -51
- package/lib/handlers/node_modules/.package-lock.json +32 -3
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.d.ts +6 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.js +14 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.d.ts +3 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.js +24 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.d.ts +3 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.js +50 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.d.ts +3 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.js +28 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.d.ts +3 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.js +49 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.d.ts +3 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.js +33 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/package.json +27 -0
- package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/tsconfig.json +3 -0
- package/lib/handlers/node_modules/@middy/core/LICENSE +21 -0
- package/lib/handlers/node_modules/@middy/core/README.md +65 -0
- package/lib/handlers/node_modules/@middy/core/index.cjs +207 -0
- package/lib/handlers/node_modules/@middy/core/index.d.ts +91 -0
- package/lib/handlers/node_modules/@middy/core/index.js +199 -0
- package/lib/handlers/node_modules/@middy/core/package.json +65 -0
- package/lib/handlers/node_modules/@types/node/README.md +4 -4
- package/lib/handlers/node_modules/@types/node/assert/strict.d.ts +5 -1
- package/lib/handlers/node_modules/@types/node/assert.d.ts +904 -67
- package/lib/handlers/node_modules/@types/node/async_hooks.d.ts +371 -96
- package/lib/handlers/node_modules/@types/node/buffer.d.ts +2199 -25
- package/lib/handlers/node_modules/@types/node/child_process.d.ts +1151 -308
- package/lib/handlers/node_modules/@types/node/cluster.d.ts +356 -208
- package/lib/handlers/node_modules/@types/node/console.d.ts +324 -45
- package/lib/handlers/node_modules/@types/node/constants.d.ts +8 -3
- package/lib/handlers/node_modules/@types/node/crypto.d.ts +3230 -846
- package/lib/handlers/node_modules/@types/node/dgram.d.ts +478 -74
- package/lib/handlers/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
- package/lib/handlers/node_modules/@types/node/dns/promises.d.ts +308 -35
- package/lib/handlers/node_modules/@types/node/dns.d.ts +444 -107
- package/lib/handlers/node_modules/@types/node/dom-events.d.ts +126 -0
- package/lib/handlers/node_modules/@types/node/domain.d.ts +162 -16
- package/lib/handlers/node_modules/@types/node/events.d.ts +624 -39
- package/lib/handlers/node_modules/@types/node/fs/promises.d.ts +911 -365
- package/lib/handlers/node_modules/@types/node/fs.d.ts +2611 -978
- package/lib/handlers/node_modules/@types/node/globals.d.ts +66 -421
- package/lib/handlers/node_modules/@types/node/globals.global.d.ts +1 -1
- package/lib/handlers/node_modules/@types/node/http.d.ts +1416 -199
- package/lib/handlers/node_modules/@types/node/http2.d.ts +1688 -530
- package/lib/handlers/node_modules/@types/node/https.d.ts +532 -26
- package/lib/handlers/node_modules/@types/node/index.d.ts +92 -16
- package/lib/handlers/node_modules/@types/node/inspector.d.ts +511 -811
- package/lib/handlers/node_modules/@types/node/module.d.ts +75 -13
- package/lib/handlers/node_modules/@types/node/net.d.ts +710 -167
- package/lib/handlers/node_modules/@types/node/os.d.ts +252 -25
- package/lib/handlers/node_modules/@types/node/package.json +30 -25
- package/lib/handlers/node_modules/@types/node/path.d.ts +59 -31
- package/lib/handlers/node_modules/@types/node/perf_hooks.d.ts +420 -105
- package/lib/handlers/node_modules/@types/node/process.d.ts +1249 -228
- package/lib/handlers/node_modules/@types/node/punycode.d.ts +67 -25
- package/lib/handlers/node_modules/@types/node/querystring.d.ts +113 -10
- package/lib/handlers/node_modules/@types/node/readline/promises.d.ts +143 -0
- package/lib/handlers/node_modules/@types/node/readline.d.ts +570 -109
- package/lib/handlers/node_modules/@types/node/repl.d.ts +154 -125
- package/lib/handlers/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/lib/handlers/node_modules/@types/node/stream/promises.d.ts +18 -43
- package/lib/handlers/node_modules/@types/node/stream/web.d.ts +330 -0
- package/lib/handlers/node_modules/@types/node/stream.d.ts +1117 -248
- package/lib/handlers/node_modules/@types/node/string_decoder.d.ts +60 -0
- package/lib/handlers/node_modules/@types/node/test.d.ts +446 -0
- package/lib/handlers/node_modules/@types/node/timers/promises.d.ts +81 -9
- package/lib/handlers/node_modules/@types/node/timers.d.ts +84 -17
- package/lib/handlers/node_modules/@types/node/tls.d.ts +510 -275
- package/lib/handlers/node_modules/@types/node/trace_events.d.ts +120 -10
- package/lib/handlers/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/async_hooks.d.ts +501 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/buffer.d.ts +2259 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/child_process.d.ts +1369 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/console.d.ts +412 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/crypto.d.ts +3964 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +153 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/dns.d.ts +659 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/events.d.ts +678 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/fs.d.ts +3872 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/globals.d.ts +294 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/http.d.ts +1651 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/http2.d.ts +2134 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/https.d.ts +542 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/module.d.ts +114 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/net.d.ts +869 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/os.d.ts +466 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/process.d.ts +1482 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/stream.d.ts +1340 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/test.d.ts +446 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/tls.d.ts +1028 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/url.d.ts +897 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/util.d.ts +1926 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/v8.d.ts +396 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/vm.d.ts +509 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/worker_threads.d.ts +689 -0
- package/lib/handlers/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/lib/handlers/node_modules/@types/node/tty.d.ts +163 -23
- package/lib/handlers/node_modules/@types/node/url.d.ts +825 -44
- package/lib/handlers/node_modules/@types/node/util.d.ts +1842 -72
- package/lib/handlers/node_modules/@types/node/v8.d.ts +276 -78
- package/lib/handlers/node_modules/@types/node/vm.d.ts +410 -53
- package/lib/handlers/node_modules/@types/node/wasi.d.ts +102 -30
- package/lib/handlers/node_modules/@types/node/worker_threads.d.ts +559 -152
- package/lib/handlers/node_modules/@types/node/zlib.d.ts +234 -78
- package/lib/handlers/node_modules/esbuild/README.md +3 -0
- package/lib/handlers/node_modules/esbuild/bin/esbuild +0 -0
- package/lib/handlers/node_modules/esbuild/install.js +256 -0
- package/lib/handlers/node_modules/esbuild/lib/main.d.ts +397 -0
- package/lib/handlers/node_modules/esbuild/lib/main.js +1939 -0
- package/lib/handlers/node_modules/esbuild/package.json +15 -0
- package/lib/handlers/package-lock.json +62 -6
- package/lib/handlers/package.json +6 -1
- package/lib/handlers/prerender-check.ts +8 -27
- package/lib/handlers/prerender.ts +8 -43
- package/package.json +1 -1
- package/lib/handlers/node_modules/@types/node/base.d.ts +0 -19
- package/lib/handlers/node_modules/@types/node/diagnostic_channel.d.ts +0 -34
- package/lib/handlers/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
- package/lib/handlers/node_modules/@types/node/ts3.6/base.d.ts +0 -68
- package/lib/handlers/node_modules/@types/node/ts3.6/index.d.ts +0 -7
- package/lib/handlers/node_modules/@types/node/util/types.d.ts +0 -53
|
@@ -1,7 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `string_decoder` module provides an API for decoding `Buffer` objects into
|
|
3
|
+
* strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
|
4
|
+
* characters. It can be accessed using:
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* const { StringDecoder } = require('string_decoder');
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* The following example shows the basic use of the `StringDecoder` class.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* const { StringDecoder } = require('string_decoder');
|
|
14
|
+
* const decoder = new StringDecoder('utf8');
|
|
15
|
+
*
|
|
16
|
+
* const cent = Buffer.from([0xC2, 0xA2]);
|
|
17
|
+
* console.log(decoder.write(cent));
|
|
18
|
+
*
|
|
19
|
+
* const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
|
20
|
+
* console.log(decoder.write(euro));
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* When a `Buffer` instance is written to the `StringDecoder` instance, an
|
|
24
|
+
* internal buffer is used to ensure that the decoded string does not contain
|
|
25
|
+
* any incomplete multibyte characters. These are held in the buffer until the
|
|
26
|
+
* next call to `stringDecoder.write()` or until `stringDecoder.end()` is called.
|
|
27
|
+
*
|
|
28
|
+
* In the following example, the three UTF-8 encoded bytes of the European Euro
|
|
29
|
+
* symbol (`€`) are written over three separate operations:
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* const { StringDecoder } = require('string_decoder');
|
|
33
|
+
* const decoder = new StringDecoder('utf8');
|
|
34
|
+
*
|
|
35
|
+
* decoder.write(Buffer.from([0xE2]));
|
|
36
|
+
* decoder.write(Buffer.from([0x82]));
|
|
37
|
+
* console.log(decoder.end(Buffer.from([0xAC])));
|
|
38
|
+
* ```
|
|
39
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js)
|
|
40
|
+
*/
|
|
1
41
|
declare module 'string_decoder' {
|
|
2
42
|
class StringDecoder {
|
|
3
43
|
constructor(encoding?: BufferEncoding);
|
|
44
|
+
/**
|
|
45
|
+
* Returns a decoded string, ensuring that any incomplete multibyte characters at
|
|
46
|
+
* the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the
|
|
47
|
+
* returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`.
|
|
48
|
+
* @since v0.1.99
|
|
49
|
+
* @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
|
50
|
+
*/
|
|
4
51
|
write(buffer: Buffer): string;
|
|
52
|
+
/**
|
|
53
|
+
* Returns any remaining input stored in the internal buffer as a string. Bytes
|
|
54
|
+
* representing incomplete UTF-8 and UTF-16 characters will be replaced with
|
|
55
|
+
* substitution characters appropriate for the character encoding.
|
|
56
|
+
*
|
|
57
|
+
* If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input.
|
|
58
|
+
* After `end()` is called, the `stringDecoder` object can be reused for new input.
|
|
59
|
+
* @since v0.9.3
|
|
60
|
+
* @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
|
|
61
|
+
*/
|
|
5
62
|
end(buffer?: Buffer): string;
|
|
6
63
|
}
|
|
7
64
|
}
|
|
65
|
+
declare module 'node:string_decoder' {
|
|
66
|
+
export * from 'string_decoder';
|
|
67
|
+
}
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `node:test` module provides a standalone testing module.
|
|
3
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.x/lib/test.js)
|
|
4
|
+
*/
|
|
5
|
+
declare module 'node:test' {
|
|
6
|
+
/**
|
|
7
|
+
* Programmatically start the test runner.
|
|
8
|
+
* @since v18.9.0
|
|
9
|
+
* @param options Configuration options for running tests.
|
|
10
|
+
* @returns A {@link TapStream} that emits events about the test execution.
|
|
11
|
+
*/
|
|
12
|
+
function run(options?: RunOptions): TapStream;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The `test()` function is the value imported from the test module. Each invocation of this
|
|
16
|
+
* function results in the creation of a test point in the TAP output.
|
|
17
|
+
*
|
|
18
|
+
* The {@link TestContext} object passed to the fn argument can be used to perform actions
|
|
19
|
+
* related to the current test. Examples include skipping the test, adding additional TAP
|
|
20
|
+
* diagnostic information, or creating subtests.
|
|
21
|
+
*
|
|
22
|
+
* `test()` returns a {@link Promise} that resolves once the test completes. The return value
|
|
23
|
+
* can usually be discarded for top level tests. However, the return value from subtests should
|
|
24
|
+
* be used to prevent the parent test from finishing first and cancelling the subtest as shown
|
|
25
|
+
* in the following example.
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* test('top level test', async (t) => {
|
|
29
|
+
* // The setTimeout() in the following subtest would cause it to outlive its
|
|
30
|
+
* // parent test if 'await' is removed on the next line. Once the parent test
|
|
31
|
+
* // completes, it will cancel any outstanding subtests.
|
|
32
|
+
* await t.test('longer running subtest', async (t) => {
|
|
33
|
+
* return new Promise((resolve, reject) => {
|
|
34
|
+
* setTimeout(resolve, 1000);
|
|
35
|
+
* });
|
|
36
|
+
* });
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
* @since v18.0.0
|
|
40
|
+
* @param name The name of the test, which is displayed when reporting test results.
|
|
41
|
+
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
|
42
|
+
* @param options Configuration options for the test
|
|
43
|
+
* @param fn The function under test. The first argument to this function is a
|
|
44
|
+
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
|
45
|
+
* passed as the second argument. Default: A no-op function.
|
|
46
|
+
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
47
|
+
*/
|
|
48
|
+
function test(name?: string, fn?: TestFn): Promise<void>;
|
|
49
|
+
function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
50
|
+
function test(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
51
|
+
function test(fn?: TestFn): Promise<void>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @since v18.6.0
|
|
55
|
+
* @param name The name of the suite, which is displayed when reporting suite results.
|
|
56
|
+
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
|
57
|
+
* @param options Configuration options for the suite
|
|
58
|
+
* @param fn The function under suite. Default: A no-op function.
|
|
59
|
+
*/
|
|
60
|
+
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
|
61
|
+
function describe(name?: string, fn?: SuiteFn): void;
|
|
62
|
+
function describe(options?: TestOptions, fn?: SuiteFn): void;
|
|
63
|
+
function describe(fn?: SuiteFn): void;
|
|
64
|
+
namespace describe {
|
|
65
|
+
// Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
|
|
66
|
+
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
|
67
|
+
function skip(name?: string, fn?: SuiteFn): void;
|
|
68
|
+
function skip(options?: TestOptions, fn?: SuiteFn): void;
|
|
69
|
+
function skip(fn?: SuiteFn): void;
|
|
70
|
+
|
|
71
|
+
// Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
|
|
72
|
+
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void;
|
|
73
|
+
function todo(name?: string, fn?: SuiteFn): void;
|
|
74
|
+
function todo(options?: TestOptions, fn?: SuiteFn): void;
|
|
75
|
+
function todo(fn?: SuiteFn): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @since v18.6.0
|
|
80
|
+
* @param name The name of the test, which is displayed when reporting test results.
|
|
81
|
+
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
|
82
|
+
* @param options Configuration options for the test
|
|
83
|
+
* @param fn The function under test. If the test uses callbacks, the callback function is
|
|
84
|
+
* passed as the second argument. Default: A no-op function.
|
|
85
|
+
*/
|
|
86
|
+
function it(name?: string, options?: TestOptions, fn?: ItFn): void;
|
|
87
|
+
function it(name?: string, fn?: ItFn): void;
|
|
88
|
+
function it(options?: TestOptions, fn?: ItFn): void;
|
|
89
|
+
function it(fn?: ItFn): void;
|
|
90
|
+
namespace it {
|
|
91
|
+
// Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
|
|
92
|
+
function skip(name?: string, options?: TestOptions, fn?: ItFn): void;
|
|
93
|
+
function skip(name?: string, fn?: ItFn): void;
|
|
94
|
+
function skip(options?: TestOptions, fn?: ItFn): void;
|
|
95
|
+
function skip(fn?: ItFn): void;
|
|
96
|
+
|
|
97
|
+
// Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
|
|
98
|
+
function todo(name?: string, options?: TestOptions, fn?: ItFn): void;
|
|
99
|
+
function todo(name?: string, fn?: ItFn): void;
|
|
100
|
+
function todo(options?: TestOptions, fn?: ItFn): void;
|
|
101
|
+
function todo(fn?: ItFn): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The type of a function under test. The first argument to this function is a
|
|
106
|
+
* {@link TestContext} object. If the test uses callbacks, the callback function is passed as
|
|
107
|
+
* the second argument.
|
|
108
|
+
*/
|
|
109
|
+
type TestFn = (t: TestContext, done: (result?: any) => void) => any;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The type of a function under Suite.
|
|
113
|
+
* If the test uses callbacks, the callback function is passed as an argument
|
|
114
|
+
*/
|
|
115
|
+
type SuiteFn = (done: (result?: any) => void) => void;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The type of a function under test.
|
|
119
|
+
* If the test uses callbacks, the callback function is passed as an argument
|
|
120
|
+
*/
|
|
121
|
+
type ItFn = (done: (result?: any) => void) => any;
|
|
122
|
+
|
|
123
|
+
interface RunOptions {
|
|
124
|
+
/**
|
|
125
|
+
* If a number is provided, then that many files would run in parallel.
|
|
126
|
+
* If truthy, it would run (number of cpu cores - 1) files in parallel.
|
|
127
|
+
* If falsy, it would only run one file at a time.
|
|
128
|
+
* If unspecified, subtests inherit this value from their parent.
|
|
129
|
+
* @default true
|
|
130
|
+
*/
|
|
131
|
+
concurrency?: number | boolean | undefined;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* An array containing the list of files to run.
|
|
135
|
+
* If unspecified, the test runner execution model will be used.
|
|
136
|
+
*/
|
|
137
|
+
files?: readonly string[] | undefined;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Allows aborting an in-progress test execution.
|
|
141
|
+
* @default undefined
|
|
142
|
+
*/
|
|
143
|
+
signal?: AbortSignal | undefined;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A number of milliseconds the test will fail after.
|
|
147
|
+
* If unspecified, subtests inherit this value from their parent.
|
|
148
|
+
* @default Infinity
|
|
149
|
+
*/
|
|
150
|
+
timeout?: number | undefined;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Sets inspector port of test child process.
|
|
154
|
+
* If a nullish value is provided, each process gets its own port,
|
|
155
|
+
* incremented from the primary's `process.debugPort`.
|
|
156
|
+
*/
|
|
157
|
+
inspectPort?: number | (() => number) | undefined;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A successful call of the `run()` method will return a new `TapStream` object,
|
|
162
|
+
* streaming a [TAP](https://testanything.org/) output.
|
|
163
|
+
* `TapStream` will emit events in the order of the tests' definitions.
|
|
164
|
+
* @since v18.9.0
|
|
165
|
+
*/
|
|
166
|
+
interface TapStream extends NodeJS.ReadableStream {
|
|
167
|
+
addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
|
168
|
+
addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
169
|
+
addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
170
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
171
|
+
emit(event: 'test:diagnostic', message: string): boolean;
|
|
172
|
+
emit(event: 'test:fail', data: TestFail): boolean;
|
|
173
|
+
emit(event: 'test:pass', data: TestPass): boolean;
|
|
174
|
+
emit(event: string | symbol, ...args: any[]): boolean;
|
|
175
|
+
on(event: 'test:diagnostic', listener: (message: string) => void): this;
|
|
176
|
+
on(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
177
|
+
on(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
178
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
179
|
+
once(event: 'test:diagnostic', listener: (message: string) => void): this;
|
|
180
|
+
once(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
181
|
+
once(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
182
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
183
|
+
prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
|
184
|
+
prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
185
|
+
prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
186
|
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
187
|
+
prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
|
|
188
|
+
prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
|
|
189
|
+
prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
|
|
190
|
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface TestFail {
|
|
194
|
+
/**
|
|
195
|
+
* The test duration.
|
|
196
|
+
*/
|
|
197
|
+
duration: number;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The failure casing test to fail.
|
|
201
|
+
*/
|
|
202
|
+
error: Error;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The test name.
|
|
206
|
+
*/
|
|
207
|
+
name: string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The ordinal number of the test.
|
|
211
|
+
*/
|
|
212
|
+
testNumber: number;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Present if `context.todo` is called.
|
|
216
|
+
*/
|
|
217
|
+
todo?: string;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Present if `context.skip` is called.
|
|
221
|
+
*/
|
|
222
|
+
skip?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface TestPass {
|
|
226
|
+
/**
|
|
227
|
+
* The test duration.
|
|
228
|
+
*/
|
|
229
|
+
duration: number;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The test name.
|
|
233
|
+
*/
|
|
234
|
+
name: string;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The ordinal number of the test.
|
|
238
|
+
*/
|
|
239
|
+
testNumber: number;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Present if `context.todo` is called.
|
|
243
|
+
*/
|
|
244
|
+
todo?: string;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Present if `context.skip` is called.
|
|
248
|
+
*/
|
|
249
|
+
skip?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* An instance of `TestContext` is passed to each test function in order to interact with the
|
|
254
|
+
* test runner. However, the `TestContext` constructor is not exposed as part of the API.
|
|
255
|
+
* @since v18.0.0
|
|
256
|
+
*/
|
|
257
|
+
interface TestContext {
|
|
258
|
+
/**
|
|
259
|
+
* This function is used to create a hook running before each subtest of the current test.
|
|
260
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
261
|
+
* the second argument. Default: A no-op function.
|
|
262
|
+
* @param options Configuration options for the hook.
|
|
263
|
+
* @since v18.8.0
|
|
264
|
+
*/
|
|
265
|
+
beforeEach: typeof beforeEach;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* This function is used to create a hook running after each subtest of the current test.
|
|
269
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
270
|
+
* the second argument. Default: A no-op function.
|
|
271
|
+
* @param options Configuration options for the hook.
|
|
272
|
+
* @since v18.8.0
|
|
273
|
+
*/
|
|
274
|
+
afterEach: typeof afterEach;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* This function is used to write TAP diagnostics to the output. Any diagnostic information is
|
|
278
|
+
* included at the end of the test's results. This function does not return a value.
|
|
279
|
+
* @param message Message to be displayed as a TAP diagnostic.
|
|
280
|
+
* @since v18.0.0
|
|
281
|
+
*/
|
|
282
|
+
diagnostic(message: string): void;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* The name of the test.
|
|
286
|
+
* @since v18.8.0
|
|
287
|
+
*/
|
|
288
|
+
readonly name: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
|
|
292
|
+
* option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
|
|
293
|
+
* command-line option, this function is a no-op.
|
|
294
|
+
* @param shouldRunOnlyTests Whether or not to run `only` tests.
|
|
295
|
+
* @since v18.0.0
|
|
296
|
+
*/
|
|
297
|
+
runOnly(shouldRunOnlyTests: boolean): void;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Can be used to abort test subtasks when the test has been aborted.
|
|
301
|
+
* @since v18.7.0
|
|
302
|
+
*/
|
|
303
|
+
readonly signal: AbortSignal;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* This function causes the test's output to indicate the test as skipped. If `message` is
|
|
307
|
+
* provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
|
|
308
|
+
* the test function. This function does not return a value.
|
|
309
|
+
* @param message Optional skip message to be displayed in TAP output.
|
|
310
|
+
* @since v18.0.0
|
|
311
|
+
*/
|
|
312
|
+
skip(message?: string): void;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* This function adds a `TODO` directive to the test's output. If `message` is provided, it is
|
|
316
|
+
* included in the TAP output. Calling `todo()` does not terminate execution of the test
|
|
317
|
+
* function. This function does not return a value.
|
|
318
|
+
* @param message Optional `TODO` message to be displayed in TAP output.
|
|
319
|
+
* @since v18.0.0
|
|
320
|
+
*/
|
|
321
|
+
todo(message?: string): void;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* This function is used to create subtests under the current test. This function behaves in
|
|
325
|
+
* the same fashion as the top level {@link test} function.
|
|
326
|
+
* @since v18.0.0
|
|
327
|
+
* @param name The name of the test, which is displayed when reporting test results.
|
|
328
|
+
* Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
|
|
329
|
+
* @param options Configuration options for the test
|
|
330
|
+
* @param fn The function under test. This first argument to this function is a
|
|
331
|
+
* {@link TestContext} object. If the test uses callbacks, the callback function is
|
|
332
|
+
* passed as the second argument. Default: A no-op function.
|
|
333
|
+
* @returns A {@link Promise} resolved with `undefined` once the test completes.
|
|
334
|
+
*/
|
|
335
|
+
test: typeof test;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
interface TestOptions {
|
|
339
|
+
/**
|
|
340
|
+
* If a number is provided, then that many tests would run in parallel.
|
|
341
|
+
* If truthy, it would run (number of cpu cores - 1) tests in parallel.
|
|
342
|
+
* For subtests, it will be `Infinity` tests in parallel.
|
|
343
|
+
* If falsy, it would only run one test at a time.
|
|
344
|
+
* If unspecified, subtests inherit this value from their parent.
|
|
345
|
+
* @default false
|
|
346
|
+
*/
|
|
347
|
+
concurrency?: number | boolean | undefined;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* If truthy, and the test context is configured to run `only` tests, then this test will be
|
|
351
|
+
* run. Otherwise, the test is skipped.
|
|
352
|
+
* @default false
|
|
353
|
+
*/
|
|
354
|
+
only?: boolean | undefined;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Allows aborting an in-progress test.
|
|
358
|
+
* @since v18.8.0
|
|
359
|
+
*/
|
|
360
|
+
signal?: AbortSignal | undefined;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* If truthy, the test is skipped. If a string is provided, that string is displayed in the
|
|
364
|
+
* test results as the reason for skipping the test.
|
|
365
|
+
* @default false
|
|
366
|
+
*/
|
|
367
|
+
skip?: boolean | string | undefined;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* A number of milliseconds the test will fail after. If unspecified, subtests inherit this
|
|
371
|
+
* value from their parent.
|
|
372
|
+
* @default Infinity
|
|
373
|
+
* @since v18.7.0
|
|
374
|
+
*/
|
|
375
|
+
timeout?: number | undefined;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
|
|
379
|
+
* the test results as the reason why the test is `TODO`.
|
|
380
|
+
* @default false
|
|
381
|
+
*/
|
|
382
|
+
todo?: boolean | string | undefined;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* This function is used to create a hook running before running a suite.
|
|
387
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
388
|
+
* the second argument. Default: A no-op function.
|
|
389
|
+
* @param options Configuration options for the hook.
|
|
390
|
+
* @since v18.8.0
|
|
391
|
+
*/
|
|
392
|
+
function before(fn?: HookFn, options?: HookOptions): void;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* This function is used to create a hook running after running a suite.
|
|
396
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
397
|
+
* the second argument. Default: A no-op function.
|
|
398
|
+
* @param options Configuration options for the hook.
|
|
399
|
+
* @since v18.8.0
|
|
400
|
+
*/
|
|
401
|
+
function after(fn?: HookFn, options?: HookOptions): void;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* This function is used to create a hook running before each subtest of the current suite.
|
|
405
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
406
|
+
* the second argument. Default: A no-op function.
|
|
407
|
+
* @param options Configuration options for the hook.
|
|
408
|
+
* @since v18.8.0
|
|
409
|
+
*/
|
|
410
|
+
function beforeEach(fn?: HookFn, options?: HookOptions): void;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* This function is used to create a hook running after each subtest of the current test.
|
|
414
|
+
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as
|
|
415
|
+
* the second argument. Default: A no-op function.
|
|
416
|
+
* @param options Configuration options for the hook.
|
|
417
|
+
* @since v18.8.0
|
|
418
|
+
*/
|
|
419
|
+
function afterEach(fn?: HookFn, options?: HookOptions): void;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* The hook function. If the hook uses callbacks, the callback function is passed as the
|
|
423
|
+
* second argument.
|
|
424
|
+
*/
|
|
425
|
+
type HookFn = (done: (result?: any) => void) => any;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Configuration options for hooks.
|
|
429
|
+
* @since v18.8.0
|
|
430
|
+
*/
|
|
431
|
+
interface HookOptions {
|
|
432
|
+
/**
|
|
433
|
+
* Allows aborting an in-progress hook.
|
|
434
|
+
*/
|
|
435
|
+
signal?: AbortSignal | undefined;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* A number of milliseconds the hook will fail after. If unspecified, subtests inherit this
|
|
439
|
+
* value from their parent.
|
|
440
|
+
* @default Infinity
|
|
441
|
+
*/
|
|
442
|
+
timeout?: number | undefined;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach };
|
|
446
|
+
}
|
|
@@ -1,21 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `timers/promises` API provides an alternative set of timer functions
|
|
3
|
+
* that return `Promise` objects. The API is accessible via`require('timers/promises')`.
|
|
4
|
+
*
|
|
5
|
+
* ```js
|
|
6
|
+
* import {
|
|
7
|
+
* setTimeout,
|
|
8
|
+
* setImmediate,
|
|
9
|
+
* setInterval,
|
|
10
|
+
* } from 'timers/promises';
|
|
11
|
+
* ```
|
|
12
|
+
* @since v15.0.0
|
|
13
|
+
*/
|
|
1
14
|
declare module 'timers/promises' {
|
|
2
|
-
import { TimerOptions } from 'timers';
|
|
3
|
-
|
|
15
|
+
import { TimerOptions } from 'node:timers';
|
|
4
16
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import {
|
|
19
|
+
* setTimeout,
|
|
20
|
+
* } from 'timers/promises';
|
|
21
|
+
*
|
|
22
|
+
* const res = await setTimeout(100, 'result');
|
|
23
|
+
*
|
|
24
|
+
* console.log(res); // Prints 'result'
|
|
25
|
+
* ```
|
|
26
|
+
* @since v15.0.0
|
|
27
|
+
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
|
28
|
+
* @param value A value with which the promise is fulfilled.
|
|
7
29
|
*/
|
|
8
30
|
function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
|
9
|
-
|
|
10
31
|
/**
|
|
11
|
-
*
|
|
32
|
+
* ```js
|
|
33
|
+
* import {
|
|
34
|
+
* setImmediate,
|
|
35
|
+
* } from 'timers/promises';
|
|
36
|
+
*
|
|
37
|
+
* const res = await setImmediate('result');
|
|
38
|
+
*
|
|
39
|
+
* console.log(res); // Prints 'result'
|
|
40
|
+
* ```
|
|
41
|
+
* @since v15.0.0
|
|
42
|
+
* @param value A value with which the promise is fulfilled.
|
|
12
43
|
*/
|
|
13
44
|
function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
|
14
|
-
|
|
15
45
|
/**
|
|
46
|
+
* Returns an async iterator that generates values in an interval of `delay` ms.
|
|
47
|
+
*
|
|
48
|
+
* ```js
|
|
49
|
+
* import {
|
|
50
|
+
* setInterval,
|
|
51
|
+
* } from 'timers/promises';
|
|
16
52
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
53
|
+
* const interval = 100;
|
|
54
|
+
* for await (const startTime of setInterval(interval, Date.now())) {
|
|
55
|
+
* const now = Date.now();
|
|
56
|
+
* console.log(now);
|
|
57
|
+
* if ((now - startTime) > 1000)
|
|
58
|
+
* break;
|
|
59
|
+
* }
|
|
60
|
+
* console.log(Date.now());
|
|
61
|
+
* ```
|
|
62
|
+
* @since v15.9.0
|
|
19
63
|
*/
|
|
20
64
|
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
|
65
|
+
|
|
66
|
+
interface Scheduler {
|
|
67
|
+
/**
|
|
68
|
+
* ```js
|
|
69
|
+
* import { scheduler } from 'node:timers/promises';
|
|
70
|
+
*
|
|
71
|
+
* await scheduler.wait(1000); // Wait one second before continuing
|
|
72
|
+
* ```
|
|
73
|
+
* An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API.
|
|
74
|
+
* Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported.
|
|
75
|
+
* @since v16.14.0
|
|
76
|
+
* @experimental
|
|
77
|
+
* @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
|
|
78
|
+
*/
|
|
79
|
+
wait: (delay?: number, options?: TimerOptions) => Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API.
|
|
82
|
+
* Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments.
|
|
83
|
+
* @since v16.14.0
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
yield: () => Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const scheduler: Scheduler;
|
|
90
|
+
}
|
|
91
|
+
declare module 'node:timers/promises' {
|
|
92
|
+
export * from 'timers/promises';
|
|
21
93
|
}
|