qorstack-report-sdk 0.1.0 → 0.1.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 +499 -370
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,370 +1,499 @@
|
|
|
1
|
-
# Qorstack Report SDK
|
|
2
|
-
|
|
3
|
-
The official SDK for Qorstack Report
|
|
4
|
-
This SDK simplifies
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{ "
|
|
165
|
-
{ "
|
|
166
|
-
{ "
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
new Dictionary<string, object> { { "
|
|
266
|
-
new Dictionary<string, object> { { "
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
1
|
+
# Qorstack Report SDK
|
|
2
|
+
|
|
3
|
+
The official SDK for **Qorstack Report** — a REST API for generating **PDF**, **DOCX**, and **XLSX** reports from Microsoft Word and Excel templates.
|
|
4
|
+
This SDK simplifies integration into your **Node.js** and **.NET** applications.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Word template rendering** — generate PDF or DOCX from a stored DOCX template.
|
|
9
|
+
- **Excel template rendering** — generate XLSX (or PDF) from a stored XLSX template, with auto-filter, freeze header, table styles, and conditional formatting.
|
|
10
|
+
- **Sandbox rendering** — render a template using its configured sample payload (great for previews).
|
|
11
|
+
- **Render job history** — list and inspect past render jobs.
|
|
12
|
+
- **Rich data binding:**
|
|
13
|
+
- Text replacement
|
|
14
|
+
- Dynamic tables (with vertical merge / column collapse on Word; auto-filter / freeze / split-to-sheets on Excel)
|
|
15
|
+
- Images (URL or Base64)
|
|
16
|
+
- QR codes and barcodes
|
|
17
|
+
- **Pro features** *(requires Pro license on self-hosted, included on cloud Pro plans)*:
|
|
18
|
+
- PDF password protection
|
|
19
|
+
- PDF watermarking
|
|
20
|
+
- **Zip output** — bundle multiple output files into a `.zip`.
|
|
21
|
+
- **Cross-platform** — fully typed clients for TypeScript/Node.js and C#/.NET 8.0+.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Node.js (TypeScript/JavaScript)
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install qorstack-report-sdk
|
|
31
|
+
# or
|
|
32
|
+
pnpm add qorstack-report-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### .NET (C#)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
dotnet add package Qorstack.Report.Sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Authentication
|
|
44
|
+
|
|
45
|
+
You need an **API Key** from the Qorstack Portal.
|
|
46
|
+
|
|
47
|
+
1. Log in to the Qorstack Portal.
|
|
48
|
+
2. Navigate to **Settings → API Keys**.
|
|
49
|
+
3. Create a new API Key (scoped per project).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Getting Started
|
|
54
|
+
|
|
55
|
+
### Node.js Setup
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { QorstackApi } from "qorstack-report-sdk";
|
|
59
|
+
|
|
60
|
+
// Initialize the client with API Key
|
|
61
|
+
const qorstackApi = new QorstackApi({
|
|
62
|
+
securityData: {
|
|
63
|
+
headers: {
|
|
64
|
+
"X-API-KEY": "YOUR_API_KEY_HERE",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// OR: with custom Base URL (e.g. self-hosted instance)
|
|
70
|
+
const qorstackApiCustom = new QorstackApi({
|
|
71
|
+
baseUrl: "https://your-custom-url.com",
|
|
72
|
+
securityData: {
|
|
73
|
+
headers: {
|
|
74
|
+
"X-API-KEY": "YOUR_API_KEY_HERE",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### .NET Setup
|
|
81
|
+
|
|
82
|
+
```csharp
|
|
83
|
+
using Qorstack.Report.Sdk;
|
|
84
|
+
|
|
85
|
+
// Initialize with API Key
|
|
86
|
+
var qorstackApi = new QorstackApi(apiKey: "YOUR_API_KEY_HERE");
|
|
87
|
+
|
|
88
|
+
// OR: with custom Base URL
|
|
89
|
+
var qorstackApiCustom = new QorstackApi("https://your-custom-url.com", "YOUR_API_KEY_HERE");
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Usage Examples
|
|
95
|
+
|
|
96
|
+
### 1. Render Word/PDF from template (`PdfFromTemplateRequest`)
|
|
97
|
+
|
|
98
|
+
Endpoint: `POST /render/word/template`
|
|
99
|
+
Method: `render.postRenderWordTemplate` (Node) / `PostRenderWordTemplateAsync` (.NET)
|
|
100
|
+
|
|
101
|
+
Use `fileType: "pdf"` (default) to get a PDF, or `"docx"` to get the rendered Word document.
|
|
102
|
+
|
|
103
|
+
#### Full feature example (text, table, image, QR, barcode)
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Node.js (TypeScript)
|
|
107
|
+
const tableRows = data.map((item, index) => ({
|
|
108
|
+
no: index + 1,
|
|
109
|
+
category: item.category,
|
|
110
|
+
description: item.description,
|
|
111
|
+
qty: item.quantity,
|
|
112
|
+
unit_price: item.price,
|
|
113
|
+
amount: item.total,
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
const response = await qorstackApi.render.postRenderWordTemplate({
|
|
117
|
+
templateKey: "RENDOX-7326-758-974-2067",
|
|
118
|
+
fileName: "Full_Report_Example",
|
|
119
|
+
fileType: "pdf", // "pdf" | "docx"
|
|
120
|
+
replace: {
|
|
121
|
+
customer_name: "Example Company Ltd.",
|
|
122
|
+
document_date: new Date().toLocaleDateString("en-GB"),
|
|
123
|
+
total_amount: "1,500.00",
|
|
124
|
+
},
|
|
125
|
+
table: [
|
|
126
|
+
{
|
|
127
|
+
rows: tableRows,
|
|
128
|
+
verticalMerge: ["category"],
|
|
129
|
+
collapse: ["description"],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
image: {
|
|
133
|
+
header_logo: {
|
|
134
|
+
src: "https://example.com/logo.png",
|
|
135
|
+
width: 200,
|
|
136
|
+
fit: "contain",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
qrcode: {
|
|
140
|
+
payment_qr: {
|
|
141
|
+
text: "https://payment.link/123456",
|
|
142
|
+
size: 150,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
barcode: {
|
|
146
|
+
product_barcode: {
|
|
147
|
+
text: "PROD-123456789",
|
|
148
|
+
format: "Code128",
|
|
149
|
+
width: 300,
|
|
150
|
+
height: 80,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
console.log("Download URL:", response.data.downloadUrl);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```csharp
|
|
159
|
+
// C# (.NET)
|
|
160
|
+
var data = await _exampleService.GetDataAsync(id);
|
|
161
|
+
|
|
162
|
+
var tableRows = data.Select((item, index) => new Dictionary<string, object>
|
|
163
|
+
{
|
|
164
|
+
{ "no", index + 1 },
|
|
165
|
+
{ "category", item.Category },
|
|
166
|
+
{ "description", item.Description },
|
|
167
|
+
{ "qty", item.Quantity },
|
|
168
|
+
{ "unit_price", item.Price },
|
|
169
|
+
{ "amount", item.Total }
|
|
170
|
+
}).ToList();
|
|
171
|
+
|
|
172
|
+
var request = new PdfFromTemplateRequest
|
|
173
|
+
{
|
|
174
|
+
TemplateKey = "RENDOX-7326-758-974-2067",
|
|
175
|
+
FileName = "Full_Report_Example",
|
|
176
|
+
FileType = "pdf",
|
|
177
|
+
Replace = new()
|
|
178
|
+
{
|
|
179
|
+
{ "customer_name", "Example Company Ltd." },
|
|
180
|
+
{ "document_date", DateTime.Now.ToString("dd/MM/yyyy") },
|
|
181
|
+
{ "total_amount", "1,500.00" }
|
|
182
|
+
},
|
|
183
|
+
Table = new()
|
|
184
|
+
{
|
|
185
|
+
new()
|
|
186
|
+
{
|
|
187
|
+
Rows = tableRows,
|
|
188
|
+
VerticalMerge = new() { "category" },
|
|
189
|
+
Collapse = new() { "description" }
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
Image = new()
|
|
193
|
+
{
|
|
194
|
+
{ "header_logo", new() { Src = "https://example.com/logo.png", Width = 200, Fit = "contain" } }
|
|
195
|
+
},
|
|
196
|
+
QrCode = new()
|
|
197
|
+
{
|
|
198
|
+
{ "payment_qr", new() { Text = "https://payment.link/123456", Size = 150 } }
|
|
199
|
+
},
|
|
200
|
+
Barcode = new()
|
|
201
|
+
{
|
|
202
|
+
{ "product_barcode", new() { Text = "PROD-123456789", Format = "Code128", Width = 300, Height = 80 } }
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var response = await qorstackApi.PostRenderWordTemplateAsync(request);
|
|
207
|
+
Console.WriteLine($"Download URL: {response.DownloadUrl}");
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### 2. Render Excel from template (`ExcelFromTemplateRequest`)
|
|
213
|
+
|
|
214
|
+
Endpoint: `POST /render/excel/template`
|
|
215
|
+
Method: `render.postRenderExcelTemplate` (Node) / `PostRenderExcelTemplateAsync` (.NET)
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// Node.js (TypeScript)
|
|
219
|
+
const response = await qorstackApi.render.postRenderExcelTemplate({
|
|
220
|
+
templateKey: "XLSX-1234-5678",
|
|
221
|
+
fileName: "Sales_Report_Q1",
|
|
222
|
+
replace: {
|
|
223
|
+
report_period: "Q1 2026",
|
|
224
|
+
generated_by: "Sales Team",
|
|
225
|
+
},
|
|
226
|
+
table: [
|
|
227
|
+
{
|
|
228
|
+
rows: [
|
|
229
|
+
{ region: "North", product: "A", qty: 10, total: 1000 },
|
|
230
|
+
{ region: "North", product: "B", qty: 5, total: 500 },
|
|
231
|
+
{ region: "South", product: "A", qty: 8, total: 800 },
|
|
232
|
+
],
|
|
233
|
+
autoFilter: true,
|
|
234
|
+
freezeHeader: true,
|
|
235
|
+
autoFitColumns: true,
|
|
236
|
+
asExcelTable: true,
|
|
237
|
+
excelTableStyle: "TableStyleMedium2",
|
|
238
|
+
generateTotals: { total: "sum", qty: "sum" },
|
|
239
|
+
numberFormat: { total: "#,##0.00" },
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
console.log("Download URL:", response.data.downloadUrl);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
```csharp
|
|
248
|
+
// C# (.NET)
|
|
249
|
+
var request = new ExcelFromTemplateRequest
|
|
250
|
+
{
|
|
251
|
+
TemplateKey = "XLSX-1234-5678",
|
|
252
|
+
FileName = "Sales_Report_Q1",
|
|
253
|
+
Replace = new()
|
|
254
|
+
{
|
|
255
|
+
{ "report_period", "Q1 2026" },
|
|
256
|
+
{ "generated_by", "Sales Team" }
|
|
257
|
+
},
|
|
258
|
+
Table = new()
|
|
259
|
+
{
|
|
260
|
+
new()
|
|
261
|
+
{
|
|
262
|
+
Rows = new()
|
|
263
|
+
{
|
|
264
|
+
new Dictionary<string, object> { { "region", "North" }, { "product", "A" }, { "qty", 10 }, { "total", 1000 } },
|
|
265
|
+
new Dictionary<string, object> { { "region", "North" }, { "product", "B" }, { "qty", 5 }, { "total", 500 } },
|
|
266
|
+
new Dictionary<string, object> { { "region", "South" }, { "product", "A" }, { "qty", 8 }, { "total", 800 } }
|
|
267
|
+
},
|
|
268
|
+
AutoFilter = true,
|
|
269
|
+
FreezeHeader = true,
|
|
270
|
+
AutoFitColumns = true,
|
|
271
|
+
AsExcelTable = true,
|
|
272
|
+
ExcelTableStyle = "TableStyleMedium2",
|
|
273
|
+
GenerateTotals = new() { { "total", "sum" }, { "qty", "sum" } },
|
|
274
|
+
NumberFormat = new() { { "total", "#,##0.00" } }
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
var response = await qorstackApi.PostRenderExcelTemplateAsync(request);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
### 3. PDF password protection *(Pro)*
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
const response = await qorstackApi.render.postRenderWordTemplate({
|
|
288
|
+
templateKey: "RENDOX-7326-758-974-2067",
|
|
289
|
+
fileName: "Confidential_Report",
|
|
290
|
+
fileType: "pdf",
|
|
291
|
+
pdfPassword: {
|
|
292
|
+
userPassword: "open-me",
|
|
293
|
+
ownerPassword: "owner-secret",
|
|
294
|
+
restrictPrinting: true,
|
|
295
|
+
restrictCopying: true,
|
|
296
|
+
restrictModifying: true,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
### 4. PDF watermark *(Pro)*
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const response = await qorstackApi.render.postRenderWordTemplate({
|
|
307
|
+
templateKey: "RENDOX-7326-758-974-2067",
|
|
308
|
+
fileName: "Draft_Report",
|
|
309
|
+
fileType: "pdf",
|
|
310
|
+
watermark: {
|
|
311
|
+
text: "DRAFT",
|
|
312
|
+
fontSize: 72,
|
|
313
|
+
fontFamily: "Arial",
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
### 5. Sandbox render (preview using template's sample payload)
|
|
321
|
+
|
|
322
|
+
Endpoint: `POST /render/word/template-sandbox/{templateKey}`
|
|
323
|
+
Useful for previewing a template without supplying real data.
|
|
324
|
+
|
|
325
|
+
```typescript
|
|
326
|
+
const response = await qorstackApi.render.postRenderWordTemplateSandbox(
|
|
327
|
+
"RENDOX-7326-758-974-2067",
|
|
328
|
+
{ fileName: "Preview" },
|
|
329
|
+
/* body */ null, // or a JSON object to override the sandbox payload
|
|
330
|
+
);
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### 6. Inspect render jobs
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
// List jobs
|
|
339
|
+
const jobs = await qorstackApi.render.getRenderJobs({
|
|
340
|
+
page: 1,
|
|
341
|
+
pageSize: 20,
|
|
342
|
+
// templateKey: "...", status: "Success" | "Failed" | "Pending"
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Get one
|
|
346
|
+
const job = await qorstackApi.render.getRenderJobById("job-id-here");
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Data Binding Reference
|
|
352
|
+
|
|
353
|
+
### Text replacement (`replace`)
|
|
354
|
+
|
|
355
|
+
Replaces `{{variable}}` placeholders with strings.
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
"replace": {
|
|
359
|
+
"customerName": "Acme Corp",
|
|
360
|
+
"totalAmount": "$1,050.00"
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Word table (`table` — `WordTableDataRequest[]`)
|
|
365
|
+
|
|
366
|
+
```json
|
|
367
|
+
"table": [
|
|
368
|
+
{
|
|
369
|
+
"rows": [
|
|
370
|
+
{ "name": "Value A", "last_name": "Value B" },
|
|
371
|
+
{ "name": "Value C", "last_name": "Value D" }
|
|
372
|
+
],
|
|
373
|
+
"verticalMerge": ["category"],
|
|
374
|
+
"collapse": ["description"]
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
| Field | Description |
|
|
380
|
+
| --- | --- |
|
|
381
|
+
| `rows` | Array of row objects. Keys match column placeholders. |
|
|
382
|
+
| `verticalMerge` | Columns whose adjacent identical values are merged vertically. |
|
|
383
|
+
| `collapse` | Columns whose empty/duplicate values collapse to keep layout tidy. |
|
|
384
|
+
|
|
385
|
+
### Excel table (`table` — `ExcelTableDataRequest[]`)
|
|
386
|
+
|
|
387
|
+
```json
|
|
388
|
+
"table": [
|
|
389
|
+
{
|
|
390
|
+
"rows": [{ "region": "North", "qty": 10 }],
|
|
391
|
+
"autoFilter": true,
|
|
392
|
+
"freezeHeader": true,
|
|
393
|
+
"autoFitColumns": true,
|
|
394
|
+
"asExcelTable": true,
|
|
395
|
+
"excelTableStyle": "TableStyleMedium2",
|
|
396
|
+
"generateTotals": { "qty": "sum" },
|
|
397
|
+
"numberFormat": { "qty": "#,##0" }
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
| Field | Description |
|
|
403
|
+
| --- | --- |
|
|
404
|
+
| `autoFilter` | Enable Excel auto-filter on the header row. |
|
|
405
|
+
| `freezeHeader` | Freeze the header row. |
|
|
406
|
+
| `autoFitColumns` | Auto-fit column widths to content. |
|
|
407
|
+
| `asExcelTable` / `excelTableStyle` | Render as native Excel table with style. |
|
|
408
|
+
| `generateTotals` | Per-column aggregation (`sum`, `avg`, `count`, `min`, `max`). |
|
|
409
|
+
| `numberFormat` | Excel number format string per column. |
|
|
410
|
+
| `conditionalFormat` | Conditional formatting rules. |
|
|
411
|
+
| `splitToSheets` | Split rows into multiple sheets by a column value. |
|
|
412
|
+
| `sort` | Sort rows before render. |
|
|
413
|
+
|
|
414
|
+
### Images (`image`)
|
|
415
|
+
|
|
416
|
+
Replaces `{{image:logo}}`. Accepts URL or Base64.
|
|
417
|
+
|
|
418
|
+
```json
|
|
419
|
+
"image": {
|
|
420
|
+
"logo": {
|
|
421
|
+
"src": "https://example.com/logo.png",
|
|
422
|
+
"width": 150,
|
|
423
|
+
"height": 50,
|
|
424
|
+
"fit": "contain"
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### QR codes (`qrcode`)
|
|
430
|
+
|
|
431
|
+
Replaces `{{qr:website}}`.
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
"qrcode": {
|
|
435
|
+
"website": {
|
|
436
|
+
"text": "https://qorstack.dev",
|
|
437
|
+
"size": 200,
|
|
438
|
+
"color": "#000000"
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Barcodes (`barcode`)
|
|
444
|
+
|
|
445
|
+
Replaces `{{barcode:productId}}`. Default format: `Code128`.
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
"barcode": {
|
|
449
|
+
"productId": {
|
|
450
|
+
"text": "1234567890",
|
|
451
|
+
"format": "Code128",
|
|
452
|
+
"includeText": true,
|
|
453
|
+
"width": 300,
|
|
454
|
+
"height": 80
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Output options
|
|
460
|
+
|
|
461
|
+
| Field | Type | Description |
|
|
462
|
+
| --- | --- | --- |
|
|
463
|
+
| `fileName` | string | Output file name (without extension). |
|
|
464
|
+
| `fileType` | string | Word only: `"pdf"` (default) or `"docx"`. |
|
|
465
|
+
| `zipOutput` | boolean | If `true`, bundle the output into a `.zip` archive. |
|
|
466
|
+
| `pdfPassword` | object | *(Pro)* Encrypt the PDF and set permissions. |
|
|
467
|
+
| `watermark` | object | *(Pro)* Apply a text watermark to the PDF. |
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Response shape
|
|
472
|
+
|
|
473
|
+
All render endpoints return a download URL plus metadata:
|
|
474
|
+
|
|
475
|
+
```jsonc
|
|
476
|
+
{
|
|
477
|
+
"downloadUrl": "https://.../output.pdf",
|
|
478
|
+
"fileName": "Full_Report_Example.pdf",
|
|
479
|
+
"fileSize": 102400,
|
|
480
|
+
"fileType": "pdf",
|
|
481
|
+
"status": "Success",
|
|
482
|
+
"isZipped": false
|
|
483
|
+
}
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
---
|
|
487
|
+
|
|
488
|
+
## Error Handling
|
|
489
|
+
|
|
490
|
+
The SDK throws when the API returns 4xx/5xx (`ProblemDetails` payload).
|
|
491
|
+
|
|
492
|
+
- **Node.js** — the promise rejects; `error.error` contains the `ProblemDetails` body.
|
|
493
|
+
- **.NET** — `ApiException<ProblemDetails>` is thrown; access `ex.Result` for the body.
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
## License
|
|
498
|
+
|
|
499
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qorstack-report-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
10
|
"sync-config": "node scripts/sync-config.js",
|
|
11
|
-
"prebuild": "
|
|
11
|
+
"prebuild": "pnpm sync-config",
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
14
|
"gen:nodejs": "swagger-typescript-api generate -p ../backend/swagger-sdk.json -o ./src/nodejs --name QorstackApi.ts",
|
|
15
15
|
"gen:dotnet": "nswag openapi2csclient /input:../backend/swagger-sdk.json /output:src/dotnet/QorstackApi.cs /namespace:Qorstack.Report.Sdk /ClassName:QorstackApi",
|
|
16
|
-
"gen:all": "
|
|
16
|
+
"gen:all": "pnpm gen:nodejs && pnpm gen:dotnet"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"qorstack",
|