Revert "AAE-30882 Replace superagent (#11134)" (#11210)

* Revert "AAE-30882 Replace superagent (#11134)"

This reverts commit a347b20f20.

* AAE-0000 - Fixed lock for cli and adf
This commit is contained in:
Vito Albano
2025-09-19 12:44:06 +01:00
committed by GitHub
parent ef29bafc75
commit 91d6b80965
57 changed files with 3074 additions and 1051 deletions

View File

@@ -51,69 +51,6 @@ export class UploadApi extends NodesApi {
formParam = Object.assign(formParam, opts);
const originalPromise = this.createNode(rootFolderId, nodeBody, opts, formParam);
let isAborted = false;
let abortReject: (reason?: any) => void;
// Create a new promise that can be aborted
const abortablePromise = new Promise((resolve, reject) => {
abortReject = reject;
if (isAborted) {
reject(new Error('Upload aborted'));
return;
}
setTimeout(() => {
if (!isAborted && typeof (abortablePromise as any).emit === 'function') {
(abortablePromise as any).emit('progress', { loaded: 25, total: 100 });
}
}, 10);
setTimeout(() => {
if (!isAborted && typeof (abortablePromise as any).emit === 'function') {
(abortablePromise as any).emit('progress', { loaded: 50, total: 100 });
}
}, 50);
originalPromise
.then((result) => {
if (!isAborted) {
if (typeof (abortablePromise as any).emit === 'function') {
(abortablePromise as any).emit('progress', { loaded: 100, total: 100 });
}
resolve(result);
}
})
.catch((error) => {
if (!isAborted) {
reject(error);
}
});
});
Object.setPrototypeOf(abortablePromise, Object.getPrototypeOf(originalPromise));
Object.getOwnPropertyNames(originalPromise).forEach((key) => {
if (key !== 'then' && key !== 'catch' && key !== 'finally') {
(abortablePromise as any)[key] = (originalPromise as any)[key];
}
});
(abortablePromise as any).abort = () => {
if (!isAborted) {
isAborted = true;
if (typeof (abortablePromise as any).emit === 'function') {
(abortablePromise as any).emit('abort');
}
if (abortReject) {
abortReject(new Error('Upload aborted'));
}
}
};
return abortablePromise;
return this.createNode(rootFolderId, nodeBody, opts, formParam);
}
}