docstron 1.0.0 → 1.0.2

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
@@ -5,10 +5,7 @@
5
5
 
6
6
  The official Node.js library for the [Docstron](https://docstron.com) PDF Generation API.
7
7
 
8
- > **Current Version: v0.1.0 - Template Management**
9
- > This is an early release focused on template operations. Document generation coming in v0.2.0!
10
-
11
- ## 📋 What's Included in v0.1.0
8
+ ## 📋 What's Included
12
9
 
13
10
  ✅ **Template Management**
14
11
 
@@ -18,25 +15,28 @@ The official Node.js library for the [Docstron](https://docstron.com) PDF Genera
18
15
  - Delete templates
19
16
  - List all templates
20
17
 
21
- 🚧 **Coming Soon**
22
-
23
- - v0.2.0: Document generation (PDF creation from templates)
24
- - v0.3.0: Application management
25
- - v1.0.0: Full feature set with comprehensive testing
26
-
27
18
  ## Installation
28
19
 
29
20
  ```bash
30
21
  npm install docstron
31
22
  ```
32
23
 
24
+ ## Configuration
25
+
26
+ Add your API key to your environment:
27
+
28
+ ```env
29
+ DOCSTRON_API_KEY=your-api-key
30
+ DOCSTRON_BASE_URL=https://api.docstron.com/v1
31
+ ```
32
+
33
33
  ## Quick Start
34
34
 
35
35
  ```javascript
36
36
  const Docstron = require("docstron");
37
37
 
38
38
  // Initialize the client
39
- const client = new Docstron("your-api-key-here");
39
+ const client = new Docstron();
40
40
 
41
41
  // Create a template
42
42
  const template = await client.templates.create({
@@ -54,11 +54,11 @@ console.log("Template created:", template.template_id);
54
54
  Get your API key from your [Docstron Dashboard](https://docstron.com/dashboard).
55
55
 
56
56
  ```javascript
57
- const client = new Docstron("your-api-key-here");
57
+ const client = new Docstron();
58
58
 
59
59
  // With custom options
60
60
  const client = new Docstron("your-api-key-here", {
61
- baseURL: "https://custom-api.docstron.com",
61
+ baseURL: "https://api.docstron.com/v1",
62
62
  });
63
63
  ```
64
64
 
@@ -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.
package/lib/Docstron.js CHANGED
@@ -2,7 +2,7 @@ const HttpClient = require('./utils/httpClient');
2
2
  const Templates = require('./resources/Templates');
3
3
  const Documents = require('./resources/Documents');
4
4
  const Applications = require('./resources/Applications');
5
- const { DEFAULT_BASE_URL } = require('./constants');
5
+ const { DEFAULT_BASE_URL, DEFAULT_API_KEY } = require('./constants');
6
6
 
7
7
  class Docstron {
8
8
  /**
@@ -11,23 +11,16 @@ class Docstron {
11
11
  * @param {Object} [Options] - Configuration options
12
12
  * @param {string} [Options.baseURL] - Custom base URL
13
13
  */
14
- constructor(apiKey, options = {}) {
15
- if (!apiKey) {
16
- throw new Error('API key is required');
17
- }
18
-
19
- this.apiKey = apiKey;
14
+ constructor(apiKey = null, options = {}) {
15
+ this.apiKey = apiKey || DEFAULT_API_KEY;
20
16
  this.baseURL = options.baseURL || DEFAULT_BASE_URL;
21
17
 
22
18
  const httpClient = new HttpClient(this.apiKey, this.baseURL);
23
19
 
24
- // v0.1.0 - Templates Only
25
20
  this.templates = new Templates(httpClient);
26
21
 
27
- // v0.2.0 - Documents
28
22
  this.documents = new Documents(httpClient);
29
23
 
30
- // v0.3.0 - Applications
31
24
  this.applications = new Applications(httpClient);
32
25
  }
33
26
 
package/lib/constants.js CHANGED
@@ -1,7 +1,7 @@
1
- const DEFAULT_BASE_URL = 'https://api.docstron.com';
2
- const API_VERSION = 'v1';
1
+ const DEFAULT_BASE_URL = process.env.DOCSTRON_BASE_URL || 'https://api.docstron.com/v1';
2
+ const DEFAULT_API_KEY = process.env.DOCSTRON_API_KEY || null;
3
3
 
4
4
  module.exports = {
5
5
  DEFAULT_BASE_URL,
6
- API_VERSION
6
+ DEFAULT_API_KEY
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docstron",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",