dragdropdo-sdk 1.0.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.
@@ -0,0 +1,208 @@
1
+ /**
2
+ * dragdropdo.com Business API Client
3
+ *
4
+ * A Node.js client library for interacting with the dragdropdo.com Business API.
5
+ * Provides methods for file uploads, operations, and status checking.
6
+ */
7
+ import { DragdropdoConfig, UploadFileOptions, UploadResponse, SupportedOperationOptions, SupportedOperationResponse, OperationOptions, OperationResponse, StatusOptions, StatusResponse, PollStatusOptions } from "./types";
8
+ export declare class Dragdropdo {
9
+ private apiKey;
10
+ private baseURL;
11
+ private timeout;
12
+ private axiosInstance;
13
+ /**
14
+ * Create a new DragDropDo Client instance
15
+ *
16
+ * @param config - Client configuration
17
+ * @example
18
+ * ```typescript
19
+ * const client = new Dragdropdo({
20
+ * apiKey: 'your-api-key',
21
+ * baseURL: 'https://dragdropdo.com',
22
+ * timeout: 30000
23
+ * });
24
+ * ```
25
+ */
26
+ constructor(config: DragdropdoConfig);
27
+ /**
28
+ * Upload a file to D3 storage
29
+ *
30
+ * This method handles the complete upload flow:
31
+ * 1. Request presigned URLs from the API
32
+ * 2. Upload file parts to presigned URLs
33
+ * 3. Return the file key for use in operations
34
+ *
35
+ * @param options - Upload options
36
+ * @returns Promise resolving to upload response with file key
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // Upload from file path
41
+ * const result = await client.uploadFile({
42
+ * file: '/path/to/file.pdf',
43
+ * fileName: 'document.pdf',
44
+ * mimeType: 'application/pdf',
45
+ * onProgress: (progress) => {
46
+ * console.log(`Upload: ${progress.percentage}%`);
47
+ * }
48
+ * });
49
+ * console.log('File key:', result.fileKey);
50
+ * ```
51
+ */
52
+ uploadFile(options: UploadFileOptions): Promise<UploadResponse>;
53
+ /**
54
+ * Check if an operation is supported for a file extension
55
+ *
56
+ * @param options - Supported operation options
57
+ * @returns Promise resolving to supported operation response
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Check all available actions for PDF
62
+ * const result = await client.checkSupportedOperation({
63
+ * ext: 'pdf'
64
+ * });
65
+ * console.log('Available actions:', result.availableActions);
66
+ *
67
+ * // Check if convert to PNG is supported
68
+ * const result = await client.checkSupportedOperation({
69
+ * ext: 'pdf',
70
+ * action: 'convert',
71
+ * parameters: { convert_to: 'png' }
72
+ * });
73
+ * console.log('Supported:', result.supported);
74
+ *
75
+ * // Get available compression levels
76
+ * const result = await client.checkSupportedOperation({
77
+ * ext: 'pdf',
78
+ * action: 'compress'
79
+ * });
80
+ * console.log('Compression levels:', result.parameters?.compression_value);
81
+ * ```
82
+ */
83
+ checkSupportedOperation(options: SupportedOperationOptions): Promise<SupportedOperationResponse>;
84
+ /**
85
+ * Create a file operation (convert, compress, merge, zip, etc.)
86
+ *
87
+ * @param options - Operation options
88
+ * @returns Promise resolving to operation response with main task ID
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Convert PDF to PNG
93
+ * const result = await client.createOperation({
94
+ * action: 'convert',
95
+ * fileKeys: ['file-key-123'],
96
+ * parameters: { convert_to: 'png' }
97
+ * });
98
+ *
99
+ * // Compress PDF
100
+ * const result = await client.createOperation({
101
+ * action: 'compress',
102
+ * fileKeys: ['file-key-123'],
103
+ * parameters: { compression_value: 'recommended' }
104
+ * });
105
+ *
106
+ * // Merge multiple PDFs
107
+ * const result = await client.createOperation({
108
+ * action: 'merge',
109
+ * fileKeys: ['file-key-1', 'file-key-2', 'file-key-3']
110
+ * });
111
+ *
112
+ * // Lock PDF with password
113
+ * const result = await client.createOperation({
114
+ * action: 'lock',
115
+ * fileKeys: ['file-key-123'],
116
+ * parameters: { password: 'secure-password' }
117
+ * });
118
+ * ```
119
+ */
120
+ createOperation(options: OperationOptions): Promise<OperationResponse>;
121
+ /**
122
+ * Convenience methods for specific operations
123
+ */
124
+ /**
125
+ * Convert files to a different format
126
+ */
127
+ convert(fileKeys: string[], convertTo: string, notes?: Record<string, string>): Promise<OperationResponse>;
128
+ /**
129
+ * Compress files
130
+ */
131
+ compress(fileKeys: string[], compressionValue?: string, notes?: Record<string, string>): Promise<OperationResponse>;
132
+ /**
133
+ * Merge multiple files
134
+ */
135
+ merge(fileKeys: string[], notes?: Record<string, string>): Promise<OperationResponse>;
136
+ /**
137
+ * Create a ZIP archive from files
138
+ */
139
+ zip(fileKeys: string[], notes?: Record<string, string>): Promise<OperationResponse>;
140
+ /**
141
+ * Share files (generate shareable links)
142
+ */
143
+ share(fileKeys: string[], notes?: Record<string, string>): Promise<OperationResponse>;
144
+ /**
145
+ * Lock PDF with password
146
+ */
147
+ lockPdf(fileKeys: string[], password: string, notes?: Record<string, string>): Promise<OperationResponse>;
148
+ /**
149
+ * Unlock PDF with password
150
+ */
151
+ unlockPdf(fileKeys: string[], password: string, notes?: Record<string, string>): Promise<OperationResponse>;
152
+ /**
153
+ * Reset PDF password
154
+ */
155
+ resetPdfPassword(fileKeys: string[], oldPassword: string, newPassword: string, notes?: Record<string, string>): Promise<OperationResponse>;
156
+ /**
157
+ * Get operation status
158
+ *
159
+ * @param options - Status options
160
+ * @returns Promise resolving to status response
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * // Get main task status
165
+ * const status = await client.getStatus({
166
+ * mainTaskId: 'task-123'
167
+ * });
168
+ *
169
+ * // Get specific file task status
170
+ * const status = await client.getStatus({
171
+ * mainTaskId: 'task-123',
172
+ * fileTaskId: 'file-task-456'
173
+ * });
174
+ * ```
175
+ */
176
+ getStatus(options: StatusOptions): Promise<StatusResponse>;
177
+ /**
178
+ * Poll operation status until completion or failure
179
+ *
180
+ * @param options - Poll status options
181
+ * @returns Promise resolving to final status response
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const status = await client.pollStatus({
186
+ * mainTaskId: 'task-123',
187
+ * interval: 2000, // Check every 2 seconds
188
+ * timeout: 300000, // 5 minutes max
189
+ * onUpdate: (status) => {
190
+ * console.log('Status:', status.operationStatus);
191
+ * }
192
+ * });
193
+ *
194
+ * if (status.operationStatus === 'completed') {
195
+ * console.log('Download links:', status.filesData.map(f => f.downloadLink));
196
+ * }
197
+ * ```
198
+ */
199
+ pollStatus(options: PollStatusOptions): Promise<StatusResponse>;
200
+ /**
201
+ * Convert snake_case object keys to camelCase
202
+ */
203
+ private toCamelCase;
204
+ /**
205
+ * Get MIME type from file extension
206
+ */
207
+ private getMimeType;
208
+ }