pdfdancer-client-typescript 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.
Files changed (52) hide show
  1. package/.eslintrc.js +19 -0
  2. package/README.md +267 -0
  3. package/dist/__tests__/e2e/test-helpers.d.ts +32 -0
  4. package/dist/__tests__/e2e/test-helpers.d.ts.map +1 -0
  5. package/dist/__tests__/e2e/test-helpers.js +157 -0
  6. package/dist/__tests__/e2e/test-helpers.js.map +1 -0
  7. package/dist/client-v1.d.ts +169 -0
  8. package/dist/client-v1.d.ts.map +1 -0
  9. package/dist/client-v1.js +558 -0
  10. package/dist/client-v1.js.map +1 -0
  11. package/dist/exceptions.d.ts +43 -0
  12. package/dist/exceptions.d.ts.map +1 -0
  13. package/dist/exceptions.js +66 -0
  14. package/dist/exceptions.js.map +1 -0
  15. package/dist/index.d.ts +13 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +33 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/models.d.ts +216 -0
  20. package/dist/models.d.ts.map +1 -0
  21. package/dist/models.js +427 -0
  22. package/dist/models.js.map +1 -0
  23. package/dist/paragraph-builder.d.ts +67 -0
  24. package/dist/paragraph-builder.d.ts.map +1 -0
  25. package/dist/paragraph-builder.js +160 -0
  26. package/dist/paragraph-builder.js.map +1 -0
  27. package/example.ts +103 -0
  28. package/fixtures/DancingScript-Regular.ttf +0 -0
  29. package/fixtures/JetBrainsMono-Regular.ttf +0 -0
  30. package/fixtures/ObviouslyAwesome.pdf +0 -0
  31. package/fixtures/README.md +25 -0
  32. package/fixtures/basic-paths.pdf +0 -0
  33. package/fixtures/logo-80.png +0 -0
  34. package/fixtures/mixed-form-types.pdf +0 -0
  35. package/jest.config.js +26 -0
  36. package/package.json +38 -0
  37. package/scripts/release.js +91 -0
  38. package/scripts/test-release.js +59 -0
  39. package/src/__tests__/client-v1.test.ts +111 -0
  40. package/src/__tests__/e2e/form.test.ts +51 -0
  41. package/src/__tests__/e2e/image.test.ts +108 -0
  42. package/src/__tests__/e2e/line.test.ts +134 -0
  43. package/src/__tests__/e2e/page.test.ts +45 -0
  44. package/src/__tests__/e2e/paragraph.test.ts +210 -0
  45. package/src/__tests__/e2e/path.test.ts +72 -0
  46. package/src/__tests__/e2e/test-helpers.ts +132 -0
  47. package/src/client-v1.ts +673 -0
  48. package/src/exceptions.ts +67 -0
  49. package/src/index.ts +34 -0
  50. package/src/models.ts +476 -0
  51. package/src/paragraph-builder.ts +184 -0
  52. package/tsconfig.json +20 -0
