@zola_do/docx 0.1.20 → 0.1.21

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 +75 -75
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,75 +1,75 @@
1
- # @zola_do/docx
2
-
3
- DOCX template processing for NestJS using docx-templates.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # Install individually
9
- npm install @zola_do/docx
10
-
11
- # Or via meta package
12
- npm install @zola_do/nestjs-shared
13
- ```
14
-
15
- ## Usage
16
-
17
- ### Module Setup
18
-
19
- ```typescript
20
- import { Module } from '@nestjs/common';
21
- import { DocxModule } from '@zola_do/docx';
22
-
23
- @Module({
24
- imports: [DocxModule],
25
- })
26
- export class AppModule {}
27
- ```
28
-
29
- ### Generating Documents
30
-
31
- Fill a DOCX template with data. Use `{placeholder}` syntax in your Word document:
32
-
33
- ```typescript
34
- import { Injectable } from '@nestjs/common';
35
- import { DocxService } from '@zola_do/docx';
36
-
37
- @Injectable()
38
- export class ReportService {
39
- constructor(private readonly docxService: DocxService) {}
40
-
41
- async generateReport(templateBuffer: Buffer, data: Record<string, any>) {
42
- // Template contains {name}, {date}, etc.
43
- const result = await this.docxService.generateDocx(templateBuffer, data);
44
- return result; // Buffer of filled DOCX
45
- }
46
- }
47
- ```
48
-
49
- ### Validating Templates
50
-
51
- Ensure a template has all required placeholders before generating:
52
-
53
- ```typescript
54
- const missingProps = await this.docxService.validateDocument(
55
- templateBuffer,
56
- ['name', 'date', 'amount'],
57
- );
58
- if (missingProps.length > 0) {
59
- throw new Error(`Missing placeholders: ${missingProps.join(', ')}`);
60
- }
61
- ```
62
-
63
- ## Template Syntax
64
-
65
- Uses [docx-templates](https://github.com/guigrpa/docx-templates) syntax. Placeholders use `{variableName}`. Supports loops, conditionals, and images—see the docx-templates documentation.
66
-
67
- ## Exports
68
-
69
- - `DocxModule` — Register the DOCX module
70
- - `DocxService` — `generateDocx`, `validateDocument`
71
-
72
- ## Related Packages
73
-
74
- - [@zola_do/document-manipulator](../document-manipulator) — PDF/DOCX merge and conversion, uses similar template population
75
- - [@zola_do/minio](../minio) — Store generated documents
1
+ # @zola_do/docx
2
+
3
+ DOCX template processing for NestJS using docx-templates.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install individually
9
+ npm install @zola_do/docx
10
+
11
+ # Or via meta package
12
+ npm install @zola_do/nestjs-shared
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Module Setup
18
+
19
+ ```typescript
20
+ import { Module } from '@nestjs/common';
21
+ import { DocxModule } from '@zola_do/docx';
22
+
23
+ @Module({
24
+ imports: [DocxModule],
25
+ })
26
+ export class AppModule {}
27
+ ```
28
+
29
+ ### Generating Documents
30
+
31
+ Fill a DOCX template with data. Use `{placeholder}` syntax in your Word document:
32
+
33
+ ```typescript
34
+ import { Injectable } from '@nestjs/common';
35
+ import { DocxService } from '@zola_do/docx';
36
+
37
+ @Injectable()
38
+ export class ReportService {
39
+ constructor(private readonly docxService: DocxService) {}
40
+
41
+ async generateReport(templateBuffer: Buffer, data: Record<string, any>) {
42
+ // Template contains {name}, {date}, etc.
43
+ const result = await this.docxService.generateDocx(templateBuffer, data);
44
+ return result; // Buffer of filled DOCX
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### Validating Templates
50
+
51
+ Ensure a template has all required placeholders before generating:
52
+
53
+ ```typescript
54
+ const missingProps = await this.docxService.validateDocument(
55
+ templateBuffer,
56
+ ['name', 'date', 'amount'],
57
+ );
58
+ if (missingProps.length > 0) {
59
+ throw new Error(`Missing placeholders: ${missingProps.join(', ')}`);
60
+ }
61
+ ```
62
+
63
+ ## Template Syntax
64
+
65
+ Uses [docx-templates](https://github.com/guigrpa/docx-templates) syntax. Placeholders use `{variableName}`. Supports loops, conditionals, and images—see the docx-templates documentation.
66
+
67
+ ## Exports
68
+
69
+ - `DocxModule` — Register the DOCX module
70
+ - `DocxService` — `generateDocx`, `validateDocument`
71
+
72
+ ## Related Packages
73
+
74
+ - [@zola_do/document-manipulator](../document-manipulator) — PDF/DOCX merge and conversion, uses similar template population
75
+ - [@zola_do/minio](../minio) — Store generated documents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zola_do/docx",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "DOCX template processing for NestJS",
5
5
  "author": "zolaDO",
6
6
  "license": "ISC",