@narrow-os/document-templates 1.0.0 β†’ 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +57 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,13 @@
1
- # @bizflow/document-templates
1
+ # @narrow-os/document-templates
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@narrow-os/document-templates.svg)](https://www.npmjs.com/package/@narrow-os/document-templates)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
5
 
3
6
  Universal, framework-agnostic document templates and HTML/PDF generators for **Invoices**, **Quotations**, **Retail POS Receipts**, and **Delivery Notes**.
4
7
 
5
8
  Designed to run seamlessly across:
6
9
 
7
- - **Node.js / NestJS** (for automated background emails, cron jobs, and Puppeteer PDF generation)
10
+ - **Node.js / NestJS** (automated background emails, queues, and Puppeteer PDF generation)
8
11
  - **Next.js Server & Client** (App Router, Pages, SSR, API routes)
9
12
  - **Browsers & POS Terminals** (Direct printing, thermal receipt printing, live canvas-free preview)
10
13
 
@@ -14,26 +17,25 @@ Designed to run seamlessly across:
14
17
 
15
18
  - 🎨 **10 Distinct A4 Design Presets**: `classic`, `modern`, `minimal`, `corporate`, `bold`, `elegant`, `tech`, `vibrant`, `compact`, and `mono`.
16
19
  - 🧾 **10 Thermal Receipt Presets**: `classic`, `compact`, `wide`, `dense`, `sparse`, `boxed`, `lined`, `split`, `monobold`, and `elegant` (for 80mm & 58mm thermal receipt printers).
17
- - πŸ‡ΏπŸ‡¦ **South African 15% VAT & Multi-Currency Ready**: Built-in compliant tax calculation, deposit breakdowns, installment terms, and banking payment instructions.
18
- - ⚑ **Zero DOM Canvas Crashes**: Built-in vector SVG Code 128 barcode and QR code generators that run headlessly in pure Node.js without requiring `<canvas>` or native DOM bindings.
20
+ - πŸ‡ΏπŸ‡¦ **South African 15% VAT & Multi-Currency Ready**: Built-in compliant tax calculations, deposit breakdowns, installment terms, and banking payment instructions.
21
+ - ⚑ **Zero DOM Canvas Crashes**: Pure vector SVG Code 128 barcode and QR code generators that run headlessly in pure Node.js without requiring `<canvas>` or native DOM bindings.
19
22
  - πŸ“¦ **Framework Agnostic**: Pure TypeScript returning clean HTML strings ready for `puppeteer.page.setContent(html)` or `window.open().document.write(html)`.
23
+ - πŸš€ **Dual ESM & CJS**: Full TypeScript type declarations included out-of-the-box.
20
24
 
21
25
  ---
22
26
 
23
27
  ## Installation
24
28
 
25
- ### Local Installation in Monorepo / Relative Path
26
-
27
29
  ```bash
28
- npm install ../packages/document-templates
29
- # or from root
30
- npm install ./packages/document-templates
30
+ npm install @narrow-os/document-templates
31
31
  ```
32
32
 
33
- ### When Published to npm
33
+ Or with yarn / pnpm / bun:
34
34
 
35
35
  ```bash
36
- npm install @bizflow/document-templates
36
+ yarn add @narrow-os/document-templates
37
+ pnpm add @narrow-os/document-templates
38
+ bun add @narrow-os/document-templates
37
39
  ```
38
40
 
39
41
  ---
@@ -46,7 +48,7 @@ npm install @bizflow/document-templates
46
48
  import {
47
49
  InvoiceReportGenerator,
48
50
  generateInvoiceHTML,
49
- } from "@bizflow/document-templates";
51
+ } from "@narrow-os/document-templates";
50
52
 
