forked from jaydenseric/graphql-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processRequest.d.ts
101 lines (101 loc) · 3.62 KB
/
processRequest.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
export = processRequest;
declare function processRequest(request: import("http").IncomingMessage, response: import("http").ServerResponse, options?: ProcessRequestOptions | undefined): Promise<{
[key: string]: unknown;
} | {
[key: string]: unknown;
}[]>;
declare namespace processRequest {
export { GraphQLUpload, FileUpload, FileUploadCreateReadStream, FileUploadCreateReadStreamOptions, ProcessRequestFunction, ProcessRequestOptions };
}
/**
* {@linkcode ProcessRequestFunction } options.
*/
type ProcessRequestOptions = {
/**
* Maximum allowed non file multipart form field
* size in bytes; enough for your queries. Defaults to `1000000` (1 MB).
*/
maxFieldSize?: number | undefined;
/**
* Maximum allowed file size in bytes. Defaults to
* `Infinity`.
*/
maxFileSize?: number | undefined;
/**
* Maximum allowed number of files. Defaults to
* `Infinity`.
*/
maxFiles?: number | undefined;
};
type GraphQLUpload = import("graphql").GraphQLScalarType<Promise<FileUpload>, never>;
/**
* File upload details that are only available after the file’s field in the
* [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec)
* has begun streaming in.
*/
type FileUpload = {
/**
* File name.
*/
filename: string;
/**
* File MIME type. Provided by the client and can’t be
* trusted.
*/
mimetype: string;
/**
* File stream transfer encoding.
*/
encoding: string;
/**
* A private implementation
* detail that shouldn’t be used outside
* [`graphql-upload`](https://npm.im/graphql-upload).
*/
capacitor: import("fs-capacitor").WriteStream;
/**
* Creates a
* [Node.js readable stream](https://nodejs.org/api/stream.html#readable-streams)
* of the file’s contents, for processing and storage.
*/
createReadStream: FileUploadCreateReadStream;
};
/**
* Creates a
* [Node.js readable stream](https://nodejs.org/api/stream.html#readable-streams)
* of an {@link FileUpload uploading file’s} contents, for processing and
* storage. Multiple calls create independent streams. Throws if called after
* all resolvers have resolved, or after an error has interrupted the request.
*/
type FileUploadCreateReadStream = (options?: FileUploadCreateReadStreamOptions | undefined) => import("stream").Readable;
/**
* {@linkcode FileUploadCreateReadStream } options.
*/
type FileUploadCreateReadStreamOptions = {
/**
* Specify an encoding for the
* [`data`](https://nodejs.org/api/stream.html#event-data) chunks to be
* strings (without splitting multi-byte characters across chunks) instead of
* Node.js [`Buffer`](https://nodejs.org/api/buffer.html#buffer) instances.
* Supported values depend on the
* [`Buffer` implementation](https://github.com/nodejs/node/blob/v18.1.0/lib/buffer.js#L590-L680)
* and include `utf8`, `ucs2`, `utf16le`, `latin1`, `ascii`, `base64`,
* `base64url`, or `hex`. Defaults to `utf8`.
*/
encoding?: string | undefined;
/**
* Maximum number of bytes to store in
* the internal buffer before ceasing to read from the underlying resource.
* Defaults to `16384`.
*/
highWaterMark?: number | undefined;
};
/**
* Processes an incoming
* [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec).
*/
type ProcessRequestFunction = (request: import("http").IncomingMessage, response: import("http").ServerResponse, options?: ProcessRequestOptions | undefined) => Promise<{
[key: string]: unknown;
} | {
[key: string]: unknown;
}[]>;