@@ -0,0 +1,558 @@
1
+ "use strict";
2
+ /**
3
+ * PDFDancer TypeScript Client V1
4
+ *
5
+ * A TypeScript client that closely mirrors the Python Client class structure and functionality.
6
+ * Provides session-based PDF manipulation operations with strict validation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ClientV1 = void 0;
10
+ const exceptions_1 = require("./exceptions");
11
+ const models_1 = require("./models");
12
+ const paragraph_builder_1 = require("./paragraph-builder");
13
+ /**
14
+ * REST API client for interacting with the PDFDancer PDF manipulation service.
15
+ * This client provides a convenient TypeScript interface for performing PDF operations
16
+ * including session management, object searching, manipulation, and retrieval.
17
+ * Handles authentication, session lifecycle, and HTTP communication transparently.
18
+ *
19
+ * Mirrors the Python Client class functionality exactly.
20
+ */
21
+ class ClientV1 {
22
+ /**
23
+ * Creates a new client with PDF data.
24
+ * This constructor initializes the client, uploads the PDF data to create
25
+ * a new session, and prepares the client for PDF manipulation operations.
26
+ */
27
+ constructor(token, pdfData, baseUrl = "http://localhost:8080", readTimeout = 30000) {
28
+ // Strict validation like Python client
29
+ if (!token || !token.trim()) {
30
+ throw new exceptions_1.ValidationException("Authentication token cannot be null or empty");
31
+ }
32
+ this._token = token.trim();
33
+ this._baseUrl = baseUrl.replace(/\/$/, ''); // Remove trailing slash
34
+ this._readTimeout = readTimeout;
35
+ // Process PDF data with validation
36
+ this._pdfBytes = this._processPdfData(pdfData);
37
+ }
38
+ /**
39
+ * Initialize the client by creating a session.
40
+ * Must be called after constructor before using the client.
41
+ */
42
+ async init() {
43
+ this._sessionId = await this._createSession();
44
+ }
45
+ /**
46
+ * Process PDF data from various input types with strict validation.
47
+ * Equivalent to readFile() method in Python client.
48
+ */
49
+ _processPdfData(pdfData) {
50
+ if (!pdfData) {
51
+ throw new exceptions_1.ValidationException("PDF data cannot be null");
52
+ }
53
+ try {
54
+ if (pdfData instanceof Uint8Array) {
55
+ if (pdfData.length === 0) {
56
+ throw new exceptions_1.ValidationException("PDF data cannot be empty");
57
+ }
58
+ return pdfData;
59
+ }
60
+ else if (pdfData instanceof ArrayBuffer) {
61
+ const uint8Array = new Uint8Array(pdfData);
62
+ if (uint8Array.length === 0) {
63
+ throw new exceptions_1.ValidationException("PDF data cannot be empty");
64
+ }
65
+ return uint8Array;
66
+ }
67
+ else if (pdfData instanceof File) {
68
+ // Note: File reading will be handled asynchronously in the session creation
69
+ return new Uint8Array(); // Placeholder, will be replaced in _createSession
70
+ }
71
+ else {
72
+ throw new exceptions_1.ValidationException(`Unsupported PDF data type: ${typeof pdfData}`);
73
+ }
74
+ }
75
+ catch (error) {
76
+ if (error instanceof exceptions_1.ValidationException) {
77
+ throw error;
78
+ }
79
+ throw new exceptions_1.PdfDancerException(`Failed to process PDF data: ${error}`, error);
80
+ }
81
+ }
82
+ /**
83
+ * Extract meaningful error messages from API response.
84
+ * Parses JSON error responses with _embedded.errors structure.
85
+ */
86
+ async _extractErrorMessage(response) {
87
+ if (!response) {
88
+ return "Unknown error";
89
+ }
90
+ try {
91
+ const errorData = await response.json();
92
+ // Check for embedded errors structure
93
+ if (errorData._embedded?.errors) {
94
+ const errors = errorData._embedded.errors;
95
+ if (Array.isArray(errors)) {
96
+ const messages = errors
97
+ .filter(error => error.message)
98
+ .map(error => error.message);
99
+ if (messages.length > 0) {
100
+ return messages.join("; ");
101
+ }
102
+ }
103
+ }
104
+ // Check for top-level message
105
+ if (errorData.message) {
106
+ return errorData.message;
107
+ }
108
+ // Fallback to response text or status
109
+ return await response.text() || `HTTP ${response.status}`;
110
+ }
111
+ catch {
112
+ // If JSON parsing fails, return response text or status
113
+ try {
114
+ return await response.text() || `HTTP ${response.status}`;
115
+ }
116
+ catch {
117
+ return `HTTP ${response.status}`;
118
+ }
119
+ }
120
+ }
121
+ /**
122
+ * Creates a new PDF processing session by uploading the PDF data.
123
+ * Equivalent to createSession() method in Python client.
124
+ */
125
+ async _createSession() {
126
+ try {
127
+ const formData = new FormData();
128
+ // Handle File objects by reading their content
129
+ if (this._pdfBytes instanceof File) {
130
+ formData.append('pdf', this._pdfBytes, 'document.pdf');
131
+ }
132
+ else {
133
+ const blob = new Blob([this._pdfBytes.buffer], { type: 'application/pdf' });
134
+ formData.append('pdf', blob, 'document.pdf');
135
+ }
136
+ const response = await fetch(`${this._baseUrl}/session/create`, {
137
+ method: 'POST',
138
+ headers: {
139
+ 'Authorization': `Bearer ${this._token}`
140
+ },
141
+ body: formData,
142
+ signal: this._readTimeout > 0 ? AbortSignal.timeout(this._readTimeout) : undefined
143
+ });
144
+ if (!response.ok) {
145
+ const errorMessage = await this._extractErrorMessage(response);
146
+ throw new exceptions_1.HttpClientException(`Failed to create session: ${errorMessage}`, response);
147
+ }
148
+ const sessionId = (await response.text()).trim();
149
+ if (!sessionId) {
150
+ throw new exceptions_1.SessionException("Server returned empty session ID");
151
+ }
152
+ return sessionId;
153
+ }
154
+ catch (error) {
155
+ if (error instanceof exceptions_1.HttpClientException || error instanceof exceptions_1.SessionException) {
156
+ throw error;
157
+ }
158
+ const errorMessage = error instanceof Error ? error.message : String(error);
159
+ throw new exceptions_1.HttpClientException(`Failed to create session: ${errorMessage}`, undefined, error);
160
+ }
161
+ }
162
+ /**
163
+ * Make HTTP request with session headers and error handling.
164
+ * Equivalent to retrieve() method pattern in Python client.
165
+ */
166
+ async _makeRequest(method, path, data, params) {
167
+ const url = new URL(`${this._baseUrl}${path}`);
168
+ if (params) {
169
+ Object.entries(params).forEach(([key, value]) => {
170
+ url.searchParams.append(key, value);
171
+ });
172
+ }
173
+ const headers = {
174
+ 'Authorization': `Bearer ${this._token}`,
175
+ 'X-Session-Id': this._sessionId,
176
+ 'Content-Type': 'application/json'
177
+ };
178
+ try {
179
+ const response = await fetch(url.toString(), {
180
+ method,
181
+ headers,
182
+ body: data ? JSON.stringify(data) : undefined,
183
+ signal: this._readTimeout > 0 ? AbortSignal.timeout(this._readTimeout) : undefined
184
+ });
185
+ // Handle FontNotFoundException specifically like Python client
186
+ if (response.status === 404) {
187
+ try {
188
+ const errorData = await response.json();
189
+ if (errorData.error === 'FontNotFoundException') {
190
+ throw new exceptions_1.FontNotFoundException(errorData.message || 'Font not found');
191
+ }
192
+ }
193
+ catch (e) {
194
+ if (e instanceof exceptions_1.FontNotFoundException) {
195
+ throw e;
196
+ }
197
+ // Continue with normal error handling if JSON parsing fails
198
+ }
199
+ }
200
+ if (!response.ok) {
201
+ const errorMessage = await this._extractErrorMessage(response);
202
+ throw new exceptions_1.HttpClientException(`API request failed: ${errorMessage}`, response);
203
+ }
204
+ return response;
205
+ }
206
+ catch (error) {
207
+ if (error instanceof exceptions_1.FontNotFoundException || error instanceof exceptions_1.HttpClientException) {
208
+ throw error;
209
+ }
210
+ const errorMessage = error instanceof Error ? error.message : String(error);
211
+ throw new exceptions_1.HttpClientException(`API request failed: ${errorMessage}`, undefined, error);
212
+ }
213
+ }
214
+ // Search Operations - matching Python client exactly
215
+ /**
216
+ * Searches for PDF objects matching the specified criteria.
217
+ * This method provides flexible search capabilities across all PDF content,
218
+ * allowing filtering by object type and position constraints.
219
+ */
220
+ async find(objectType, position) {
221
+ const requestData = new models_1.FindRequest(objectType, position).toDict();
222
+ const response = await this._makeRequest('POST', '/pdf/find', requestData);
223
+ const objectsData = await response.json();
224
+ return objectsData.map((objData) => this._parseObjectRef(objData));
225
+ }
226
+ /**
227
+ * Searches for paragraph objects at the specified position.
228
+ * Equivalent to findParagraphs() in Python client.
229
+ */
230
+ async findParagraphs(position) {
231
+ return this.find(models_1.ObjectType.PARAGRAPH, position);
232
+ }
233
+ /**
234
+ * Searches for image objects at the specified position.
235
+ * Equivalent to findImages() in Python client.
236
+ */
237
+ async findImages(position) {
238
+ return this.find(models_1.ObjectType.IMAGE, position);
239
+ }
240
+ /**
241
+ * Searches for form field objects at the specified position.
242
+ * Equivalent to findForms() in Python client.
243
+ */
244
+ async findForms(position) {
245
+ return this.find(models_1.ObjectType.FORM, position);
246
+ }
247
+ /**
248
+ * Searches for vector path objects at the specified position.
249
+ * Equivalent to findPaths() in Python client.
250
+ */
251
+ async findPaths(position) {
252
+ return this.find(models_1.ObjectType.PATH, position);
253
+ }
254
+ /**
255
+ * Searches for text line objects at the specified position.
256
+ * Equivalent to findTextLines() in Python client.
257
+ */
258
+ async findTextLines(position) {
259
+ return this.find(models_1.ObjectType.TEXT_LINE, position);
260
+ }
261
+ // Page Operations
262
+ /**
263
+ * Retrieves references to all pages in the PDF document.
264
+ * Equivalent to getPages() in Python client.
265
+ */
266
+ async getPages() {
267
+ const response = await this._makeRequest('POST', '/pdf/page/find');
268
+ const pagesData = await response.json();
269
+ return pagesData.map((pageData) => this._parseObjectRef(pageData));
270
+ }
271
+ /**
272
+ * Retrieves a reference to a specific page by its page index.
273
+ * Equivalent to getPage() in Python client.
274
+ */
275
+ async getPage(pageIndex) {
276
+ if (pageIndex < 0) {
277
+ throw new exceptions_1.ValidationException(`Page index must be >= 0, got ${pageIndex}`);
278
+ }
279
+ const params = { pageIndex: pageIndex.toString() };
280
+ const response = await this._makeRequest('POST', '/pdf/page/find', undefined, params);
281
+ const pagesData = await response.json();
282
+ if (!pagesData || pagesData.length === 0) {
283
+ return null;
284
+ }
285
+ return this._parseObjectRef(pagesData[0]);
286
+ }
287
+ /**
288
+ * Deletes a page from the PDF document.
289
+ * Equivalent to deletePage() in Python client.
290
+ */
291
+ async deletePage(pageRef) {
292
+ if (!pageRef) {
293
+ throw new exceptions_1.ValidationException("Page reference cannot be null");
294
+ }
295
+ const requestData = pageRef.toDict();
296
+ const response = await this._makeRequest('DELETE', '/pdf/page/delete', requestData);
297
+ return await response.json();
298
+ }
299
+ // Manipulation Operations
300
+ /**
301
+ * Deletes the specified PDF object from the document.
302
+ * Equivalent to delete() in Python client.
303
+ */
304
+ async delete(objectRef) {
305
+ if (!objectRef) {
306
+ throw new exceptions_1.ValidationException("Object reference cannot be null");
307
+ }
308
+ const requestData = new models_1.DeleteRequest(objectRef).toDict();
309
+ const response = await this._makeRequest('DELETE', '/pdf/delete', requestData);
310
+ return await response.json();
311
+ }
312
+ /**
313
+ * Moves a PDF object to a new position within the document.
314
+ * Equivalent to move() in Python client.
315
+ */
316
+ async move(objectRef, position) {
317
+ if (!objectRef) {
318
+ throw new exceptions_1.ValidationException("Object reference cannot be null");
319
+ }
320
+ if (!position) {
321
+ throw new exceptions_1.ValidationException("Position cannot be null");
322
+ }
323
+ const requestData = new models_1.MoveRequest(objectRef, position).toDict();
324
+ const response = await this._makeRequest('PUT', '/pdf/move', requestData);
325
+ return await response.json();
326
+ }
327
+ // Add Operations
328
+ /**
329
+ * Adds an image to the PDF document.
330
+ * Equivalent to addImage() methods in Python client.
331
+ */
332
+ async addImage(image, position) {
333
+ if (!image) {
334
+ throw new exceptions_1.ValidationException("Image cannot be null");
335
+ }
336
+ if (position) {
337
+ image.setPosition(position);
338
+ }
339
+ if (!image.getPosition()) {
340
+ throw new exceptions_1.ValidationException("Image position is null");
341
+ }
342
+ return this._addObject(image);
343
+ }
344
+ /**
345
+ * Adds a paragraph to the PDF document.
346
+ * Equivalent to addParagraph() in Python client with validation.
347
+ */
348
+ async addParagraph(paragraph) {
349
+ if (!paragraph) {
350
+ throw new exceptions_1.ValidationException("Paragraph cannot be null");
351
+ }
352
+ if (!paragraph.getPosition()) {
353
+ throw new exceptions_1.ValidationException("Paragraph position is null");
354
+ }
355
+ if (paragraph.getPosition().pageIndex === undefined) {
356
+ throw new exceptions_1.ValidationException("Paragraph position page index is null");
357
+ }
358
+ if (paragraph.getPosition().pageIndex < 0) {
359
+ throw new exceptions_1.ValidationException("Paragraph position page index is less than 0");
360
+ }
361
+ return this._addObject(paragraph);
362
+ }
363
+ /**
364
+ * Internal method to add any PDF object.
365
+ * Equivalent to addObject() in Python client.
366
+ */
367
+ async _addObject(pdfObject) {
368
+ const requestData = new models_1.AddRequest(pdfObject).toDict();
369
+ const response = await this._makeRequest('POST', '/pdf/add', requestData);
370
+ return await response.json();
371
+ }
372
+ // Modify Operations
373
+ /**
374
+ * Modifies a paragraph object or its text content.
375
+ * Equivalent to modifyParagraph() methods in Python client.
376
+ */
377
+ async modifyParagraph(objectRef, newParagraph) {
378
+ if (!objectRef) {
379
+ throw new exceptions_1.ValidationException("Object reference cannot be null");
380
+ }
381
+ if (newParagraph === null || newParagraph === undefined) {
382
+ throw new exceptions_1.ValidationException("New paragraph cannot be null");
383
+ }
384
+ if (typeof newParagraph === 'string') {
385
+ // Text modification
386
+ const requestData = new models_1.ModifyTextRequest(objectRef, newParagraph).toDict();
387
+ const response = await this._makeRequest('PUT', '/pdf/text/paragraph', requestData);
388
+ return await response.json();
389
+ }
390
+ else {
391
+ // Object modification
392
+ const requestData = new models_1.ModifyRequest(objectRef, newParagraph).toDict();
393
+ const response = await this._makeRequest('PUT', '/pdf/modify', requestData);
394
+ return await response.json();
395
+ }
396
+ }
397
+ /**
398
+ * Modifies a text line object.
399
+ * Equivalent to modifyTextLine() in Python client.
400
+ */
401
+ async modifyTextLine(objectRef, newText) {
402
+ if (!objectRef) {
403
+ throw new exceptions_1.ValidationException("Object reference cannot be null");
404
+ }
405
+ if (newText === null || newText === undefined) {
406
+ throw new exceptions_1.ValidationException("New text cannot be null");
407
+ }
408
+ const requestData = new models_1.ModifyTextRequest(objectRef, newText).toDict();
409
+ const response = await this._makeRequest('PUT', '/pdf/text/line', requestData);
410
+ return await response.json();
411
+ }
412
+ // Font Operations
413
+ /**
414
+ * Finds available fonts matching the specified name and size.
415
+ * Equivalent to findFonts() in Python client.
416
+ */
417
+ async findFonts(fontName, fontSize) {
418
+ if (!fontName || !fontName.trim()) {
419
+ throw new exceptions_1.ValidationException("Font name cannot be null or empty");
420
+ }
421
+ if (fontSize <= 0) {
422
+ throw new exceptions_1.ValidationException(`Font size must be positive, got ${fontSize}`);
423
+ }
424
+ const params = { fontName: fontName.trim() };
425
+ const response = await this._makeRequest('GET', '/font/find', undefined, params);
426
+ const fontNames = await response.json();
427
+ return fontNames.map((name) => new models_1.Font(name, fontSize));
428
+ }
429
+ /**
430
+ * Registers a custom font for use in PDF operations.
431
+ * Equivalent to registerFont() in Python client.
432
+ */
433
+ async registerFont(ttfFile) {
434
+ if (!ttfFile) {
435
+ throw new exceptions_1.ValidationException("TTF file cannot be null");
436
+ }
437
+ try {
438
+ let fontData;
439
+ let filename;
440
+ if (ttfFile instanceof Uint8Array) {
441
+ if (ttfFile.length === 0) {
442
+ throw new exceptions_1.ValidationException("Font data cannot be empty");
443
+ }
444
+ fontData = ttfFile;
445
+ filename = 'font.ttf';
446
+ }
447
+ else if (ttfFile instanceof File) {
448
+ if (ttfFile.size === 0) {
449
+ throw new exceptions_1.ValidationException("Font file is empty");
450
+ }
451
+ fontData = new Uint8Array(await ttfFile.arrayBuffer());
452
+ filename = ttfFile.name;
453
+ }
454
+ else {
455
+ throw new exceptions_1.ValidationException(`Unsupported font file type: ${typeof ttfFile}`);
456
+ }
457
+ // Upload font file
458
+ const formData = new FormData();
459
+ const blob = new Blob([fontData.buffer], { type: 'font/ttf' });
460
+ formData.append('ttfFile', blob, filename);
461
+ const response = await fetch(`${this._baseUrl}/font/register`, {
462
+ method: 'POST',
463
+ headers: {
464
+ 'Authorization': `Bearer ${this._token}`,
465
+ 'X-Session-Id': this._sessionId
466
+ },
467
+ body: formData,
468
+ signal: AbortSignal.timeout(30000)
469
+ });
470
+ if (!response.ok) {
471
+ const errorMessage = await this._extractErrorMessage(response);
472
+ throw new exceptions_1.HttpClientException(`Font registration failed: ${errorMessage}`, response);
473
+ }
474
+ return (await response.text()).trim();
475
+ }
476
+ catch (error) {
477
+ if (error instanceof exceptions_1.ValidationException || error instanceof exceptions_1.HttpClientException) {
478
+ throw error;
479
+ }
480
+ const errorMessage = error instanceof Error ? error.message : String(error);
481
+ throw new exceptions_1.PdfDancerException(`Failed to read font file: ${errorMessage}`, error);
482
+ }
483
+ }
484
+ // Document Operations
485
+ /**
486
+ * Downloads the current state of the PDF document with all modifications applied.
487
+ * Equivalent to getPDFFile() in Python client.
488
+ */
489
+ async getPdfFile() {
490
+ const response = await this._makeRequest('GET', `/session/${this._sessionId}/pdf`);
491
+ return new Uint8Array(await response.arrayBuffer());
492
+ }
493
+ /**
494
+ * Saves the current PDF to a file (browser environment).
495
+ * Downloads the PDF in the browser.
496
+ */
497
+ async savePdf(filename = 'document.pdf') {
498
+ if (!filename) {
499
+ throw new exceptions_1.ValidationException("Filename cannot be null or empty");
500
+ }
501
+ try {
502
+ const pdfData = await this.getPdfFile();
503
+ // Create blob and download link
504
+ const blob = new Blob([pdfData.buffer], { type: 'application/pdf' });
505
+ const url = URL.createObjectURL(blob);
506
+ const link = document.createElement('a');
507
+ link.href = url;
508
+ link.download = filename;
509
+ document.body.appendChild(link);
510
+ link.click();
511
+ document.body.removeChild(link);
512
+ URL.revokeObjectURL(url);
513
+ }
514
+ catch (error) {
515
+ const errorMessage = error instanceof Error ? error.message : String(error);
516
+ throw new exceptions_1.PdfDancerException(`Failed to save PDF file: ${errorMessage}`, error);
517
+ }
518
+ }
519
+ // Utility Methods
520
+ /**
521
+ * Parse JSON object data into ObjectRef instance.
522
+ */
523
+ _parseObjectRef(objData) {
524
+ const positionData = objData.position || {};
525
+ const position = positionData ? this._parsePosition(positionData) : new models_1.Position();
526
+ const objectType = models_1.ObjectType[objData.type];
527
+ return new models_1.ObjectRef(objData.internalId, position, objectType);
528
+ }
529
+ /**
530
+ * Parse JSON position data into Position instance.
531
+ */
532
+ _parsePosition(posData) {
533
+ const position = new models_1.Position();
534
+ position.pageIndex = posData.pageIndex;
535
+ position.textStartsWith = posData.textStartsWith;
536
+ if (posData.shape) {
537
+ position.shape = models_1.ShapeType[posData.shape];
538
+ }
539
+ if (posData.mode) {
540
+ position.mode = models_1.PositionMode[posData.mode];
541
+ }
542
+ if (posData.boundingRect) {
543
+ const rectData = posData.boundingRect;
544
+ position.boundingRect = new models_1.BoundingRect(rectData.x, rectData.y, rectData.width, rectData.height);
545
+ }
546
+ return position;
547
+ }
548
+ // Builder Pattern Support
549
+ /**
550
+ * Creates a new ParagraphBuilder for fluent paragraph construction.
551
+ * Equivalent to paragraphBuilder() in Python client.
552
+ */
553
+ paragraphBuilder() {
554
+ return new paragraph_builder_1.ParagraphBuilder(this);
555
+ }
556
+ }
557
+ exports.ClientV1 = ClientV1;
558
+ //# sourceMappingURL=client-v1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-v1.js","sourceRoot":"","sources":["../src/client-v1.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAMsB;AACtB,qCAgBkB;AAClB,2DAAuD;AAEvD;;;;;;;GAOG;AACH,MAAa,QAAQ;IAOnB;;;;OAIG;IACH,YACE,KAAa,EACb,OAAwC,EACxC,UAAkB,uBAAuB,EACzC,cAAsB,KAAK;QAE3B,uCAAuC;QACvC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,gCAAmB,CAAC,8CAA8C,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;QACpE,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAEhC,mCAAmC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,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,IAAI,EAAE,CAAC;YACjB,QAAQ,CAAC,IAAI,GAAG,qBAAY,CAAC,OAAO,CAAC,IAAiC,CAAC,CAAC;QAC1E,CAAC;QAED,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;YACtC,QAAQ,CAAC,YAAY,GAAG,IAAI,qBAAY,CACtC,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,KAAK,EACd,QAAQ,CAAC,MAAM,CAChB,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,0BAA0B;IAE1B;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAI,oCAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAvnBD,4BAunBC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Exception classes for the PDFDancer TypeScript client.
3
+ * Mirrors the Python client exception hierarchy.
4
+ */
5
+ /**
6
+ * Base exception for all PDFDancer client errors.
7
+ * Equivalent to PdfDancerException in the Python client.
8
+ */
9
+ export declare class PdfDancerException extends Error {
10
+ readonly cause?: Error;
11
+ constructor(message: string, cause?: Error);
12
+ }
13
+ /**
14
+ * Exception raised when a required font is not found or available.
15
+ * Equivalent to FontNotFoundException in the Python client.
16
+ */
17
+ export declare class FontNotFoundException extends PdfDancerException {
18
+ constructor(message: string);
19
+ }
20
+ /**
21
+ * Exception raised for HTTP client errors during API communication.
22
+ * Wraps fetch exceptions and HTTP errors from the API.
23
+ */
24
+ export declare class HttpClientException extends PdfDancerException {
25
+ readonly response?: Response;
26
+ readonly statusCode?: number;
27
+ constructor(message: string, response?: Response, cause?: Error);
28
+ }
29
+ /**
30
+ * Exception raised for session-related errors.
31
+ * Occurs when session creation fails or session is invalid.
32
+ */
33
+ export declare class SessionException extends PdfDancerException {
34
+ constructor(message: string, cause?: Error);
35
+ }
36
+ /**
37
+ * Exception raised for input validation errors.
38
+ * Equivalent to ValidationException in the Python client.
39
+ */
40
+ export declare class ValidationException extends PdfDancerException {
41
+ constructor(message: string);
42
+ }
43
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,KAAK,CAAC,EAAE,KAAK,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAK3C;AAED;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,kBAAkB;gBAC/C,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,SAAgB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,KAAK;CAMhE;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,kBAAkB;gBAC1C,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI3C;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;gBAC7C,OAAO,EAAE,MAAM;CAI5B"}