51
53
  const invoiceHtml = await generateInvoiceHTML(
52
54
  {
@@ -102,7 +104,7 @@ const invoiceHtml = await generateInvoiceHTML(
102
104
  ### 2. Generating Quotations
103
105
 
104
106
  ```typescript
105
- import { generateQuotationHTML } from "@bizflow/document-templates";
107
+ import { generateQuotationHTML } from "@narrow-os/document-templates";
106
108
 
107
109
  const quoteHtml = await generateQuotationHTML(quotationData, {
108
110
  templateId: "corporate",
@@ -110,12 +112,12 @@ const quoteHtml = await generateQuotationHTML(quotationData, {
110
112
  });
111
113
  ```
112
114
 
113
- ### 3. Printing POS Receipts (A4 & Thermal 80mm)
115
+ ### 3. Printing POS Receipts (A4 & Thermal 80mm / 58mm)
114
116
 
115
117
  ```typescript
116
- import { receiptGenerator } from "@bizflow/document-templates";
118
+ import { receiptGenerator } from "@narrow-os/document-templates";
117
119
 
118
- // Thermal 80mm
120
+ // Thermal 80mm (ESC/POS style web print)
119
121
  const thermalHtml = await receiptGenerator.generateReceiptHTML(
120
122
  saleData,
121
123
  "thermal",
@@ -130,42 +132,68 @@ const a4ReceiptHtml = await receiptGenerator.generateReceiptHTML(
130
132
  );
131
133
  ```
132
134
 
133
- ### 4. Headless PDF Generation in Node.js / NestJS
135
+ ### 4. Headless PDF Generation in Node.js / NestJS (Puppeteer)
134
136
 
135
137
  ```typescript
136
138
  import puppeteer from "puppeteer";
137
- import { generateInvoiceHTML } from "@bizflow/document-templates";
139
+ import { generateInvoiceHTML } from "@narrow-os/document-templates";
138
140
 
139
141
  const html = await generateInvoiceHTML(invoice, { companyInfo });
140
142
 
141
- const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
143
+ const browser = await puppeteer.launch({
144
+ headless: true,
145
+ args: ["--no-sandbox", "--disable-setuid-sandbox"],
146
+ });
147
+
142
148
  const page = await browser.newPage();
143
149
  await page.setContent(html, { waitUntil: "load" });
150
+
144
151
  const pdfBuffer = await page.pdf({
145
152
  format: "A4",
146
153
  printBackground: true,
147
- margin: { top: "0.5in", right: "0.5in", bottom: "0.5in", left: "0.5in" },
154
+ margin: {
155
+ top: "0.5in",
156
+ right: "0.5in",
157
+ bottom: "0.5in",
158
+ left: "0.5in",
159
+ },
148
160
  });
161
+
149
162
  await browser.close();
150
163
 
151
- // pdfBuffer is ready to attach to Resend, SendGrid, or nodemailer!
164
+ // pdfBuffer is ready to attach to emails via Resend, SendGrid, or nodemailer!
152
165
  ```
153
166
 
154
167
  ---
155
168
 
156
- ## Publishing to npm
169
+ ## Available A4 Design Templates
170
+
171
+ | Template ID | Style | Best For |
172
+ |---|---|---|
173
+ | `classic` | Traditional corporate border with dual header | Formal invoices, government, tenders |
174
+ | `modern` | Clean slate accents with rounded cards | SaaS, modern tech, startups |
175
+ | `minimal` | Ultra-clean layout with delicate lines | Creative agencies, design studios |
176
+ | `corporate` | Navy blue accent with structured tables | Enterprise, legal, financial firms |
177
+ | `bold` | High-contrast black headers and thick borders | Construction, industrial, trades |
178
+ | `elegant` | Serif typography with subtle borders | Law firms, consulting, luxury services |
179
+ | `tech` | Emerald green badges and monospace elements | Software development, hardware, hosting |
180
+ | `vibrant` | Violet gradients and modern card styling | Marketing agencies, event organizers |
181
+ | `compact` | Dense line items and narrow margins | Long item lists, inventory invoices |
182
+ | `mono` | Pure grayscale typography | Black-and-white laser printers |
183
+
184
+ ---
157
185
 
158
- To publish this package to npm:
186
+ ## Publishing Updates to npm
159
187
 
160
- 1. Build the distribution bundle:
188
+ 1. Bump the version in `package.json`:
161
189
  ```bash
162
- npm run build
190
+ npm version patch
163
191
  ```
164
- 2. Login to npm:
192
+ 2. Build the bundle:
165
193
  ```bash
166
- npm login
194
+ npm run build
167
195
  ```
168
- 3. Publish:
196
+ 3. Publish to npm:
169
197
  ```bash
170
198
  npm publish --access public
171
199
  ```
@@ -174,4 +202,4 @@ To publish this package to npm:
174
202
 
175
203
  ## License
176
204
 
177
- MIT Β© Rethynk Web Studio
205
+ MIT Β© Narrow OS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narrow-os/document-templates",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Universal document templates and HTML/PDF generators for invoices, quotations, receipts, and delivery notes",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",