@planqk/planqk-service-sdk 2.1.1 → 2.2.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/.gitlab-ci.yml +8 -39
- package/README-node.md +16 -12
- package/README.md +30 -41
- package/dist/sdk/Client.d.ts +10 -4
- package/dist/sdk/Client.js +46 -4
- package/dist/sdk/api/index.d.ts +2 -3
- package/dist/sdk/api/index.js +2 -3
- package/dist/sdk/api/resources/index.d.ts +2 -2
- package/dist/sdk/api/resources/index.js +2 -2
- package/dist/sdk/api/resources/serviceApi/client/Client.d.ts +41 -55
- package/dist/sdk/api/resources/serviceApi/client/Client.js +131 -227
- package/dist/sdk/api/resources/serviceApi/index.d.ts +2 -2
- package/dist/sdk/api/resources/serviceApi/index.js +2 -2
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponse.d.ts +13 -3
- package/dist/sdk/api/resources/serviceApi/types/index.d.ts +1 -4
- package/dist/sdk/api/resources/serviceApi/types/index.js +1 -4
- package/dist/sdk/api/types/ServiceExecution.d.ts +12 -2
- package/dist/sdk/api/types/ServiceExecution.js +12 -0
- package/dist/sdk/api/types/index.d.ts +2 -6
- package/dist/sdk/api/types/index.js +2 -6
- package/dist/sdk/core/auth/BasicAuth.js +3 -3
- package/dist/sdk/core/auth/index.d.ts +2 -2
- package/dist/sdk/core/auth/index.js +4 -4
- package/dist/sdk/core/base64.d.ts +2 -0
- package/dist/sdk/core/base64.js +26 -0
- package/dist/sdk/core/fetcher/APIResponse.d.ts +10 -0
- package/dist/sdk/core/fetcher/BinaryResponse.d.ts +20 -0
- package/dist/sdk/core/fetcher/BinaryResponse.js +17 -0
- package/dist/sdk/core/fetcher/Fetcher.d.ts +5 -4
- package/dist/sdk/core/fetcher/Fetcher.js +41 -22
- package/dist/sdk/core/fetcher/Headers.d.ts +2 -0
- package/dist/sdk/core/fetcher/Headers.js +85 -0
- package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/sdk/core/fetcher/HttpResponsePromise.js +94 -0
- package/dist/sdk/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/sdk/core/fetcher/RawResponse.js +44 -0
- package/dist/sdk/core/fetcher/ResponseWithBody.d.ts +4 -0
- package/dist/sdk/core/fetcher/ResponseWithBody.js +6 -0
- package/dist/sdk/core/fetcher/createRequestUrl.d.ts +1 -1
- package/dist/sdk/core/fetcher/createRequestUrl.js +3 -7
- package/dist/sdk/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/sdk/core/fetcher/getErrorResponseBody.js +32 -0
- package/dist/sdk/core/fetcher/getFetchFn.d.ts +1 -4
- package/dist/sdk/core/fetcher/getFetchFn.js +1 -52
- package/dist/sdk/core/fetcher/getRequestBody.js +2 -1
- package/dist/sdk/core/fetcher/getResponseBody.js +34 -30
- package/dist/sdk/core/fetcher/index.d.ts +9 -5
- package/dist/sdk/core/fetcher/index.js +13 -7
- package/dist/sdk/core/fetcher/makeRequest.js +3 -3
- package/dist/sdk/core/fetcher/requestWithRetries.js +14 -5
- package/dist/sdk/core/headers.d.ts +3 -0
- package/dist/sdk/core/headers.js +29 -0
- package/dist/sdk/core/index.d.ts +5 -3
- package/dist/sdk/core/index.js +28 -3
- package/dist/sdk/core/json.d.ts +15 -0
- package/dist/sdk/core/json.js +24 -0
- package/dist/sdk/core/runtime/index.d.ts +1 -1
- package/dist/sdk/core/runtime/index.js +2 -2
- package/dist/sdk/core/runtime/runtime.d.ts +1 -1
- package/dist/sdk/core/runtime/runtime.js +49 -40
- package/dist/sdk/core/url/index.d.ts +2 -0
- package/dist/sdk/core/url/index.js +7 -0
- package/dist/sdk/core/url/join.d.ts +1 -0
- package/dist/sdk/core/url/join.js +49 -0
- package/dist/sdk/core/url/qs.d.ts +6 -0
- package/dist/sdk/core/url/qs.js +67 -0
- package/dist/sdk/errors/PlanqkServiceApiError.d.ts +4 -1
- package/dist/sdk/errors/PlanqkServiceApiError.js +7 -8
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.d.ts +1 -1
- package/dist/sdk/errors/PlanqkServiceApiTimeoutError.js +2 -2
- package/dist/sdk/errors/index.d.ts +2 -2
- package/dist/sdk/errors/index.js +4 -4
- package/dist/sdk/index.d.ts +4 -4
- package/dist/sdk/index.js +9 -9
- package/fern/fern.config.json +1 -1
- package/fern/generators.yml +2 -2
- package/fern/openapi/openapi.yml +41 -131
- package/notebooks/python-sdk.ipynb +1 -1
- package/package.json +2 -3
- package/planqk/service/_version.py +1 -1
- package/pyproject.toml +1 -1
- package/src/index.test.ts +29 -16
- package/src/sdk/Client.ts +27 -7
- package/src/sdk/api/index.ts +2 -3
- package/src/sdk/api/resources/index.ts +2 -2
- package/src/sdk/api/resources/serviceApi/client/Client.ts +223 -250
- package/src/sdk/api/resources/serviceApi/index.ts +2 -2
- package/src/sdk/api/resources/serviceApi/types/GetResultResponse.ts +15 -3
- package/src/sdk/api/resources/serviceApi/types/index.ts +1 -4
- package/src/sdk/api/types/ServiceExecution.ts +13 -3
- package/src/sdk/api/types/index.ts +2 -6
- package/src/sdk/core/auth/BasicAuth.ts +3 -3
- package/src/sdk/core/auth/index.ts +2 -2
- package/src/sdk/core/base64.ts +27 -0
- package/src/sdk/core/fetcher/APIResponse.ts +11 -0
- package/src/sdk/core/fetcher/BinaryResponse.ts +36 -0
- package/src/sdk/core/fetcher/Fetcher.ts +46 -26
- package/src/sdk/core/fetcher/Headers.ts +93 -0
- package/src/sdk/core/fetcher/HttpResponsePromise.ts +116 -0
- package/src/sdk/core/fetcher/RawResponse.ts +61 -0
- package/src/sdk/core/fetcher/ResponseWithBody.ts +7 -0
- package/src/sdk/core/fetcher/createRequestUrl.ts +4 -8
- package/src/sdk/core/fetcher/getErrorResponseBody.ts +32 -0
- package/src/sdk/core/fetcher/getFetchFn.ts +2 -24
- package/src/sdk/core/fetcher/getRequestBody.ts +3 -1
- package/src/sdk/core/fetcher/getResponseBody.ts +38 -27
- package/src/sdk/core/fetcher/index.ts +9 -5
- package/src/sdk/core/fetcher/makeRequest.ts +2 -2
- package/src/sdk/core/fetcher/requestWithRetries.ts +18 -6
- package/src/sdk/core/fetcher/signals.ts +1 -1
- package/src/sdk/core/headers.ts +35 -0
- package/src/sdk/core/index.ts +5 -3
- package/src/sdk/core/json.ts +27 -0
- package/src/sdk/core/runtime/index.ts +1 -1
- package/src/sdk/core/runtime/runtime.ts +60 -53
- package/src/sdk/core/url/index.ts +2 -0
- package/src/sdk/core/url/join.ts +55 -0
- package/src/sdk/core/url/qs.ts +74 -0
- package/src/sdk/errors/PlanqkServiceApiError.ts +21 -11
- package/src/sdk/errors/PlanqkServiceApiTimeoutError.ts +2 -2
- package/src/sdk/errors/index.ts +2 -2
- package/src/sdk/index.ts +4 -4
- package/dist/sdk/api/errors/BadRequestError.d.ts +0 -7
- package/dist/sdk/api/errors/BadRequestError.js +0 -51
- package/dist/sdk/api/errors/ForbiddenError.d.ts +0 -7
- package/dist/sdk/api/errors/ForbiddenError.js +0 -51
- package/dist/sdk/api/errors/InternalServerError.d.ts +0 -7
- package/dist/sdk/api/errors/InternalServerError.js +0 -51
- package/dist/sdk/api/errors/NotFoundError.d.ts +0 -7
- package/dist/sdk/api/errors/NotFoundError.js +0 -51
- package/dist/sdk/api/errors/UnauthorizedError.d.ts +0 -7
- package/dist/sdk/api/errors/UnauthorizedError.js +0 -51
- package/dist/sdk/api/errors/index.d.ts +0 -5
- package/dist/sdk/api/errors/index.js +0 -21
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.d.ts +0 -7
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.js +0 -5
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.d.ts +0 -7
- package/dist/sdk/api/resources/serviceApi/types/GetResultResponseLinks.js +0 -5
- package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.d.ts +0 -7
- package/dist/sdk/api/resources/serviceApi/types/HealthCheckResponse.js +0 -5
- package/dist/sdk/api/types/InputData.d.ts +0 -4
- package/dist/sdk/api/types/InputData.js +0 -5
- package/dist/sdk/api/types/InputDataRef.d.ts +0 -8
- package/dist/sdk/api/types/InputDataRef.js +0 -5
- package/dist/sdk/api/types/InputParams.d.ts +0 -4
- package/dist/sdk/api/types/InputParams.js +0 -5
- package/dist/sdk/api/types/ServiceExecutionStatus.d.ts +0 -12
- package/dist/sdk/api/types/ServiceExecutionStatus.js +0 -14
- package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +0 -30
- package/dist/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +0 -232
- package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -21
- package/dist/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +0 -91
- package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +0 -31
- package/dist/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +0 -214
- package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +0 -18
- package/dist/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.js +0 -48
- package/src/sdk/api/errors/BadRequestError.ts +0 -16
- package/src/sdk/api/errors/ForbiddenError.ts +0 -16
- package/src/sdk/api/errors/InternalServerError.ts +0 -16
- package/src/sdk/api/errors/NotFoundError.ts +0 -16
- package/src/sdk/api/errors/UnauthorizedError.ts +0 -16
- package/src/sdk/api/errors/index.ts +0 -5
- package/src/sdk/api/resources/serviceApi/types/GetResultResponseEmbedded.ts +0 -9
- package/src/sdk/api/resources/serviceApi/types/GetResultResponseLinks.ts +0 -9
- package/src/sdk/api/resources/serviceApi/types/HealthCheckResponse.ts +0 -8
- package/src/sdk/api/types/InputData.ts +0 -5
- package/src/sdk/api/types/InputDataRef.ts +0 -9
- package/src/sdk/api/types/InputParams.ts +0 -5
- package/src/sdk/api/types/ServiceExecutionStatus.ts +0 -14
- package/src/sdk/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +0 -252
- package/src/sdk/core/fetcher/stream-wrappers/NodePre18StreamWrapper.ts +0 -106
- package/src/sdk/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +0 -239
- package/src/sdk/core/fetcher/stream-wrappers/chooseStreamWrapper.ts +0 -33
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Node18UniversalStreamWrapper = void 0;
|
|
4
|
-
class Node18UniversalStreamWrapper {
|
|
5
|
-
readableStream;
|
|
6
|
-
reader;
|
|
7
|
-
events;
|
|
8
|
-
paused;
|
|
9
|
-
resumeCallback;
|
|
10
|
-
encoding;
|
|
11
|
-
constructor(readableStream) {
|
|
12
|
-
this.readableStream = readableStream;
|
|
13
|
-
this.reader = this.readableStream.getReader();
|
|
14
|
-
this.events = {
|
|
15
|
-
data: [],
|
|
16
|
-
end: [],
|
|
17
|
-
error: [],
|
|
18
|
-
readable: [],
|
|
19
|
-
close: [],
|
|
20
|
-
pause: [],
|
|
21
|
-
resume: [],
|
|
22
|
-
};
|
|
23
|
-
this.paused = false;
|
|
24
|
-
this.resumeCallback = null;
|
|
25
|
-
this.encoding = null;
|
|
26
|
-
}
|
|
27
|
-
on(event, callback) {
|
|
28
|
-
this.events[event]?.push(callback);
|
|
29
|
-
}
|
|
30
|
-
off(event, callback) {
|
|
31
|
-
this.events[event] = this.events[event]?.filter((cb) => cb !== callback);
|
|
32
|
-
}
|
|
33
|
-
pipe(dest) {
|
|
34
|
-
this.on("data", async (chunk) => {
|
|
35
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
36
|
-
dest._write(chunk);
|
|
37
|
-
}
|
|
38
|
-
else if (dest instanceof WritableStream) {
|
|
39
|
-
const writer = dest.getWriter();
|
|
40
|
-
writer.write(chunk).then(() => writer.releaseLock());
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
dest.write(chunk);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
this.on("end", async () => {
|
|
47
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
48
|
-
dest._end();
|
|
49
|
-
}
|
|
50
|
-
else if (dest instanceof WritableStream) {
|
|
51
|
-
const writer = dest.getWriter();
|
|
52
|
-
writer.close();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
dest.end();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
this.on("error", async (error) => {
|
|
59
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
60
|
-
dest._error(error);
|
|
61
|
-
}
|
|
62
|
-
else if (dest instanceof WritableStream) {
|
|
63
|
-
const writer = dest.getWriter();
|
|
64
|
-
writer.abort(error);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
dest.destroy(error);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
this._startReading();
|
|
71
|
-
return dest;
|
|
72
|
-
}
|
|
73
|
-
pipeTo(dest) {
|
|
74
|
-
return this.pipe(dest);
|
|
75
|
-
}
|
|
76
|
-
unpipe(dest) {
|
|
77
|
-
this.off("data", async (chunk) => {
|
|
78
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
79
|
-
dest._write(chunk);
|
|
80
|
-
}
|
|
81
|
-
else if (dest instanceof WritableStream) {
|
|
82
|
-
const writer = dest.getWriter();
|
|
83
|
-
writer.write(chunk).then(() => writer.releaseLock());
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
dest.write(chunk);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
this.off("end", async () => {
|
|
90
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
91
|
-
dest._end();
|
|
92
|
-
}
|
|
93
|
-
else if (dest instanceof WritableStream) {
|
|
94
|
-
const writer = dest.getWriter();
|
|
95
|
-
writer.close();
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
dest.end();
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
this.off("error", async (error) => {
|
|
102
|
-
if (dest instanceof Node18UniversalStreamWrapper) {
|
|
103
|
-
dest._error(error);
|
|
104
|
-
}
|
|
105
|
-
else if (dest instanceof WritableStream) {
|
|
106
|
-
const writer = dest.getWriter();
|
|
107
|
-
writer.abort(error);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
dest.destroy(error);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
destroy(error) {
|
|
115
|
-
this.reader
|
|
116
|
-
.cancel(error)
|
|
117
|
-
.then(() => {
|
|
118
|
-
this._emit("close");
|
|
119
|
-
})
|
|
120
|
-
.catch((err) => {
|
|
121
|
-
this._emit("error", err);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
pause() {
|
|
125
|
-
this.paused = true;
|
|
126
|
-
this._emit("pause");
|
|
127
|
-
}
|
|
128
|
-
resume() {
|
|
129
|
-
if (this.paused) {
|
|
130
|
-
this.paused = false;
|
|
131
|
-
this._emit("resume");
|
|
132
|
-
if (this.resumeCallback) {
|
|
133
|
-
this.resumeCallback();
|
|
134
|
-
this.resumeCallback = null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
get isPaused() {
|
|
139
|
-
return this.paused;
|
|
140
|
-
}
|
|
141
|
-
async read() {
|
|
142
|
-
if (this.paused) {
|
|
143
|
-
await new Promise((resolve) => {
|
|
144
|
-
this.resumeCallback = resolve;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
const { done, value } = await this.reader.read();
|
|
148
|
-
if (done) {
|
|
149
|
-
return undefined;
|
|
150
|
-
}
|
|
151
|
-
return value;
|
|
152
|
-
}
|
|
153
|
-
setEncoding(encoding) {
|
|
154
|
-
this.encoding = encoding;
|
|
155
|
-
}
|
|
156
|
-
async text() {
|
|
157
|
-
const chunks = [];
|
|
158
|
-
while (true) {
|
|
159
|
-
const { done, value } = await this.reader.read();
|
|
160
|
-
if (done)
|
|
161
|
-
break;
|
|
162
|
-
if (value)
|
|
163
|
-
chunks.push(value);
|
|
164
|
-
}
|
|
165
|
-
const decoder = new TextDecoder(this.encoding || "utf-8");
|
|
166
|
-
return decoder.decode(await new Blob(chunks).arrayBuffer());
|
|
167
|
-
}
|
|
168
|
-
async json() {
|
|
169
|
-
const text = await this.text();
|
|
170
|
-
return JSON.parse(text);
|
|
171
|
-
}
|
|
172
|
-
_write(chunk) {
|
|
173
|
-
this._emit("data", chunk);
|
|
174
|
-
}
|
|
175
|
-
_end() {
|
|
176
|
-
this._emit("end");
|
|
177
|
-
}
|
|
178
|
-
_error(error) {
|
|
179
|
-
this._emit("error", error);
|
|
180
|
-
}
|
|
181
|
-
_emit(event, data) {
|
|
182
|
-
if (this.events[event]) {
|
|
183
|
-
for (const callback of this.events[event] || []) {
|
|
184
|
-
callback(data);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async _startReading() {
|
|
189
|
-
try {
|
|
190
|
-
this._emit("readable");
|
|
191
|
-
while (true) {
|
|
192
|
-
if (this.paused) {
|
|
193
|
-
await new Promise((resolve) => {
|
|
194
|
-
this.resumeCallback = resolve;
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
const { done, value } = await this.reader.read();
|
|
198
|
-
if (done) {
|
|
199
|
-
this._emit("end");
|
|
200
|
-
this._emit("close");
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
if (value) {
|
|
204
|
-
this._emit("data", value);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
this._emit("error", error);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
[Symbol.asyncIterator]() {
|
|
213
|
-
return {
|
|
214
|
-
next: async () => {
|
|
215
|
-
if (this.paused) {
|
|
216
|
-
await new Promise((resolve) => {
|
|
217
|
-
this.resumeCallback = resolve;
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
const { done, value } = await this.reader.read();
|
|
221
|
-
if (done) {
|
|
222
|
-
return { done: true, value: undefined };
|
|
223
|
-
}
|
|
224
|
-
return { done: false, value };
|
|
225
|
-
},
|
|
226
|
-
[Symbol.asyncIterator]() {
|
|
227
|
-
return this;
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
exports.Node18UniversalStreamWrapper = Node18UniversalStreamWrapper;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "stream";
|
|
2
|
-
import { EventCallback, StreamWrapper } from "./chooseStreamWrapper";
|
|
3
|
-
export declare class NodePre18StreamWrapper implements StreamWrapper<Writable, Buffer> {
|
|
4
|
-
private readableStream;
|
|
5
|
-
private encoding;
|
|
6
|
-
constructor(readableStream: Readable);
|
|
7
|
-
on(event: string, callback: EventCallback): void;
|
|
8
|
-
off(event: string, callback: EventCallback): void;
|
|
9
|
-
pipe(dest: Writable): Writable;
|
|
10
|
-
pipeTo(dest: Writable): Writable;
|
|
11
|
-
unpipe(dest?: Writable): void;
|
|
12
|
-
destroy(error?: Error): void;
|
|
13
|
-
pause(): void;
|
|
14
|
-
resume(): void;
|
|
15
|
-
get isPaused(): boolean;
|
|
16
|
-
read(): Promise<Buffer | undefined>;
|
|
17
|
-
setEncoding(encoding?: string): void;
|
|
18
|
-
text(): Promise<string>;
|
|
19
|
-
json<T>(): Promise<T>;
|
|
20
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<Buffer>;
|
|
21
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodePre18StreamWrapper = void 0;
|
|
4
|
-
class NodePre18StreamWrapper {
|
|
5
|
-
readableStream;
|
|
6
|
-
encoding;
|
|
7
|
-
constructor(readableStream) {
|
|
8
|
-
this.readableStream = readableStream;
|
|
9
|
-
}
|
|
10
|
-
on(event, callback) {
|
|
11
|
-
this.readableStream.on(event, callback);
|
|
12
|
-
}
|
|
13
|
-
off(event, callback) {
|
|
14
|
-
this.readableStream.off(event, callback);
|
|
15
|
-
}
|
|
16
|
-
pipe(dest) {
|
|
17
|
-
this.readableStream.pipe(dest);
|
|
18
|
-
return dest;
|
|
19
|
-
}
|
|
20
|
-
pipeTo(dest) {
|
|
21
|
-
return this.pipe(dest);
|
|
22
|
-
}
|
|
23
|
-
unpipe(dest) {
|
|
24
|
-
if (dest) {
|
|
25
|
-
this.readableStream.unpipe(dest);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
this.readableStream.unpipe();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
destroy(error) {
|
|
32
|
-
this.readableStream.destroy(error);
|
|
33
|
-
}
|
|
34
|
-
pause() {
|
|
35
|
-
this.readableStream.pause();
|
|
36
|
-
}
|
|
37
|
-
resume() {
|
|
38
|
-
this.readableStream.resume();
|
|
39
|
-
}
|
|
40
|
-
get isPaused() {
|
|
41
|
-
return this.readableStream.isPaused();
|
|
42
|
-
}
|
|
43
|
-
async read() {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
const chunk = this.readableStream.read();
|
|
46
|
-
if (chunk) {
|
|
47
|
-
resolve(chunk);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.readableStream.once("readable", () => {
|
|
51
|
-
const chunk = this.readableStream.read();
|
|
52
|
-
resolve(chunk);
|
|
53
|
-
});
|
|
54
|
-
this.readableStream.once("error", reject);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
setEncoding(encoding) {
|
|
59
|
-
this.readableStream.setEncoding(encoding);
|
|
60
|
-
this.encoding = encoding;
|
|
61
|
-
}
|
|
62
|
-
async text() {
|
|
63
|
-
const chunks = [];
|
|
64
|
-
const encoder = new TextEncoder();
|
|
65
|
-
this.readableStream.setEncoding((this.encoding || "utf-8"));
|
|
66
|
-
for await (const chunk of this.readableStream) {
|
|
67
|
-
chunks.push(encoder.encode(chunk));
|
|
68
|
-
}
|
|
69
|
-
const decoder = new TextDecoder(this.encoding || "utf-8");
|
|
70
|
-
return decoder.decode(Buffer.concat(chunks));
|
|
71
|
-
}
|
|
72
|
-
async json() {
|
|
73
|
-
const text = await this.text();
|
|
74
|
-
return JSON.parse(text);
|
|
75
|
-
}
|
|
76
|
-
[Symbol.asyncIterator]() {
|
|
77
|
-
const readableStream = this.readableStream;
|
|
78
|
-
const iterator = readableStream[Symbol.asyncIterator]();
|
|
79
|
-
// Create and return an async iterator that yields buffers
|
|
80
|
-
return {
|
|
81
|
-
async next() {
|
|
82
|
-
const { value, done } = await iterator.next();
|
|
83
|
-
return { value: value, done };
|
|
84
|
-
},
|
|
85
|
-
[Symbol.asyncIterator]() {
|
|
86
|
-
return this;
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.NodePre18StreamWrapper = NodePre18StreamWrapper;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { StreamWrapper } from "./chooseStreamWrapper";
|
|
2
|
-
type EventCallback = (data?: any) => void;
|
|
3
|
-
export declare class UndiciStreamWrapper<ReadFormat extends Uint8Array | Uint16Array | Uint32Array> implements StreamWrapper<UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>, ReadFormat> {
|
|
4
|
-
private readableStream;
|
|
5
|
-
private reader;
|
|
6
|
-
private events;
|
|
7
|
-
private paused;
|
|
8
|
-
private resumeCallback;
|
|
9
|
-
private encoding;
|
|
10
|
-
constructor(readableStream: ReadableStream<ReadFormat>);
|
|
11
|
-
on(event: string, callback: EventCallback): void;
|
|
12
|
-
off(event: string, callback: EventCallback): void;
|
|
13
|
-
pipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
|
|
14
|
-
pipeTo(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>): UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>;
|
|
15
|
-
unpipe(dest: UndiciStreamWrapper<ReadFormat> | WritableStream<any>): void;
|
|
16
|
-
destroy(error?: Error): void;
|
|
17
|
-
pause(): void;
|
|
18
|
-
resume(): void;
|
|
19
|
-
get isPaused(): boolean;
|
|
20
|
-
read(): Promise<ReadFormat | undefined>;
|
|
21
|
-
setEncoding(encoding: string): void;
|
|
22
|
-
text(): Promise<string>;
|
|
23
|
-
json<T>(): Promise<T>;
|
|
24
|
-
private _write;
|
|
25
|
-
private _end;
|
|
26
|
-
private _error;
|
|
27
|
-
private _emit;
|
|
28
|
-
private _startReading;
|
|
29
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<ReadFormat>;
|
|
30
|
-
}
|
|
31
|
-
export {};
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UndiciStreamWrapper = void 0;
|
|
4
|
-
class UndiciStreamWrapper {
|
|
5
|
-
readableStream;
|
|
6
|
-
reader;
|
|
7
|
-
events;
|
|
8
|
-
paused;
|
|
9
|
-
resumeCallback;
|
|
10
|
-
encoding;
|
|
11
|
-
constructor(readableStream) {
|
|
12
|
-
this.readableStream = readableStream;
|
|
13
|
-
this.reader = this.readableStream.getReader();
|
|
14
|
-
this.events = {
|
|
15
|
-
data: [],
|
|
16
|
-
end: [],
|
|
17
|
-
error: [],
|
|
18
|
-
readable: [],
|
|
19
|
-
close: [],
|
|
20
|
-
pause: [],
|
|
21
|
-
resume: [],
|
|
22
|
-
};
|
|
23
|
-
this.paused = false;
|
|
24
|
-
this.resumeCallback = null;
|
|
25
|
-
this.encoding = null;
|
|
26
|
-
}
|
|
27
|
-
on(event, callback) {
|
|
28
|
-
this.events[event]?.push(callback);
|
|
29
|
-
}
|
|
30
|
-
off(event, callback) {
|
|
31
|
-
this.events[event] = this.events[event]?.filter((cb) => cb !== callback);
|
|
32
|
-
}
|
|
33
|
-
pipe(dest) {
|
|
34
|
-
this.on("data", (chunk) => {
|
|
35
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
36
|
-
dest._write(chunk);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const writer = dest.getWriter();
|
|
40
|
-
writer.write(chunk).then(() => writer.releaseLock());
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
this.on("end", () => {
|
|
44
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
45
|
-
dest._end();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const writer = dest.getWriter();
|
|
49
|
-
writer.close();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
this.on("error", (error) => {
|
|
53
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
54
|
-
dest._error(error);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const writer = dest.getWriter();
|
|
58
|
-
writer.abort(error);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
this._startReading();
|
|
62
|
-
return dest;
|
|
63
|
-
}
|
|
64
|
-
pipeTo(dest) {
|
|
65
|
-
return this.pipe(dest);
|
|
66
|
-
}
|
|
67
|
-
unpipe(dest) {
|
|
68
|
-
this.off("data", (chunk) => {
|
|
69
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
70
|
-
dest._write(chunk);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const writer = dest.getWriter();
|
|
74
|
-
writer.write(chunk).then(() => writer.releaseLock());
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
this.off("end", () => {
|
|
78
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
79
|
-
dest._end();
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
const writer = dest.getWriter();
|
|
83
|
-
writer.close();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
this.off("error", (error) => {
|
|
87
|
-
if (dest instanceof UndiciStreamWrapper) {
|
|
88
|
-
dest._error(error);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const writer = dest.getWriter();
|
|
92
|
-
writer.abort(error);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
destroy(error) {
|
|
97
|
-
this.reader
|
|
98
|
-
.cancel(error)
|
|
99
|
-
.then(() => {
|
|
100
|
-
this._emit("close");
|
|
101
|
-
})
|
|
102
|
-
.catch((err) => {
|
|
103
|
-
this._emit("error", err);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
pause() {
|
|
107
|
-
this.paused = true;
|
|
108
|
-
this._emit("pause");
|
|
109
|
-
}
|
|
110
|
-
resume() {
|
|
111
|
-
if (this.paused) {
|
|
112
|
-
this.paused = false;
|
|
113
|
-
this._emit("resume");
|
|
114
|
-
if (this.resumeCallback) {
|
|
115
|
-
this.resumeCallback();
|
|
116
|
-
this.resumeCallback = null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
get isPaused() {
|
|
121
|
-
return this.paused;
|
|
122
|
-
}
|
|
123
|
-
async read() {
|
|
124
|
-
if (this.paused) {
|
|
125
|
-
await new Promise((resolve) => {
|
|
126
|
-
this.resumeCallback = resolve;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
const { done, value } = await this.reader.read();
|
|
130
|
-
if (done) {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
setEncoding(encoding) {
|
|
136
|
-
this.encoding = encoding;
|
|
137
|
-
}
|
|
138
|
-
async text() {
|
|
139
|
-
const chunks = [];
|
|
140
|
-
while (true) {
|
|
141
|
-
const { done, value } = await this.reader.read();
|
|
142
|
-
if (done)
|
|
143
|
-
break;
|
|
144
|
-
if (value)
|
|
145
|
-
chunks.push(value);
|
|
146
|
-
}
|
|
147
|
-
const decoder = new TextDecoder(this.encoding || "utf-8");
|
|
148
|
-
return decoder.decode(await new Blob(chunks).arrayBuffer());
|
|
149
|
-
}
|
|
150
|
-
async json() {
|
|
151
|
-
const text = await this.text();
|
|
152
|
-
return JSON.parse(text);
|
|
153
|
-
}
|
|
154
|
-
_write(chunk) {
|
|
155
|
-
this._emit("data", chunk);
|
|
156
|
-
}
|
|
157
|
-
_end() {
|
|
158
|
-
this._emit("end");
|
|
159
|
-
}
|
|
160
|
-
_error(error) {
|
|
161
|
-
this._emit("error", error);
|
|
162
|
-
}
|
|
163
|
-
_emit(event, data) {
|
|
164
|
-
if (this.events[event]) {
|
|
165
|
-
for (const callback of this.events[event] || []) {
|
|
166
|
-
callback(data);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async _startReading() {
|
|
171
|
-
try {
|
|
172
|
-
this._emit("readable");
|
|
173
|
-
while (true) {
|
|
174
|
-
if (this.paused) {
|
|
175
|
-
await new Promise((resolve) => {
|
|
176
|
-
this.resumeCallback = resolve;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
const { done, value } = await this.reader.read();
|
|
180
|
-
if (done) {
|
|
181
|
-
this._emit("end");
|
|
182
|
-
this._emit("close");
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (value) {
|
|
186
|
-
this._emit("data", value);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
this._emit("error", error);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
[Symbol.asyncIterator]() {
|
|
195
|
-
return {
|
|
196
|
-
next: async () => {
|
|
197
|
-
if (this.paused) {
|
|
198
|
-
await new Promise((resolve) => {
|
|
199
|
-
this.resumeCallback = resolve;
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
const { done, value } = await this.reader.read();
|
|
203
|
-
if (done) {
|
|
204
|
-
return { done: true, value: undefined };
|
|
205
|
-
}
|
|
206
|
-
return { done: false, value };
|
|
207
|
-
},
|
|
208
|
-
[Symbol.asyncIterator]() {
|
|
209
|
-
return this;
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
exports.UndiciStreamWrapper = UndiciStreamWrapper;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type EventCallback = (data?: any) => void;
|
|
2
|
-
export interface StreamWrapper<WritableStream, ReadFormat> {
|
|
3
|
-
setEncoding(encoding?: string): void;
|
|
4
|
-
on(event: string, callback: EventCallback): void;
|
|
5
|
-
off(event: string, callback: EventCallback): void;
|
|
6
|
-
pipe(dest: WritableStream): WritableStream;
|
|
7
|
-
pipeTo(dest: WritableStream): WritableStream;
|
|
8
|
-
unpipe(dest?: WritableStream): void;
|
|
9
|
-
destroy(error?: Error): void;
|
|
10
|
-
pause(): void;
|
|
11
|
-
resume(): void;
|
|
12
|
-
get isPaused(): boolean;
|
|
13
|
-
read(): Promise<ReadFormat | undefined>;
|
|
14
|
-
text(): Promise<string>;
|
|
15
|
-
json<T>(): Promise<T>;
|
|
16
|
-
[Symbol.asyncIterator](): AsyncIterableIterator<ReadFormat>;
|
|
17
|
-
}
|
|
18
|
-
export declare function chooseStreamWrapper(responseBody: any): Promise<Promise<StreamWrapper<any, any>>>;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.chooseStreamWrapper = chooseStreamWrapper;
|
|
37
|
-
const runtime_1 = require("../../runtime");
|
|
38
|
-
async function chooseStreamWrapper(responseBody) {
|
|
39
|
-
if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion >= 18) {
|
|
40
|
-
return new (await Promise.resolve().then(() => __importStar(require("./Node18UniversalStreamWrapper")))).Node18UniversalStreamWrapper(responseBody);
|
|
41
|
-
}
|
|
42
|
-
else if (runtime_1.RUNTIME.type !== "node" && typeof fetch == "function") {
|
|
43
|
-
return new (await Promise.resolve().then(() => __importStar(require("./UndiciStreamWrapper")))).UndiciStreamWrapper(responseBody);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return new (await Promise.resolve().then(() => __importStar(require("./NodePre18StreamWrapper")))).NodePre18StreamWrapper(responseBody);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as errors from "../../errors/index";
|
|
6
|
-
|
|
7
|
-
export class BadRequestError extends errors.PlanqkServiceApiError {
|
|
8
|
-
constructor(body?: any) {
|
|
9
|
-
super({
|
|
10
|
-
message: "BadRequestError",
|
|
11
|
-
statusCode: 400,
|
|
12
|
-
body: body,
|
|
13
|
-
});
|
|
14
|
-
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as errors from "../../errors/index";
|
|
6
|
-
|
|
7
|
-
export class ForbiddenError extends errors.PlanqkServiceApiError {
|
|
8
|
-
constructor(body?: any) {
|
|
9
|
-
super({
|
|
10
|
-
message: "ForbiddenError",
|
|
11
|
-
statusCode: 403,
|
|
12
|
-
body: body,
|
|
13
|
-
});
|
|
14
|
-
Object.setPrototypeOf(this, ForbiddenError.prototype);
|
|
15
|
-
}
|
|
16
|
-
}
|