endia 0.0.0-stage → 0.0.2
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/LICENSE +202 -0
- package/README.md +34 -2
- package/dist/archives/archive-file.d.ts +36 -0
- package/dist/archives/archive-file.js +71 -0
- package/dist/archives/build-context.d.ts +63 -0
- package/dist/archives/build-context.js +132 -0
- package/dist/archives/docker-ignore.d.ts +57 -0
- package/dist/archives/docker-ignore.js +250 -0
- package/dist/archives/fleet-archive.d.ts +33 -0
- package/dist/archives/fleet-archive.js +134 -0
- package/dist/compose-model.d.ts +32 -0
- package/dist/compose-model.js +39 -0
- package/dist/contract/archives.d.ts +14 -0
- package/dist/contract/archives.js +1 -0
- package/dist/contract/bases.d.ts +48 -0
- package/dist/contract/bases.js +1 -0
- package/dist/contract/clients.d.ts +29 -0
- package/dist/contract/clients.js +1 -0
- package/dist/contract/common.d.ts +30 -0
- package/dist/contract/common.js +1 -0
- package/dist/contract/compose.d.ts +27 -0
- package/dist/contract/compose.js +1 -0
- package/dist/contract/desktop.d.ts +269 -0
- package/dist/contract/desktop.js +1 -0
- package/dist/contract/execs.d.ts +61 -0
- package/dist/contract/execs.js +1 -0
- package/dist/contract/fleets.d.ts +136 -0
- package/dist/contract/fleets.js +1 -0
- package/dist/contract/images.d.ts +130 -0
- package/dist/contract/images.js +1 -0
- package/dist/contract/machines.d.ts +199 -0
- package/dist/contract/machines.js +1 -0
- package/dist/contract/operations.d.ts +28 -0
- package/dist/contract/operations.js +1 -0
- package/dist/contract/processes.d.ts +75 -0
- package/dist/contract/processes.js +1 -0
- package/dist/contract/purposes.d.ts +62 -0
- package/dist/contract/purposes.js +1 -0
- package/dist/contract/space.d.ts +114 -0
- package/dist/contract/space.js +1 -0
- package/dist/contract/stats.d.ts +58 -0
- package/dist/contract/stats.js +1 -0
- package/dist/contract/status.d.ts +151 -0
- package/dist/contract/status.js +1 -0
- package/dist/contract/volumes.d.ts +22 -0
- package/dist/contract/volumes.js +1 -0
- package/dist/eastindia-client.d.ts +118 -0
- package/dist/eastindia-client.js +142 -0
- package/dist/environment.d.ts +52 -0
- package/dist/environment.js +133 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +108 -0
- package/dist/exec/exec-frame.d.ts +38 -0
- package/dist/exec/exec-frame.js +50 -0
- package/dist/exec/exec-session.d.ts +64 -0
- package/dist/exec/exec-session.js +117 -0
- package/dist/groups/archives.d.ts +78 -0
- package/dist/groups/archives.js +117 -0
- package/dist/groups/bases.d.ts +28 -0
- package/dist/groups/bases.js +39 -0
- package/dist/groups/certificates.d.ts +32 -0
- package/dist/groups/certificates.js +43 -0
- package/dist/groups/desktop.d.ts +143 -0
- package/dist/groups/desktop.js +182 -0
- package/dist/groups/execs.d.ts +110 -0
- package/dist/groups/execs.js +119 -0
- package/dist/groups/fleets.d.ts +206 -0
- package/dist/groups/fleets.js +255 -0
- package/dist/groups/images.d.ts +130 -0
- package/dist/groups/images.js +109 -0
- package/dist/groups/machines.d.ts +124 -0
- package/dist/groups/machines.js +127 -0
- package/dist/groups/operations.d.ts +127 -0
- package/dist/groups/operations.js +174 -0
- package/dist/groups/processes.d.ts +77 -0
- package/dist/groups/processes.js +75 -0
- package/dist/groups/stats.d.ts +29 -0
- package/dist/groups/stats.js +33 -0
- package/dist/groups/system.d.ts +33 -0
- package/dist/groups/system.js +40 -0
- package/dist/groups/volumes.d.ts +36 -0
- package/dist/groups/volumes.js +40 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +20 -0
- package/dist/purposes.d.ts +17 -0
- package/dist/purposes.js +21 -0
- package/dist/routes.d.ts +71 -0
- package/dist/routes.js +73 -0
- package/dist/transport/api-connection.d.ts +185 -0
- package/dist/transport/api-connection.js +396 -0
- package/dist/transport/connection-failures.d.ts +14 -0
- package/dist/transport/connection-failures.js +57 -0
- package/dist/transport/json-lines.d.ts +10 -0
- package/dist/transport/json-lines.js +23 -0
- package/dist/transport/query-text.d.ts +49 -0
- package/dist/transport/query-text.js +62 -0
- package/dist/transport/service-address.d.ts +30 -0
- package/dist/transport/service-address.js +37 -0
- package/dist/transport/tls-files.d.ts +9 -0
- package/dist/transport/tls-files.js +1 -0
- package/package.json +44 -5
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The paths of the API's routes, each built from its parts with every name escaped. One place builds them, so that a route group
|
|
3
|
+
* cannot misspell a path or forget to escape a name.
|
|
4
|
+
*/
|
|
5
|
+
export declare const Routes: {
|
|
6
|
+
readonly version: "/v1/version";
|
|
7
|
+
readonly info: "/v1/info";
|
|
8
|
+
readonly hostStats: "/v1/host/stats";
|
|
9
|
+
readonly systemDf: "/v1/system/df";
|
|
10
|
+
readonly systemPrune: "/v1/system/prune";
|
|
11
|
+
readonly builderPrune: "/v1/builder/prune";
|
|
12
|
+
readonly images: "/v1/images";
|
|
13
|
+
readonly build: "/v1/images/build";
|
|
14
|
+
readonly baseImport: "/v1/bases/import";
|
|
15
|
+
readonly basePrepare: "/v1/bases/prepare";
|
|
16
|
+
readonly clients: "/v1/clients";
|
|
17
|
+
readonly operations: "/v1/operations";
|
|
18
|
+
readonly fleets: "/v1/fleets";
|
|
19
|
+
readonly machines: "/v1/machines";
|
|
20
|
+
readonly volumes: "/v1/volumes";
|
|
21
|
+
readonly image: (reference: string) => string;
|
|
22
|
+
readonly tag: (target: string) => string;
|
|
23
|
+
readonly operation: (id: string) => string;
|
|
24
|
+
readonly operationLog: (id: string) => string;
|
|
25
|
+
readonly operationCancel: (id: string) => string;
|
|
26
|
+
readonly fleet: (name: string) => string;
|
|
27
|
+
readonly fleetLogs: (name: string) => string;
|
|
28
|
+
readonly fleetStop: (name: string) => string;
|
|
29
|
+
readonly fleetStart: (name: string) => string;
|
|
30
|
+
readonly fleetRestart: (name: string) => string;
|
|
31
|
+
readonly fleetPurpose: (name: string) => string;
|
|
32
|
+
readonly machine: (name: string) => string;
|
|
33
|
+
readonly machineStart: (name: string) => string;
|
|
34
|
+
readonly machineStop: (name: string) => string;
|
|
35
|
+
readonly machineRestart: (name: string) => string;
|
|
36
|
+
readonly machineLogs: (name: string) => string;
|
|
37
|
+
readonly machinePurpose: (name: string) => string;
|
|
38
|
+
readonly machineStats: (name: string) => string;
|
|
39
|
+
readonly machineExec: (name: string) => string;
|
|
40
|
+
readonly machineArchive: (name: string, path: string) => string;
|
|
41
|
+
readonly processes: (machine: string) => string;
|
|
42
|
+
readonly process: (machine: string, processId: number) => string;
|
|
43
|
+
readonly processWait: (machine: string, processId: number) => string;
|
|
44
|
+
readonly processStop: (machine: string, processId: number) => string;
|
|
45
|
+
readonly processLogs: (machine: string, processId: number) => string;
|
|
46
|
+
readonly desktop: (machine: string, action: DesktopAction) => string;
|
|
47
|
+
readonly exec: (id: string) => string;
|
|
48
|
+
readonly execStart: (id: string) => string;
|
|
49
|
+
readonly execResize: (id: string) => string;
|
|
50
|
+
readonly client: (name: string) => string;
|
|
51
|
+
readonly volume: (name: string) => string;
|
|
52
|
+
};
|
|
53
|
+
/** The last part of each desktop route's path, after `/v1/machines/{name}/desktop/`. */
|
|
54
|
+
export type DesktopAction = "launch" | "screenshot" | "inspect" | "wait" | "invoke" | "click" | "set-value" | "keys" | "pointer" | "windows" | "tray" | "tray/click" | "uac";
|
|
55
|
+
/** The media types of the bodies the client sends and reads. */
|
|
56
|
+
export declare const MediaTypes: {
|
|
57
|
+
readonly json: "application/json";
|
|
58
|
+
readonly tar: "application/x-tar";
|
|
59
|
+
};
|
|
60
|
+
/** The headers the API defines beyond HTTP's own. */
|
|
61
|
+
export declare const Headers: {
|
|
62
|
+
readonly idempotencyKey: "Idempotency-Key";
|
|
63
|
+
/** A HEAD answer's error, as Base64 of the error's JSON, because a HEAD answer has no body. */
|
|
64
|
+
readonly error: "X-EastIndia-Error";
|
|
65
|
+
/** A path's description on the archive routes, as Base64 of its JSON. */
|
|
66
|
+
readonly pathStat: "X-EastIndia-Path-Stat";
|
|
67
|
+
readonly screenshotWidth: "X-EastIndia-Width";
|
|
68
|
+
readonly screenshotHeight: "X-EastIndia-Height";
|
|
69
|
+
readonly screenshotSession: "X-EastIndia-Session";
|
|
70
|
+
readonly screenshotTaken: "X-EastIndia-Taken";
|
|
71
|
+
};
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The paths of the API's routes, each built from its parts with every name escaped. One place builds them, so that a route group
|
|
3
|
+
* cannot misspell a path or forget to escape a name.
|
|
4
|
+
*/
|
|
5
|
+
export const Routes = {
|
|
6
|
+
version: "/v1/version",
|
|
7
|
+
info: "/v1/info",
|
|
8
|
+
hostStats: "/v1/host/stats",
|
|
9
|
+
systemDf: "/v1/system/df",
|
|
10
|
+
systemPrune: "/v1/system/prune",
|
|
11
|
+
builderPrune: "/v1/builder/prune",
|
|
12
|
+
images: "/v1/images",
|
|
13
|
+
build: "/v1/images/build",
|
|
14
|
+
baseImport: "/v1/bases/import",
|
|
15
|
+
basePrepare: "/v1/bases/prepare",
|
|
16
|
+
clients: "/v1/clients",
|
|
17
|
+
operations: "/v1/operations",
|
|
18
|
+
fleets: "/v1/fleets",
|
|
19
|
+
machines: "/v1/machines",
|
|
20
|
+
volumes: "/v1/volumes",
|
|
21
|
+
// An image reference may hold "/", and the route takes the rest of the path, so each part is escaped on its own.
|
|
22
|
+
image: (reference) => `/v1/images/${escapeEachPart(reference)}`,
|
|
23
|
+
tag: (target) => `/v1/images/tags/${escapeEachPart(target)}`,
|
|
24
|
+
operation: (id) => `/v1/operations/${encodeURIComponent(id)}`,
|
|
25
|
+
operationLog: (id) => `${Routes.operation(id)}/log`,
|
|
26
|
+
operationCancel: (id) => `${Routes.operation(id)}/cancel`,
|
|
27
|
+
fleet: (name) => `/v1/fleets/${encodeURIComponent(name)}`,
|
|
28
|
+
fleetLogs: (name) => `${Routes.fleet(name)}/logs`,
|
|
29
|
+
fleetStop: (name) => `${Routes.fleet(name)}/stop`,
|
|
30
|
+
fleetStart: (name) => `${Routes.fleet(name)}/start`,
|
|
31
|
+
fleetRestart: (name) => `${Routes.fleet(name)}/restart`,
|
|
32
|
+
fleetPurpose: (name) => `${Routes.fleet(name)}/purpose`,
|
|
33
|
+
machine: (name) => `/v1/machines/${encodeURIComponent(name)}`,
|
|
34
|
+
machineStart: (name) => `${Routes.machine(name)}/start`,
|
|
35
|
+
machineStop: (name) => `${Routes.machine(name)}/stop`,
|
|
36
|
+
machineRestart: (name) => `${Routes.machine(name)}/restart`,
|
|
37
|
+
machineLogs: (name) => `${Routes.machine(name)}/logs`,
|
|
38
|
+
machinePurpose: (name) => `${Routes.machine(name)}/purpose`,
|
|
39
|
+
machineStats: (name) => `${Routes.machine(name)}/stats`,
|
|
40
|
+
machineExec: (name) => `${Routes.machine(name)}/exec`,
|
|
41
|
+
machineArchive: (name, path) => `${Routes.machine(name)}/archive?path=${encodeURIComponent(path)}`,
|
|
42
|
+
processes: (machine) => `${Routes.machine(machine)}/processes`,
|
|
43
|
+
process: (machine, processId) => `${Routes.processes(machine)}/${String(processId)}`,
|
|
44
|
+
processWait: (machine, processId) => `${Routes.process(machine, processId)}/wait`,
|
|
45
|
+
processStop: (machine, processId) => `${Routes.process(machine, processId)}/stop`,
|
|
46
|
+
processLogs: (machine, processId) => `${Routes.process(machine, processId)}/logs`,
|
|
47
|
+
desktop: (machine, action) => `${Routes.machine(machine)}/desktop/${action}`,
|
|
48
|
+
exec: (id) => `/v1/execs/${encodeURIComponent(id)}`,
|
|
49
|
+
execStart: (id) => `${Routes.exec(id)}/start`,
|
|
50
|
+
execResize: (id) => `${Routes.exec(id)}/resize`,
|
|
51
|
+
client: (name) => `/v1/clients/${encodeURIComponent(name)}`,
|
|
52
|
+
volume: (name) => `/v1/volumes/${encodeURIComponent(name)}`,
|
|
53
|
+
};
|
|
54
|
+
/** The media types of the bodies the client sends and reads. */
|
|
55
|
+
export const MediaTypes = {
|
|
56
|
+
json: "application/json",
|
|
57
|
+
tar: "application/x-tar",
|
|
58
|
+
};
|
|
59
|
+
/** The headers the API defines beyond HTTP's own. */
|
|
60
|
+
export const Headers = {
|
|
61
|
+
idempotencyKey: "Idempotency-Key",
|
|
62
|
+
/** A HEAD answer's error, as Base64 of the error's JSON, because a HEAD answer has no body. */
|
|
63
|
+
error: "X-EastIndia-Error",
|
|
64
|
+
/** A path's description on the archive routes, as Base64 of its JSON. */
|
|
65
|
+
pathStat: "X-EastIndia-Path-Stat",
|
|
66
|
+
screenshotWidth: "X-EastIndia-Width",
|
|
67
|
+
screenshotHeight: "X-EastIndia-Height",
|
|
68
|
+
screenshotSession: "X-EastIndia-Session",
|
|
69
|
+
screenshotTaken: "X-EastIndia-Taken",
|
|
70
|
+
};
|
|
71
|
+
function escapeEachPart(reference) {
|
|
72
|
+
return reference.split("/").map(encodeURIComponent).join("/");
|
|
73
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { type IncomingHttpHeaders, type IncomingMessage } from "node:http";
|
|
2
|
+
import type { Readable } from "node:stream";
|
|
3
|
+
import WebSocket from "ws";
|
|
4
|
+
import type { ApiError } from "../contract/common.js";
|
|
5
|
+
import { type ServiceAddress } from "./service-address.js";
|
|
6
|
+
import type { TlsFiles } from "./tls-files.js";
|
|
7
|
+
/** How the connection reaches the service and how patient it is. */
|
|
8
|
+
export interface ConnectionSettings {
|
|
9
|
+
readonly address: ServiceAddress;
|
|
10
|
+
/** The certificate files; required over HTTPS, unused on a local socket. */
|
|
11
|
+
readonly tls: TlsFiles | undefined;
|
|
12
|
+
readonly requestTimeoutMilliseconds: number;
|
|
13
|
+
readonly requestRetries: number;
|
|
14
|
+
readonly requestRetryDelayMilliseconds: number;
|
|
15
|
+
}
|
|
16
|
+
/** A request body: bytes held in memory, or a stream opened afresh for each attempt, so that a retried request sends the same bytes. */
|
|
17
|
+
export type RequestBody = {
|
|
18
|
+
readonly contentType: string;
|
|
19
|
+
readonly bytes: Uint8Array;
|
|
20
|
+
} | {
|
|
21
|
+
readonly contentType: string;
|
|
22
|
+
readonly open: () => Readable;
|
|
23
|
+
readonly length?: number;
|
|
24
|
+
};
|
|
25
|
+
/** One request to the service. */
|
|
26
|
+
export interface Exchange {
|
|
27
|
+
readonly method: "GET" | "HEAD" | "POST" | "PUT" | "DELETE";
|
|
28
|
+
/** The route's path with its query. */
|
|
29
|
+
readonly path: string;
|
|
30
|
+
readonly body?: RequestBody;
|
|
31
|
+
/** Cancels the request; the promise then rejects with the signal's reason. */
|
|
32
|
+
readonly signal?: AbortSignal | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** A whole answer, read into memory. */
|
|
35
|
+
export interface Answer {
|
|
36
|
+
readonly status: number;
|
|
37
|
+
readonly headers: IncomingHttpHeaders;
|
|
38
|
+
readonly body: Buffer;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The one connection the route groups share, over HTTPS with mutual TLS or over a local socket. Without it each group would repeat
|
|
42
|
+
* three rules that every request follows. A changing request carries an `Idempotency-Key`, and it is sent again with the same key
|
|
43
|
+
* when its connection fails before any reply. A refusal becomes a `EastIndiaApiError` with the service's error. A request that gets
|
|
44
|
+
* no answer becomes a `EastIndiaConnectionError` that says why.
|
|
45
|
+
*
|
|
46
|
+
* Over HTTPS the client presents the caller's certificate and accepts the server only when its certificate chains to `ca.pem`, is
|
|
47
|
+
* meant for server authentication and names the address: Node's TLS checks all three when `ca.pem` is the only authority given.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ApiConnection {
|
|
50
|
+
private readonly settings;
|
|
51
|
+
private readonly agent;
|
|
52
|
+
private readonly addressText;
|
|
53
|
+
/**
|
|
54
|
+
* Opens the connection; no request is sent until a route group sends one.
|
|
55
|
+
*
|
|
56
|
+
* @param settings - The address, certificate files and patience.
|
|
57
|
+
* @throws Error when an HTTPS address comes without the certificate files.
|
|
58
|
+
*/
|
|
59
|
+
constructor(settings: ConnectionSettings);
|
|
60
|
+
/**
|
|
61
|
+
* Reads a route's JSON answer. A read is sent once: it changes nothing, so a failed connection is reported rather than retried.
|
|
62
|
+
*
|
|
63
|
+
* @param path - The route's path with its query.
|
|
64
|
+
* @param signal - Cancels the request.
|
|
65
|
+
* @returns The parsed answer.
|
|
66
|
+
*/
|
|
67
|
+
read<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Sends a request that changes something and reads its JSON answer. It carries a new `Idempotency-Key`, and when its connection
|
|
70
|
+
* fails before any reply it is sent again with the same key, so that the service does the work once.
|
|
71
|
+
*
|
|
72
|
+
* @param exchange - The request.
|
|
73
|
+
* @param timed - Whether the client's time limit applies; false for an upload and for a wait the service answers only when it ends.
|
|
74
|
+
* @returns The parsed answer.
|
|
75
|
+
*/
|
|
76
|
+
change<T>(exchange: Exchange, timed?: boolean): Promise<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Sends a request that changes something and answers without a body, with the key and retries of `change`.
|
|
79
|
+
*
|
|
80
|
+
* @param exchange - The request.
|
|
81
|
+
* @returns When the service has answered with success.
|
|
82
|
+
*/
|
|
83
|
+
changeWithoutAnswer(exchange: Exchange): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Sends a request exactly once, without an `Idempotency-Key`, without a retry and without the client's time limit, and reads its
|
|
86
|
+
* JSON answer. A request whose body carries a password goes this way, because the service must never store it and a repeat could
|
|
87
|
+
* answer a prompt twice; so does a request whose answer carries a private key.
|
|
88
|
+
*
|
|
89
|
+
* @param exchange - The request.
|
|
90
|
+
* @returns The parsed answer.
|
|
91
|
+
*/
|
|
92
|
+
sendOnce<T>(exchange: Exchange): Promise<T>;
|
|
93
|
+
/**
|
|
94
|
+
* Sends a request that changes nothing although it is a `POST`, such as a screenshot, without an `Idempotency-Key`, and gives the
|
|
95
|
+
* whole answer, for an answer that is not JSON.
|
|
96
|
+
*
|
|
97
|
+
* @param exchange - The request.
|
|
98
|
+
* @returns The answer.
|
|
99
|
+
*/
|
|
100
|
+
sendWithoutKey(exchange: Exchange): Promise<Answer>;
|
|
101
|
+
/**
|
|
102
|
+
* Sends a request that has no body and whose answer has none, such as a HEAD, and gives the answer's headers.
|
|
103
|
+
*
|
|
104
|
+
* @param path - The route's path with its query.
|
|
105
|
+
* @param signal - Cancels the request.
|
|
106
|
+
* @returns The answer's headers.
|
|
107
|
+
*/
|
|
108
|
+
head(path: string, signal?: AbortSignal): Promise<IncomingHttpHeaders>;
|
|
109
|
+
/**
|
|
110
|
+
* Sends a request whose answer is streamed, such as a followed log, and gives the answer once its headers have arrived. The client's
|
|
111
|
+
* time limit does not apply, because a followed stream stays open for as long as the service has more to send.
|
|
112
|
+
*
|
|
113
|
+
* @param exchange - The request.
|
|
114
|
+
* @returns The answer's body as it arrives; the caller reads it to its end or destroys it.
|
|
115
|
+
*/
|
|
116
|
+
openStream(exchange: Exchange): Promise<IncomingMessage>;
|
|
117
|
+
/**
|
|
118
|
+
* Reads a route whose answer is a stream of JSON objects, one per line, such as a machine's log or its readings. The request is
|
|
119
|
+
* sent when the iteration starts, and stopping the iteration early ends it.
|
|
120
|
+
*
|
|
121
|
+
* @param path - The route's path with its query.
|
|
122
|
+
* @param signal - Ends the request.
|
|
123
|
+
* @returns The objects, as their lines arrive.
|
|
124
|
+
*/
|
|
125
|
+
readLines<T>(path: string, signal?: AbortSignal): AsyncGenerator<T, void, undefined>;
|
|
126
|
+
/**
|
|
127
|
+
* Opens a route as a WebSocket, with the same certificate and the same server check as every other request.
|
|
128
|
+
*
|
|
129
|
+
* @param path - The route, such as `/v1/execs/{id}/start`.
|
|
130
|
+
* @param signal - Cancels the opening.
|
|
131
|
+
* @returns The open WebSocket; the caller closes it.
|
|
132
|
+
* @throws EastIndiaApiError when the service refuses the upgrade, with the error its answer carries.
|
|
133
|
+
* @throws EastIndiaConnectionError when no answer came.
|
|
134
|
+
*/
|
|
135
|
+
openWebSocket(path: string, signal?: AbortSignal): Promise<WebSocket>;
|
|
136
|
+
/** Closes the connections kept open for later requests. A request sent afterwards opens a new one. */
|
|
137
|
+
close(): void;
|
|
138
|
+
private send;
|
|
139
|
+
private sendAttempt;
|
|
140
|
+
private dispatch;
|
|
141
|
+
private createRequest;
|
|
142
|
+
private writeBody;
|
|
143
|
+
private createWebSocket;
|
|
144
|
+
private connectionError;
|
|
145
|
+
private static createAgent;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Writes a JSON request body. Members whose value is undefined are left out, so that the service applies their defaults; the service
|
|
149
|
+
* refuses a member it does not know.
|
|
150
|
+
*
|
|
151
|
+
* @param value - The body.
|
|
152
|
+
* @returns The body as UTF-8 JSON.
|
|
153
|
+
*/
|
|
154
|
+
export declare function jsonBody(value: object): RequestBody;
|
|
155
|
+
/**
|
|
156
|
+
* Writes a tar archive the caller packed as a request body.
|
|
157
|
+
*
|
|
158
|
+
* @param archive - The archive's bytes, or a function that opens it afresh, so that a retried request sends the same bytes.
|
|
159
|
+
* @returns The body, of type `application/x-tar`.
|
|
160
|
+
*/
|
|
161
|
+
export declare function tarBody(archive: Uint8Array | (() => Readable)): RequestBody;
|
|
162
|
+
/**
|
|
163
|
+
* Reads the error of a refusal: the JSON body, or, for an answer without a body such as a HEAD's, the `X-EastIndia-Error` header,
|
|
164
|
+
* which holds the same JSON in Base64. Gives null when neither holds a readable error.
|
|
165
|
+
*
|
|
166
|
+
* @param answer - The refusal.
|
|
167
|
+
* @returns The error, or null.
|
|
168
|
+
*/
|
|
169
|
+
export declare function readError(answer: Answer): ApiError | null;
|
|
170
|
+
/**
|
|
171
|
+
* Reads a JSON value that the API sends Base64-encoded in a header, such as `X-EastIndia-Path-Stat`.
|
|
172
|
+
*
|
|
173
|
+
* @param headers - The answer's headers.
|
|
174
|
+
* @param name - The header's name.
|
|
175
|
+
* @returns The value, or undefined when the header is absent or not Base64 of JSON.
|
|
176
|
+
*/
|
|
177
|
+
export declare function readHeaderJson(headers: IncomingHttpHeaders, name: string): unknown;
|
|
178
|
+
/**
|
|
179
|
+
* Reads a body to its end.
|
|
180
|
+
*
|
|
181
|
+
* @param stream - The body.
|
|
182
|
+
* @param signal - Stops the reading; the promise then rejects with the signal's reason.
|
|
183
|
+
* @returns The bytes.
|
|
184
|
+
*/
|
|
185
|
+
export declare function readAll(stream: Readable, signal?: AbortSignal): Promise<Buffer>;
|