@planqk/planqk-api-sdk 1.9.3 → 1.9.4
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-node.md +17 -0
- package/README-python.md +17 -0
- package/README.md +66 -6
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/uv.lock +1 -1
- package/.gitlab-ci.yml +0 -110
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/sdk/Client.d.ts +0 -44
- package/dist/sdk/Client.js +0 -71
- package/dist/sdk/api/errors/BadRequestError.d.ts +0 -8
- package/dist/sdk/api/errors/BadRequestError.js +0 -52
- package/dist/sdk/api/errors/ForbiddenError.d.ts +0 -8
- package/dist/sdk/api/errors/ForbiddenError.js +0 -52
- package/dist/sdk/api/errors/InternalServerError.d.ts +0 -8
- package/dist/sdk/api/errors/InternalServerError.js +0 -52
- package/dist/sdk/api/errors/NotFoundError.d.ts +0 -8
- package/dist/sdk/api/errors/NotFoundError.js +0 -52
- package/dist/sdk/api/errors/UnauthorizedError.d.ts +0 -8
- package/dist/sdk/api/errors/UnauthorizedError.js +0 -52
- package/dist/sdk/api/errors/index.d.ts +0 -5
- package/dist/sdk/api/errors/index.js +0 -21
- package/dist/sdk/api/index.d.ts +0 -3
- package/dist/sdk/api/index.js +0 -19
- package/dist/sdk/api/resources/dataPools/client/Client.d.ts +0 -187
- package/dist/sdk/api/resources/dataPools/client/Client.js +0 -722
- package/dist/sdk/api/resources/dataPools/client/index.d.ts +0 -2
- package/dist/sdk/api/resources/dataPools/client/index.js +0 -17
- package/dist/sdk/api/resources/dataPools/client/requests/AddDataPoolFileRequest.d.ts +0 -14
- package/dist/sdk/api/resources/dataPools/client/requests/AddDataPoolFileRequest.js +0 -5
- package/dist/sdk/api/resources/dataPools/client/requests/CreateDataPoolRequest.d.ts +0 -11
- package/dist/sdk/api/resources/dataPools/client/requests/CreateDataPoolRequest.js +0 -5
- package/dist/sdk/api/resources/dataPools/client/requests/UpdateDataPoolRequest.d.ts +0 -15
- package/dist/sdk/api/resources/dataPools/client/requests/UpdateDataPoolRequest.js +0 -5
- package/dist/sdk/api/resources/dataPools/client/requests/index.d.ts +0 -3
- package/dist/sdk/api/resources/dataPools/client/requests/index.js +0 -2
- package/dist/sdk/api/resources/dataPools/index.d.ts +0 -1
- package/dist/sdk/api/resources/dataPools/index.js +0 -17
- package/dist/sdk/api/resources/index.d.ts +0 -5
- package/dist/sdk/api/resources/index.js +0 -44
- package/dist/sdk/api/resources/serviceExecutions/client/Client.d.ts +0 -90
- package/dist/sdk/api/resources/serviceExecutions/client/Client.js +0 -271
- package/dist/sdk/api/resources/serviceExecutions/client/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceExecutions/client/index.js +0 -2
- package/dist/sdk/api/resources/serviceExecutions/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceExecutions/index.js +0 -17
- package/dist/sdk/api/resources/serviceJobs/client/Client.d.ts +0 -138
- package/dist/sdk/api/resources/serviceJobs/client/Client.js +0 -489
- package/dist/sdk/api/resources/serviceJobs/client/index.d.ts +0 -2
- package/dist/sdk/api/resources/serviceJobs/client/index.js +0 -17
- package/dist/sdk/api/resources/serviceJobs/client/requests/CreateServiceJobRequest.d.ts +0 -15
- package/dist/sdk/api/resources/serviceJobs/client/requests/CreateServiceJobRequest.js +0 -5
- package/dist/sdk/api/resources/serviceJobs/client/requests/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceJobs/client/requests/index.js +0 -2
- package/dist/sdk/api/resources/serviceJobs/index.d.ts +0 -1
- package/dist/sdk/api/resources/serviceJobs/index.js +0 -17
- package/dist/sdk/api/types/ActivityInstance.d.ts +0 -20
- package/dist/sdk/api/types/ActivityInstance.js +0 -14
- package/dist/sdk/api/types/DataPoolDto.d.ts +0 -28
- package/dist/sdk/api/types/DataPoolDto.js +0 -14
- package/dist/sdk/api/types/DataPoolFileDto.d.ts +0 -19
- package/dist/sdk/api/types/DataPoolFileDto.js +0 -5
- package/dist/sdk/api/types/LogEntry.d.ts +0 -24
- package/dist/sdk/api/types/LogEntry.js +0 -16
- package/dist/sdk/api/types/MetricDataPoint.d.ts +0 -12
- package/dist/sdk/api/types/MetricDataPoint.js +0 -5
- package/dist/sdk/api/types/OauthScope.d.ts +0 -9
- package/dist/sdk/api/types/OauthScope.js +0 -9
- package/dist/sdk/api/types/ServiceExecutionDto.d.ts +0 -21
- package/dist/sdk/api/types/ServiceExecutionDto.js +0 -17
- package/dist/sdk/api/types/ServiceExecutionLogs.d.ts +0 -5
- package/dist/sdk/api/types/ServiceExecutionLogs.js +0 -5
- package/dist/sdk/api/types/ServiceExecutionMetrics.d.ts +0 -23
- package/dist/sdk/api/types/ServiceExecutionMetrics.js +0 -5
- package/dist/sdk/api/types/ServiceJobDto.d.ts +0 -46
- package/dist/sdk/api/types/ServiceJobDto.js +0 -22
- package/dist/sdk/api/types/VariableInstance.d.ts +0 -9
- package/dist/sdk/api/types/VariableInstance.js +0 -5
- package/dist/sdk/api/types/WorkflowInstance.d.ts +0 -23
- package/dist/sdk/api/types/WorkflowInstance.js +0 -17
- package/dist/sdk/api/types/WorkflowServiceExecutionDto.d.ts +0 -8
- package/dist/sdk/api/types/WorkflowServiceExecutionDto.js +0 -5
- package/dist/sdk/api/types/index.d.ts +0 -13
- package/dist/sdk/api/types/index.js +0 -29
- package/dist/sdk/core/exports.d.ts +0 -1
- package/dist/sdk/core/exports.js +0 -17
- package/dist/sdk/core/fetcher/APIResponse.d.ts +0 -20
- package/dist/sdk/core/fetcher/APIResponse.js +0 -2
- package/dist/sdk/core/fetcher/BinaryResponse.d.ts +0 -20
- package/dist/sdk/core/fetcher/BinaryResponse.js +0 -17
- package/dist/sdk/core/fetcher/Fetcher.d.ts +0 -40
- package/dist/sdk/core/fetcher/Fetcher.js +0 -105
- package/dist/sdk/core/fetcher/Headers.d.ts +0 -2
- package/dist/sdk/core/fetcher/Headers.js +0 -85
- package/dist/sdk/core/fetcher/HttpResponsePromise.d.ts +0 -58
- package/dist/sdk/core/fetcher/HttpResponsePromise.js +0 -94
- package/dist/sdk/core/fetcher/RawResponse.d.ts +0 -29
- package/dist/sdk/core/fetcher/RawResponse.js +0 -44
- package/dist/sdk/core/fetcher/ResponseWithBody.d.ts +0 -4
- package/dist/sdk/core/fetcher/ResponseWithBody.js +0 -6
- package/dist/sdk/core/fetcher/Supplier.d.ts +0 -4
- package/dist/sdk/core/fetcher/Supplier.js +0 -13
- package/dist/sdk/core/fetcher/createRequestUrl.d.ts +0 -1
- package/dist/sdk/core/fetcher/createRequestUrl.js +0 -8
- package/dist/sdk/core/fetcher/getErrorResponseBody.d.ts +0 -1
- package/dist/sdk/core/fetcher/getErrorResponseBody.js +0 -32
- package/dist/sdk/core/fetcher/getFetchFn.d.ts +0 -1
- package/dist/sdk/core/fetcher/getFetchFn.js +0 -6
- package/dist/sdk/core/fetcher/getHeader.d.ts +0 -1
- package/dist/sdk/core/fetcher/getHeader.js +0 -11
- package/dist/sdk/core/fetcher/getRequestBody.d.ts +0 -7
- package/dist/sdk/core/fetcher/getRequestBody.js +0 -12
- package/dist/sdk/core/fetcher/getResponseBody.d.ts +0 -1
- package/dist/sdk/core/fetcher/getResponseBody.js +0 -44
- package/dist/sdk/core/fetcher/index.d.ts +0 -9
- package/dist/sdk/core/fetcher/index.js +0 -15
- package/dist/sdk/core/fetcher/makeRequest.d.ts +0 -1
- package/dist/sdk/core/fetcher/makeRequest.js +0 -33
- package/dist/sdk/core/fetcher/requestWithRetries.d.ts +0 -1
- package/dist/sdk/core/fetcher/requestWithRetries.js +0 -29
- package/dist/sdk/core/fetcher/signals.d.ts +0 -11
- package/dist/sdk/core/fetcher/signals.js +0 -36
- package/dist/sdk/core/file/exports.d.ts +0 -1
- package/dist/sdk/core/file/exports.js +0 -2
- package/dist/sdk/core/file/file.d.ts +0 -5
- package/dist/sdk/core/file/file.js +0 -185
- package/dist/sdk/core/file/index.d.ts +0 -2
- package/dist/sdk/core/file/index.js +0 -18
- package/dist/sdk/core/file/types.d.ts +0 -66
- package/dist/sdk/core/file/types.js +0 -2
- package/dist/sdk/core/form-data-utils/FormDataWrapper.d.ts +0 -16
- package/dist/sdk/core/form-data-utils/FormDataWrapper.js +0 -175
- package/dist/sdk/core/form-data-utils/encodeAsFormParameter.d.ts +0 -1
- package/dist/sdk/core/form-data-utils/encodeAsFormParameter.js +0 -12
- package/dist/sdk/core/form-data-utils/index.d.ts +0 -2
- package/dist/sdk/core/form-data-utils/index.js +0 -20
- package/dist/sdk/core/headers.d.ts +0 -3
- package/dist/sdk/core/headers.js +0 -29
- package/dist/sdk/core/index.d.ts +0 -5
- package/dist/sdk/core/index.js +0 -44
- package/dist/sdk/core/json.d.ts +0 -15
- package/dist/sdk/core/json.js +0 -24
- package/dist/sdk/core/runtime/index.d.ts +0 -1
- package/dist/sdk/core/runtime/index.js +0 -5
- package/dist/sdk/core/runtime/runtime.d.ts +0 -9
- package/dist/sdk/core/runtime/runtime.js +0 -101
- package/dist/sdk/core/url/index.d.ts +0 -2
- package/dist/sdk/core/url/index.js +0 -7
- package/dist/sdk/core/url/join.d.ts +0 -1
- package/dist/sdk/core/url/join.js +0 -69
- package/dist/sdk/core/url/qs.d.ts +0 -6
- package/dist/sdk/core/url/qs.js +0 -67
- package/dist/sdk/environments.d.ts +0 -7
- package/dist/sdk/environments.js +0 -9
- package/dist/sdk/errors/PlanqkApiError.d.ts +0 -15
- package/dist/sdk/errors/PlanqkApiError.js +0 -33
- package/dist/sdk/errors/PlanqkApiTimeoutError.d.ts +0 -6
- package/dist/sdk/errors/PlanqkApiTimeoutError.js +0 -13
- package/dist/sdk/errors/index.d.ts +0 -2
- package/dist/sdk/errors/index.js +0 -7
- package/dist/sdk/exports.d.ts +0 -1
- package/dist/sdk/exports.js +0 -17
- package/dist/sdk/index.d.ts +0 -5
- package/dist/sdk/index.js +0 -48
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeRequest = void 0;
|
|
4
|
-
const signals_js_1 = require("./signals.js");
|
|
5
|
-
const makeRequest = async (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => {
|
|
6
|
-
const signals = [];
|
|
7
|
-
// Add timeout signal
|
|
8
|
-
let timeoutAbortId = undefined;
|
|
9
|
-
if (timeoutMs != null) {
|
|
10
|
-
const { signal, abortId } = (0, signals_js_1.getTimeoutSignal)(timeoutMs);
|
|
11
|
-
timeoutAbortId = abortId;
|
|
12
|
-
signals.push(signal);
|
|
13
|
-
}
|
|
14
|
-
// Add arbitrary signal
|
|
15
|
-
if (abortSignal != null) {
|
|
16
|
-
signals.push(abortSignal);
|
|
17
|
-
}
|
|
18
|
-
let newSignals = (0, signals_js_1.anySignal)(signals);
|
|
19
|
-
const response = await fetchFn(url, {
|
|
20
|
-
method: method,
|
|
21
|
-
headers,
|
|
22
|
-
body: requestBody,
|
|
23
|
-
signal: newSignals,
|
|
24
|
-
credentials: withCredentials ? "include" : undefined,
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
duplex,
|
|
27
|
-
});
|
|
28
|
-
if (timeoutAbortId != null) {
|
|
29
|
-
clearTimeout(timeoutAbortId);
|
|
30
|
-
}
|
|
31
|
-
return response;
|
|
32
|
-
};
|
|
33
|
-
exports.makeRequest = makeRequest;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function requestWithRetries(requestFn: () => Promise<Response>, maxRetries?: number): Promise<Response>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requestWithRetries = requestWithRetries;
|
|
4
|
-
const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
5
|
-
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
6
|
-
const DEFAULT_MAX_RETRIES = 2;
|
|
7
|
-
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
8
|
-
function addJitter(delay) {
|
|
9
|
-
// Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR
|
|
10
|
-
const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
|
|
11
|
-
return delay * jitterMultiplier;
|
|
12
|
-
}
|
|
13
|
-
async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
14
|
-
let response = await requestFn();
|
|
15
|
-
for (let i = 0; i < maxRetries; ++i) {
|
|
16
|
-
if ([408, 429].includes(response.status) || response.status >= 500) {
|
|
17
|
-
// Calculate base delay using exponential backoff (in milliseconds)
|
|
18
|
-
const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
|
|
19
|
-
// Add jitter to the delay
|
|
20
|
-
const delayWithJitter = addJitter(baseDelay);
|
|
21
|
-
await new Promise((resolve) => setTimeout(resolve, delayWithJitter));
|
|
22
|
-
response = await requestFn();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return response;
|
|
29
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function getTimeoutSignal(timeoutMs: number): {
|
|
2
|
-
signal: AbortSignal;
|
|
3
|
-
abortId: NodeJS.Timeout;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Returns an abort signal that is getting aborted when
|
|
7
|
-
* at least one of the specified abort signals is aborted.
|
|
8
|
-
*
|
|
9
|
-
* Requires at least node.js 18.
|
|
10
|
-
*/
|
|
11
|
-
export declare function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTimeoutSignal = getTimeoutSignal;
|
|
4
|
-
exports.anySignal = anySignal;
|
|
5
|
-
const TIMEOUT = "timeout";
|
|
6
|
-
function getTimeoutSignal(timeoutMs) {
|
|
7
|
-
const controller = new AbortController();
|
|
8
|
-
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
9
|
-
return { signal: controller.signal, abortId };
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Returns an abort signal that is getting aborted when
|
|
13
|
-
* at least one of the specified abort signals is aborted.
|
|
14
|
-
*
|
|
15
|
-
* Requires at least node.js 18.
|
|
16
|
-
*/
|
|
17
|
-
function anySignal(...args) {
|
|
18
|
-
// Allowing signals to be passed either as array
|
|
19
|
-
// of signals or as multiple arguments.
|
|
20
|
-
const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
|
|
21
|
-
const controller = new AbortController();
|
|
22
|
-
for (const signal of signals) {
|
|
23
|
-
if (signal.aborted) {
|
|
24
|
-
// Exiting early if one of the signals
|
|
25
|
-
// is already aborted.
|
|
26
|
-
controller.abort(signal?.reason);
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
// Listening for signals and removing the listeners
|
|
30
|
-
// when at least one symbol is aborted.
|
|
31
|
-
signal.addEventListener("abort", () => controller.abort(signal?.reason), {
|
|
32
|
-
signal: controller.signal,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return controller.signal;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Uploadable } from "./types.js";
|
|
@@ -1,185 +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.toBinaryUploadRequest = toBinaryUploadRequest;
|
|
37
|
-
async function toBinaryUploadRequest(file) {
|
|
38
|
-
const { data, filename, contentLength, contentType } = await getFileWithMetadata(file);
|
|
39
|
-
const request = {
|
|
40
|
-
body: data,
|
|
41
|
-
headers: {},
|
|
42
|
-
};
|
|
43
|
-
if (filename) {
|
|
44
|
-
request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
|
|
45
|
-
}
|
|
46
|
-
if (contentType) {
|
|
47
|
-
request.headers["Content-Type"] = contentType;
|
|
48
|
-
}
|
|
49
|
-
if (contentLength != null) {
|
|
50
|
-
request.headers["Content-Length"] = contentLength.toString();
|
|
51
|
-
}
|
|
52
|
-
return request;
|
|
53
|
-
}
|
|
54
|
-
async function getFileWithMetadata(file) {
|
|
55
|
-
if (isFileLike(file)) {
|
|
56
|
-
return getFileWithMetadata({
|
|
57
|
-
data: file,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
if ("path" in file) {
|
|
61
|
-
const fs = await Promise.resolve().then(() => __importStar(require("fs")));
|
|
62
|
-
if (!fs || !fs.createReadStream) {
|
|
63
|
-
throw new Error("File path uploads are not supported in this environment.");
|
|
64
|
-
}
|
|
65
|
-
const data = fs.createReadStream(file.path);
|
|
66
|
-
const contentLength = file.contentLength ?? (await tryGetFileSizeFromPath(file.path));
|
|
67
|
-
const filename = file.filename ?? getNameFromPath(file.path);
|
|
68
|
-
return {
|
|
69
|
-
data,
|
|
70
|
-
filename,
|
|
71
|
-
contentType: file.contentType,
|
|
72
|
-
contentLength,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if ("data" in file) {
|
|
76
|
-
const data = file.data;
|
|
77
|
-
const contentLength = file.contentLength ?? (await tryGetContentLengthFromFileLike(data));
|
|
78
|
-
const filename = file.filename ?? tryGetNameFromFileLike(data);
|
|
79
|
-
return {
|
|
80
|
-
data,
|
|
81
|
-
filename,
|
|
82
|
-
contentType: file.contentType ?? tryGetContentTypeFromFileLike(data),
|
|
83
|
-
contentLength,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
|
|
87
|
-
}
|
|
88
|
-
function isFileLike(value) {
|
|
89
|
-
return (isBuffer(value) ||
|
|
90
|
-
isArrayBufferView(value) ||
|
|
91
|
-
isArrayBuffer(value) ||
|
|
92
|
-
isUint8Array(value) ||
|
|
93
|
-
isBlob(value) ||
|
|
94
|
-
isFile(value) ||
|
|
95
|
-
isStreamLike(value) ||
|
|
96
|
-
isReadableStream(value));
|
|
97
|
-
}
|
|
98
|
-
async function tryGetFileSizeFromPath(path) {
|
|
99
|
-
try {
|
|
100
|
-
const fs = await Promise.resolve().then(() => __importStar(require("fs")));
|
|
101
|
-
if (!fs || !fs.promises || !fs.promises.stat) {
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
const fileStat = await fs.promises.stat(path);
|
|
105
|
-
return fileStat.size;
|
|
106
|
-
}
|
|
107
|
-
catch (fallbackError) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function tryGetNameFromFileLike(data) {
|
|
112
|
-
if (isNamedValue(data)) {
|
|
113
|
-
return data.name;
|
|
114
|
-
}
|
|
115
|
-
if (isPathedValue(data)) {
|
|
116
|
-
return getNameFromPath(data.path.toString());
|
|
117
|
-
}
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
120
|
-
async function tryGetContentLengthFromFileLike(data) {
|
|
121
|
-
if (isBuffer(data)) {
|
|
122
|
-
return data.length;
|
|
123
|
-
}
|
|
124
|
-
if (isArrayBufferView(data)) {
|
|
125
|
-
return data.byteLength;
|
|
126
|
-
}
|
|
127
|
-
if (isArrayBuffer(data)) {
|
|
128
|
-
return data.byteLength;
|
|
129
|
-
}
|
|
130
|
-
if (isBlob(data)) {
|
|
131
|
-
return data.size;
|
|
132
|
-
}
|
|
133
|
-
if (isFile(data)) {
|
|
134
|
-
return data.size;
|
|
135
|
-
}
|
|
136
|
-
if (isPathedValue(data)) {
|
|
137
|
-
return await tryGetFileSizeFromPath(data.path.toString());
|
|
138
|
-
}
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
function tryGetContentTypeFromFileLike(data) {
|
|
142
|
-
if (isBlob(data)) {
|
|
143
|
-
return data.type;
|
|
144
|
-
}
|
|
145
|
-
if (isFile(data)) {
|
|
146
|
-
return data.type;
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
function getNameFromPath(path) {
|
|
151
|
-
const lastForwardSlash = path.lastIndexOf("/");
|
|
152
|
-
const lastBackSlash = path.lastIndexOf("\\");
|
|
153
|
-
const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
|
|
154
|
-
return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
|
|
155
|
-
}
|
|
156
|
-
function isNamedValue(value) {
|
|
157
|
-
return typeof value === "object" && value != null && "name" in value;
|
|
158
|
-
}
|
|
159
|
-
function isPathedValue(value) {
|
|
160
|
-
return typeof value === "object" && value != null && "path" in value;
|
|
161
|
-
}
|
|
162
|
-
function isStreamLike(value) {
|
|
163
|
-
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
164
|
-
}
|
|
165
|
-
function isReadableStream(value) {
|
|
166
|
-
return typeof value === "object" && value != null && "getReader" in value;
|
|
167
|
-
}
|
|
168
|
-
function isBuffer(value) {
|
|
169
|
-
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
170
|
-
}
|
|
171
|
-
function isArrayBufferView(value) {
|
|
172
|
-
return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
|
|
173
|
-
}
|
|
174
|
-
function isArrayBuffer(value) {
|
|
175
|
-
return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
|
|
176
|
-
}
|
|
177
|
-
function isUint8Array(value) {
|
|
178
|
-
return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
|
|
179
|
-
}
|
|
180
|
-
function isBlob(value) {
|
|
181
|
-
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
182
|
-
}
|
|
183
|
-
function isFile(value) {
|
|
184
|
-
return typeof File !== "undefined" && value instanceof File;
|
|
185
|
-
}
|
|
@@ -1,18 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./file.js"), exports);
|
|
18
|
-
__exportStar(require("./types.js"), exports);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
|
|
3
|
-
* a path to a file, or an object with a file-like object and metadata.
|
|
4
|
-
*/
|
|
5
|
-
export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
|
|
6
|
-
export declare namespace Uploadable {
|
|
7
|
-
/**
|
|
8
|
-
* Various file-like objects that can be used to upload a file.
|
|
9
|
-
*/
|
|
10
|
-
type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
|
|
11
|
-
/**
|
|
12
|
-
* A file path with optional metadata, used for uploading a file from the file system.
|
|
13
|
-
*/
|
|
14
|
-
type FromPath = {
|
|
15
|
-
/** The path to the file to upload */
|
|
16
|
-
path: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional override for the file name (defaults to basename of path).
|
|
19
|
-
* This is used to set the `Content-Disposition` header in upload requests.
|
|
20
|
-
*/
|
|
21
|
-
filename?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
24
|
-
* This is used to set the `Content-Type` header in upload requests.
|
|
25
|
-
*/
|
|
26
|
-
contentType?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Optional file size in bytes.
|
|
29
|
-
* If not provided, the file size will be determined from the file system.
|
|
30
|
-
* The content length is used to set the `Content-Length` header in upload requests.
|
|
31
|
-
*/
|
|
32
|
-
contentLength?: number;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* A file-like object with metadata, used for uploading files.
|
|
36
|
-
*/
|
|
37
|
-
type WithMetadata = {
|
|
38
|
-
/** The file data */
|
|
39
|
-
data: FileLike;
|
|
40
|
-
/**
|
|
41
|
-
* Optional override for the file name (defaults to basename of path).
|
|
42
|
-
* This is used to set the `Content-Disposition` header in upload requests.
|
|
43
|
-
*/
|
|
44
|
-
filename?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
47
|
-
* This is used to set the `Content-Type` header in upload requests.
|
|
48
|
-
*
|
|
49
|
-
* If not provided, the content type may be determined from the data itself.
|
|
50
|
-
* * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
|
|
51
|
-
* * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
|
|
52
|
-
*/
|
|
53
|
-
contentType?: string;
|
|
54
|
-
/**
|
|
55
|
-
* Optional file size in bytes.
|
|
56
|
-
* The content length is used to set the `Content-Length` header in upload requests.
|
|
57
|
-
* If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
|
|
58
|
-
*
|
|
59
|
-
* If not provided, the file size will be determined depending on the data type.
|
|
60
|
-
* * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
|
|
61
|
-
* * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
|
|
62
|
-
* * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
|
|
63
|
-
*/
|
|
64
|
-
contentLength?: number;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface FormDataRequest<Body> {
|
|
2
|
-
body: Body;
|
|
3
|
-
headers: Record<string, string>;
|
|
4
|
-
duplex?: "half";
|
|
5
|
-
}
|
|
6
|
-
export declare function newFormData(): Promise<FormDataWrapper>;
|
|
7
|
-
export declare class FormDataWrapper {
|
|
8
|
-
private fd;
|
|
9
|
-
setup(): Promise<void>;
|
|
10
|
-
append(key: string, value: unknown): void;
|
|
11
|
-
private getFileName;
|
|
12
|
-
private convertToBlob;
|
|
13
|
-
appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
|
|
14
|
-
getRequest(): FormDataRequest<FormData>;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,175 +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.FormDataWrapper = void 0;
|
|
37
|
-
exports.newFormData = newFormData;
|
|
38
|
-
const json_js_1 = require("../../core/json.js");
|
|
39
|
-
const index_js_1 = require("../runtime/index.js");
|
|
40
|
-
function isNamedValue(value) {
|
|
41
|
-
return typeof value === "object" && value != null && "name" in value;
|
|
42
|
-
}
|
|
43
|
-
function isPathedValue(value) {
|
|
44
|
-
return typeof value === "object" && value != null && "path" in value;
|
|
45
|
-
}
|
|
46
|
-
function isStreamLike(value) {
|
|
47
|
-
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
48
|
-
}
|
|
49
|
-
function isReadableStream(value) {
|
|
50
|
-
return typeof value === "object" && value != null && "getReader" in value;
|
|
51
|
-
}
|
|
52
|
-
function isBuffer(value) {
|
|
53
|
-
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
54
|
-
}
|
|
55
|
-
function isArrayBufferView(value) {
|
|
56
|
-
return ArrayBuffer.isView(value);
|
|
57
|
-
}
|
|
58
|
-
function getLastPathSegment(pathStr) {
|
|
59
|
-
const lastForwardSlash = pathStr.lastIndexOf("/");
|
|
60
|
-
const lastBackSlash = pathStr.lastIndexOf("\\");
|
|
61
|
-
const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
|
|
62
|
-
return lastSlashIndex >= 0 ? pathStr.substring(lastSlashIndex + 1) : pathStr;
|
|
63
|
-
}
|
|
64
|
-
async function streamToBuffer(stream) {
|
|
65
|
-
if (index_js_1.RUNTIME.type === "node") {
|
|
66
|
-
const { Readable } = await Promise.resolve().then(() => __importStar(require("stream")));
|
|
67
|
-
if (stream instanceof Readable) {
|
|
68
|
-
const chunks = [];
|
|
69
|
-
for await (const chunk of stream) {
|
|
70
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
71
|
-
}
|
|
72
|
-
return Buffer.concat(chunks);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (isReadableStream(stream)) {
|
|
76
|
-
const reader = stream.getReader();
|
|
77
|
-
const chunks = [];
|
|
78
|
-
try {
|
|
79
|
-
while (true) {
|
|
80
|
-
const { done, value } = await reader.read();
|
|
81
|
-
if (done)
|
|
82
|
-
break;
|
|
83
|
-
chunks.push(value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
reader.releaseLock();
|
|
88
|
-
}
|
|
89
|
-
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
90
|
-
const result = new Uint8Array(totalLength);
|
|
91
|
-
let offset = 0;
|
|
92
|
-
for (const chunk of chunks) {
|
|
93
|
-
result.set(chunk, offset);
|
|
94
|
-
offset += chunk.length;
|
|
95
|
-
}
|
|
96
|
-
return Buffer.from(result);
|
|
97
|
-
}
|
|
98
|
-
throw new Error("Unsupported stream type: " + typeof stream + ". Expected Node.js Readable stream or Web ReadableStream.");
|
|
99
|
-
}
|
|
100
|
-
async function newFormData() {
|
|
101
|
-
return new FormDataWrapper();
|
|
102
|
-
}
|
|
103
|
-
class FormDataWrapper {
|
|
104
|
-
fd = new FormData();
|
|
105
|
-
async setup() {
|
|
106
|
-
// noop
|
|
107
|
-
}
|
|
108
|
-
append(key, value) {
|
|
109
|
-
this.fd.append(key, String(value));
|
|
110
|
-
}
|
|
111
|
-
getFileName(value, filename) {
|
|
112
|
-
if (filename != null) {
|
|
113
|
-
return filename;
|
|
114
|
-
}
|
|
115
|
-
if (isNamedValue(value)) {
|
|
116
|
-
return value.name;
|
|
117
|
-
}
|
|
118
|
-
if (isPathedValue(value) && value.path) {
|
|
119
|
-
return getLastPathSegment(value.path.toString());
|
|
120
|
-
}
|
|
121
|
-
return undefined;
|
|
122
|
-
}
|
|
123
|
-
async convertToBlob(value) {
|
|
124
|
-
if (isStreamLike(value) || isReadableStream(value)) {
|
|
125
|
-
const buffer = await streamToBuffer(value);
|
|
126
|
-
// Create a new Uint8Array to ensure ArrayBuffer compatibility
|
|
127
|
-
const uint8Array = new Uint8Array(buffer.length);
|
|
128
|
-
uint8Array.set(buffer);
|
|
129
|
-
return new Blob([uint8Array]);
|
|
130
|
-
}
|
|
131
|
-
if (value instanceof Blob) {
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
if (isBuffer(value)) {
|
|
135
|
-
// Create a new Uint8Array to ensure ArrayBuffer compatibility
|
|
136
|
-
const uint8Array = new Uint8Array(value.length);
|
|
137
|
-
uint8Array.set(value);
|
|
138
|
-
return new Blob([uint8Array]);
|
|
139
|
-
}
|
|
140
|
-
if (value instanceof ArrayBuffer) {
|
|
141
|
-
return new Blob([value]);
|
|
142
|
-
}
|
|
143
|
-
if (isArrayBufferView(value)) {
|
|
144
|
-
// Create a new Uint8Array to ensure ArrayBuffer compatibility
|
|
145
|
-
const uint8Array = new Uint8Array(value.byteLength);
|
|
146
|
-
uint8Array.set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
|
|
147
|
-
return new Blob([uint8Array]);
|
|
148
|
-
}
|
|
149
|
-
if (typeof value === "string") {
|
|
150
|
-
return new Blob([value]);
|
|
151
|
-
}
|
|
152
|
-
if (typeof value === "object" && value !== null) {
|
|
153
|
-
return new Blob([(0, json_js_1.toJson)(value)], { type: "application/json" });
|
|
154
|
-
}
|
|
155
|
-
return new Blob([String(value)]);
|
|
156
|
-
}
|
|
157
|
-
async appendFile(key, value, fileName) {
|
|
158
|
-
fileName = this.getFileName(value, fileName);
|
|
159
|
-
const blob = await this.convertToBlob(value);
|
|
160
|
-
if (fileName) {
|
|
161
|
-
this.fd.append(key, blob, fileName);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.fd.append(key, blob);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
getRequest() {
|
|
168
|
-
return {
|
|
169
|
-
body: this.fd,
|
|
170
|
-
headers: {},
|
|
171
|
-
duplex: "half",
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exports.FormDataWrapper = FormDataWrapper;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function encodeAsFormParameter(value: unknown): Record<string, string>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeAsFormParameter = encodeAsFormParameter;
|
|
4
|
-
const qs_js_1 = require("../url/qs.js");
|
|
5
|
-
function encodeAsFormParameter(value) {
|
|
6
|
-
const stringified = (0, qs_js_1.toQueryString)(value, { encode: false });
|
|
7
|
-
const keyValuePairs = stringified.split("&").map((pair) => {
|
|
8
|
-
const [key, value] = pair.split("=");
|
|
9
|
-
return [key, value];
|
|
10
|
-
});
|
|
11
|
-
return Object.fromEntries(keyValuePairs);
|
|
12
|
-
}
|
|
@@ -1,20 +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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.encodeAsFormParameter = void 0;
|
|
18
|
-
var encodeAsFormParameter_js_1 = require("./encodeAsFormParameter.js");
|
|
19
|
-
Object.defineProperty(exports, "encodeAsFormParameter", { enumerable: true, get: function () { return encodeAsFormParameter_js_1.encodeAsFormParameter; } });
|
|
20
|
-
__exportStar(require("./FormDataWrapper.js"), exports);
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as core from "./index.js";
|
|
2
|
-
export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|
|
3
|
-
export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|