@rastr/pdf-template 0.0.0-stage → 0.1.0-beta.1
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/LICENSE +21 -0
- package/README.md +34 -2
- package/dist/index.cjs +1135 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +324 -0
- package/dist/index.d.ts +324 -0
- package/dist/index.js +1091 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ondřej Synek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @rastr/pdf-template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The PDF report template format (`version: 1`) and the layout engine shared with `Rastr.Export`.
|
|
4
|
+
`validateTemplate` checks a template and reports every issue with its path. `layoutReport` turns a
|
|
5
|
+
template and data into absolutely placed pages. The same algorithm in C# produces the same layout to
|
|
6
|
+
0.01 mm (contract fixtures in `contracts/pdf-layout`).
|
|
7
|
+
|
|
8
|
+
`ReportInput.summaryRow` (texts per field) is drawn as a bold row with a rule above it after the last
|
|
9
|
+
table row when `table.summary` is true; it moves to a new page (with the header) when it does not fit.
|
|
10
|
+
Expressions reading a missing `summary.*` value produce a layout warning.
|
|
11
|
+
|
|
12
|
+
## Template storage
|
|
13
|
+
|
|
14
|
+
Templates are stored per grid (`gridId`). `shared` means visible to the whole company; otherwise only
|
|
15
|
+
its author sees it. The server decides this from the signed-in user. Each grid has at most one
|
|
16
|
+
default template.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { createLocalTemplateStore, createRestTemplateStore, templateLoader } from '@rastr/pdf-template';
|
|
20
|
+
|
|
21
|
+
const local = createLocalTemplateStore(); // one localStorage key, 'rastr.pdf-templates'
|
|
22
|
+
const rest = createRestTemplateStore({ url: '/api/pdf-templates', headers: () => ({ Authorization: `Bearer ${token}` }) });
|
|
23
|
+
|
|
24
|
+
await rest.save({ gridId: 'orders', name: 'Přehled', isDefault: true, shared: false, template });
|
|
25
|
+
const loadDefault = templateLoader(rest, 'orders'); // for GridPdfOptions.template; null → default look
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `TemplateStore` has `list(gridId)`, `load(id)`, `save(input)` (no `id` creates a new template) and
|
|
29
|
+
`remove(id)`. An application can implement it over its own API.
|
|
30
|
+
- A failed request is a `TemplateStoreError` with `status`. A 400 for an invalid template carries the
|
|
31
|
+
server's `issues`.
|
|
32
|
+
- A stored `template` is `unknown`: validate it before use.
|
|
33
|
+
- REST contract: `contracts/wire/pdf-templates.md`. On the server,
|
|
34
|
+
`app.MapRastrPdfTemplates("/api/pdf-templates")` (`Rastr.AspNetCore`) maps it over the
|
|
35
|
+
application's `IPdfTemplateRepository` and validates templates before they are stored.
|