@formancy/report-spec 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 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,66 @@
1
- # Temporary Holding Version
1
+ # @formancy/report-spec
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Formancy Report definition: what a report template is, whether a document
4
+ is a valid one, and the hash that names it. No framework, no PDF engine, no
5
+ Node. Why a report is a document of its own, and what it holds, is decision
6
+ [0007](../../docs/decisions/0007-a-report-definition-is-its-own-versioned-document.md).
7
+
8
+ ## Validate
9
+
10
+ ```ts
11
+ import { validateReport } from '@formancy/report-spec'
12
+
13
+ const outcome = validateReport(JSON.parse(text))
14
+ if (!outcome.valid) {
15
+ for (const error of outcome.errors) {
16
+ // error.code is stable ('unknown-field', 'misplaced-detail-field', ...),
17
+ // error.path a JSON Pointer, error.componentId the component it is in.
18
+ console.warn(`${error.path}: ${error.message}`)
19
+ }
20
+ } else {
21
+ render(outcome.report) // a ReportDefinition, read once, sharing nothing with the input
22
+ }
23
+ ```
24
+
25
+ `validateReport` takes anything and never throws. It refuses:
26
+
27
+ - a formancy form, named as one, and a report of another version;
28
+ - anything a shape does not have, and every reference to something the
29
+ report does not declare;
30
+ - a value standing where it has none: a detail field outside the table's
31
+ cells, a page number outside the page header and footer;
32
+ - a fixed size the page cannot hold.
33
+
34
+ It reports up to `MAX_ERRORS` errors and says when there were more. It
35
+ checks structure only: whether an expression compiles, and whether the
36
+ rendered output fits, are the runtime's and the renderer's questions.
37
+
38
+ ## Hash
39
+
40
+ ```ts
41
+ import { reportHash } from '@formancy/report-spec'
42
+
43
+ const hash = reportHash(outcome.report) // 64 lower-case hex digits
44
+ ```
45
+
46
+ `reportHash` is `@formancy/spec`'s `schemaHash` over an envelope that names
47
+ the format, so key order never changes it and a form never shares one with a
48
+ report. It validates first, and throws a `RangeError` for a report the
49
+ validator refuses: only a valid report has a hash.
50
+
51
+ ## Start, find and measure
52
+
53
+ ```ts
54
+ import { componentAt, emptyReport, mmToPt, printableArea, walkComponents } from '@formancy/report-spec'
55
+
56
+ const blank = emptyReport('site-visit', 'Site visit', 'de-CH') // A4 portrait, 20 mm margins
57
+ const margin = mmToPt(15) // 42.52: lengths are points, stored to the hundredth
58
+ const { width } = printableArea(blank.page) // what the margins leave
59
+ for (const { component, path, depth } of walkComponents(blank)) console.log(depth, path, component.id)
60
+ componentAt(blank, 'title') // where a component is, by id: the path its errors use
61
+ ```
62
+
63
+ `REPORT_SPEC_VERSION` is `0`, the draft: nothing written under it is promised
64
+ to be read by a later release.
65
+
66
+ Source-available, not open source: see [`LICENSE.md`](../../LICENSE.md).