dragdropdo-sdk 1.0.0 → 1.0.1
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/dist/src/client.js
CHANGED
|
@@ -155,7 +155,7 @@ class Dragdropdo {
|
|
|
155
155
|
}
|
|
156
156
|
try {
|
|
157
157
|
// Step 1: Request presigned URLs
|
|
158
|
-
const uploadResponse = await this.axiosInstance.post("/v1/
|
|
158
|
+
const uploadResponse = await this.axiosInstance.post("/api/v1/initiate-upload", {
|
|
159
159
|
file_name: fileName,
|
|
160
160
|
size: fileSize,
|
|
161
161
|
mime_type: detectedMimeType,
|
|
@@ -218,7 +218,7 @@ class Dragdropdo {
|
|
|
218
218
|
}
|
|
219
219
|
// Step 3: Complete the multipart upload
|
|
220
220
|
try {
|
|
221
|
-
await this.axiosInstance.post("/v1/
|
|
221
|
+
await this.axiosInstance.post("/api/v1/complete-upload", {
|
|
222
222
|
file_key: fileKey,
|
|
223
223
|
upload_id: uploadId,
|
|
224
224
|
object_name: objectName,
|
|
@@ -291,7 +291,7 @@ class Dragdropdo {
|
|
|
291
291
|
throw new errors_1.D3ValidationError("Extension (ext) is required");
|
|
292
292
|
}
|
|
293
293
|
try {
|
|
294
|
-
const response = await this.axiosInstance.post("/v1/
|
|
294
|
+
const response = await this.axiosInstance.post("/api/v1/supported-operation", {
|
|
295
295
|
ext: options.ext,
|
|
296
296
|
action: options.action,
|
|
297
297
|
parameters: options.parameters,
|
|
@@ -350,7 +350,7 @@ class Dragdropdo {
|
|
|
350
350
|
throw new errors_1.D3ValidationError("At least one file key is required");
|
|
351
351
|
}
|
|
352
352
|
try {
|
|
353
|
-
const response = await this.axiosInstance.post("/v1/
|
|
353
|
+
const response = await this.axiosInstance.post("/api/v1/do", {
|
|
354
354
|
action: options.action,
|
|
355
355
|
file_keys: options.fileKeys,
|
|
356
356
|
parameters: options.parameters,
|
|
@@ -487,7 +487,7 @@ class Dragdropdo {
|
|
|
487
487
|
throw new errors_1.D3ValidationError("mainTaskId is required");
|
|
488
488
|
}
|
|
489
489
|
try {
|
|
490
|
-
let url = `/v1/
|
|
490
|
+
let url = `/api/v1/status/${options.mainTaskId}`;
|
|
491
491
|
if (options.fileTaskId) {
|
|
492
492
|
url += `/${options.fileTaskId}`;
|
|
493
493
|
}
|
|
@@ -495,11 +495,12 @@ class Dragdropdo {
|
|
|
495
495
|
const rawData = response.data.data;
|
|
496
496
|
// Transform snake_case to camelCase
|
|
497
497
|
const transformed = this.toCamelCase(rawData);
|
|
498
|
+
const rawStatus = (transformed.operationStatus || transformed.operation_status || "").toLowerCase();
|
|
498
499
|
return {
|
|
499
|
-
operationStatus:
|
|
500
|
+
operationStatus: rawStatus,
|
|
500
501
|
filesData: (transformed.filesData || transformed.files_data || []).map((file) => ({
|
|
501
502
|
fileKey: file.fileKey || file.file_key,
|
|
502
|
-
status: file.status,
|
|
503
|
+
status: (file.status || "").toLowerCase(),
|
|
503
504
|
downloadLink: file.downloadLink || file.download_link,
|
|
504
505
|
errorCode: file.errorCode || file.error_code,
|
|
505
506
|
errorMessage: file.errorMessage || file.error_message,
|
|
@@ -68,7 +68,7 @@ describe("Dragdropdo end-to-end (mocked HTTP)", () => {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
(0, nock_1.default)(API_BASE)
|
|
71
|
-
.post("/v1/
|
|
71
|
+
.post("/api/v1/initiate-upload", (body) => {
|
|
72
72
|
return (body.file_name === "test.pdf" &&
|
|
73
73
|
body.size === 6 * 1024 * 1024 &&
|
|
74
74
|
body.mime_type === "application/pdf" &&
|
|
@@ -91,7 +91,7 @@ describe("Dragdropdo end-to-end (mocked HTTP)", () => {
|
|
|
91
91
|
.put("/part2")
|
|
92
92
|
.reply(200, {}, { ETag: '"etag-part-2"' });
|
|
93
93
|
(0, nock_1.default)(API_BASE)
|
|
94
|
-
.post("/v1/
|
|
94
|
+
.post("/api/v1/complete-upload", (body) => {
|
|
95
95
|
return (body.file_key === "file-key-123" &&
|
|
96
96
|
body.upload_id === "upload-id-456" &&
|
|
97
97
|
Array.isArray(body.parts) &&
|
|
@@ -126,7 +126,7 @@ describe("Dragdropdo end-to-end (mocked HTTP)", () => {
|
|
|
126
126
|
test("creates an operation and polls status to completion", async () => {
|
|
127
127
|
const client = new src_1.Dragdropdo({ apiKey: "test-key", baseURL: API_BASE });
|
|
128
128
|
(0, nock_1.default)(API_BASE)
|
|
129
|
-
.post("/v1/
|
|
129
|
+
.post("/api/v1/do", {
|
|
130
130
|
action: "convert",
|
|
131
131
|
file_keys: ["file-key-123"],
|
|
132
132
|
parameters: { convert_to: "png" },
|
|
@@ -134,14 +134,14 @@ describe("Dragdropdo end-to-end (mocked HTTP)", () => {
|
|
|
134
134
|
})
|
|
135
135
|
.reply(200, { data: { mainTaskId: "task-123" } });
|
|
136
136
|
(0, nock_1.default)(API_BASE)
|
|
137
|
-
.get("/v1/
|
|
137
|
+
.get("/api/v1/status/task-123")
|
|
138
138
|
.reply(200, {
|
|
139
139
|
data: {
|
|
140
140
|
operationStatus: "queued",
|
|
141
141
|
filesData: [{ fileKey: "file-key-123", status: "queued" }],
|
|
142
142
|
},
|
|
143
143
|
})
|
|
144
|
-
.get("/v1/
|
|
144
|
+
.get("/api/v1/status/task-123")
|
|
145
145
|
.reply(200, {
|
|
146
146
|
data: {
|
|
147
147
|
operationStatus: "completed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dragdropdo-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Official Node.js client library for the dragdropdo.com Business API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"convert",
|
|
20
20
|
"compress"
|
|
21
21
|
],
|
|
22
|
+
"homepage": "https://dragdropdo.com",
|
|
22
23
|
"author": "TrippyTech Labs LLP",
|
|
23
24
|
"license": "ISC",
|
|
24
25
|
"dependencies": {
|