@renamed-to/sdk 0.1.0-beta.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/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # @renamed/sdk
2
+
3
+ Official TypeScript/JavaScript SDK for the [renamed.to](https://www.renamed.to) API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @renamed/sdk
9
+ # or
10
+ pnpm add @renamed/sdk
11
+ # or
12
+ yarn add @renamed/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { RenamedClient } from "@renamed/sdk";
19
+
20
+ const client = new RenamedClient({
21
+ apiKey: "rt_your_api_key_here",
22
+ });
23
+
24
+ // Rename a file using AI
25
+ const result = await client.rename("invoice.pdf");
26
+ console.log(result.suggestedFilename);
27
+ // => "2025-01-15_AcmeCorp_INV-12345.pdf"
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### Rename Files
33
+
34
+ Rename files using AI-powered content analysis:
35
+
36
+ ```typescript
37
+ import { RenamedClient } from "@renamed/sdk";
38
+
39
+ const client = new RenamedClient({ apiKey: "rt_..." });
40
+
41
+ // From file path
42
+ const result = await client.rename("/path/to/document.pdf");
43
+
44
+ // From Buffer
45
+ const buffer = fs.readFileSync("document.pdf");
46
+ const result = await client.rename(buffer);
47
+
48
+ // With custom template
49
+ const result = await client.rename("invoice.pdf", {
50
+ template: "{date}_{vendor}_{type}",
51
+ });
52
+
53
+ console.log(result.suggestedFilename); // "2025-01-15_AcmeCorp_Invoice.pdf"
54
+ console.log(result.folderPath); // "2025/AcmeCorp/Invoices"
55
+ console.log(result.confidence); // 0.95
56
+ ```
57
+
58
+ ### Split PDFs
59
+
60
+ Split multi-page PDFs into individual documents:
61
+
62
+ ```typescript
63
+ // Start the split job
64
+ const job = await client.pdfSplit("multi-page.pdf", { mode: "auto" });
65
+
66
+ // Wait for completion with progress updates
67
+ const result = await job.wait((status) => {
68
+ console.log(`Progress: ${status.progress}%`);
69
+ });
70
+
71
+ // Download the split documents
72
+ for (const doc of result.documents) {
73
+ const buffer = await client.downloadFile(doc.downloadUrl);
74
+ fs.writeFileSync(doc.filename, buffer);
75
+ }
76
+ ```
77
+
78
+ Split modes:
79
+ - `auto` - AI detects document boundaries
80
+ - `pages` - Split every N pages
81
+ - `blank` - Split at blank pages
82
+
83
+ ### Extract Data
84
+
85
+ Extract structured data from documents:
86
+
87
+ ```typescript
88
+ const result = await client.extract("invoice.pdf", {
89
+ prompt: "Extract invoice number, date, vendor name, and total amount",
90
+ });
91
+
92
+ console.log(result.data);
93
+ // {
94
+ // invoiceNumber: "INV-12345",
95
+ // date: "2025-01-15",
96
+ // vendor: "Acme Corp",
97
+ // total: 1234.56
98
+ // }
99
+ ```
100
+
101
+ ### Check Credits
102
+
103
+ ```typescript
104
+ const user = await client.getUser();
105
+ console.log(`Credits remaining: ${user.credits}`);
106
+ ```
107
+
108
+ ## Configuration
109
+
110
+ ```typescript
111
+ const client = new RenamedClient({
112
+ // Required: Your API key (get one at https://www.renamed.to/settings)
113
+ apiKey: "rt_...",
114
+
115
+ // Optional: Custom base URL (default: https://www.renamed.to/api/v1)
116
+ baseUrl: "https://www.renamed.to/api/v1",
117
+
118
+ // Optional: Request timeout in ms (default: 30000)
119
+ timeout: 30000,
120
+
121
+ // Optional: Max retries for failed requests (default: 2)
122
+ maxRetries: 2,
123
+ });
124
+ ```
125
+
126
+ ## Error Handling
127
+
128
+ ```typescript
129
+ import {
130
+ RenamedClient,
131
+ AuthenticationError,
132
+ RateLimitError,
133
+ InsufficientCreditsError,
134
+ ValidationError,
135
+ } from "@renamed/sdk";
136
+
137
+ try {
138
+ const result = await client.rename("document.pdf");
139
+ } catch (error) {
140
+ if (error instanceof AuthenticationError) {
141
+ console.error("Invalid API key");
142
+ } else if (error instanceof RateLimitError) {
143
+ console.error(`Rate limited. Retry after ${error.retryAfter}s`);
144
+ } else if (error instanceof InsufficientCreditsError) {
145
+ console.error("Not enough credits");
146
+ } else if (error instanceof ValidationError) {
147
+ console.error("Invalid request:", error.message);
148
+ } else {
149
+ throw error;
150
+ }
151
+ }
152
+ ```
153
+
154
+ ## File Input Types
155
+
156
+ The SDK accepts multiple file input types:
157
+
158
+ ```typescript
159
+ // File path (string)
160
+ await client.rename("/path/to/file.pdf");
161
+
162
+ // Buffer
163
+ const buffer = fs.readFileSync("file.pdf");
164
+ await client.rename(buffer);
165
+
166
+ // Blob (browser)
167
+ const blob = new Blob([arrayBuffer], { type: "application/pdf" });
168
+ await client.rename(blob);
169
+
170
+ // File (browser)
171
+ const file = document.querySelector("input[type=file]").files[0];
172
+ await client.rename(file);
173
+ ```
174
+
175
+ ## Supported File Types
176
+
177
+ - PDF (`.pdf`)
178
+ - Images: JPEG (`.jpg`, `.jpeg`), PNG (`.png`), TIFF (`.tiff`, `.tif`)
179
+
180
+ ## Requirements
181
+
182
+ - Node.js 18+ (uses native `fetch` and `FormData`)
183
+ - Or modern browser with Fetch API
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,101 @@
1
+ import { RenamedClientOptions, RenameResult, RenameOptions, PdfSplitOptions, PdfSplitResult, JobStatusResponse, ExtractOptions, ExtractResult, User, FileInput } from "./types.js";
2
+ /**
3
+ * Async job handle for long-running operations like PDF split
4
+ */
5
+ export declare class AsyncJob<T> {
6
+ private readonly client;
7
+ private readonly statusUrl;
8
+ private pollInterval;
9
+ private maxAttempts;
10
+ constructor(client: RenamedClient, statusUrl: string, pollInterval?: number, maxAttempts?: number);
11
+ /**
12
+ * Get current job status
13
+ */
14
+ status(): Promise<JobStatusResponse>;
15
+ /**
16
+ * Wait for job completion, polling at regular intervals
17
+ */
18
+ wait(onProgress?: (status: JobStatusResponse) => void): Promise<T>;
19
+ }
20
+ /**
21
+ * renamed.to API client
22
+ */
23
+ export declare class RenamedClient {
24
+ private readonly apiKey;
25
+ private readonly baseUrl;
26
+ private readonly timeout;
27
+ private readonly maxRetries;
28
+ private readonly fetchImpl;
29
+ constructor(options: RenamedClientOptions);
30
+ /**
31
+ * Make an authenticated request to the API
32
+ */
33
+ request<T>(path: string, init?: RequestInit): Promise<T>;
34
+ /**
35
+ * Upload a file to the API
36
+ */
37
+ uploadFile<T>(path: string, file: FileInput, filename?: string, fieldName?: string, additionalFields?: Record<string, string>): Promise<T>;
38
+ /**
39
+ * Rename a file using AI
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const result = await client.rename("invoice.pdf");
44
+ * console.log(result.suggestedFilename); // "2025-01-15_AcmeCorp_INV-12345.pdf"
45
+ * ```
46
+ */
47
+ rename(file: FileInput, options?: RenameOptions): Promise<RenameResult>;
48
+ /**
49
+ * Split a PDF into multiple documents
50
+ *
51
+ * Returns an AsyncJob that can be polled for completion.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const job = await client.pdfSplit("multi-page.pdf", { mode: "auto" });
56
+ * const result = await job.wait((status) => {
57
+ * console.log(`Progress: ${status.progress}%`);
58
+ * });
59
+ * for (const doc of result.documents) {
60
+ * console.log(doc.filename, doc.downloadUrl);
61
+ * }
62
+ * ```
63
+ */
64
+ pdfSplit(file: FileInput, options?: PdfSplitOptions): Promise<AsyncJob<PdfSplitResult>>;
65
+ /**
66
+ * Extract structured data from a document
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const result = await client.extract("invoice.pdf", {
71
+ * prompt: "Extract invoice number, date, and total amount"
72
+ * });
73
+ * console.log(result.data);
74
+ * ```
75
+ */
76
+ extract(file: FileInput, options?: ExtractOptions): Promise<ExtractResult>;
77
+ /**
78
+ * Get current user profile and credits
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const user = await client.getUser();
83
+ * console.log(`Credits remaining: ${user.credits}`);
84
+ * ```
85
+ */
86
+ getUser(): Promise<User>;
87
+ /**
88
+ * Download a file from a URL (e.g., split document)
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * const result = await job.wait();
93
+ * for (const doc of result.documents) {
94
+ * const buffer = await client.downloadFile(doc.downloadUrl);
95
+ * fs.writeFileSync(doc.filename, buffer);
96
+ * }
97
+ * ```
98
+ */
99
+ downloadFile(url: string): Promise<Buffer>;
100
+ }
101
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,EACL,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,IAAI,EACJ,SAAS,EAEV,MAAM,YAAY,CAAC;AAiBpB;;GAEG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAKnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAL5B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAS;gBAGT,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,EAClC,YAAY,SAAgB,EAC5B,WAAW,SAAoB;IAMjC;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAI1C;;OAEG;IACG,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAwBzE;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;gBAExC,OAAO,EAAE,oBAAoB;IAYzC;;OAEG;IACG,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,CAAC,CAAC;IAgFlE;;OAEG;IACG,UAAU,CAAC,CAAC,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,EACf,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,SAAS,EAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,OAAO,CAAC,CAAC,CAAC;IA+Eb;;;;;;;;OAQG;IACG,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAgB7E;;;;;;;;;;;;;;;OAeG;IACG,QAAQ,CACZ,IAAI,EAAE,SAAS,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAqBpC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBhF;;;;;;;;OAQG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;;;;;;;;;OAWG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAkCjD"}
package/dist/client.js ADDED
@@ -0,0 +1,334 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { basename, extname } from "node:path";
3
+ import { AuthenticationError, NetworkError, TimeoutError, JobError, fromHttpStatus, } from "./errors.js";
4
+ import { MIME_TYPES, } from "./types.js";
5
+ const DEFAULT_BASE_URL = "https://www.renamed.to/api/v1";
6
+ const DEFAULT_TIMEOUT = 30_000;
7
+ const DEFAULT_MAX_RETRIES = 2;
8
+ const POLL_INTERVAL = 2_000;
9
+ const MAX_POLL_ATTEMPTS = 150; // 5 minutes at 2s intervals
10
+ function getMimeType(filename) {
11
+ const ext = extname(filename).toLowerCase();
12
+ return MIME_TYPES[ext] ?? "application/octet-stream";
13
+ }
14
+ function isAbsoluteUrl(path) {
15
+ return path.startsWith("http://") || path.startsWith("https://");
16
+ }
17
+ /**
18
+ * Async job handle for long-running operations like PDF split
19
+ */
20
+ export class AsyncJob {
21
+ client;
22
+ statusUrl;
23
+ pollInterval;
24
+ maxAttempts;
25
+ constructor(client, statusUrl, pollInterval = POLL_INTERVAL, maxAttempts = MAX_POLL_ATTEMPTS) {
26
+ this.client = client;
27
+ this.statusUrl = statusUrl;
28
+ this.pollInterval = pollInterval;
29
+ this.maxAttempts = maxAttempts;
30
+ }
31
+ /**
32
+ * Get current job status
33
+ */
34
+ async status() {
35
+ return this.client.request(this.statusUrl, { method: "GET" });
36
+ }
37
+ /**
38
+ * Wait for job completion, polling at regular intervals
39
+ */
40
+ async wait(onProgress) {
41
+ let attempts = 0;
42
+ while (attempts < this.maxAttempts) {
43
+ const status = await this.status();
44
+ if (onProgress) {
45
+ onProgress(status);
46
+ }
47
+ if (status.status === "completed" && status.result) {
48
+ return status.result;
49
+ }
50
+ if (status.status === "failed") {
51
+ throw new JobError(status.error ?? "Job failed", status.jobId);
52
+ }
53
+ attempts++;
54
+ await new Promise((resolve) => setTimeout(resolve, this.pollInterval));
55
+ }
56
+ throw new JobError("Job polling timeout exceeded");
57
+ }
58
+ }
59
+ /**
60
+ * renamed.to API client
61
+ */
62
+ export class RenamedClient {
63
+ apiKey;
64
+ baseUrl;
65
+ timeout;
66
+ maxRetries;
67
+ fetchImpl;
68
+ constructor(options) {
69
+ if (!options.apiKey) {
70
+ throw new AuthenticationError("API key is required");
71
+ }
72
+ this.apiKey = options.apiKey;
73
+ this.baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
74
+ this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
75
+ this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
76
+ this.fetchImpl = options.fetch ?? globalThis.fetch;
77
+ }
78
+ /**
79
+ * Make an authenticated request to the API
80
+ */
81
+ async request(path, init = {}) {
82
+ const url = isAbsoluteUrl(path)
83
+ ? path
84
+ : path.startsWith("/")
85
+ ? `${this.baseUrl}${path}`
86
+ : `${this.baseUrl}/${path}`;
87
+ const headers = new Headers(init.headers);
88
+ if (!headers.has("Content-Type") && init.body && typeof init.body === "string") {
89
+ headers.set("Content-Type", "application/json");
90
+ }
91
+ headers.set("Authorization", `Bearer ${this.apiKey}`);
92
+ const controller = new AbortController();
93
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
94
+ let lastError;
95
+ let attempts = 0;
96
+ while (attempts <= this.maxRetries) {
97
+ try {
98
+ const response = await this.fetchImpl(url, {
99
+ ...init,
100
+ headers,
101
+ signal: controller.signal,
102
+ });
103
+ clearTimeout(timeoutId);
104
+ const text = await response.text();
105
+ if (!response.ok) {
106
+ let payload = text;
107
+ try {
108
+ payload = text ? JSON.parse(text) : {};
109
+ }
110
+ catch {
111
+ // ignore parse error
112
+ }
113
+ throw fromHttpStatus(response.status, response.statusText, payload);
114
+ }
115
+ return (text ? JSON.parse(text) : {});
116
+ }
117
+ catch (error) {
118
+ clearTimeout(timeoutId);
119
+ if (error instanceof Error && error.name === "AbortError") {
120
+ throw new TimeoutError();
121
+ }
122
+ if (error instanceof TypeError && error.message.includes("fetch")) {
123
+ throw new NetworkError();
124
+ }
125
+ lastError = error;
126
+ // Don't retry client errors (4xx)
127
+ if (error instanceof Error &&
128
+ "statusCode" in error &&
129
+ typeof error.statusCode === "number") {
130
+ const statusCode = error.statusCode;
131
+ if (statusCode >= 400 && statusCode < 500) {
132
+ throw error;
133
+ }
134
+ }
135
+ attempts++;
136
+ if (attempts <= this.maxRetries) {
137
+ // Exponential backoff
138
+ await new Promise((resolve) => setTimeout(resolve, Math.pow(2, attempts) * 100));
139
+ }
140
+ }
141
+ }
142
+ throw lastError ?? new NetworkError();
143
+ }
144
+ /**
145
+ * Upload a file to the API
146
+ */
147
+ async uploadFile(path, file, filename, fieldName = "file", additionalFields) {
148
+ const formData = new FormData();
149
+ let blob;
150
+ let resolvedFilename;
151
+ if (typeof file === "string") {
152
+ // File path - convert to Uint8Array for Blob compatibility
153
+ const buffer = readFileSync(file);
154
+ resolvedFilename = filename ?? basename(file);
155
+ blob = new Blob([new Uint8Array(buffer)], { type: getMimeType(resolvedFilename) });
156
+ }
157
+ else if (Buffer.isBuffer(file)) {
158
+ // Buffer - convert to Uint8Array for Blob compatibility
159
+ resolvedFilename = filename ?? "file";
160
+ blob = new Blob([new Uint8Array(file)], { type: getMimeType(resolvedFilename) });
161
+ }
162
+ else if (file instanceof Blob) {
163
+ // Blob or File
164
+ blob = file;
165
+ resolvedFilename = filename ?? (file instanceof File ? file.name : "file");
166
+ }
167
+ else {
168
+ throw new Error("Invalid file input");
169
+ }
170
+ formData.append(fieldName, blob, resolvedFilename);
171
+ if (additionalFields) {
172
+ for (const [key, value] of Object.entries(additionalFields)) {
173
+ formData.append(key, value);
174
+ }
175
+ }
176
+ const url = isAbsoluteUrl(path)
177
+ ? path
178
+ : path.startsWith("/")
179
+ ? `${this.baseUrl}${path}`
180
+ : `${this.baseUrl}/${path}`;
181
+ const controller = new AbortController();
182
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
183
+ try {
184
+ const response = await this.fetchImpl(url, {
185
+ method: "POST",
186
+ headers: {
187
+ Authorization: `Bearer ${this.apiKey}`,
188
+ },
189
+ body: formData,
190
+ signal: controller.signal,
191
+ });
192
+ clearTimeout(timeoutId);
193
+ const text = await response.text();
194
+ if (!response.ok) {
195
+ let payload = text;
196
+ try {
197
+ payload = text ? JSON.parse(text) : {};
198
+ }
199
+ catch {
200
+ // ignore parse error
201
+ }
202
+ throw fromHttpStatus(response.status, response.statusText, payload);
203
+ }
204
+ return (text ? JSON.parse(text) : {});
205
+ }
206
+ catch (error) {
207
+ clearTimeout(timeoutId);
208
+ if (error instanceof Error && error.name === "AbortError") {
209
+ throw new TimeoutError();
210
+ }
211
+ if (error instanceof TypeError && error.message.includes("fetch")) {
212
+ throw new NetworkError();
213
+ }
214
+ throw error;
215
+ }
216
+ }
217
+ /**
218
+ * Rename a file using AI
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * const result = await client.rename("invoice.pdf");
223
+ * console.log(result.suggestedFilename); // "2025-01-15_AcmeCorp_INV-12345.pdf"
224
+ * ```
225
+ */
226
+ async rename(file, options) {
227
+ const additionalFields = {};
228
+ if (options?.template) {
229
+ additionalFields.template = options.template;
230
+ }
231
+ return this.uploadFile("/rename", file, undefined, "file", Object.keys(additionalFields).length > 0 ? additionalFields : undefined);
232
+ }
233
+ /**
234
+ * Split a PDF into multiple documents
235
+ *
236
+ * Returns an AsyncJob that can be polled for completion.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * const job = await client.pdfSplit("multi-page.pdf", { mode: "auto" });
241
+ * const result = await job.wait((status) => {
242
+ * console.log(`Progress: ${status.progress}%`);
243
+ * });
244
+ * for (const doc of result.documents) {
245
+ * console.log(doc.filename, doc.downloadUrl);
246
+ * }
247
+ * ```
248
+ */
249
+ async pdfSplit(file, options) {
250
+ const additionalFields = {};
251
+ if (options?.mode) {
252
+ additionalFields.mode = options.mode;
253
+ }
254
+ if (options?.pagesPerSplit !== undefined) {
255
+ additionalFields.pagesPerSplit = String(options.pagesPerSplit);
256
+ }
257
+ const response = await this.uploadFile("/pdf-split", file, undefined, "file", Object.keys(additionalFields).length > 0 ? additionalFields : undefined);
258
+ return new AsyncJob(this, response.statusUrl);
259
+ }
260
+ /**
261
+ * Extract structured data from a document
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * const result = await client.extract("invoice.pdf", {
266
+ * prompt: "Extract invoice number, date, and total amount"
267
+ * });
268
+ * console.log(result.data);
269
+ * ```
270
+ */
271
+ async extract(file, options) {
272
+ const additionalFields = {};
273
+ if (options?.schema) {
274
+ additionalFields.schema = JSON.stringify(options.schema);
275
+ }
276
+ if (options?.prompt) {
277
+ additionalFields.prompt = options.prompt;
278
+ }
279
+ return this.uploadFile("/extract", file, undefined, "file", Object.keys(additionalFields).length > 0 ? additionalFields : undefined);
280
+ }
281
+ /**
282
+ * Get current user profile and credits
283
+ *
284
+ * @example
285
+ * ```ts
286
+ * const user = await client.getUser();
287
+ * console.log(`Credits remaining: ${user.credits}`);
288
+ * ```
289
+ */
290
+ async getUser() {
291
+ return this.request("/user", { method: "GET" });
292
+ }
293
+ /**
294
+ * Download a file from a URL (e.g., split document)
295
+ *
296
+ * @example
297
+ * ```ts
298
+ * const result = await job.wait();
299
+ * for (const doc of result.documents) {
300
+ * const buffer = await client.downloadFile(doc.downloadUrl);
301
+ * fs.writeFileSync(doc.filename, buffer);
302
+ * }
303
+ * ```
304
+ */
305
+ async downloadFile(url) {
306
+ const controller = new AbortController();
307
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
308
+ try {
309
+ const response = await this.fetchImpl(url, {
310
+ headers: {
311
+ Authorization: `Bearer ${this.apiKey}`,
312
+ },
313
+ signal: controller.signal,
314
+ });
315
+ clearTimeout(timeoutId);
316
+ if (!response.ok) {
317
+ throw fromHttpStatus(response.status, response.statusText);
318
+ }
319
+ const arrayBuffer = await response.arrayBuffer();
320
+ return Buffer.from(arrayBuffer);
321
+ }
322
+ catch (error) {
323
+ clearTimeout(timeoutId);
324
+ if (error instanceof Error && error.name === "AbortError") {
325
+ throw new TimeoutError();
326
+ }
327
+ if (error instanceof TypeError && error.message.includes("fetch")) {
328
+ throw new NetworkError();
329
+ }
330
+ throw error;
331
+ }
332
+ }
333
+ }
334
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAWL,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,MAAM,gBAAgB,GAAG,+BA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AS,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClE,MAAM,IAAI,YAAY,EAAE,CAAC;YAC3B,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Base error class for all renamed.to SDK errors
3
+ */
4
+ export declare class RenamedError extends Error {
5
+ readonly code: string;
6
+ readonly statusCode?: number | undefined;
7
+ readonly details?: unknown | undefined;
8
+ constructor(message: string, code: string, statusCode?: number | undefined, details?: unknown | undefined);
9
+ }
10
+ /**
11
+ * Authentication error - invalid or missing API key
12
+ */
13
+ export declare class AuthenticationError extends RenamedError {
14
+ constructor(message?: string);
15
+ }
16
+ /**
17
+ * Rate limit exceeded
18
+ */
19
+ export declare class RateLimitError extends RenamedError {
20
+ readonly retryAfter?: number | undefined;
21
+ constructor(message?: string, retryAfter?: number | undefined);
22
+ }
23
+ /**
24
+ * Validation error - invalid request parameters
25
+ */
26
+ export declare class ValidationError extends RenamedError {
27
+ constructor(message: string, details?: unknown);
28
+ }
29
+ /**
30
+ * Network error - connection failed
31
+ */
32
+ export declare class NetworkError extends RenamedError {
33
+ constructor(message?: string);
34
+ }
35
+ /**
36
+ * Timeout error - request took too long
37
+ */
38
+ export declare class TimeoutError extends RenamedError {
39
+ constructor(message?: string);
40
+ }
41
+ /**
42
+ * Insufficient credits error
43
+ */
44
+ export declare class InsufficientCreditsError extends RenamedError {
45
+ constructor(message?: string);
46
+ }
47
+ /**
48
+ * Job error - async job failed
49
+ */
50
+ export declare class JobError extends RenamedError {
51
+ readonly jobId?: string | undefined;
52
+ constructor(message: string, jobId?: string | undefined);
53
+ }
54
+ /**
55
+ * Create appropriate error from HTTP status code
56
+ */
57
+ export declare function fromHttpStatus(status: number, statusText: string, payload?: unknown): RenamedError;
58
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,MAAM;aACZ,UAAU,CAAC,EAAE,MAAM;aACnB,OAAO,CAAC,EAAE,OAAO;gBAHjC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,OAAO,CAAC,EAAE,OAAO,YAAA;CAMpC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,OAAO,SAA+B;CAInD;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,YAAY;aAG5B,UAAU,CAAC,EAAE,MAAM;gBADnC,OAAO,SAAwB,EACf,UAAU,CAAC,EAAE,MAAM,YAAA;CAKtC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAI/C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,SAA2B;CAI/C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,SAAsB;CAI1C;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,YAAY;gBAC5C,OAAO,SAAyB;CAI7C;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,YAAY;aACK,KAAK,CAAC,EAAE,MAAM;gBAA/C,OAAO,EAAE,MAAM,EAAkB,KAAK,CAAC,EAAE,MAAM,YAAA;CAI5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,YAAY,CAwBd"}
package/dist/errors.js ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Base error class for all renamed.to SDK errors
3
+ */
4
+ export class RenamedError extends Error {
5
+ code;
6
+ statusCode;
7
+ details;
8
+ constructor(message, code, statusCode, details) {
9
+ super(message);
10
+ this.code = code;
11
+ this.statusCode = statusCode;
12
+ this.details = details;
13
+ this.name = "RenamedError";
14
+ Object.setPrototypeOf(this, new.target.prototype);
15
+ }
16
+ }
17
+ /**
18
+ * Authentication error - invalid or missing API key
19
+ */
20
+ export class AuthenticationError extends RenamedError {
21
+ constructor(message = "Invalid or missing API key") {
22
+ super(message, "AUTHENTICATION_ERROR", 401);
23
+ this.name = "AuthenticationError";
24
+ }
25
+ }
26
+ /**
27
+ * Rate limit exceeded
28
+ */
29
+ export class RateLimitError extends RenamedError {
30
+ retryAfter;
31
+ constructor(message = "Rate limit exceeded", retryAfter) {
32
+ super(message, "RATE_LIMIT_ERROR", 429);
33
+ this.retryAfter = retryAfter;
34
+ this.name = "RateLimitError";
35
+ }
36
+ }
37
+ /**
38
+ * Validation error - invalid request parameters
39
+ */
40
+ export class ValidationError extends RenamedError {
41
+ constructor(message, details) {
42
+ super(message, "VALIDATION_ERROR", 400, details);
43
+ this.name = "ValidationError";
44
+ }
45
+ }
46
+ /**
47
+ * Network error - connection failed
48
+ */
49
+ export class NetworkError extends RenamedError {
50
+ constructor(message = "Network request failed") {
51
+ super(message, "NETWORK_ERROR");
52
+ this.name = "NetworkError";
53
+ }
54
+ }
55
+ /**
56
+ * Timeout error - request took too long
57
+ */
58
+ export class TimeoutError extends RenamedError {
59
+ constructor(message = "Request timed out") {
60
+ super(message, "TIMEOUT_ERROR");
61
+ this.name = "TimeoutError";
62
+ }
63
+ }
64
+ /**
65
+ * Insufficient credits error
66
+ */
67
+ export class InsufficientCreditsError extends RenamedError {
68
+ constructor(message = "Insufficient credits") {
69
+ super(message, "INSUFFICIENT_CREDITS", 402);
70
+ this.name = "InsufficientCreditsError";
71
+ }
72
+ }
73
+ /**
74
+ * Job error - async job failed
75
+ */
76
+ export class JobError extends RenamedError {
77
+ jobId;
78
+ constructor(message, jobId) {
79
+ super(message, "JOB_ERROR");
80
+ this.jobId = jobId;
81
+ this.name = "JobError";
82
+ }
83
+ }
84
+ /**
85
+ * Create appropriate error from HTTP status code
86
+ */
87
+ export function fromHttpStatus(status, statusText, payload) {
88
+ const message = typeof payload === "object" && payload !== null && "error" in payload
89
+ ? String(payload.error)
90
+ : statusText;
91
+ switch (status) {
92
+ case 401:
93
+ return new AuthenticationError(message);
94
+ case 402:
95
+ return new InsufficientCreditsError(message);
96
+ case 400:
97
+ case 422:
98
+ return new ValidationError(message, payload);
99
+ case 429: {
100
+ const retryAfter = typeof payload === "object" && payload !== null && "retryAfter" in payload
101
+ ? Number(payload.retryAfter)
102
+ : undefined;
103
+ return new RateLimitError(message, retryAfter);
104
+ }
105
+ default:
106
+ return new RenamedError(message, "API_ERROR", status, payload);
107
+ }
108
+ }
109
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGnB;IACA;IACA;IAJlB,YACE,OAAe,EACC,IAAY,EACZ,UAAmB,EACnB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAS;QACnB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IACnD,YAAY,OAAO,GAAG,4BAA4B;QAChD,KAAK,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IAG5B;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ACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,UAAkB,EAClB,OAAiB;IAEjB,MAAM,OAAO,GACX,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,IAAI,OAAO;QACnE,CAAC,CAAC,MAAM,CAAE,OAA8B,CAAC,KAAK,CAAC;QAC/C,CAAC,CAAC,UAAU,CAAC;IAEjB,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG;YACN,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC1C,KAAK,GAAG;YACN,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,MAAM,UAAU,GACd,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,YAAY,IAAI,OAAO;gBACxE,CAAC,CAAC,MAAM,CAAE,OAAmC,CAAC,UAAU,CAAC;gBACzD,CAAC,CAAC,SAAS,CAAC;YAChB,OAAO,IAAI,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjD,CAAC;QACD;YACE,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { RenamedClient, AsyncJob } from "./client.js";
2
+ export type { RenamedClientOptions, RenameResult, RenameOptions, PdfSplitOptions, PdfSplitResult, JobStatusResponse, JobStatus, SplitDocument, ExtractOptions, ExtractResult, User, FileInput, } from "./types.js";
3
+ export { RenamedError, AuthenticationError, RateLimitError, ValidationError, NetworkError, TimeoutError, InsufficientCreditsError, JobError, } from "./errors.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGtD,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,IAAI,EACJ,SAAS,GACV,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,QAAQ,GACT,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Main client
2
+ export { RenamedClient, AsyncJob } from "./client.js";
3
+ // Errors
4
+ export { RenamedError, AuthenticationError, RateLimitError, ValidationError, NetworkError, TimeoutError, InsufficientCreditsError, JobError, } from "./errors.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkBtD,SAAS;AACT,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,QAAQ,GACT,MAAM,aAAa,CAAC"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Configuration options for the Renamed client
3
+ */
4
+ export interface RenamedClientOptions {
5
+ /**
6
+ * API key for authentication (starts with rt_)
7
+ */
8
+ apiKey: string;
9
+ /**
10
+ * Base URL for the API (default: https://www.renamed.to/api/v1)
11
+ */
12
+ baseUrl?: string;
13
+ /**
14
+ * Request timeout in milliseconds (default: 30000)
15
+ */
16
+ timeout?: number;
17
+ /**
18
+ * Maximum number of retries for failed requests (default: 2)
19
+ */
20
+ maxRetries?: number;
21
+ /**
22
+ * Custom fetch implementation (for testing or special environments)
23
+ */
24
+ fetch?: typeof globalThis.fetch;
25
+ }
26
+ /**
27
+ * Result of a rename operation
28
+ */
29
+ export interface RenameResult {
30
+ /**
31
+ * Original filename that was uploaded
32
+ */
33
+ originalFilename: string;
34
+ /**
35
+ * AI-suggested new filename
36
+ */
37
+ suggestedFilename: string;
38
+ /**
39
+ * Suggested folder path for organization
40
+ */
41
+ folderPath?: string;
42
+ /**
43
+ * Confidence score (0-1) of the suggestion
44
+ */
45
+ confidence?: number;
46
+ }
47
+ /**
48
+ * Options for rename operation
49
+ */
50
+ export interface RenameOptions {
51
+ /**
52
+ * Custom template for filename generation
53
+ */
54
+ template?: string;
55
+ }
56
+ /**
57
+ * Options for PDF split operation
58
+ */
59
+ export interface PdfSplitOptions {
60
+ /**
61
+ * Split mode: 'auto' (AI-detected), 'pages' (every N pages), 'blank' (at blank pages)
62
+ */
63
+ mode?: "auto" | "pages" | "blank";
64
+ /**
65
+ * Number of pages per split (for 'pages' mode)
66
+ */
67
+ pagesPerSplit?: number;
68
+ }
69
+ /**
70
+ * Status of an async job
71
+ */
72
+ export type JobStatus = "pending" | "processing" | "completed" | "failed";
73
+ /**
74
+ * Response from job status endpoint
75
+ */
76
+ export interface JobStatusResponse {
77
+ /**
78
+ * Unique job identifier
79
+ */
80
+ jobId: string;
81
+ /**
82
+ * Current job status
83
+ */
84
+ status: JobStatus;
85
+ /**
86
+ * Progress percentage (0-100)
87
+ */
88
+ progress?: number;
89
+ /**
90
+ * Error message if job failed
91
+ */
92
+ error?: string;
93
+ /**
94
+ * Result data when job is completed
95
+ */
96
+ result?: PdfSplitResult;
97
+ }
98
+ /**
99
+ * A single document from PDF split
100
+ */
101
+ export interface SplitDocument {
102
+ /**
103
+ * Document index (0-based)
104
+ */
105
+ index: number;
106
+ /**
107
+ * Suggested filename for this document
108
+ */
109
+ filename: string;
110
+ /**
111
+ * Page range included in this document
112
+ */
113
+ pages: string;
114
+ /**
115
+ * URL to download this document
116
+ */
117
+ downloadUrl: string;
118
+ /**
119
+ * Size in bytes
120
+ */
121
+ size: number;
122
+ }
123
+ /**
124
+ * Result of PDF split operation
125
+ */
126
+ export interface PdfSplitResult {
127
+ /**
128
+ * Original filename
129
+ */
130
+ originalFilename: string;
131
+ /**
132
+ * Split documents
133
+ */
134
+ documents: SplitDocument[];
135
+ /**
136
+ * Total number of pages in original document
137
+ */
138
+ totalPages: number;
139
+ }
140
+ /**
141
+ * Extract operation options
142
+ */
143
+ export interface ExtractOptions {
144
+ /**
145
+ * Schema defining what to extract
146
+ */
147
+ schema?: Record<string, unknown>;
148
+ /**
149
+ * Prompt describing what to extract
150
+ */
151
+ prompt?: string;
152
+ }
153
+ /**
154
+ * Result of extract operation
155
+ */
156
+ export interface ExtractResult {
157
+ /**
158
+ * Extracted data matching the schema
159
+ */
160
+ data: Record<string, unknown>;
161
+ /**
162
+ * Confidence score (0-1)
163
+ */
164
+ confidence: number;
165
+ }
166
+ /**
167
+ * User profile information
168
+ */
169
+ export interface User {
170
+ /**
171
+ * User ID
172
+ */
173
+ id: string;
174
+ /**
175
+ * Email address
176
+ */
177
+ email: string;
178
+ /**
179
+ * Display name
180
+ */
181
+ name?: string;
182
+ /**
183
+ * Available credits
184
+ */
185
+ credits?: number;
186
+ /**
187
+ * Team information (if applicable)
188
+ */
189
+ team?: {
190
+ id: string;
191
+ name: string;
192
+ };
193
+ }
194
+ /**
195
+ * File input - can be a path, Buffer, Blob, or File
196
+ */
197
+ export type FileInput = string | Buffer | Blob | File;
198
+ /**
199
+ * MIME types for supported file formats
200
+ */
201
+ export declare const MIME_TYPES: Record<string, string>;
202
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,MAAM,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AK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,SAAS,EAAE,aAAa,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO7C,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * MIME types for supported file formats
3
+ */
4
+ export const MIME_TYPES = {
5
+ ".pdf": "application/pdf",
6
+ ".jpg": "image/jpeg",
7
+ ".jpeg": "image/jpeg",
8
+ ".png": "image/png",
9
+ ".tiff": "image/tiff",
10
+ ".tif": "image/tiff",
11
+ };
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyOA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAA2B;IAChD,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,YAAY;CACrB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@renamed-to/sdk",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "Official TypeScript/JavaScript SDK for renamed.to API",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "typecheck": "tsc --noEmit",
27
+ "clean": "rm -rf dist"
28
+ },
29
+ "keywords": [
30
+ "renamed",
31
+ "pdf",
32
+ "rename",
33
+ "ocr",
34
+ "ai",
35
+ "document",
36
+ "sdk"
37
+ ],
38
+ "author": "renamed.to",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/renamed-to/renamed-sdk.git",
43
+ "directory": "sdks/typescript"
44
+ },
45
+ "homepage": "https://www.renamed.to/docs/api-docs",
46
+ "bugs": {
47
+ "url": "https://github.com/renamed-to/renamed-sdk/issues"
48
+ },
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20.0.0",
54
+ "typescript": "^5.3.0",
55
+ "vitest": "^2.0.0"
56
+ }
57
+ }