docstron 1.0.1 → 1.0.3

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 CHANGED
@@ -78,7 +78,7 @@ Create a new PDF template.
78
78
  - `is_active` (boolean, optional) - Active status (default: `true`)
79
79
  - `extra_css` (string, optional) - Additional CSS rules for PDF styling
80
80
 
81
- **Returns:** Promise<Template>
81
+ **Returns:** Promise
82
82
 
83
83
  **Example:**
84
84
 
@@ -108,7 +108,7 @@ Retrieve a specific template by ID.
108
108
 
109
109
  - `templateId` (string, required) - The template ID
110
110
 
111
- **Returns:** Promise<Template>
111
+ **Returns:** Promise
112
112
 
113
113
  **Example:**
114
114
 
@@ -126,7 +126,7 @@ Update an existing template.
126
126
  - `templateId` (string, required) - The template ID
127
127
  - `params` (object, required) - Fields to update
128
128
 
129
- **Returns:** Promise<Template>
129
+ **Returns:** Promise
130
130
 
131
131
  **Example:**
132
132
 
@@ -145,7 +145,7 @@ Delete a template.
145
145
 
146
146
  - `templateId` (string, required) - The template ID
147
147
 
148
- **Returns:** Promise<Object>
148
+ **Returns:** Promise
149
149
 
150
150
  **Example:**
151
151
 
@@ -162,7 +162,7 @@ List all templates for an application.
162
162
 
163
163
  - `applicationId` (string, required) - The application ID
164
164
 
165
- **Returns:** Promise<Array<Template>>
165
+ **Returns:** Promise
166
166
 
167
167
  **Example:**
168
168
 
@@ -274,7 +274,7 @@ Update document data.
274
274
 
275
275
  Delete a document.
276
276
 
277
- ### Applications (v0.3.0+)
277
+ ### Applications
278
278
 
279
279
  #### `applications.create(params)`
280
280
 
@@ -286,7 +286,7 @@ Create a new application to organize your templates and documents.
286
286
  - `params.description` (string, optional) - Application description
287
287
  - `params.is_active` (boolean, optional) - Active status (default: `true`)
288
288
 
289
- **Returns:** Promise<Application>
289
+ **Returns:** Promise
290
290
 
291
291
  **Example:**
292
292
 
@@ -357,28 +357,6 @@ await client.applications.delete("app-xxx");
357
357
  console.log("Application deleted");
358
358
  ```
359
359
 
360
- #### `applications.listActive()`
361
-
362
- Get only active applications.
363
-
364
- **Example:**
365
-
366
- ```javascript
367
- const activeApps = await client.applications.listActive();
368
- console.log(`Active: ${activeApps.length}`);
369
- ```
370
-
371
- #### `applications.listInactive()`
372
-
373
- Get only inactive applications.
374
-
375
- **Example:**
376
-
377
- ```javascript
378
- const inactiveApps = await client.applications.listInactive();
379
- console.log(`Inactive: ${inactiveApps.length}`);
380
- ```
381
-
382
360
  ## Response Types
383
361
 
384
362
  When generating documents, you can choose the response format:
@@ -423,10 +401,9 @@ Use double curly braces to create dynamic placeholders:
423
401
  <p>Date: {{order_date}}</p>
424
402
  ```
425
403
 
426
- When generating PDFs (coming in v0.2.0), you'll pass data to fill these placeholders:
404
+ When generating PDFs, you'll pass data to fill these placeholders:
427
405
 
428
406
  ```javascript
429
- // Coming in v0.2.0
430
407
  {
431
408
  customer_name: "John Doe",
432
409
  order_number: "12345",
@@ -467,116 +444,23 @@ try {
467
444
  }
468
445
  ```
469
446
 
