@orkestrel/test 0.0.11 → 0.0.13
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/README.md +58 -39
- package/dist/src/browser/index.d.ts +516 -268
- package/dist/src/browser/index.js +363 -89
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +191 -23
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +272 -23
- package/dist/src/core/index.d.ts +272 -23
- package/dist/src/core/index.js +185 -24
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +69 -50
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +74 -36
- package/dist/src/server/index.d.ts +74 -36
- package/dist/src/server/index.js +68 -52
- package/dist/src/server/index.js.map +1 -1
- package/package.json +14 -11
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Server } from 'node:net';
|
|
2
2
|
import { Socket } from 'node:net';
|
|
3
|
+
import { Stats } from 'node:fs';
|
|
3
4
|
import { WaitOptions } from '@orkestrel/test';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
+
/** Holds a name-keyed cookie store a test drives one origin with, filled from real responses. */
|
|
6
7
|
export declare interface CookieJarInterface {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Reports the `Cookie` request header naming every stored cookie, or `undefined` while the jar
|
|
10
|
+
* holds none.
|
|
9
11
|
*/
|
|
10
12
|
readonly header: string | undefined;
|
|
11
13
|
/**
|
|
@@ -68,8 +70,8 @@ export declare function createLoopback(server: Server): Promise<LoopbackInterfac
|
|
|
68
70
|
* @returns The scratch directory and its file operations.
|
|
69
71
|
* @throws When the parent is missing, a symbolic link, or not a directory; when the prefix contains
|
|
70
72
|
* `/` or `\`; or when allocation or seeding fails.
|
|
71
|
-
* @remarks
|
|
72
|
-
*
|
|
73
|
+
* @remarks Default parent: the host temporary directory. Default prefix: `orkestrel-test-`. Seed
|
|
74
|
+
* keys use root-relative paths.
|
|
73
75
|
*/
|
|
74
76
|
export declare function createScratch(options?: ScratchOptions): ScratchInterface;
|
|
75
77
|
|
|
@@ -100,13 +102,14 @@ export declare function createScratch(options?: ScratchOptions): ScratchInterfac
|
|
|
100
102
|
*/
|
|
101
103
|
export declare function destroyScratch(scratch: ScratchInterface, options?: WaitOptions): Promise<void>;
|
|
102
104
|
|
|
103
|
-
/**
|
|
105
|
+
/** Configures a source inventory read. */
|
|
104
106
|
export declare interface InventoryOptions {
|
|
105
|
-
/**
|
|
107
|
+
/** Lists the file extensions to include, each written with its leading dot. */
|
|
106
108
|
readonly extensions?: readonly string[];
|
|
107
109
|
/**
|
|
108
|
-
*
|
|
109
|
-
* on whole segments, so `excluded` drops `excluded/file.ts` and keeps
|
|
110
|
+
* Lists the root-relative path keys to exclude. A key excludes itself and every key below it,
|
|
111
|
+
* matched on whole segments, so `excluded` drops `excluded/file.ts` and keeps
|
|
112
|
+
* `excluded-other/file.ts`.
|
|
110
113
|
*/
|
|
111
114
|
readonly exclude?: readonly string[];
|
|
112
115
|
}
|
|
@@ -116,7 +119,7 @@ export declare interface InventoryOptions {
|
|
|
116
119
|
*
|
|
117
120
|
* @param key - The root-relative key to test.
|
|
118
121
|
* @param exclusions - The normalized root-relative exclusion keys.
|
|
119
|
-
* @returns
|
|
122
|
+
* @returns True if an exclusion names the key or one of its ancestors; false otherwise.
|
|
120
123
|
*/
|
|
121
124
|
export declare function isExcluded(key: string, exclusions: readonly string[]): boolean;
|
|
122
125
|
|
|
@@ -139,14 +142,14 @@ export declare function isExcluded(key: string, exclusions: readonly string[]):
|
|
|
139
142
|
*/
|
|
140
143
|
export declare function isRunning(pid: number): boolean;
|
|
141
144
|
|
|
142
|
-
/**
|
|
145
|
+
/** Holds a server a test owns, listening on an ephemeral loopback port until the test releases it. */
|
|
143
146
|
export declare interface LoopbackInterface {
|
|
144
147
|
/**
|
|
145
|
-
*
|
|
146
|
-
* same port under `https`.
|
|
148
|
+
* Names the `http` origin for the assigned port, without a trailing slash. A TLS server answers
|
|
149
|
+
* on the same port under `https`.
|
|
147
150
|
*/
|
|
148
151
|
readonly url: string;
|
|
149
|
-
/**
|
|
152
|
+
/** Holds the ephemeral port the host assigned. */
|
|
150
153
|
readonly port: number;
|
|
151
154
|
/**
|
|
152
155
|
* Drops every live connection on a server that carries `closeAllConnections`, stops listening, and
|
|
@@ -162,13 +165,33 @@ export declare interface LoopbackInterface {
|
|
|
162
165
|
*
|
|
163
166
|
* @param current - The identity read from the path now.
|
|
164
167
|
* @param allocation - The identity recorded when the directory was allocated.
|
|
165
|
-
* @returns
|
|
168
|
+
* @returns True if the device, the index node, and the creation time all match; false otherwise.
|
|
166
169
|
* @remarks All three fields are compared because none of them alone identifies an allocation. A
|
|
167
170
|
* device is shared by every directory on one filesystem, an index node is reused once its directory
|
|
168
171
|
* is removed, and a creation time repeats within the host's timestamp resolution.
|
|
169
172
|
*/
|
|
170
173
|
export declare function matchesIdentity(current: ScratchIdentity, allocation: ScratchIdentity): boolean;
|
|
171
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Reads the `code` an unknown thrown value carries.
|
|
177
|
+
*
|
|
178
|
+
* @param error - The thrown value to read.
|
|
179
|
+
* @returns The string `code` the value carries, or `undefined` when it carries none.
|
|
180
|
+
* @remarks The read is contained on its own terms: a value that is not an object, one carrying no
|
|
181
|
+
* `code`, and one carrying a `code` that is not a string all answer `undefined`. A null-prototype
|
|
182
|
+
* object is read the same way, because the key is tested with `in` rather than through
|
|
183
|
+
* `hasOwnProperty`.
|
|
184
|
+
*/
|
|
185
|
+
export declare function readErrorCode(error: unknown): string | undefined;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Reads the identity of one allocated directory off a host status.
|
|
189
|
+
*
|
|
190
|
+
* @param status - The status read from the directory's path.
|
|
191
|
+
* @returns The device, index node, and creation time that together name the allocation.
|
|
192
|
+
*/
|
|
193
|
+
export declare function readIdentity(status: Stats): ScratchIdentity;
|
|
194
|
+
|
|
172
195
|
/**
|
|
173
196
|
* Reads files from selected targets below a root directory.
|
|
174
197
|
*
|
|
@@ -185,17 +208,17 @@ export declare function matchesIdentity(current: ScratchIdentity, allocation: Sc
|
|
|
185
208
|
export declare function readInventory(root: URL | string, targets: readonly string[], options?: InventoryOptions): Readonly<Record<string, string>>;
|
|
186
209
|
|
|
187
210
|
/**
|
|
188
|
-
*
|
|
211
|
+
* Caps the attempts `removeTree` makes before rethrowing a retryable removal error.
|
|
189
212
|
*/
|
|
190
213
|
export declare const REMOVE_TREE_MAX_ATTEMPTS = 10;
|
|
191
214
|
|
|
192
215
|
/**
|
|
193
|
-
*
|
|
216
|
+
* Names the synchronous delay, in milliseconds, `removeTree` waits between attempts.
|
|
194
217
|
*/
|
|
195
218
|
export declare const REMOVE_TREE_RETRY_DELAY_MS = 100;
|
|
196
219
|
|
|
197
220
|
/**
|
|
198
|
-
*
|
|
221
|
+
* Names the error codes `removeTree` retries; every other code rethrows immediately.
|
|
199
222
|
*/
|
|
200
223
|
export declare const REMOVE_TREE_RETRYABLE_CODES: readonly string[];
|
|
201
224
|
|
|
@@ -248,6 +271,20 @@ export declare function removeTree(path: string): void;
|
|
|
248
271
|
*/
|
|
249
272
|
export declare function requestUpgrade(port: number, options?: UpgradeOptions): Promise<UpgradeResult>;
|
|
250
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Resolves a target that stays below a root directory, refusing an escape.
|
|
276
|
+
*
|
|
277
|
+
* @param root - The absolute root directory.
|
|
278
|
+
* @param target - The relative or absolute target to resolve.
|
|
279
|
+
* @returns The absolute target below the root.
|
|
280
|
+
* @throws An `Error` reading `Path outside scratch directory: <target>` when the target escapes the
|
|
281
|
+
* root.
|
|
282
|
+
* @remarks This is {@link resolveContained} with the refusal every contained scratch operation makes
|
|
283
|
+
* of an escape, so the check and its one message are stated once. Read `resolveContained` where an
|
|
284
|
+
* escape is an answer rather than a refusal.
|
|
285
|
+
*/
|
|
286
|
+
export declare function requireContained(root: string, target: string): string;
|
|
287
|
+
|
|
251
288
|
/**
|
|
252
289
|
* Resolves a target that stays below a root directory.
|
|
253
290
|
*
|
|
@@ -257,19 +294,19 @@ export declare function requestUpgrade(port: number, options?: UpgradeOptions):
|
|
|
257
294
|
*/
|
|
258
295
|
export declare function resolveContained(root: string, target: string): string | undefined;
|
|
259
296
|
|
|
260
|
-
/**
|
|
297
|
+
/** Represents the fields that together identify one allocated directory on its host. */
|
|
261
298
|
export declare interface ScratchIdentity {
|
|
262
|
-
/**
|
|
299
|
+
/** Holds the identifier of the device holding the directory. */
|
|
263
300
|
readonly device: number;
|
|
264
|
-
/**
|
|
301
|
+
/** Holds the number of the directory's index node on that device. */
|
|
265
302
|
readonly inode: number;
|
|
266
|
-
/**
|
|
303
|
+
/** Holds the directory's creation time in milliseconds. */
|
|
267
304
|
readonly birth: number;
|
|
268
305
|
}
|
|
269
306
|
|
|
270
|
-
/**
|
|
307
|
+
/** Holds a temporary directory a test owns, writes into, reads back, and removes when it is done. */
|
|
271
308
|
export declare interface ScratchInterface {
|
|
272
|
-
/**
|
|
309
|
+
/** Holds the absolute path of the allocated directory. */
|
|
273
310
|
readonly path: string;
|
|
274
311
|
/**
|
|
275
312
|
* Writes a file, creating each parent directory that does not exist.
|
|
@@ -296,15 +333,16 @@ export declare interface ScratchInterface {
|
|
|
296
333
|
* Reports whether a path exists without following its final symbolic link.
|
|
297
334
|
*
|
|
298
335
|
* @param target - A relative or absolute path contained by the scratch directory.
|
|
299
|
-
* @returns True
|
|
336
|
+
* @returns True if the entry exists, including a symbolic link whose target is
|
|
337
|
+
* missing; false otherwise.
|
|
300
338
|
* @throws When the path escapes the scratch directory or its root is a symbolic link or file.
|
|
301
339
|
*/
|
|
302
340
|
has(target: string): boolean;
|
|
303
341
|
/**
|
|
304
342
|
* Lists the names directly inside a directory in sorted order.
|
|
305
343
|
*
|
|
306
|
-
* @param target - A relative or absolute directory path contained by the scratch directory.
|
|
307
|
-
* scratch root
|
|
344
|
+
* @param target - A relative or absolute directory path contained by the scratch directory.
|
|
345
|
+
* Default: the scratch root.
|
|
308
346
|
* @returns The sorted entry names, without their parent paths.
|
|
309
347
|
* @throws When the path escapes the scratch directory, the target is missing or is not a
|
|
310
348
|
* directory, or the scratch root is a symbolic link or file.
|
|
@@ -353,23 +391,23 @@ export declare interface ScratchInterface {
|
|
|
353
391
|
destroy(): void;
|
|
354
392
|
}
|
|
355
393
|
|
|
356
|
-
/**
|
|
394
|
+
/** Configures a scratch directory allocation. */
|
|
357
395
|
export declare interface ScratchOptions {
|
|
358
396
|
/**
|
|
359
|
-
*
|
|
397
|
+
* Names the existing directory in which to create the allocation. Defaults to the host temporary
|
|
360
398
|
* directory. Allocation throws when this path is missing, a symbolic link, or not a directory.
|
|
361
399
|
*/
|
|
362
400
|
readonly parent?: string;
|
|
363
401
|
/**
|
|
364
|
-
*
|
|
365
|
-
* contains `/` or `\`. Both are refused on every host, so the rule does not vary by host. A
|
|
402
|
+
* Holds the name fragment that starts the generated directory name. Allocation throws when this
|
|
403
|
+
* value contains `/` or `\`. Both are refused on every host, so the rule does not vary by host. A
|
|
366
404
|
* fragment carrying no separator is one path segment and cannot steer the allocation, so
|
|
367
405
|
* `release-0..2-` allocates.
|
|
368
406
|
*/
|
|
369
407
|
readonly prefix?: string;
|
|
370
408
|
/**
|
|
371
|
-
*
|
|
372
|
-
* directory and rethrows when a key escapes or the host refuses a write.
|
|
409
|
+
* Holds the files to write on allocation, keyed by path below the scratch directory. Allocation
|
|
410
|
+
* removes its directory and rethrows when a key escapes or the host refuses a write.
|
|
373
411
|
*/
|
|
374
412
|
readonly files?: Readonly<Record<string, string>>;
|
|
375
413
|
}
|
|
@@ -449,23 +487,23 @@ export declare function supportsFileLinks(): boolean;
|
|
|
449
487
|
export declare function supportsMode(): boolean;
|
|
450
488
|
|
|
451
489
|
/**
|
|
452
|
-
*
|
|
490
|
+
* Configures a client upgrade request.
|
|
453
491
|
*
|
|
454
492
|
* @remarks The time bounds and abort signal bound the wait for the server's answer, so a server
|
|
455
493
|
* that accepts the connection and never answers ends the call rather than parking it.
|
|
456
494
|
*/
|
|
457
495
|
export declare interface UpgradeOptions extends WaitOptions {
|
|
458
|
-
/**
|
|
496
|
+
/** Names the request path, written with its leading slash. Defaults to `/`. */
|
|
459
497
|
readonly path?: string;
|
|
460
498
|
/**
|
|
461
|
-
*
|
|
499
|
+
* Lists the subprotocol tokens the request offers. They are sent as one comma-separated
|
|
462
500
|
* `Sec-WebSocket-Protocol` field, and an empty or omitted list sends no field at all.
|
|
463
501
|
*/
|
|
464
502
|
readonly protocols?: readonly string[];
|
|
465
503
|
}
|
|
466
504
|
|
|
467
505
|
/**
|
|
468
|
-
*
|
|
506
|
+
* Represents what one server did with a client upgrade request.
|
|
469
507
|
*
|
|
470
508
|
* @remarks `claimed` is the discriminant. The claimed arm carries `protocol`, the subprotocol the
|
|
471
509
|
* server selected, which is `undefined` when it selected none; a claimed upgrade produced no plain
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Server } from 'node:net';
|
|
2
2
|
import { Socket } from 'node:net';
|
|
3
|
+
import { Stats } from 'node:fs';
|
|
3
4
|
import { WaitOptions } from '@orkestrel/test';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
+
/** Holds a name-keyed cookie store a test drives one origin with, filled from real responses. */
|
|
6
7
|
export declare interface CookieJarInterface {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Reports the `Cookie` request header naming every stored cookie, or `undefined` while the jar
|
|
10
|
+
* holds none.
|
|
9
11
|
*/
|
|
10
12
|
readonly header: string | undefined;
|
|
11
13
|
/**
|
|
@@ -68,8 +70,8 @@ export declare function createLoopback(server: Server): Promise<LoopbackInterfac
|
|
|
68
70
|
* @returns The scratch directory and its file operations.
|
|
69
71
|
* @throws When the parent is missing, a symbolic link, or not a directory; when the prefix contains
|
|
70
72
|
* `/` or `\`; or when allocation or seeding fails.
|
|
71
|
-
* @remarks
|
|
72
|
-
*
|
|
73
|
+
* @remarks Default parent: the host temporary directory. Default prefix: `orkestrel-test-`. Seed
|
|
74
|
+
* keys use root-relative paths.
|
|
73
75
|
*/
|
|
74
76
|
export declare function createScratch(options?: ScratchOptions): ScratchInterface;
|
|
75
77
|
|
|
@@ -100,13 +102,14 @@ export declare function createScratch(options?: ScratchOptions): ScratchInterfac
|
|
|
100
102
|
*/
|
|
101
103
|
export declare function destroyScratch(scratch: ScratchInterface, options?: WaitOptions): Promise<void>;
|
|
102
104
|
|
|
103
|
-
/**
|
|
105
|
+
/** Configures a source inventory read. */
|
|
104
106
|
export declare interface InventoryOptions {
|
|
105
|
-
/**
|
|
107
|
+
/** Lists the file extensions to include, each written with its leading dot. */
|
|
106
108
|
readonly extensions?: readonly string[];
|
|
107
109
|
/**
|
|
108
|
-
*
|
|
109
|
-
* on whole segments, so `excluded` drops `excluded/file.ts` and keeps
|
|
110
|
+
* Lists the root-relative path keys to exclude. A key excludes itself and every key below it,
|
|
111
|
+
* matched on whole segments, so `excluded` drops `excluded/file.ts` and keeps
|
|
112
|
+
* `excluded-other/file.ts`.
|
|
110
113
|
*/
|
|
111
114
|
readonly exclude?: readonly string[];
|
|
112
115
|
}
|
|
@@ -116,7 +119,7 @@ export declare interface InventoryOptions {
|
|
|
116
119
|
*
|
|
117
120
|
* @param key - The root-relative key to test.
|
|
118
121
|
* @param exclusions - The normalized root-relative exclusion keys.
|
|
119
|
-
* @returns
|
|
122
|
+
* @returns True if an exclusion names the key or one of its ancestors; false otherwise.
|
|
120
123
|
*/
|
|
121
124
|
export declare function isExcluded(key: string, exclusions: readonly string[]): boolean;
|
|
122
125
|
|
|
@@ -139,14 +142,14 @@ export declare function isExcluded(key: string, exclusions: readonly string[]):
|
|
|
139
142
|
*/
|
|
140
143
|
export declare function isRunning(pid: number): boolean;
|
|
141
144
|
|
|
142
|
-
/**
|
|
145
|
+
/** Holds a server a test owns, listening on an ephemeral loopback port until the test releases it. */
|
|
143
146
|
export declare interface LoopbackInterface {
|
|
144
147
|
/**
|
|
145
|
-
*
|
|
146
|
-
* same port under `https`.
|
|
148
|
+
* Names the `http` origin for the assigned port, without a trailing slash. A TLS server answers
|
|
149
|
+
* on the same port under `https`.
|
|
147
150
|
*/
|
|
148
151
|
readonly url: string;
|
|
149
|
-
/**
|
|
152
|
+
/** Holds the ephemeral port the host assigned. */
|
|
150
153
|
readonly port: number;
|
|
151
154
|
/**
|
|
152
155
|
* Drops every live connection on a server that carries `closeAllConnections`, stops listening, and
|
|
@@ -162,13 +165,33 @@ export declare interface LoopbackInterface {
|
|
|
162
165
|
*
|
|
163
166
|
* @param current - The identity read from the path now.
|
|
164
167
|
* @param allocation - The identity recorded when the directory was allocated.
|
|
165
|
-
* @returns
|
|
168
|
+
* @returns True if the device, the index node, and the creation time all match; false otherwise.
|
|
166
169
|
* @remarks All three fields are compared because none of them alone identifies an allocation. A
|
|
167
170
|
* device is shared by every directory on one filesystem, an index node is reused once its directory
|
|
168
171
|
* is removed, and a creation time repeats within the host's timestamp resolution.
|
|
169
172
|
*/
|
|
170
173
|
export declare function matchesIdentity(current: ScratchIdentity, allocation: ScratchIdentity): boolean;
|
|
171
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Reads the `code` an unknown thrown value carries.
|
|
177
|
+
*
|
|
178
|
+
* @param error - The thrown value to read.
|
|
179
|
+
* @returns The string `code` the value carries, or `undefined` when it carries none.
|
|
180
|
+
* @remarks The read is contained on its own terms: a value that is not an object, one carrying no
|
|
181
|
+
* `code`, and one carrying a `code` that is not a string all answer `undefined`. A null-prototype
|
|
182
|
+
* object is read the same way, because the key is tested with `in` rather than through
|
|
183
|
+
* `hasOwnProperty`.
|
|
184
|
+
*/
|
|
185
|
+
export declare function readErrorCode(error: unknown): string | undefined;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Reads the identity of one allocated directory off a host status.
|
|
189
|
+
*
|
|
190
|
+
* @param status - The status read from the directory's path.
|
|
191
|
+
* @returns The device, index node, and creation time that together name the allocation.
|
|
192
|
+
*/
|
|
193
|
+
export declare function readIdentity(status: Stats): ScratchIdentity;
|
|
194
|
+
|
|
172
195
|
/**
|
|
173
196
|
* Reads files from selected targets below a root directory.
|
|
174
197
|
*
|
|
@@ -185,17 +208,17 @@ export declare function matchesIdentity(current: ScratchIdentity, allocation: Sc
|
|
|
185
208
|
export declare function readInventory(root: URL | string, targets: readonly string[], options?: InventoryOptions): Readonly<Record<string, string>>;
|
|
186
209
|
|
|
187
210
|
/**
|
|
188
|
-
*
|
|
211
|
+
* Caps the attempts `removeTree` makes before rethrowing a retryable removal error.
|
|
189
212
|
*/
|
|
190
213
|
export declare const REMOVE_TREE_MAX_ATTEMPTS = 10;
|
|
191
214
|
|
|
192
215
|
/**
|
|
193
|
-
*
|
|
216
|
+
* Names the synchronous delay, in milliseconds, `removeTree` waits between attempts.
|
|
194
217
|
*/
|
|
195
218
|
export declare const REMOVE_TREE_RETRY_DELAY_MS = 100;
|
|
196
219
|
|
|
197
220
|
/**
|
|
198
|
-
*
|
|
221
|
+
* Names the error codes `removeTree` retries; every other code rethrows immediately.
|
|
199
222
|
*/
|
|
200
223
|
export declare const REMOVE_TREE_RETRYABLE_CODES: readonly string[];
|
|
201
224
|
|
|
@@ -248,6 +271,20 @@ export declare function removeTree(path: string): void;
|
|
|
248
271
|
*/
|
|
249
272
|
export declare function requestUpgrade(port: number, options?: UpgradeOptions): Promise<UpgradeResult>;
|
|
250
273
|
|
|
274
|
+
/**
|
|
275
|
+
* Resolves a target that stays below a root directory, refusing an escape.
|
|
276
|
+
*
|
|
277
|
+
* @param root - The absolute root directory.
|
|
278
|
+
* @param target - The relative or absolute target to resolve.
|
|
279
|
+
* @returns The absolute target below the root.
|
|
280
|
+
* @throws An `Error` reading `Path outside scratch directory: <target>` when the target escapes the
|
|
281
|
+
* root.
|
|
282
|
+
* @remarks This is {@link resolveContained} with the refusal every contained scratch operation makes
|
|
283
|
+
* of an escape, so the check and its one message are stated once. Read `resolveContained` where an
|
|
284
|
+
* escape is an answer rather than a refusal.
|
|
285
|
+
*/
|
|
286
|
+
export declare function requireContained(root: string, target: string): string;
|
|
287
|
+
|
|
251
288
|
/**
|
|
252
289
|
* Resolves a target that stays below a root directory.
|
|
253
290
|
*
|
|
@@ -257,19 +294,19 @@ export declare function requestUpgrade(port: number, options?: UpgradeOptions):
|
|
|
257
294
|
*/
|
|
258
295
|
export declare function resolveContained(root: string, target: string): string | undefined;
|
|
259
296
|
|
|
260
|
-
/**
|
|
297
|
+
/** Represents the fields that together identify one allocated directory on its host. */
|
|
261
298
|
export declare interface ScratchIdentity {
|
|
262
|
-
/**
|
|
299
|
+
/** Holds the identifier of the device holding the directory. */
|
|
263
300
|
readonly device: number;
|
|
264
|
-
/**
|
|
301
|
+
/** Holds the number of the directory's index node on that device. */
|
|
265
302
|
readonly inode: number;
|
|
266
|
-
/**
|
|
303
|
+
/** Holds the directory's creation time in milliseconds. */
|
|
267
304
|
readonly birth: number;
|
|
268
305
|
}
|
|
269
306
|
|
|
270
|
-
/**
|
|
307
|
+
/** Holds a temporary directory a test owns, writes into, reads back, and removes when it is done. */
|
|
271
308
|
export declare interface ScratchInterface {
|
|
272
|
-
/**
|
|
309
|
+
/** Holds the absolute path of the allocated directory. */
|
|
273
310
|
readonly path: string;
|
|
274
311
|
/**
|
|
275
312
|
* Writes a file, creating each parent directory that does not exist.
|
|
@@ -296,15 +333,16 @@ export declare interface ScratchInterface {
|
|
|
296
333
|
* Reports whether a path exists without following its final symbolic link.
|
|
297
334
|
*
|
|
298
335
|
* @param target - A relative or absolute path contained by the scratch directory.
|
|
299
|
-
* @returns True
|
|
336
|
+
* @returns True if the entry exists, including a symbolic link whose target is
|
|
337
|
+
* missing; false otherwise.
|
|
300
338
|
* @throws When the path escapes the scratch directory or its root is a symbolic link or file.
|
|
301
339
|
*/
|
|
302
340
|
has(target: string): boolean;
|
|
303
341
|
/**
|
|
304
342
|
* Lists the names directly inside a directory in sorted order.
|
|
305
343
|
*
|
|
306
|
-
* @param target - A relative or absolute directory path contained by the scratch directory.
|
|
307
|
-
* scratch root
|
|
344
|
+
* @param target - A relative or absolute directory path contained by the scratch directory.
|
|
345
|
+
* Default: the scratch root.
|
|
308
346
|
* @returns The sorted entry names, without their parent paths.
|
|
309
347
|
* @throws When the path escapes the scratch directory, the target is missing or is not a
|
|
310
348
|
* directory, or the scratch root is a symbolic link or file.
|
|
@@ -353,23 +391,23 @@ export declare interface ScratchInterface {
|
|
|
353
391
|
destroy(): void;
|
|
354
392
|
}
|
|
355
393
|
|
|
356
|
-
/**
|
|
394
|
+
/** Configures a scratch directory allocation. */
|
|
357
395
|
export declare interface ScratchOptions {
|
|
358
396
|
/**
|
|
359
|
-
*
|
|
397
|
+
* Names the existing directory in which to create the allocation. Defaults to the host temporary
|
|
360
398
|
* directory. Allocation throws when this path is missing, a symbolic link, or not a directory.
|
|
361
399
|
*/
|
|
362
400
|
readonly parent?: string;
|
|
363
401
|
/**
|
|
364
|
-
*
|
|
365
|
-
* contains `/` or `\`. Both are refused on every host, so the rule does not vary by host. A
|
|
402
|
+
* Holds the name fragment that starts the generated directory name. Allocation throws when this
|
|
403
|
+
* value contains `/` or `\`. Both are refused on every host, so the rule does not vary by host. A
|
|
366
404
|
* fragment carrying no separator is one path segment and cannot steer the allocation, so
|
|
367
405
|
* `release-0..2-` allocates.
|
|
368
406
|
*/
|
|
369
407
|
readonly prefix?: string;
|
|
370
408
|
/**
|
|
371
|
-
*
|
|
372
|
-
* directory and rethrows when a key escapes or the host refuses a write.
|
|
409
|
+
* Holds the files to write on allocation, keyed by path below the scratch directory. Allocation
|
|
410
|
+
* removes its directory and rethrows when a key escapes or the host refuses a write.
|
|
373
411
|
*/
|
|
374
412
|
readonly files?: Readonly<Record<string, string>>;
|
|
375
413
|
}
|
|
@@ -449,23 +487,23 @@ export declare function supportsFileLinks(): boolean;
|
|
|
449
487
|
export declare function supportsMode(): boolean;
|
|
450
488
|
|
|
451
489
|
/**
|
|
452
|
-
*
|
|
490
|
+
* Configures a client upgrade request.
|
|
453
491
|
*
|
|
454
492
|
* @remarks The time bounds and abort signal bound the wait for the server's answer, so a server
|
|
455
493
|
* that accepts the connection and never answers ends the call rather than parking it.
|
|
456
494
|
*/
|
|
457
495
|
export declare interface UpgradeOptions extends WaitOptions {
|
|
458
|
-
/**
|
|
496
|
+
/** Names the request path, written with its leading slash. Defaults to `/`. */
|
|
459
497
|
readonly path?: string;
|
|
460
498
|
/**
|
|
461
|
-
*
|
|
499
|
+
* Lists the subprotocol tokens the request offers. They are sent as one comma-separated
|
|
462
500
|
* `Sec-WebSocket-Protocol` field, and an empty or omitted list sends no field at all.
|
|
463
501
|
*/
|
|
464
502
|
readonly protocols?: readonly string[];
|
|
465
503
|
}
|
|
466
504
|
|
|
467
505
|
/**
|
|
468
|
-
*
|
|
506
|
+
* Represents what one server did with a client upgrade request.
|
|
469
507
|
*
|
|
470
508
|
* @remarks `claimed` is the discriminant. The claimed arm carries `protocol`, the subprotocol the
|
|
471
509
|
* server selected, which is `undefined` when it selected none; a claimed upgrade produced no plain
|