increase 0.6.0 → 0.7.0
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/CHANGELOG.md +251 -0
- package/LICENSE +201 -0
- package/README.md +245 -0
- package/core.d.ts +5 -1
- package/core.d.ts.map +1 -1
- package/core.js +45 -11
- package/core.js.map +1 -1
- package/core.mjs +46 -12
- package/core.mjs.map +1 -1
- package/error.d.ts +17 -0
- package/error.d.ts.map +1 -1
- package/error.js +24 -0
- package/error.js.map +1 -1
- package/error.mjs +20 -0
- package/error.mjs.map +1 -1
- package/index.d.mts +12 -1
- package/index.d.ts +12 -1
- package/index.d.ts.map +1 -1
- package/index.js +8 -1
- package/index.js.map +1 -1
- package/index.mjs +5 -0
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/account-transfers.d.ts +14 -0
- package/resources/account-transfers.d.ts.map +1 -1
- package/resources/account-transfers.js.map +1 -1
- package/resources/account-transfers.mjs.map +1 -1
- package/resources/ach-transfers.d.ts +42 -1
- package/resources/ach-transfers.d.ts.map +1 -1
- package/resources/ach-transfers.js.map +1 -1
- package/resources/ach-transfers.mjs.map +1 -1
- package/resources/bookkeeping-entry-sets.d.ts +2 -2
- package/resources/card-profiles.d.ts +46 -0
- package/resources/card-profiles.d.ts.map +1 -1
- package/resources/card-profiles.js.map +1 -1
- package/resources/card-profiles.mjs.map +1 -1
- package/resources/check-transfers.d.ts +14 -0
- package/resources/check-transfers.d.ts.map +1 -1
- package/resources/check-transfers.js.map +1 -1
- package/resources/check-transfers.mjs.map +1 -1
- package/resources/entities/entities.d.ts +55 -10
- package/resources/entities/entities.d.ts.map +1 -1
- package/resources/entities/entities.js.map +1 -1
- package/resources/entities/entities.mjs.map +1 -1
- package/resources/files.d.ts +10 -9
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js.map +1 -1
- package/resources/files.mjs.map +1 -1
- package/resources/pending-transactions.d.ts +5 -0
- package/resources/pending-transactions.d.ts.map +1 -1
- package/resources/pending-transactions.js.map +1 -1
- package/resources/pending-transactions.mjs.map +1 -1
- package/resources/real-time-payments-transfers.d.ts +14 -0
- package/resources/real-time-payments-transfers.d.ts.map +1 -1
- package/resources/real-time-payments-transfers.js.map +1 -1
- package/resources/real-time-payments-transfers.mjs.map +1 -1
- package/resources/simulations/cards.d.ts +5 -0
- package/resources/simulations/cards.d.ts.map +1 -1
- package/resources/simulations/cards.js.map +1 -1
- package/resources/simulations/cards.mjs.map +1 -1
- package/resources/simulations/inbound-funds-holds.d.ts +74 -0
- package/resources/simulations/inbound-funds-holds.d.ts.map +1 -0
- package/resources/simulations/inbound-funds-holds.js +19 -0
- package/resources/simulations/inbound-funds-holds.js.map +1 -0
- package/resources/simulations/inbound-funds-holds.mjs +13 -0
- package/resources/simulations/inbound-funds-holds.mjs.map +1 -0
- package/resources/simulations/index.d.ts +1 -0
- package/resources/simulations/index.d.ts.map +1 -1
- package/resources/simulations/index.js +8 -0
- package/resources/simulations/index.js.map +1 -1
- package/resources/simulations/index.mjs +1 -0
- package/resources/simulations/index.mjs.map +1 -1
- package/resources/simulations/simulations.d.ts +4 -0
- package/resources/simulations/simulations.d.ts.map +1 -1
- package/resources/simulations/simulations.js +3 -0
- package/resources/simulations/simulations.js.map +1 -1
- package/resources/simulations/simulations.mjs +3 -0
- package/resources/simulations/simulations.mjs.map +1 -1
- package/resources/wire-transfers.d.ts +14 -0
- package/resources/wire-transfers.d.ts.map +1 -1
- package/resources/wire-transfers.js.map +1 -1
- package/resources/wire-transfers.mjs.map +1 -1
- package/src/_shims/fileFromPath.node.ts +1 -1
- package/src/_shims/fileFromPath.ts +1 -1
- package/src/_shims/getMultipartRequestOptions.node.ts +1 -1
- package/src/_shims/getMultipartRequestOptions.ts +1 -1
- package/src/core.ts +47 -11
- package/src/error.ts +40 -0
- package/src/index.ts +14 -1
- package/src/resources/account-numbers.ts +5 -5
- package/src/resources/account-statements.ts +5 -5
- package/src/resources/account-transfers.ts +22 -5
- package/src/resources/accounts.ts +5 -5
- package/src/resources/ach-prenotifications.ts +5 -5
- package/src/resources/ach-transfers.ts +50 -6
- package/src/resources/balance-lookups.ts +3 -3
- package/src/resources/bookkeeping-accounts.ts +5 -5
- package/src/resources/bookkeeping-entries.ts +5 -5
- package/src/resources/bookkeeping-entry-sets.ts +5 -5
- package/src/resources/card-disputes.ts +5 -5
- package/src/resources/card-profiles.ts +60 -5
- package/src/resources/cards.ts +5 -5
- package/src/resources/check-deposits.ts +5 -5
- package/src/resources/check-transfers.ts +22 -5
- package/src/resources/declined-transactions.ts +6 -6
- package/src/resources/digital-wallet-tokens.ts +5 -5
- package/src/resources/documents.ts +5 -5
- package/src/resources/entities/entities.ts +70 -15
- package/src/resources/entities/supplemental-documents.ts +5 -5
- package/src/resources/event-subscriptions.ts +5 -5
- package/src/resources/events.ts +5 -5
- package/src/resources/exports.ts +5 -5
- package/src/resources/external-accounts.ts +5 -5
- package/src/resources/files.ts +16 -15
- package/src/resources/groups.ts +3 -3
- package/src/resources/inbound-ach-transfer-returns.ts +5 -5
- package/src/resources/inbound-wire-drawdown-requests.ts +5 -5
- package/src/resources/limits.ts +5 -5
- package/src/resources/oauth-connections.ts +5 -5
- package/src/resources/pending-transactions.ts +12 -6
- package/src/resources/programs.ts +5 -5
- package/src/resources/real-time-decisions.ts +4 -4
- package/src/resources/real-time-payments-transfers.ts +22 -5
- package/src/resources/routing-numbers.ts +4 -4
- package/src/resources/simulations/account-statements.ts +4 -4
- package/src/resources/simulations/account-transfers.ts +3 -3
- package/src/resources/simulations/ach-transfers.ts +5 -5
- package/src/resources/simulations/card-disputes.ts +4 -4
- package/src/resources/simulations/card-profiles.ts +3 -3
- package/src/resources/simulations/card-refunds.ts +4 -4
- package/src/resources/simulations/cards.ts +11 -5
- package/src/resources/simulations/check-deposits.ts +3 -3
- package/src/resources/simulations/check-transfers.ts +3 -3
- package/src/resources/simulations/digital-wallet-token-requests.ts +3 -3
- package/src/resources/simulations/documents.ts +4 -4
- package/src/resources/simulations/inbound-funds-holds.ts +88 -0
- package/src/resources/simulations/inbound-wire-drawdown-requests.ts +4 -4
- package/src/resources/simulations/index.ts +1 -0
- package/src/resources/simulations/interest-payments.ts +3 -3
- package/src/resources/simulations/programs.ts +4 -4
- package/src/resources/simulations/real-time-payments-transfers.ts +5 -5
- package/src/resources/simulations/simulations.ts +7 -2
- package/src/resources/simulations/wire-transfers.ts +3 -3
- package/src/resources/transactions.ts +5 -5
- package/src/resources/wire-drawdown-requests.ts +5 -5
- package/src/resources/wire-transfers.ts +22 -5
- package/src/streaming.ts +146 -76
- package/src/uploads.ts +10 -9
- package/src/version.ts +1 -1
- package/streaming.d.ts.map +1 -1
- package/streaming.js +115 -57
- package/streaming.js.map +1 -1
- package/streaming.mjs +115 -57
- package/streaming.mjs.map +1 -1
- package/uploads.d.ts +1 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +2 -1
- package/uploads.js.map +1 -1
- package/uploads.mjs +2 -1
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/streaming.ts
CHANGED
|
@@ -1,67 +1,15 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from './_shims/fetch.js';
|
|
2
|
+
|
|
2
3
|
import { APIResponse, Headers, createResponseHeaders } from './core';
|
|
3
4
|
|
|
5
|
+
type Bytes = string | ArrayBuffer | Uint8Array | Buffer | null | undefined;
|
|
6
|
+
|
|
4
7
|
type ServerSentEvent = {
|
|
5
8
|
event: string | null;
|
|
6
9
|
data: string;
|
|
7
10
|
raw: string[];
|
|
8
11
|
};
|
|
9
12
|
|
|
10
|
-
class SSEDecoder {
|
|
11
|
-
private data: string[];
|
|
12
|
-
private event: string | null;
|
|
13
|
-
private chunks: string[];
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
this.event = null;
|
|
17
|
-
this.data = [];
|
|
18
|
-
this.chunks = [];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
decode(line: string) {
|
|
22
|
-
if (line.endsWith('\r')) {
|
|
23
|
-
line = line.substring(0, line.length - 1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!line) {
|
|
27
|
-
// empty line and we didn't previously encounter any messages
|
|
28
|
-
if (!this.event && !this.data.length) return null;
|
|
29
|
-
|
|
30
|
-
const sse: ServerSentEvent = {
|
|
31
|
-
event: this.event,
|
|
32
|
-
data: this.data.join('\n'),
|
|
33
|
-
raw: this.chunks,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
this.event = null;
|
|
37
|
-
this.data = [];
|
|
38
|
-
this.chunks = [];
|
|
39
|
-
|
|
40
|
-
return sse;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.chunks.push(line);
|
|
44
|
-
|
|
45
|
-
if (line.startsWith(':')) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let [fieldname, _, value] = partition(line, ':');
|
|
50
|
-
|
|
51
|
-
if (value.startsWith(' ')) {
|
|
52
|
-
value = value.substring(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (fieldname === 'event') {
|
|
56
|
-
this.event = value;
|
|
57
|
-
} else if (fieldname === 'data') {
|
|
58
|
-
this.data.push(value);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
13
|
export class Stream<Item> implements AsyncIterable<Item>, APIResponse<Stream<Item>> {
|
|
66
14
|
/** @deprecated - please use the async iterator instead. We plan to add additional helper methods shortly. */
|
|
67
15
|
response: Response;
|
|
@@ -83,21 +31,11 @@ export class Stream<Item> implements AsyncIterable<Item>, APIResponse<Stream<Ite
|
|
|
83
31
|
this.controller.abort();
|
|
84
32
|
throw new Error(`Attempted to iterate over a response with no body`);
|
|
85
33
|
}
|
|
86
|
-
|
|
87
34
|
const lineDecoder = new LineDecoder();
|
|
88
35
|
|
|
89
|
-
|
|
90
|
-
for await (const chunk of
|
|
91
|
-
|
|
92
|
-
if (chunk instanceof Buffer) {
|
|
93
|
-
text = chunk.toString();
|
|
94
|
-
} else if ((chunk as any) instanceof Uint8Array) {
|
|
95
|
-
text = Buffer.from(chunk).toString();
|
|
96
|
-
} else {
|
|
97
|
-
text = chunk;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
for (const line of lineDecoder.decode(text)) {
|
|
36
|
+
const iter = readableStreamAsyncIterable<Bytes>(this.response.body);
|
|
37
|
+
for await (const chunk of iter) {
|
|
38
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
101
39
|
const sse = this.decoder.decode(line);
|
|
102
40
|
if (sse) yield sse;
|
|
103
41
|
}
|
|
@@ -110,6 +48,7 @@ export class Stream<Item> implements AsyncIterable<Item>, APIResponse<Stream<Ite
|
|
|
110
48
|
}
|
|
111
49
|
|
|
112
50
|
async *[Symbol.asyncIterator](): AsyncIterator<Item, any, undefined> {
|
|
51
|
+
let done = false;
|
|
113
52
|
try {
|
|
114
53
|
for await (const sse of this.iterMessages()) {
|
|
115
54
|
try {
|
|
@@ -120,18 +59,72 @@ export class Stream<Item> implements AsyncIterable<Item>, APIResponse<Stream<Ite
|
|
|
120
59
|
throw e;
|
|
121
60
|
}
|
|
122
61
|
}
|
|
62
|
+
done = true;
|
|
123
63
|
} catch (e) {
|
|
124
64
|
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
125
65
|
if (e instanceof Error && e.name === 'AbortError') return;
|
|
126
66
|
throw e;
|
|
127
67
|
} finally {
|
|
128
68
|
// If the user `break`s, abort the ongoing request.
|
|
129
|
-
this.controller.abort();
|
|
69
|
+
if (!done) this.controller.abort();
|
|
130
70
|
}
|
|
131
71
|
}
|
|
132
72
|
}
|
|
133
73
|
|
|
134
|
-
|
|
74
|
+
class SSEDecoder {
|
|
75
|
+
private data: string[];
|
|
76
|
+
private event: string | null;
|
|
77
|
+
private chunks: string[];
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
this.event = null;
|
|
81
|
+
this.data = [];
|
|
82
|
+
this.chunks = [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
decode(line: string) {
|
|
86
|
+
if (line.endsWith('\r')) {
|
|
87
|
+
line = line.substring(0, line.length - 1);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!line) {
|
|
91
|
+
// empty line and we didn't previously encounter any messages
|
|
92
|
+
if (!this.event && !this.data.length) return null;
|
|
93
|
+
|
|
94
|
+
const sse: ServerSentEvent = {
|
|
95
|
+
event: this.event,
|
|
96
|
+
data: this.data.join('\n'),
|
|
97
|
+
raw: this.chunks,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
this.event = null;
|
|
101
|
+
this.data = [];
|
|
102
|
+
this.chunks = [];
|
|
103
|
+
|
|
104
|
+
return sse;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.chunks.push(line);
|
|
108
|
+
|
|
109
|
+
if (line.startsWith(':')) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
114
|
+
|
|
115
|
+
if (value.startsWith(' ')) {
|
|
116
|
+
value = value.substring(1);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (fieldname === 'event') {
|
|
120
|
+
this.event = value;
|
|
121
|
+
} else if (fieldname === 'data') {
|
|
122
|
+
this.data.push(value);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
135
128
|
|
|
136
129
|
/**
|
|
137
130
|
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
@@ -140,15 +133,22 @@ const NEWLINE_CHARS = '\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029';
|
|
|
140
133
|
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
141
134
|
*/
|
|
142
135
|
class LineDecoder {
|
|
136
|
+
// prettier-ignore
|
|
137
|
+
static NEWLINE_CHARS = new Set(['\n', '\r', '\x0b', '\x0c', '\x1c', '\x1d', '\x1e', '\x85', '\u2028', '\u2029']);
|
|
138
|
+
static NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
139
|
+
|
|
143
140
|
buffer: string[];
|
|
144
141
|
trailingCR: boolean;
|
|
142
|
+
textDecoder: any; // TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
|
|
145
143
|
|
|
146
144
|
constructor() {
|
|
147
145
|
this.buffer = [];
|
|
148
146
|
this.trailingCR = false;
|
|
149
147
|
}
|
|
150
148
|
|
|
151
|
-
decode(
|
|
149
|
+
decode(chunk: Bytes): string[] {
|
|
150
|
+
let text = this.decodeText(chunk);
|
|
151
|
+
|
|
152
152
|
if (this.trailingCR) {
|
|
153
153
|
text = '\r' + text;
|
|
154
154
|
this.trailingCR = false;
|
|
@@ -162,10 +162,10 @@ class LineDecoder {
|
|
|
162
162
|
return [];
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
const
|
|
166
|
-
let lines = text.split(
|
|
165
|
+
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
166
|
+
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
167
167
|
|
|
168
|
-
if (lines.length === 1 && !
|
|
168
|
+
if (lines.length === 1 && !trailingNewline) {
|
|
169
169
|
this.buffer.push(lines[0]!);
|
|
170
170
|
return [];
|
|
171
171
|
}
|
|
@@ -175,13 +175,50 @@ class LineDecoder {
|
|
|
175
175
|
this.buffer = [];
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
if (!
|
|
178
|
+
if (!trailingNewline) {
|
|
179
179
|
this.buffer = [lines.pop() || ''];
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return lines;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
decodeText(bytes: Bytes): string {
|
|
186
|
+
if (bytes == null) return '';
|
|
187
|
+
if (typeof bytes === 'string') return bytes;
|
|
188
|
+
|
|
189
|
+
// Node:
|
|
190
|
+
if (typeof Buffer !== 'undefined') {
|
|
191
|
+
if (bytes instanceof Buffer) {
|
|
192
|
+
return bytes.toString();
|
|
193
|
+
}
|
|
194
|
+
if (bytes instanceof Uint8Array) {
|
|
195
|
+
return Buffer.from(bytes).toString();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Browser
|
|
204
|
+
if (typeof TextDecoder !== 'undefined') {
|
|
205
|
+
if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
|
|
206
|
+
this.textDecoder ??= new TextDecoder('utf8');
|
|
207
|
+
return this.textDecoder.decode(bytes);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Unexpected: received non-Uint8Array/ArrayBuffer (${
|
|
212
|
+
(bytes as any).constructor.name
|
|
213
|
+
}) in a web platform. Please report this error.`,
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
throw new Error(
|
|
218
|
+
`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
185
222
|
flush(): string[] {
|
|
186
223
|
if (!this.buffer.length && !this.trailingCR) {
|
|
187
224
|
return [];
|
|
@@ -202,3 +239,36 @@ function partition(str: string, delimiter: string): [string, string, string] {
|
|
|
202
239
|
|
|
203
240
|
return [str, '', ''];
|
|
204
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
245
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
246
|
+
*
|
|
247
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
248
|
+
*/
|
|
249
|
+
function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
|
|
250
|
+
if (stream[Symbol.asyncIterator]) return stream;
|
|
251
|
+
|
|
252
|
+
const reader = stream.getReader();
|
|
253
|
+
return {
|
|
254
|
+
async next() {
|
|
255
|
+
try {
|
|
256
|
+
const result = await reader.read();
|
|
257
|
+
if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
|
|
258
|
+
return result;
|
|
259
|
+
} catch (e) {
|
|
260
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
261
|
+
throw e;
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
async return() {
|
|
265
|
+
const cancelPromise = reader.cancel();
|
|
266
|
+
reader.releaseLock();
|
|
267
|
+
await cancelPromise;
|
|
268
|
+
return { done: true, value: undefined };
|
|
269
|
+
},
|
|
270
|
+
[Symbol.asyncIterator]() {
|
|
271
|
+
return this;
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
package/src/uploads.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type RequestOptions } from './core';
|
|
2
|
-
import { type Readable } from '
|
|
3
|
-
import { type BodyInit } from '
|
|
4
|
-
import { FormData, File, type FilePropertyBag } from '
|
|
5
|
-
import { getMultipartRequestOptions } from '
|
|
6
|
-
import { fileFromPath } from '
|
|
7
|
-
import { type FsReadStream, isFsReadStream } from '
|
|
2
|
+
import { type Readable } from './_shims/node-readable';
|
|
3
|
+
import { type BodyInit } from './_shims/fetch.js';
|
|
4
|
+
import { FormData, File, type FilePropertyBag } from './_shims/formdata.js';
|
|
5
|
+
import { getMultipartRequestOptions } from './_shims/getMultipartRequestOptions';
|
|
6
|
+
import { fileFromPath } from './_shims/fileFromPath';
|
|
7
|
+
import { type FsReadStream, isFsReadStream } from './_shims/node-readable';
|
|
8
8
|
|
|
9
9
|
export { fileFromPath };
|
|
10
10
|
|
|
@@ -96,7 +96,7 @@ export type ToFileInput = Uploadable | Exclude<BlobPart, string> | AsyncIterable
|
|
|
96
96
|
* @returns a {@link File} with the given properties
|
|
97
97
|
*/
|
|
98
98
|
export async function toFile(
|
|
99
|
-
value: ToFileInput
|
|
99
|
+
value: ToFileInput | PromiseLike<ToFileInput>,
|
|
100
100
|
name?: string | null | undefined,
|
|
101
101
|
options: FilePropertyBag | undefined = {},
|
|
102
102
|
): Promise<FileLike> {
|
|
@@ -121,8 +121,9 @@ export async function toFile(
|
|
|
121
121
|
return new File(bits, name, options);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
async function getBytes(value: ToFileInput): Promise<Array<BlobPart>> {
|
|
125
|
-
|
|
124
|
+
async function getBytes(value: ToFileInput | PromiseLike<ToFileInput>): Promise<Array<BlobPart>> {
|
|
125
|
+
// resolve input promise or promiselike object
|
|
126
|
+
value = await value;
|
|
126
127
|
|
|
127
128
|
let parts: Array<BlobPart> = [];
|
|
128
129
|
if (
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.7.0'; // x-release-please-version
|
package/streaming.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"streaming.d.ts","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAyB,MAAM,QAAQ,CAAC;AAUrE,qBAAa,MAAM,CAAC,IAAI,CAAE,YAAW,aAAa,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjF,6GAA6G;IAC7G,QAAQ,EAAE,QAAQ,CAAC;IACnB,+FAA+F;IAC/F,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;IAE5B,OAAO,CAAC,OAAO,CAAa;gBAEhB,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe;YAO5C,YAAY;IAqBpB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC;CAsBrE"}
|
package/streaming.js
CHANGED
|
@@ -2,45 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.Stream = void 0;
|
|
4
4
|
const core_1 = require('./core.js');
|
|
5
|
-
class SSEDecoder {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.event = null;
|
|
8
|
-
this.data = [];
|
|
9
|
-
this.chunks = [];
|
|
10
|
-
}
|
|
11
|
-
decode(line) {
|
|
12
|
-
if (line.endsWith('\r')) {
|
|
13
|
-
line = line.substring(0, line.length - 1);
|
|
14
|
-
}
|
|
15
|
-
if (!line) {
|
|
16
|
-
// empty line and we didn't previously encounter any messages
|
|
17
|
-
if (!this.event && !this.data.length) return null;
|
|
18
|
-
const sse = {
|
|
19
|
-
event: this.event,
|
|
20
|
-
data: this.data.join('\n'),
|
|
21
|
-
raw: this.chunks,
|
|
22
|
-
};
|
|
23
|
-
this.event = null;
|
|
24
|
-
this.data = [];
|
|
25
|
-
this.chunks = [];
|
|
26
|
-
return sse;
|
|
27
|
-
}
|
|
28
|
-
this.chunks.push(line);
|
|
29
|
-
if (line.startsWith(':')) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
let [fieldname, _, value] = partition(line, ':');
|
|
33
|
-
if (value.startsWith(' ')) {
|
|
34
|
-
value = value.substring(1);
|
|
35
|
-
}
|
|
36
|
-
if (fieldname === 'event') {
|
|
37
|
-
this.event = value;
|
|
38
|
-
} else if (fieldname === 'data') {
|
|
39
|
-
this.data.push(value);
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
5
|
class Stream {
|
|
45
6
|
constructor(response, controller) {
|
|
46
7
|
this.response = response;
|
|
@@ -54,17 +15,9 @@ class Stream {
|
|
|
54
15
|
throw new Error(`Attempted to iterate over a response with no body`);
|
|
55
16
|
}
|
|
56
17
|
const lineDecoder = new LineDecoder();
|
|
57
|
-
|
|
58
|
-
for await (const chunk of
|
|
59
|
-
|
|
60
|
-
if (chunk instanceof Buffer) {
|
|
61
|
-
text = chunk.toString();
|
|
62
|
-
} else if (chunk instanceof Uint8Array) {
|
|
63
|
-
text = Buffer.from(chunk).toString();
|
|
64
|
-
} else {
|
|
65
|
-
text = chunk;
|
|
66
|
-
}
|
|
67
|
-
for (const line of lineDecoder.decode(text)) {
|
|
18
|
+
const iter = readableStreamAsyncIterable(this.response.body);
|
|
19
|
+
for await (const chunk of iter) {
|
|
20
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
68
21
|
const sse = this.decoder.decode(line);
|
|
69
22
|
if (sse) yield sse;
|
|
70
23
|
}
|
|
@@ -75,6 +28,7 @@ class Stream {
|
|
|
75
28
|
}
|
|
76
29
|
}
|
|
77
30
|
async *[Symbol.asyncIterator]() {
|
|
31
|
+
let done = false;
|
|
78
32
|
try {
|
|
79
33
|
for await (const sse of this.iterMessages()) {
|
|
80
34
|
try {
|
|
@@ -85,18 +39,57 @@ class Stream {
|
|
|
85
39
|
throw e;
|
|
86
40
|
}
|
|
87
41
|
}
|
|
42
|
+
done = true;
|
|
88
43
|
} catch (e) {
|
|
89
44
|
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
90
45
|
if (e instanceof Error && e.name === 'AbortError') return;
|
|
91
46
|
throw e;
|
|
92
47
|
} finally {
|
|
93
48
|
// If the user `break`s, abort the ongoing request.
|
|
94
|
-
this.controller.abort();
|
|
49
|
+
if (!done) this.controller.abort();
|
|
95
50
|
}
|
|
96
51
|
}
|
|
97
52
|
}
|
|
98
53
|
exports.Stream = Stream;
|
|
99
|
-
|
|
54
|
+
class SSEDecoder {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.event = null;
|
|
57
|
+
this.data = [];
|
|
58
|
+
this.chunks = [];
|
|
59
|
+
}
|
|
60
|
+
decode(line) {
|
|
61
|
+
if (line.endsWith('\r')) {
|
|
62
|
+
line = line.substring(0, line.length - 1);
|
|
63
|
+
}
|
|
64
|
+
if (!line) {
|
|
65
|
+
// empty line and we didn't previously encounter any messages
|
|
66
|
+
if (!this.event && !this.data.length) return null;
|
|
67
|
+
const sse = {
|
|
68
|
+
event: this.event,
|
|
69
|
+
data: this.data.join('\n'),
|
|
70
|
+
raw: this.chunks,
|
|
71
|
+
};
|
|
72
|
+
this.event = null;
|
|
73
|
+
this.data = [];
|
|
74
|
+
this.chunks = [];
|
|
75
|
+
return sse;
|
|
76
|
+
}
|
|
77
|
+
this.chunks.push(line);
|
|
78
|
+
if (line.startsWith(':')) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
82
|
+
if (value.startsWith(' ')) {
|
|
83
|
+
value = value.substring(1);
|
|
84
|
+
}
|
|
85
|
+
if (fieldname === 'event') {
|
|
86
|
+
this.event = value;
|
|
87
|
+
} else if (fieldname === 'data') {
|
|
88
|
+
this.data.push(value);
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
100
93
|
/**
|
|
101
94
|
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
102
95
|
* reading lines from text.
|
|
@@ -108,7 +101,8 @@ class LineDecoder {
|
|
|
108
101
|
this.buffer = [];
|
|
109
102
|
this.trailingCR = false;
|
|
110
103
|
}
|
|
111
|
-
decode(
|
|
104
|
+
decode(chunk) {
|
|
105
|
+
let text = this.decodeText(chunk);
|
|
112
106
|
if (this.trailingCR) {
|
|
113
107
|
text = '\r' + text;
|
|
114
108
|
this.trailingCR = false;
|
|
@@ -120,9 +114,9 @@ class LineDecoder {
|
|
|
120
114
|
if (!text) {
|
|
121
115
|
return [];
|
|
122
116
|
}
|
|
123
|
-
const
|
|
124
|
-
let lines = text.split(
|
|
125
|
-
if (lines.length === 1 && !
|
|
117
|
+
const trailingNewline = LineDecoder.NEWLINE_CHARS.has(text[text.length - 1] || '');
|
|
118
|
+
let lines = text.split(LineDecoder.NEWLINE_REGEXP);
|
|
119
|
+
if (lines.length === 1 && !trailingNewline) {
|
|
126
120
|
this.buffer.push(lines[0]);
|
|
127
121
|
return [];
|
|
128
122
|
}
|
|
@@ -130,11 +124,41 @@ class LineDecoder {
|
|
|
130
124
|
lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
|
|
131
125
|
this.buffer = [];
|
|
132
126
|
}
|
|
133
|
-
if (!
|
|
127
|
+
if (!trailingNewline) {
|
|
134
128
|
this.buffer = [lines.pop() || ''];
|
|
135
129
|
}
|
|
136
130
|
return lines;
|
|
137
131
|
}
|
|
132
|
+
decodeText(bytes) {
|
|
133
|
+
var _a;
|
|
134
|
+
if (bytes == null) return '';
|
|
135
|
+
if (typeof bytes === 'string') return bytes;
|
|
136
|
+
// Node:
|
|
137
|
+
if (typeof Buffer !== 'undefined') {
|
|
138
|
+
if (bytes instanceof Buffer) {
|
|
139
|
+
return bytes.toString();
|
|
140
|
+
}
|
|
141
|
+
if (bytes instanceof Uint8Array) {
|
|
142
|
+
return Buffer.from(bytes).toString();
|
|
143
|
+
}
|
|
144
|
+
throw new Error(
|
|
145
|
+
`Unexpected: received non-Uint8Array (${bytes.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
// Browser
|
|
149
|
+
if (typeof TextDecoder !== 'undefined') {
|
|
150
|
+
if (bytes instanceof Uint8Array || bytes instanceof ArrayBuffer) {
|
|
151
|
+
(_a = this.textDecoder) !== null && _a !== void 0 ? _a : (this.textDecoder = new TextDecoder('utf8'));
|
|
152
|
+
return this.textDecoder.decode(bytes);
|
|
153
|
+
}
|
|
154
|
+
throw new Error(
|
|
155
|
+
`Unexpected: received non-Uint8Array/ArrayBuffer (${bytes.constructor.name}) in a web platform. Please report this error.`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
throw new Error(
|
|
159
|
+
`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
138
162
|
flush() {
|
|
139
163
|
if (!this.buffer.length && !this.trailingCR) {
|
|
140
164
|
return [];
|
|
@@ -145,6 +169,9 @@ class LineDecoder {
|
|
|
145
169
|
return lines;
|
|
146
170
|
}
|
|
147
171
|
}
|
|
172
|
+
// prettier-ignore
|
|
173
|
+
LineDecoder.NEWLINE_CHARS = new Set(['\n', '\r', '\x0b', '\x0c', '\x1c', '\x1d', '\x1e', '\x85', '\u2028', '\u2029']);
|
|
174
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
|
|
148
175
|
function partition(str, delimiter) {
|
|
149
176
|
const index = str.indexOf(delimiter);
|
|
150
177
|
if (index !== -1) {
|
|
@@ -152,4 +179,35 @@ function partition(str, delimiter) {
|
|
|
152
179
|
}
|
|
153
180
|
return [str, '', ''];
|
|
154
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Most browsers don't yet have async iterable support for ReadableStream,
|
|
184
|
+
* and Node has a very different way of reading bytes from its "ReadableStream".
|
|
185
|
+
*
|
|
186
|
+
* This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
|
|
187
|
+
*/
|
|
188
|
+
function readableStreamAsyncIterable(stream) {
|
|
189
|
+
if (stream[Symbol.asyncIterator]) return stream;
|
|
190
|
+
const reader = stream.getReader();
|
|
191
|
+
return {
|
|
192
|
+
async next() {
|
|
193
|
+
try {
|
|
194
|
+
const result = await reader.read();
|
|
195
|
+
if (result === null || result === void 0 ? void 0 : result.done) reader.releaseLock(); // release lock when stream becomes closed
|
|
196
|
+
return result;
|
|
197
|
+
} catch (e) {
|
|
198
|
+
reader.releaseLock(); // release lock when stream becomes errored
|
|
199
|
+
throw e;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
async return() {
|
|
203
|
+
const cancelPromise = reader.cancel();
|
|
204
|
+
reader.releaseLock();
|
|
205
|
+
await cancelPromise;
|
|
206
|
+
return { done: true, value: undefined };
|
|
207
|
+
},
|
|
208
|
+
[Symbol.asyncIterator]() {
|
|
209
|
+
return this;
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
155
213
|
//# sourceMappingURL=streaming.js.map
|
package/streaming.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["src/streaming.ts"],"names":[],"mappings":";;;AAEA,oCAAqE;AAUrE,MAAa,MAAM;IASjB,YAAY,QAAkB,EAAE,UAA2B;QACzD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,IAAA,4BAAqB,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IAEO,KAAK,CAAC,CAAC,YAAY;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACvB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAA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