470
- ## Examples
471
-
472
- ### Complete Workflow
473
-
474
- ```javascript
475
- const Docstron = require("docstron");
476
- const client = new Docstron("your-api-key");
477
-
478
- // 1. Create template
479
- const template = await client.templates.create({
480
- application_id: "app-xxx",
481
- name: "Invoice",
482
- content: "<h1>Invoice #{{invoice_no}}</h1>",
483
- });
484
-
485
- // 2. Generate PDF
486
- const pdf = await client.documents.generate(template.template_id, {
487
- data: { invoice_no: "12345" },
488
- response_type: "document_id",
489
- });
490
-
491
- // 3. Download PDF
492
- await client.documents.download(pdf.document_id, "./invoice.pdf");
493
-
494
- console.log("PDF saved to invoice.pdf");
495
- ```
496
-
497
- ### Quick Generation
498
-
499
- ```javascript
500
- // Generate without creating a template
501
- const doc = await client.documents.quickGenerate({
502
- html: "<h1>Receipt</h1><p>Total: {{total}}</p>",
503
- data: { total: "$99.00" },
504
- response_type: "document_id",
505
- });
506
-
507
- console.log("PDF URL:", doc.download_url);
508
- ```
509
-
510
- ### Password Protection
511
-
512
- ```javascript
513
- const doc = await client.documents.generate(templateId, {
514
- data: {
515
- /* your data */
516
- },
517
- password: "SecurePass123!",
518
- response_type: "document_id",
519
- });
520
- ```
521
-
522
- ### Basic Usage
523
-
524
- ```bash
525
- DOCSTRON_API_KEY=your-key npm run example
526
- ```
527
-
528
- ### Create Invoice Template
529
-
530
- ```bash
531
- DOCSTRON_API_KEY=your-key npm run example:invoice
532
- ```
533
-
534
- ## Development
535
-
536
- ```bash
537
- # Install dependencies
538
- npm install
539
-
540
- # Run tests (basic validation tests)
541
- npm test
542
-
543
- # Run examples
544
- npm run example
545
- npm run example:invoice
546
- ```
547
-
548
447
  ## Requirements
549
448
 
550
449
  - Node.js >= 14.0.0
551
450
  - A Docstron account and API key
552
451
 
553
- ## Roadmap
554
-
555
- ### v0.2.0 (Coming Soon)
556
-
557
- - 📄 Document generation from templates
558
- - 🔄 Asynchronous PDF processing
559
- - 📥 Multiple output formats (URL, base64, binary)
560
-
561
- ### v0.3.0 (Planned)
562
-
563
- - 🏢 Application management
564
- - 📊 Usage statistics
565
- - 🔐 Advanced authentication options
566
-
567
- ### v1.0.0 (Future)
568
-
569
- - 🎯 Full API coverage
570
- - ✅ Comprehensive test suite
571
- - 📚 Extended documentation
572
- - 🔌 Webhook support
573
-
574
452
  ## Support
575
453
 
576
454
  - 📧 Email: support@docstron.com
577
455
  - 📚 Documentation: https://docs.docstron.com
578
- - 🐛 Issues: https://github.com/yourusername/docstron-sdk/issues
579
- - 💬 Discussions: https://github.com/yourusername/docstron-sdk/discussions
456
+ - 🐛 Issues: https://github.com/playiiit/docstron-nodejs-sdk/issues
457
+ - 💬 Discussions: https://github.com/playiiit/docstron-nodejs-sdk/discussions
458
+
459
+ ## Contributors
460
+
461
+ <a href="https://github.com/chamithsoyza">
462
+ <img src="https://avatars.githubusercontent.com/u/99801726?v=4" width="60" style="border-radius: 100%; vertical-align: middle; margin-right: 5px;">
463
+ </a>
580
464
 
581
465
  ## Contributing
582
466
 
@@ -587,203 +471,3 @@ Contributions are welcome! This is an early-stage project, and we'd love your he
587
471
  3. Commit your changes (`git commit -m 'Add amazing feature'`)
588
472
  4. Push to the branch (`git push origin feature/amazing-feature`)
