@formancy/report-runtime 0.0.0-stage → 0.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.
- package/LICENSE.md +161 -0
- package/NOTICE +9 -0
- package/README.md +92 -2
- package/dist/index.d.mts +747 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2477 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Formancy Report Source-Available Licence
|
|
2
|
+
|
|
3
|
+
**Version 1 — in force from 14 October 2026. Not reviewed by a lawyer.**
|
|
4
|
+
|
|
5
|
+
This text states the terms Formancy Report is offered under. Version 1 is in
|
|
6
|
+
force from 14 October 2026. Its terms are those of the Formancy Data
|
|
7
|
+
Source-Available Licence, Version 1.1, with this product's names and with the
|
|
8
|
+
documents a reporting product generates named as yours. **This version has
|
|
9
|
+
not been reviewed by a lawyer.** It is published in the repository so that
|
|
10
|
+
the terms are visible to everyone who reads the source. Production licences,
|
|
11
|
+
which section 3 describes, can be had as section 9 says.
|
|
12
|
+
|
|
13
|
+
This is not an open-source licence. It is not Apache-2.0, and it is not the
|
|
14
|
+
licence of [formancy](https://github.com/sharkysan/formancy.ai), on which this
|
|
15
|
+
software builds and whose packages keep their own Apache-2.0 terms.
|
|
16
|
+
|
|
17
|
+
## The terms in one table
|
|
18
|
+
|
|
19
|
+
| Use | Terms |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Read the source and fork the repository | Free |
|
|
22
|
+
| Evaluate, develop and test — including in companies | Free |
|
|
23
|
+
| Run in production, internally or customer-facing | Paid licence |
|
|
24
|
+
| Redistribute inside another software product | Separate commercial agreement |
|
|
25
|
+
| Customer data, report templates and generated documents | Remain the customer's |
|
|
26
|
+
|
|
27
|
+
The rest of this document says what each row means.
|
|
28
|
+
|
|
29
|
+
## 1. Definitions
|
|
30
|
+
|
|
31
|
+
**The Software** means the source code, declarations, documentation and
|
|
32
|
+
packages in this repository and the packages published from it under the
|
|
33
|
+
`@formancy/report-*` names, in any version, including modified versions.
|
|
34
|
+
|
|
35
|
+
**The Rightsholder** means Daniel Bacher, or whoever the Rightsholder later
|
|
36
|
+
designates in a revision of this document.
|
|
37
|
+
|
|
38
|
+
**Production Use** means running the Software, or anything that incorporates
|
|
39
|
+
it, in a way that serves real end users or real business operations: an
|
|
40
|
+
application people other than its developers and testers rely on, whether
|
|
41
|
+
inside one organisation or offered to others, whether or not it earns money.
|
|
42
|
+
Production is defined by operational use, not by revenue.
|
|
43
|
+
|
|
44
|
+
**Development Use** means any use that is not Production Use: reading,
|
|
45
|
+
evaluating, building, modifying, testing, demonstrating and running in
|
|
46
|
+
development, test, staging and continuous-integration environments, including
|
|
47
|
+
by and within a commercial organisation. A staging environment that real
|
|
48
|
+
users depend on is Production Use whatever it is called.
|
|
49
|
+
|
|
50
|
+
**Redistribution** means delivering the Software, or anything that
|
|
51
|
+
incorporates it, to a third party as part of a software product, a managed
|
|
52
|
+
service, a platform or a toolkit, such that the third party runs it rather
|
|
53
|
+
than you.
|
|
54
|
+
|
|
55
|
+
**Customer Data** means the contents of any dataset, submission, database or
|
|
56
|
+
file the Software is given or connects to, and anything the Software reads
|
|
57
|
+
from or writes to it.
|
|
58
|
+
|
|
59
|
+
**Generated Definitions** means the report definitions, templates, bindings,
|
|
60
|
+
styles, parameter forms, policies and other configuration the Software
|
|
61
|
+
generates or that a person creates with it, and the documents rendered from
|
|
62
|
+
them, PDF files included.
|
|
63
|
+
|
|
64
|
+
## 2. What is free
|
|
65
|
+
|
|
66
|
+
Subject to section 4, the Rightsholder grants you a worldwide, royalty-free,
|
|
67
|
+
non-exclusive licence to:
|
|
68
|
+
|
|
69
|
+
1. read, copy, fork and modify the Software;
|
|
70
|
+
2. use the Software and your modifications for Development Use, without limit
|
|
71
|
+
of time, number of people or size of organisation;
|
|
72
|
+
3. share the Software and your modifications with others for their
|
|
73
|
+
Development Use, under this licence and with this document attached.
|
|
74
|
+
|
|
75
|
+
No production licence is required to evaluate the Software for as long as you
|
|
76
|
+
like, and no evaluation period expires.
|
|
77
|
+
|
|
78
|
+
## 3. What is paid
|
|
79
|
+
|
|
80
|
+
**Production Use requires a production licence from the Rightsholder.** A
|
|
81
|
+
production licence is a separate written agreement. It is expected to be
|
|
82
|
+
granted per application, to cover that application's development, test and
|
|
83
|
+
replica environments without further charge, to specify support and update
|
|
84
|
+
entitlements, and to leave you the right to keep running the versions you
|
|
85
|
+
licensed if you later choose not to renew. Those are intentions; the agreement
|
|
86
|
+
you sign is what governs.
|
|
87
|
+
|
|
88
|
+
**Redistribution requires a separate commercial agreement.** Shipping the
|
|
89
|
+
Software inside a product, a platform or a managed service that other parties
|
|
90
|
+
run is not covered by a production licence for your own applications.
|
|
91
|
+
|
|
92
|
+
Running the Software in production without a production licence is a breach of
|
|
93
|
+
this licence.
|
|
94
|
+
|
|
95
|
+
## 4. Conditions
|
|
96
|
+
|
|
97
|
+
1. **Notices travel.** A copy of this document, and the NOTICE file, stays
|
|
98
|
+
with every copy and every modified version of the Software.
|
|
99
|
+
2. **Modified versions carry these terms.** A modified version of the Software
|
|
100
|
+
is the Software for the purposes of this licence. You may not remove or
|
|
101
|
+
circumvent the terms by modifying it.
|
|
102
|
+
3. **No trademark grant.** This licence grants no right to use the names
|
|
103
|
+
"Formancy", "Formancy Report", "Formancy Report Studio", "formancy.ai" or
|
|
104
|
+
any associated logo, beyond what is needed to identify the Software
|
|
105
|
+
truthfully.
|
|
106
|
+
4. **Third-party components keep their own licences.** The Software depends on
|
|
107
|
+
packages licensed under the Apache License, Version 2.0, among others. Those
|
|
108
|
+
licences continue to govern those components, their notices are preserved
|
|
109
|
+
in NOTICE, and nothing in this document narrows the rights they grant.
|
|
110
|
+
|
|
111
|
+
## 5. What stays yours
|
|
112
|
+
|
|
113
|
+
**Customer Data remains the customer's.** This licence grants the Rightsholder
|
|
114
|
+
no right of any kind over the data the Software is given or reads, and the
|
|
115
|
+
Software is designed not to send any of it anywhere.
|
|
116
|
+
|
|
117
|
+
**Generated Definitions remain yours.** Report definitions, templates,
|
|
118
|
+
bindings and policies you generate or author with the Software, and the
|
|
119
|
+
documents rendered from them, are yours, under whatever terms you choose.
|
|
120
|
+
They are not the Software, and this licence does not restrict them —
|
|
121
|
+
including after a production licence ends. A logo, a font or another asset
|
|
122
|
+
you place in a report keeps the rights it came with.
|
|
123
|
+
|
|
124
|
+
## 6. Contributions
|
|
125
|
+
|
|
126
|
+
Contributions to the Software are accepted under the Contributor License
|
|
127
|
+
Agreement in `CLA.md`, which grants the Rightsholder the right to distribute
|
|
128
|
+
them under this licence and under commercial agreements, and transfers no
|
|
129
|
+
ownership.
|
|
130
|
+
|
|
131
|
+
## 7. Termination
|
|
132
|
+
|
|
133
|
+
Your rights under this licence end automatically if you breach it and do not
|
|
134
|
+
cure the breach within thirty days of becoming aware of it. The rights in
|
|
135
|
+
section 5 do not end: your data, your definitions and your documents stay
|
|
136
|
+
yours in every case.
|
|
137
|
+
|
|
138
|
+
## 8. No warranty, limited liability
|
|
139
|
+
|
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
141
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
142
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
143
|
+
RIGHTSHOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
144
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
145
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
146
|
+
|
|
147
|
+
A production licence may provide warranties and support; this document does
|
|
148
|
+
not.
|
|
149
|
+
|
|
150
|
+
## 9. Obtaining a production licence
|
|
151
|
+
|
|
152
|
+
Production licences are requested from the Rightsholder at info@formancy.ai.
|
|
153
|
+
The separate commercial agreement that Redistribution requires, which
|
|
154
|
+
section 3 describes, is requested at the same address. The Software is new
|
|
155
|
+
and has no published price; the plan is to set the price after the first
|
|
156
|
+
design partners have established what the Software is worth to them.
|
|
157
|
+
|
|
158
|
+
## 10. Governing law and place of jurisdiction
|
|
159
|
+
|
|
160
|
+
This licence is governed by Swiss law, excluding its conflict-of-laws rules.
|
|
161
|
+
The place of jurisdiction is the Rightsholder's domicile in Switzerland.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Formancy Report
|
|
2
|
+
Copyright 2026 Daniel Bacher
|
|
3
|
+
|
|
4
|
+
This product is distributed under the Formancy Report Source-Available Licence
|
|
5
|
+
(LICENSE.md). It is not open source.
|
|
6
|
+
|
|
7
|
+
This product includes software developed by the formancy project
|
|
8
|
+
(https://github.com/sharkysan/formancy.ai), licensed under the Apache License,
|
|
9
|
+
Version 2.0. Those packages keep their licence; nothing here changes it.
|
package/README.md
CHANGED
|
@@ -1,3 +1,93 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formancy/report-runtime
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Formancy Report's runtime: it resolves a report definition against the data
|
|
4
|
+
a host hands it, and returns the renderer-neutral document a PDF engine
|
|
5
|
+
draws, or every reason it will not. It holds the data to the report's
|
|
6
|
+
dataset contracts, evaluates the report's expressions, groups, sorts and
|
|
7
|
+
totals with exact decimals, and formats each value for the report's locale,
|
|
8
|
+
once. No framework, no PDF engine, no Node. What it decides, and why, is
|
|
9
|
+
decision
|
|
10
|
+
[0010](../../docs/decisions/0010-the-runtime-resolves-a-report-into-a-renderer-neutral-document.md).
|
|
11
|
+
|
|
12
|
+
## Resolve
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { resolveReport } from '@formancy/report-runtime'
|
|
16
|
+
import type { ImageResolver, ReportData } from '@formancy/report-runtime'
|
|
17
|
+
|
|
18
|
+
const data: ReportData = {
|
|
19
|
+
header: { customer: 'Bäckerei Müller AG', quotedOn: '2026-10-15' },
|
|
20
|
+
detail: [{ article: 'A-1001', quantity: '1.00', amount: '480.00' }],
|
|
21
|
+
completeness: { complete: true, captured: 1 },
|
|
22
|
+
consistency: 'host-captured',
|
|
23
|
+
}
|
|
24
|
+
// The host's approved assets, by id and digest: the runtime never follows an address.
|
|
25
|
+
const images: ImageResolver = ({ asset, digest }) => approvedAssets.get(`${asset}@${digest}`)
|
|
26
|
+
|
|
27
|
+
const resolution = resolveReport(report, data, { mode: 'final', parameters: { copies: '2' }, images, creationDate: '2026-10-15T08:00:00Z', timeZone: 'Europe/Zurich' })
|
|
28
|
+
if (resolution.ok) {
|
|
29
|
+
resolution.document // what @formancy/report-render-pdf draws
|
|
30
|
+
resolution.manifest // the report's hash, locale, zone, mode, consistency, completeness, parameters
|
|
31
|
+
} else {
|
|
32
|
+
resolution.errors // each with the stage that found it, a stable code, a JSON Pointer, never a value
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`resolveReport` refuses, with every reason at once up to a bound:
|
|
37
|
+
|
|
38
|
+
- a report `validateReport` refuses, or one `diagnose` gives an error for
|
|
39
|
+
(stage `report` or `expressions`): the editor and the runtime refuse the
|
|
40
|
+
same reports;
|
|
41
|
+
- parameters and data that break their contracts (`parameters`, `data`);
|
|
42
|
+
- an expression that fails for a row (`evaluation`), naming the component,
|
|
43
|
+
the column or the aggregate and the row;
|
|
44
|
+
- a value a format cannot show, a locale or time zone the engine lacks
|
|
45
|
+
(`format`);
|
|
46
|
+
- an image the host has no bytes for, or bytes past 20 MB, and a total that
|
|
47
|
+
cannot be computed (`resolve`).
|
|
48
|
+
|
|
49
|
+
It never returns part of a document.
|
|
50
|
+
|
|
51
|
+
## The data
|
|
52
|
+
|
|
53
|
+
One header record and one detail list, with what the provider says about
|
|
54
|
+
them. Every value is held to its field's type before anything reads it:
|
|
55
|
+
|
|
56
|
+
| Type | Accepted as |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `integer` | a string of its digits, or a JavaScript number that is a safe integer |
|
|
59
|
+
| `decimal` | a canonical string within the field's scale; never a number, which has already lost digits |
|
|
60
|
+
| `date` | `YYYY-MM-DD`, a day on the calendar from 0001 to 9999 |
|
|
61
|
+
| `datetime` | `YYYY-MM-DDTHH:mm:ss`, with up to nine digits of a second, no zone |
|
|
62
|
+
| `instant` | an ISO 8601 date-time with its zone, held in UTC |
|
|
63
|
+
| `image` | `{ asset, digest }`, an approved asset, never an address |
|
|
64
|
+
|
|
65
|
+
A field the report does not declare is refused: a report never carries what
|
|
66
|
+
it does not print. Null prints as nothing; a field the data lacks is an
|
|
67
|
+
error in a final render, never an empty cell. A final render refuses data
|
|
68
|
+
the provider calls incomplete. A **preview** prints what it has, warns once
|
|
69
|
+
for each field it lacks, labels every page as a preview of incomplete data,
|
|
70
|
+
and says so in its manifest. The host's objects are read once, as data: a
|
|
71
|
+
getter is never run, and a proxy that throws is refused.
|
|
72
|
+
|
|
73
|
+
## What else is exported
|
|
74
|
+
|
|
75
|
+
Each stage is exported for a host or a tool that needs one alone:
|
|
76
|
+
`checkReport`, `checkData`, `checkParameters`, `readValue`,
|
|
77
|
+
`prepareExpressions`, `createFormatter`, `orderTable` and the decimal
|
|
78
|
+
arithmetic. The document's types, `RenderRefusal` and `REFUSAL_CODES` are
|
|
79
|
+
the renderer's contract, declared here so that no engine defines them.
|
|
80
|
+
|
|
81
|
+
## What it does not do
|
|
82
|
+
|
|
83
|
+
- **Fetch anything.** The data and the asset bytes are the host's to hand
|
|
84
|
+
over; the runtime reads no database and follows no address.
|
|
85
|
+
- **Check an image's digest.** It has no hash function without Node or the
|
|
86
|
+
DOM; the host's lookup is trusted to return the bytes the digest pins.
|
|
87
|
+
- **Format with one engine's results everywhere.** Grouping marks, month
|
|
88
|
+
names and currency symbols are the engine's ICU's, so the same report can
|
|
89
|
+
print differently on two engines.
|
|
90
|
+
- **Compile once per render.** Each expression is compiled twice: once by
|
|
91
|
+
`diagnose`, once to evaluate.
|
|
92
|
+
|
|
93
|
+
Source-available, not open source: see [`LICENSE.md`](../../LICENSE.md).
|