589
473
  5. Open a Pull Request
590
-
591
- ## License
592
-
593
- MIT © [Your Name]
594
-
595
- ## Changelog
596
-
597
- ### [0.3.0] - 2025-11-17
598
-
599
- ### Added
600
-
601
- - Application management (create, get, list, update, delete)
602
- - Filter active/inactive applications with `listActive()` and `listInactive()`
603
- - Complete workflow example (Application → Template → Document)
604
- - Application organization best practices
605
-
606
- ### Examples
607
-
608
- - `manage-applications.js` - Full application CRUD examples
609
- - `complete-workflow-with-apps.js` - End-to-end workflow demonstration
610
-
611
- ### Improvements
612
-
613
- - Updated all documentation with application examples
614
- - Added application organization patterns
615
- - Complete SDK feature set (Templates, Documents, Applications)
616
-
617
- ### [0.2.0] - 2025-11-17
618
-
619
- ### Added
620
-
621
- - Document generation from templates
622
- - Quick PDF generation without templates
623
- - Document management (get, list, update, delete)
624
- - PDF download functionality
625
- - Password protection for PDFs
626
- - Multiple response type support
627
-
628
- ### [0.1.0] - 2025-11-17
629
-
630
- ### Added
631
-
632
- - Initial release
633
- - Template management (CRUD operations)
634
- - Basic error handling
635
-
636
- # Dependencies
637
-
638
- node_modules/
639
-
640
- # Environment
641
-
642
- .env
643
- .env.local
644
- .env.\*.local
645
-
646
- # Logs
647
-
648
- _.log
649
- npm-debug.log_
650
- yarn-debug.log*
651
- yarn-error.log*
652
-
653
- # Editor directories
654
-
655
- .vscode/
656
- .idea/
657
- _.swp
658
- _.swo
659
- \*~
660
-
661
- # OS
662
-
663
- .DS_Store
664
- Thumbs.db
665
-
666
- # Testing
667
-
668
- coverage/
669
- .nyc_output/
670
-
671
- # Build
672
-
673
- dist/
674
- build/
675
-
676
- # Optional npm cache
677
-
678
- .npm
679
-
680
- # Optional eslint cache
681
-
682
- .eslintcache
683
-
684
- ```
685
-
686
- ### 4. .npmignore
687
- ```
688
-
689
- # Development files
690
-
691
- test/
692
- examples/
693
- .vscode/
694
- .idea/
695
-
696
- # Git files
697
-
698
- .git/
699
- .gitignore
700
- .gitattributes
701
-
702
- # CI/CD
703
-
704
- .github/
705
- .travis.yml
706
- .gitlab-ci.yml
707
-
708
- # Documentation source
709
-
710
- docs/
711
-
712
- ## Complete Workflow Example
713
-
714
- Here's a complete example showing all features working together:
715
-
716
- ```javascript
717
- const Docstron = require("docstron-sdk");
718
- const client = new Docstron("your-api-key");
719
-
720
- // 1. Create application
721
- const app = await client.applications.create({
722
- name: "My Invoice App",
723
- description: "Customer invoicing system",
724
- });
725
-
726
- // 2. Create template in the application
727
- const template = await client.templates.create({
728
- application_id: app.app_id,
729
- name: "Standard Invoice",
730
- content: "<h1>Invoice #{{number}}</h1><p>Total: {{total}}</p>",
731
- });
732
-
733
- // 3. Generate PDF from template
734
- const doc = await client.documents.generate(template.template_id, {
735
- data: {
736
- number: "12345",
737
- total: "$999.00",
738
- },
739
- });
740
-
741
- // 4. Download the PDF
742
- await client.documents.download(doc.document_id, "./invoice.pdf");
743
-
744
- console.log("✅ Complete workflow finished!");
745
- ```
746
-
747
- ## Application Organization Best Practices
748
-
749
- # Environment
750
-
751
- .env
752
- .env.\*
753
-
754
- # Logs
755
-
756
- \*.log
757
-
758
- # Editor files
759
-
760
- _.swp
761
- _.swo
762
- \*~
763
-
764
- ```
765
-
766
- ### 5. LICENSE (MIT)
767
- ```
768
-
769
- MIT License
770
-
771
- Copyright (c) 2025 [Your Name]
772
-
773
- Permission is hereby granted, free of charge, to any person obtaining a copy
774
- of this software and associated documentation files (the "Software"), to deal
775
- in the Software without restriction, including without limitation the rights
776
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
777
- copies of the Software, and to permit persons to whom the Software is
778
- furnished to do so, subject to the following conditions:
779
-
780
- The above copyright notice and this permission notice shall be included in all
781
- copies or substantial portions of the Software.
782
-
783
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
784
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
785
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
786
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
787
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
788
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
789
- SOFTWARE.
@@ -15,7 +15,7 @@ class Applications {
15
15
  async create(params) {
16
16
  this._validateCreateParams(params);
17
17
 
18
- const response = await this.http.post('/v1/applications', params);
18
+ const response = await this.http.post('/applications', params);
19
19
  return response.data;
20
20
  }
21
21
 
@@ -30,7 +30,7 @@ class Applications {
30
30
  throw new Error('Applicaiton ID is required.');
31
31
  }
32
32
 
33
- const response = await this.http.get(`/v1/applications/${appId}`);
33
+ const response = await this.http.get(`/applications/${appId}`);
34
34
  return response.data;
35
35
  }
36
36
 
@@ -52,7 +52,7 @@ class Applications {
52
52
  throw new Error('At least one parameter is required to update');
53
53
  }
54
54
 
55
- const response = await this.http.put(`/v1/applications/${appId}`, params);
55
+ const response = await this.http.put(`/applications/${appId}`, params);
56
56
  return response.data;
57
57
  }
58
58
 
@@ -67,7 +67,7 @@ class Applications {
67
67
  throw new Error('Application ID is required');
68
68
  }
69
69
 
70
- const response = await this.http.delete(`/v1/applications/${appId}`);
70
+ const response = await this.http.delete(`/applications/${appId}`);
71
71
  return response.data;
72
72
  }
73
73
 
@@ -76,7 +76,7 @@ class Applications {
76
76
  * @returns {Promise<Array>} List of all applications
77
77
  */
78
78
  async list() {
79
- const response = await this.http.get('/v1/applications');
79
+ const response = await this.http.get('/applications');
80
80
  return response.data;
81
81
  }
82
82
 
@@ -31,13 +31,13 @@ class Documents {
31
31
 
32
32
  // For PDF response_type,
33
33
  if (payload.response_type === 'pdf') {
34
- const response = await this.http.post('/v1/documents/generate', payload, {
34
+ const response = await this.http.post('/documents/generate', payload, {
35
35
  responseType: 'arraybuffer',
36
36
  });
37
37
  return response;
38
38
  }
39
39
 
40
- const response = await this.http.post('/v1/documents/generate', payload);
40
+ const response = await this.http.post('/documents/generate', payload);
41
41
  return response.data;
42
42
  }
43
43
 
@@ -77,13 +77,13 @@ class Documents {
77
77
  }
78
78
 
79
79
  if (payload.response_type === 'pdf') {
80
- const response = await this.http.post('/v1/documents/quick/generate', payload, {
80
+ const response = await this.http.post('/documents/quick/generate', payload, {
81
81
  responseType: 'arraybuffer'
82
82
  });
83
83
  return response;
84
84
  }
85
85
 
86
- const response = await this.http.post('/v1/documents/quick/generate', payload);
86
+ const response = await this.http.post('/documents/quick/generate', payload);
87
87
  return response.data;
88
88
  }
89
89
 
@@ -98,7 +98,7 @@ class Documents {
98
98
  throw new Error('Document ID is required');
99
99
  }
100
100
 
101
- const response = await this.http.get(`/v1/documents/${documentId}`);
101
+ const response = await this.http.get(`/documents/${documentId}`);
102
102
  return response.data;
103
103
  }
104
104
 
@@ -108,7 +108,7 @@ class Documents {
108
108
  */
109
109
 
110
110
  async list() {
111
- const response = await this.http.get('/v1/documents');
111
+ const response = await this.http.get('/documents');
112
112
  return response.data;
113
113
  }
114
114
 
@@ -127,7 +127,7 @@ class Documents {
127
127
  throw new Error('Data is required to update the document');
128
128
  }
129
129
 
130
- const response = await this.http.put(`/v1/documents/${documentId}`, { data });
130
+ const response = await this.http.put(`/documents/${documentId}`, { data });
131
131
  return response.data;
132
132
  }
133
133
 
@@ -141,7 +141,7 @@ class Documents {
141
141
  if (!documentId) {
142
142
  throw new Error('Document ID is required');
143
143
  }
144
- const response = await this.http.delete(`/v1/documents/${documentId}`);
144
+ const response = await this.http.delete(`/documents/${documentId}`);
145
145
  return response.data;
146
146
  }
147
147
 
@@ -155,7 +155,7 @@ class Documents {
155
155
  if (!documentId) {
156
156
  throw new Error('Document ID is required');
157
157
  }
158
- const response = await this.http.get(`/v1/documents/download/${documentId}`, {
158
+ const response = await this.http.get(`/documents/download/${documentId}`, {
159
159
  responseType: 'arraybuffer'
160
160
  });
161
161
 
@@ -17,7 +17,7 @@ class Templates {
17
17
 
18
18
  async create(params) {
19
19
  this._validateCreateParams(params);
20
- const response = await this.http.post('/v1/templates', params);
20
+ const response = await this.http.post('/templates', params);
21
21
  return response.data;
22
22
  }
23
23
 
@@ -31,7 +31,7 @@ class Templates {
31
31
  throw new Error('Template ID is required');
32
32
  }
33
33
 
34
- const response = await this.http.get(`/v1/templates/${templateId}`);
34
+ const response = await this.http.get(`/templates/${templateId}`);
35
35
  return response.data;
36
36
  }
37
37
 
@@ -46,7 +46,7 @@ class Templates {
46
46
  throw new Error('Template ID is required');
47
47
  }
48
48
 
49
- const response = await this.http.put(`/v1/templates/${templateId}`, params);
49
+ const response = await this.http.put(`/templates/${templateId}`, params);
50
50
  return response.data;
51
51
  }
52
52
 
@@ -61,7 +61,7 @@ class Templates {
61
61
  throw new Error('Template ID is required');
62
62
  }
63
63
 
64
- const response = await this.http.delete(`/v1/templates/${templateId}`);
64
+ const response = await this.http.delete(`/templates/${templateId}`);
65
65
  return response.data;
66
66
  }
67
67
 
@@ -75,7 +75,7 @@ class Templates {
75
75
  throw new Error('Application ID is required');
76
76
  }
77
77
 
78
- const response = await this.http.get('/v1/templates', {
78
+ const response = await this.http.get('/templates', {
79
79
  params: { application_id: applicationId }
80
80
  });
81
81
  return response.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docstron",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Node.js SDK for Docstron PDF Generation API - Complete Features",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,11 +23,11 @@
23
23
  "templates",
24
24
  "applications"
25
25
  ],
26
- "author": "CM_Soyza cmsoyza@gmail.com",
26
+ "author": "Playiiit (Pvt) Ltd",
27
27
  "license": "MIT",
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "https://github.com/ChamithSoyza/doctron-node-sdk"
30
+ "url": "https://github.com/playiiit/docstron-nodejs-sdk"
31
31
  },
32
32
  "dependencies": {
33
33
  "axios": "^1.13.2",