@formancy/report-data-provider 0.0.0-stage → 0.2.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 +17 -0
- package/README.md +100 -2
- package/dist/index.d.mts +79 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +302 -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,17 @@
|
|
|
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.
|
|
10
|
+
|
|
11
|
+
@formancy/report-render-pdf includes the Liberation Sans fonts, version
|
|
12
|
+
2.1.5, Regular and Bold, in its fonts directory and, as base64, in its
|
|
13
|
+
browser build. Digitized data copyright (c) 2010 Google Corporation, with
|
|
14
|
+
Reserved Font Arimo, Tinos and Cousine. Copyright (c) 2012 Red Hat, Inc.,
|
|
15
|
+
with Reserved Font Name Liberation. They are licensed under the SIL Open
|
|
16
|
+
Font License, Version 1.1, whose text travels with them as
|
|
17
|
+
fonts/LICENSE-LiberationSans.txt; nothing here changes it.
|
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @formancy/report-data-provider
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Formancy Report's Formancy Data provider. It reads a report's data from a
|
|
4
|
+
[Formancy Data](https://github.com/sharkysan/formancy.ai-data) server
|
|
5
|
+
through `@formancy/data-client` at exactly 0.1.0, as the person whose token
|
|
6
|
+
the client carries. It reads the header's one record, the detail rows a
|
|
7
|
+
page at a time and each lookup's label, and hands over the data
|
|
8
|
+
`@formancy/report-runtime` renders from, or every reason it will not. No
|
|
9
|
+
framework and no Node. It is the one package of this repository that may
|
|
10
|
+
depend on Data's contracts. What it decides, and why, is decision
|
|
11
|
+
[0016](../../docs/decisions/0016-the-data-provider-reads-formancy-data-0-1-0-best-effort.md).
|
|
12
|
+
|
|
13
|
+
**Best-effort.** Data 0.1.0 has no snapshot export, so the header, each
|
|
14
|
+
page and each label are read at different moments. The data says so in
|
|
15
|
+
its `consistency`, and the render's manifest carries it. A row changed
|
|
16
|
+
between two pages can be printed twice or not at all, and a total can mix
|
|
17
|
+
moments.
|
|
18
|
+
|
|
19
|
+
## Read a report's data
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createDataClient } from '@formancy/data-client'
|
|
23
|
+
import { readReportData } from '@formancy/report-data-provider'
|
|
24
|
+
import type { DataBinding, ProviderRead } from '@formancy/report-data-provider'
|
|
25
|
+
import { resolveReport } from '@formancy/report-runtime'
|
|
26
|
+
|
|
27
|
+
const client = createDataClient({ token: () => session.token(), base: dataServer })
|
|
28
|
+
const binding: DataBinding = { header: { form: 'quotation', record: quotationToken }, detail: { form: 'quotation-line', parent: 'header' } }
|
|
29
|
+
const provided: ProviderRead = await readReportData(client, quotation, binding, { cap: 5000 })
|
|
30
|
+
if (!provided.ok) throw new Error(provided.errors.map((error) => `${error.code} at ${error.path}`).join('; '))
|
|
31
|
+
const resolution = resolveReport(quotation, provided.data, { mode: 'final', images, creationDate: '2026-10-16T08:00:00Z' })
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The install gate runs these lines from the packed packages, against a
|
|
35
|
+
server that answers Data 0.1.0's routes, and they are held to it
|
|
36
|
+
(`scripts/readme-example.test.mjs`). Data hands over the data and nothing
|
|
37
|
+
else: `images` is the host's own lookup of its approved assets, as in
|
|
38
|
+
[the repository's README](../../README.md#render-a-report), here for the
|
|
39
|
+
quotation's mark, which the template names and no record holds.
|
|
40
|
+
|
|
41
|
+
**The binding** says which published form each dataset reads:
|
|
42
|
+
|
|
43
|
+
- `header` is one record, by the token Data gave for it.
|
|
44
|
+
- `detail` is a form's records in Data's order, or in `sort`'s.
|
|
45
|
+
- `parent: 'header'` narrows the detail rows to the header record's
|
|
46
|
+
children, by the lookup field the person's menu names between the two
|
|
47
|
+
forms. A field and a token can also be given outright.
|
|
48
|
+
|
|
49
|
+
A report field reads the form field with the same key.
|
|
50
|
+
|
|
51
|
+
**The checks before any record is read:**
|
|
52
|
+
- every dataset is bound, and nothing else;
|
|
53
|
+
- every field the report declares is one the form lets this person read;
|
|
54
|
+
- no field is an image, since Data 0.1.0 holds no approved asset;
|
|
55
|
+
- the detail form offers this person a list;
|
|
56
|
+
- the menu names the parent exactly once.
|
|
57
|
+
|
|
58
|
+
**The values** are Data's, as Data gives them (formancy.ai-data 0008):
|
|
59
|
+
- decimals and large integers as canonical strings;
|
|
60
|
+
- dates as `YYYY-MM-DD`;
|
|
61
|
+
- a timestamp with a zone as an instant, `…Z`. Declare it `instant`.
|
|
62
|
+
|
|
63
|
+
Whether each value fits its field is the runtime's to say, once. It
|
|
64
|
+
refuses a decimal with more digits than the report's scale, for example,
|
|
65
|
+
and nothing here rounds. Two translations are made:
|
|
66
|
+
- a nullable yes-or-no, which a Data form holds as the strings `"true"` and
|
|
67
|
+
`"false"`, becomes a boolean;
|
|
68
|
+
- a lookup becomes its label, asked of Data at most 50 tokens a request.
|
|
69
|
+
|
|
70
|
+
**The cap** is the most detail rows to read, at most the runtime's
|
|
71
|
+
`MAX_DETAIL_ROWS`, which is the default. Past it, the data says it is
|
|
72
|
+
incomplete: a final render refuses it, and a preview prints it labelled.
|
|
73
|
+
|
|
74
|
+
**A refusal** from Data hands over nothing. That covers a record that is
|
|
75
|
+
gone, a policy that says no and a server that is down, on any page. Data's
|
|
76
|
+
own sentence, status and code travel in the error.
|
|
77
|
+
|
|
78
|
+
## What it does not do
|
|
79
|
+
|
|
80
|
+
- **Give anyone more than their token.** Every request carries the token
|
|
81
|
+
the host's `token()` returns, and Data's policy decides what it answers.
|
|
82
|
+
A report rendered in a browser is exactly as authorised as that token.
|
|
83
|
+
- **Read consistently.** See above. Formancy Data's snapshot export, which
|
|
84
|
+
a consistent capture needs, is not built.
|
|
85
|
+
- **Print a label the person may not see.** Data leaves it out of its
|
|
86
|
+
answer, and the provider refuses the data, naming the field and never
|
|
87
|
+
the token, rather than print nothing or the token.
|
|
88
|
+
- **Read a float as a decimal.** A float column is a JavaScript number in a
|
|
89
|
+
Data form, and the runtime takes a decimal only as a string, so it
|
|
90
|
+
refuses one. A time of day, `HH:MM`, can be printed as a `string`.
|
|
91
|
+
- **Read a repeater's rows.** A report field reads an answer at the top of
|
|
92
|
+
a record, or inside a group or a page.
|
|
93
|
+
- **Speak to any other Data release.** It is built against 0.1.0's routes,
|
|
94
|
+
and a Data upgrade reaches it only through a release of this package
|
|
95
|
+
(0002).
|
|
96
|
+
|
|
97
|
+
**Licence.** Source-available, not open source: see
|
|
98
|
+
[`LICENSE.md`](../../LICENSE.md). It depends on Formancy Data's
|
|
99
|
+
`@formancy/data-client`, which is under the Formancy Data Source-Available
|
|
100
|
+
Licence on the same terms. Running it in production needs a production
|
|
101
|
+
licence for both.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DataClient, ListSortTerm } from "@formancy/data-client";
|
|
2
|
+
import { ReportData } from "@formancy/report-runtime";
|
|
3
|
+
import { ReportDefinition } from "@formancy/report-spec";
|
|
4
|
+
//#region src/binding.d.ts
|
|
5
|
+
/** The header's one record: a published form, and the token that addresses the record in it. */
|
|
6
|
+
interface HeaderBinding {
|
|
7
|
+
readonly form: string;
|
|
8
|
+
readonly record: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The detail rows: a published form's records, in the order of `sort`
|
|
12
|
+
* (Data's key order when there is none). `parent` narrows them to one
|
|
13
|
+
* record's children: `'header'` for the header record's, by the lookup
|
|
14
|
+
* field the person's menu names between the two forms, or a field and a
|
|
15
|
+
* record token given outright.
|
|
16
|
+
*/
|
|
17
|
+
interface DetailBinding {
|
|
18
|
+
readonly form: string;
|
|
19
|
+
readonly parent?: 'header' | {
|
|
20
|
+
readonly field: string;
|
|
21
|
+
readonly record: string;
|
|
22
|
+
};
|
|
23
|
+
readonly sort?: readonly ListSortTerm[];
|
|
24
|
+
}
|
|
25
|
+
/** Which published form each of the report's datasets reads. */
|
|
26
|
+
interface DataBinding {
|
|
27
|
+
readonly header?: HeaderBinding;
|
|
28
|
+
readonly detail?: DetailBinding;
|
|
29
|
+
}
|
|
30
|
+
export declare const PROVIDER_ERROR_CODES: readonly ["invalid-report", "invalid-cap", "unbound-dataset", "undeclared-dataset", "unknown-parent", "unreadable-field", "unsupported-field", "not-listable", "unresolved-label", "refused"];
|
|
31
|
+
type ProviderErrorCode = (typeof PROVIDER_ERROR_CODES)[number];
|
|
32
|
+
/**
|
|
33
|
+
* What the provider can say is wrong. The path is a JSON Pointer into the
|
|
34
|
+
* binding -- `/detail/parent` -- or into the data it would have handed over
|
|
35
|
+
* -- `/header/customer`, `/detail/17/order`. Neither it nor the message
|
|
36
|
+
* ever holds a value: a token or an answer is the customer's, and an error
|
|
37
|
+
* ends up in a log. Data's own sentences promise the same
|
|
38
|
+
* (formancy.ai-data 0011).
|
|
39
|
+
*/
|
|
40
|
+
interface ProviderError {
|
|
41
|
+
readonly path: string;
|
|
42
|
+
readonly code: ProviderErrorCode;
|
|
43
|
+
readonly message: string;
|
|
44
|
+
/** Data's answer, when Data refused: its HTTP status (0 when nothing answered) and its code. */
|
|
45
|
+
readonly refusal?: {
|
|
46
|
+
readonly status: number;
|
|
47
|
+
readonly code: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/read.d.ts
|
|
52
|
+
interface ReadOptions {
|
|
53
|
+
/**
|
|
54
|
+
* The most detail rows to read: a whole number from 1 to the runtime's
|
|
55
|
+
* `MAX_DETAIL_ROWS`, which is the default. With more rows than that, the
|
|
56
|
+
* data says it is incomplete, and a final render refuses it.
|
|
57
|
+
*/
|
|
58
|
+
readonly cap?: number;
|
|
59
|
+
/** Stops the reads still to come; the call then rejects with the abort. */
|
|
60
|
+
readonly signal?: AbortSignal;
|
|
61
|
+
}
|
|
62
|
+
type ProviderRead = {
|
|
63
|
+
readonly ok: true;
|
|
64
|
+
readonly data: ReportData;
|
|
65
|
+
} | {
|
|
66
|
+
readonly ok: false;
|
|
67
|
+
readonly errors: readonly ProviderError[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The data `report` renders from, read from Formancy Data through `client`
|
|
71
|
+
* where `binding` says, or every reason it was not. Its consistency is
|
|
72
|
+
* `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and
|
|
73
|
+
* each label are read at different moments. Rejects only with the abort
|
|
74
|
+
* `options.signal` raised.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readReportData(client: DataClient, report: ReportDefinition, binding: DataBinding, options?: ReadOptions): Promise<ProviderRead>;
|
|
77
|
+
//#endregion
|
|
78
|
+
export type { DataBinding, DetailBinding, HeaderBinding, ProviderError, ProviderErrorCode, ProviderRead, ReadOptions };
|
|
79
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/binding.ts","../src/read.ts"],"mappings":";;;;;UASiB;WACN;WACA;;;;;;;;;UAUM;WACN;WACA;aAA+B;aAAwB;;WACvD,gBAAgB;;;UAIV;WACN,SAAS;WACT,SAAS;;qBAGP;KAsBD,4BAA4B;;;;;;;;;UAUvB;WACN;WACA,MAAM;WACN;;WAEA;aAAqB;aAAyB;;;;;UCjDxC;;;;;;WAMN;;WAEA,SAAS;;KAGR;WAA0B;WAAmB,MAAM;;WAA0B;WAAoB,iBAAiB;;;;;;;;;wBAkGxG,eAAe,QAAQ,YAAY,QAAQ,kBAAkB,SAAS,aAAa,UAAS,cAAmB,QAAQ"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { LIST_PAGE_SIZE } from "@formancy/data-client";
|
|
2
|
+
import { MAX_DETAIL_ROWS } from "@formancy/report-runtime";
|
|
3
|
+
import { validateReport } from "@formancy/report-spec";
|
|
4
|
+
//#region src/binding.ts
|
|
5
|
+
const PROVIDER_ERROR_CODES = [
|
|
6
|
+
"invalid-report",
|
|
7
|
+
"invalid-cap",
|
|
8
|
+
"unbound-dataset",
|
|
9
|
+
"undeclared-dataset",
|
|
10
|
+
"unknown-parent",
|
|
11
|
+
"unreadable-field",
|
|
12
|
+
"unsupported-field",
|
|
13
|
+
"not-listable",
|
|
14
|
+
"unresolved-label",
|
|
15
|
+
"refused"
|
|
16
|
+
];
|
|
17
|
+
const ROLES = ["header", "detail"];
|
|
18
|
+
/** A binding that says where each declared dataset is, and nothing else. */
|
|
19
|
+
function bindingErrors(datasets, binding) {
|
|
20
|
+
const errors = [];
|
|
21
|
+
for (const role of ROLES) {
|
|
22
|
+
const declared = datasets[role] !== void 0;
|
|
23
|
+
const bound = binding[role] !== void 0;
|
|
24
|
+
if (declared && !bound) errors.push({
|
|
25
|
+
path: `/${role}`,
|
|
26
|
+
code: "unbound-dataset",
|
|
27
|
+
message: `the report reads a ${role} dataset and the binding names no form for it`
|
|
28
|
+
});
|
|
29
|
+
if (bound && !declared) errors.push({
|
|
30
|
+
path: `/${role}`,
|
|
31
|
+
code: "undeclared-dataset",
|
|
32
|
+
message: `the binding names a form for a ${role} dataset the report does not declare`
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return errors;
|
|
36
|
+
}
|
|
37
|
+
/** Every field whose answer is in a record, by key: groups and pages hold fields of the record; a repeater's are inside its rows. */
|
|
38
|
+
function answeredFields(fields, into = /* @__PURE__ */ new Map()) {
|
|
39
|
+
for (const field of fields) if (field.type === "group" || field.type === "page") answeredFields(field.fields ?? [], into);
|
|
40
|
+
else if (field.type !== "repeater") into.set(field.key, field);
|
|
41
|
+
return into;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A nullable yes-or-no column, as Data generates its control: a radio of
|
|
45
|
+
* exactly "true" and "false" (formancy.ai-data's controls), whose answer is
|
|
46
|
+
* one of those strings or null. A report that reads it as a boolean gets
|
|
47
|
+
* true or false.
|
|
48
|
+
*/
|
|
49
|
+
function isYesOrNo(field) {
|
|
50
|
+
const values = (field.options ?? []).map((option) => option.value);
|
|
51
|
+
return field.type === "radio" && values.length === 2 && values.includes("true") && values.includes("false");
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* What `published` says about reading `contract` from it, for this person:
|
|
55
|
+
* every declared field readable, none an image, and how each is read.
|
|
56
|
+
*/
|
|
57
|
+
function planFields(role, contract, published) {
|
|
58
|
+
const readable = new Set(published.readable);
|
|
59
|
+
const fields = answeredFields(published.form.model.fields);
|
|
60
|
+
const errors = [];
|
|
61
|
+
const lookups = /* @__PURE__ */ new Map();
|
|
62
|
+
const yesOrNo = /* @__PURE__ */ new Set();
|
|
63
|
+
for (const declared of contract.fields) {
|
|
64
|
+
const path = `/${role}/${declared.id}`;
|
|
65
|
+
const field = fields.get(declared.id);
|
|
66
|
+
if (declared.type === "image") errors.push({
|
|
67
|
+
path,
|
|
68
|
+
code: "unsupported-field",
|
|
69
|
+
message: `${declared.id} is an image field, and a Formancy Data 0.1.0 form holds no approved asset to print`
|
|
70
|
+
});
|
|
71
|
+
else if (field === void 0 || !readable.has(declared.id)) errors.push({
|
|
72
|
+
path,
|
|
73
|
+
code: "unreadable-field",
|
|
74
|
+
message: `the form gives this person no field ${declared.id} to read: the form does not have it, or its policy does not let them read it`
|
|
75
|
+
});
|
|
76
|
+
else if (typeof field.optionsSource === "string") lookups.set(declared.id, field.optionsSource);
|
|
77
|
+
else if (declared.type === "boolean" && isYesOrNo(field)) yesOrNo.add(declared.id);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
plan: {
|
|
81
|
+
fields: contract.fields.map((field) => field.id),
|
|
82
|
+
lookups,
|
|
83
|
+
yesOrNo
|
|
84
|
+
},
|
|
85
|
+
errors
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/read.ts
|
|
90
|
+
/**
|
|
91
|
+
* A report's data, read from Formancy Data 0.1.0's runtime plane through
|
|
92
|
+
* `@formancy/data-client`, as the person whose token the client carries:
|
|
93
|
+
* the header's one record, the detail rows a page at a time, and each
|
|
94
|
+
* lookup's label. Everything that can be checked without a record -- the
|
|
95
|
+
* binding, the fields the person may read, the parent -- is checked first,
|
|
96
|
+
* and a refusal anywhere hands over nothing.
|
|
97
|
+
*
|
|
98
|
+
* The values are Data's, as Data gave them, with one translation: a
|
|
99
|
+
* nullable yes-or-no's "true" and "false" become booleans. Whether each
|
|
100
|
+
* fits its field is the runtime's to say, once (0010).
|
|
101
|
+
*/
|
|
102
|
+
const refused = (errors) => ({
|
|
103
|
+
ok: false,
|
|
104
|
+
errors
|
|
105
|
+
});
|
|
106
|
+
/** Data's refusal, as the provider passes it on: Data's sentence, status and code. */
|
|
107
|
+
function fromRefusal(path, refusal) {
|
|
108
|
+
return {
|
|
109
|
+
path,
|
|
110
|
+
code: "refused",
|
|
111
|
+
message: refusal.message,
|
|
112
|
+
refusal: {
|
|
113
|
+
status: refusal.status,
|
|
114
|
+
code: refusal.code
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** The declared fields of one record, nothing else it holds, with yes-or-no strings read as booleans. */
|
|
119
|
+
function pick(record, plan) {
|
|
120
|
+
const answers = {};
|
|
121
|
+
for (const field of plan.fields) {
|
|
122
|
+
if (!Object.hasOwn(record.answers, field)) continue;
|
|
123
|
+
const value = record.answers[field];
|
|
124
|
+
answers[field] = plan.yesOrNo.has(field) && (value === "true" || value === "false") ? value === "true" : value;
|
|
125
|
+
}
|
|
126
|
+
return answers;
|
|
127
|
+
}
|
|
128
|
+
/** The parent the detail rows are narrowed to: given, or the header record by the one field the person's menu names. */
|
|
129
|
+
async function parentOf(client, header, detail, signal) {
|
|
130
|
+
if (detail.parent !== "header") return detail.parent;
|
|
131
|
+
const unknown = (message) => ({
|
|
132
|
+
path: "/detail/parent",
|
|
133
|
+
code: "unknown-parent",
|
|
134
|
+
message
|
|
135
|
+
});
|
|
136
|
+
if (header === void 0) return unknown("parent 'header' reads the header record's children, and the binding names no header record");
|
|
137
|
+
const menu = await client.forms(signal);
|
|
138
|
+
if (!menu.ok) return fromRefusal("/detail/parent", menu);
|
|
139
|
+
const fields = (menu.value.forms.find((form) => form.id === header.form)?.children ?? []).filter((child) => child.form === detail.form).map((child) => child.field);
|
|
140
|
+
const [field] = fields;
|
|
141
|
+
if (fields.length === 1 && field !== void 0) return {
|
|
142
|
+
field,
|
|
143
|
+
record: header.record
|
|
144
|
+
};
|
|
145
|
+
return unknown(fields.length === 0 ? "this person's menu does not list the detail form as a child of the header form" : "this person's menu lists the detail form under the header form by more than one field; name the field in parent");
|
|
146
|
+
}
|
|
147
|
+
/** Every detail row up to `cap`, a page at a time from offset 0, and whether Data said none follow. */
|
|
148
|
+
async function readRows(client, detail, parent, cap, signal) {
|
|
149
|
+
const rows = [];
|
|
150
|
+
for (let offset = 0; offset < cap;) {
|
|
151
|
+
const limit = Math.min(LIST_PAGE_SIZE, cap - offset);
|
|
152
|
+
const page = await client.list(detail.form, {
|
|
153
|
+
...detail.sort === void 0 ? {} : { sort: [...detail.sort] },
|
|
154
|
+
...parent === void 0 ? {} : { parent },
|
|
155
|
+
offset,
|
|
156
|
+
limit
|
|
157
|
+
}, signal);
|
|
158
|
+
if (!page.ok) return fromRefusal("/detail", page);
|
|
159
|
+
rows.push(...page.value.rows.slice(0, limit));
|
|
160
|
+
if (!page.value.hasMore) return {
|
|
161
|
+
rows,
|
|
162
|
+
complete: true
|
|
163
|
+
};
|
|
164
|
+
offset += limit;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
rows,
|
|
168
|
+
complete: false
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Each lookup value in `records` replaced by its label, asked of Data at
|
|
173
|
+
* most a page's worth of tokens a request (formancy.ai-data 0044), each
|
|
174
|
+
* token once. A token whose label Data did not give is an error naming the
|
|
175
|
+
* field and where it first is, never the token.
|
|
176
|
+
*/
|
|
177
|
+
async function labelled(client, role, form, plan, records, signal) {
|
|
178
|
+
const errors = [];
|
|
179
|
+
for (const [field, source] of plan.lookups) {
|
|
180
|
+
const tokens = [...new Set(records.map((record) => record[field]).filter((value) => typeof value === "string"))];
|
|
181
|
+
const labels = /* @__PURE__ */ new Map();
|
|
182
|
+
for (let at = 0; at < tokens.length; at += LIST_PAGE_SIZE) {
|
|
183
|
+
const resolved = await client.resolve(form, source, {
|
|
184
|
+
operation: "read",
|
|
185
|
+
tokens: tokens.slice(at, at + LIST_PAGE_SIZE)
|
|
186
|
+
}, signal);
|
|
187
|
+
if (!resolved.ok) return [fromRefusal(`/${role}`, resolved)];
|
|
188
|
+
for (const row of resolved.value) labels.set(row.token, row.label);
|
|
189
|
+
}
|
|
190
|
+
let unresolved = 0;
|
|
191
|
+
let first = -1;
|
|
192
|
+
records.forEach((record, index) => {
|
|
193
|
+
const value = record[field];
|
|
194
|
+
if (typeof value !== "string") return;
|
|
195
|
+
const label = labels.get(value);
|
|
196
|
+
if (label !== void 0) record[field] = label;
|
|
197
|
+
else if (unresolved++ === 0) first = index;
|
|
198
|
+
});
|
|
199
|
+
if (unresolved > 0) {
|
|
200
|
+
const path = role === "header" ? `/header/${field}` : `/detail/${String(first)}/${field}`;
|
|
201
|
+
const message = unresolved === 1 ? `one value of ${field} names a record whose label this person may not see` : `${String(unresolved)} values of ${field} name records whose label this person may not see`;
|
|
202
|
+
errors.push({
|
|
203
|
+
path,
|
|
204
|
+
code: "unresolved-label",
|
|
205
|
+
message
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return errors;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The data `report` renders from, read from Formancy Data through `client`
|
|
213
|
+
* where `binding` says, or every reason it was not. Its consistency is
|
|
214
|
+
* `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and
|
|
215
|
+
* each label are read at different moments. Rejects only with the abort
|
|
216
|
+
* `options.signal` raised.
|
|
217
|
+
*/
|
|
218
|
+
async function readReportData(client, report, binding, options = {}) {
|
|
219
|
+
const { signal } = options;
|
|
220
|
+
signal?.throwIfAborted();
|
|
221
|
+
const checked = validateReport(report);
|
|
222
|
+
if (!checked.valid) return refused([{
|
|
223
|
+
path: "",
|
|
224
|
+
code: "invalid-report",
|
|
225
|
+
message: "report-spec refuses this report; validateReport says why"
|
|
226
|
+
}]);
|
|
227
|
+
const cap = options.cap ?? MAX_DETAIL_ROWS;
|
|
228
|
+
if (!Number.isInteger(cap) || cap < 1 || cap > MAX_DETAIL_ROWS) return refused([{
|
|
229
|
+
path: "",
|
|
230
|
+
code: "invalid-cap",
|
|
231
|
+
message: `a cap is a whole number of rows from 1 to ${String(MAX_DETAIL_ROWS)}`
|
|
232
|
+
}]);
|
|
233
|
+
const { datasets } = checked.report;
|
|
234
|
+
const unbound = bindingErrors(datasets, binding);
|
|
235
|
+
if (unbound.length > 0) return refused(unbound);
|
|
236
|
+
const plans = /* @__PURE__ */ new Map();
|
|
237
|
+
const errors = [];
|
|
238
|
+
for (const role of ROLES) {
|
|
239
|
+
const contract = datasets[role];
|
|
240
|
+
const bound = binding[role];
|
|
241
|
+
if (contract === void 0 || bound === void 0) continue;
|
|
242
|
+
signal?.throwIfAborted();
|
|
243
|
+
const published = await client.form(bound.form);
|
|
244
|
+
if (!published.ok) return refused([fromRefusal(`/${role}`, published)]);
|
|
245
|
+
const { plan, errors: found } = planFields(role, contract, published.value);
|
|
246
|
+
errors.push(...found);
|
|
247
|
+
if (role === "detail" && published.value.list === null) errors.push({
|
|
248
|
+
path: "/detail",
|
|
249
|
+
code: "not-listable",
|
|
250
|
+
message: "the detail form offers this person no list of its records"
|
|
251
|
+
});
|
|
252
|
+
plans.set(role, plan);
|
|
253
|
+
}
|
|
254
|
+
let parent;
|
|
255
|
+
if (binding.detail !== void 0) {
|
|
256
|
+
const found = await parentOf(client, binding.header, binding.detail, signal);
|
|
257
|
+
if (found !== void 0 && "code" in found) errors.push(found);
|
|
258
|
+
else parent = found;
|
|
259
|
+
}
|
|
260
|
+
if (errors.length > 0) return refused(errors);
|
|
261
|
+
const headerPlan = plans.get("header");
|
|
262
|
+
let header;
|
|
263
|
+
if (binding.header !== void 0 && headerPlan !== void 0) {
|
|
264
|
+
signal?.throwIfAborted();
|
|
265
|
+
const record = await client.read(binding.header.form, binding.header.record);
|
|
266
|
+
if (!record.ok) return refused([fromRefusal("/header", record)]);
|
|
267
|
+
header = pick(record.value, headerPlan);
|
|
268
|
+
errors.push(...await labelled(client, "header", binding.header.form, headerPlan, [header], signal));
|
|
269
|
+
}
|
|
270
|
+
const detailPlan = plans.get("detail");
|
|
271
|
+
let detail;
|
|
272
|
+
if (binding.detail !== void 0 && detailPlan !== void 0) {
|
|
273
|
+
const read = await readRows(client, binding.detail, parent, cap, signal);
|
|
274
|
+
if ("code" in read) return refused([read]);
|
|
275
|
+
detail = {
|
|
276
|
+
rows: read.rows.map((row) => pick(row, detailPlan)),
|
|
277
|
+
complete: read.complete
|
|
278
|
+
};
|
|
279
|
+
errors.push(...await labelled(client, "detail", binding.detail.form, detailPlan, detail.rows, signal));
|
|
280
|
+
}
|
|
281
|
+
if (errors.length > 0) return refused(errors);
|
|
282
|
+
return {
|
|
283
|
+
ok: true,
|
|
284
|
+
data: {
|
|
285
|
+
...header === void 0 ? {} : { header },
|
|
286
|
+
...detail === void 0 ? {} : { detail: detail.rows },
|
|
287
|
+
completeness: detail === void 0 ? {
|
|
288
|
+
complete: true,
|
|
289
|
+
captured: 0
|
|
290
|
+
} : {
|
|
291
|
+
complete: detail.complete,
|
|
292
|
+
captured: detail.rows.length,
|
|
293
|
+
cap
|
|
294
|
+
},
|
|
295
|
+
consistency: "best-effort"
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
export { PROVIDER_ERROR_CODES, readReportData };
|
|
301
|
+
|
|
302
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/binding.ts","../src/read.ts"],"sourcesContent":["/**\n * Where a report's datasets come from in Formancy Data, and what a published\n * form says about the fields a report reads from it -- everything the\n * provider can check before it reads a record.\n */\nimport type { ListSortTerm, PublishedForm } from '@formancy/data-client'\nimport type { DatasetContract, DatasetRole, Datasets } from '@formancy/report-spec'\n\n/** The header's one record: a published form, and the token that addresses the record in it. */\nexport interface HeaderBinding {\n readonly form: string\n readonly record: string\n}\n\n/**\n * The detail rows: a published form's records, in the order of `sort`\n * (Data's key order when there is none). `parent` narrows them to one\n * record's children: `'header'` for the header record's, by the lookup\n * field the person's menu names between the two forms, or a field and a\n * record token given outright.\n */\nexport interface DetailBinding {\n readonly form: string\n readonly parent?: 'header' | { readonly field: string; readonly record: string }\n readonly sort?: readonly ListSortTerm[]\n}\n\n/** Which published form each of the report's datasets reads. */\nexport interface DataBinding {\n readonly header?: HeaderBinding\n readonly detail?: DetailBinding\n}\n\nexport const PROVIDER_ERROR_CODES = [\n /** A report that `validateReport` refuses: the runtime would refuse it too, and says why. */\n 'invalid-report',\n /** A cap that is not a whole number from 1 to the runtime's `MAX_DETAIL_ROWS`. */\n 'invalid-cap',\n /** A dataset the report declares and the binding does not say where to read. */\n 'unbound-dataset',\n /** A binding for a dataset the report does not declare. */\n 'undeclared-dataset',\n /** `parent: 'header'`, and the person's menu does not name the detail form as the header form's child exactly once. */\n 'unknown-parent',\n /** A field the report declares that the form does not let this person read, or does not have. */\n 'unreadable-field',\n /** An image field: Data 0.1.0 holds no approved asset for one to print. */\n 'unsupported-field',\n /** The detail form offers this person no list of its records. */\n 'not-listable',\n /** A lookup value whose label Data did not give this person. */\n 'unresolved-label',\n /** Data refused a request; `refusal` carries its status and code, and the message is its sentence. */\n 'refused',\n] as const\nexport type ProviderErrorCode = (typeof PROVIDER_ERROR_CODES)[number]\n\n/**\n * What the provider can say is wrong. The path is a JSON Pointer into the\n * binding -- `/detail/parent` -- or into the data it would have handed over\n * -- `/header/customer`, `/detail/17/order`. Neither it nor the message\n * ever holds a value: a token or an answer is the customer's, and an error\n * ends up in a log. Data's own sentences promise the same\n * (formancy.ai-data 0011).\n */\nexport interface ProviderError {\n readonly path: string\n readonly code: ProviderErrorCode\n readonly message: string\n /** Data's answer, when Data refused: its HTTP status (0 when nothing answered) and its code. */\n readonly refusal?: { readonly status: number; readonly code: string }\n}\n\nexport const ROLES: readonly DatasetRole[] = ['header', 'detail']\n\n/** A binding that says where each declared dataset is, and nothing else. */\nexport function bindingErrors(datasets: Datasets, binding: DataBinding): ProviderError[] {\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const declared = datasets[role] !== undefined\n const bound = binding[role] !== undefined\n if (declared && !bound) errors.push({ path: `/${role}`, code: 'unbound-dataset', message: `the report reads a ${role} dataset and the binding names no form for it` })\n if (bound && !declared) errors.push({ path: `/${role}`, code: 'undeclared-dataset', message: `the binding names a form for a ${role} dataset the report does not declare` })\n }\n return errors\n}\n\ntype Field = PublishedForm['form']['model']['fields'][number]\n\n/** Every field whose answer is in a record, by key: groups and pages hold fields of the record; a repeater's are inside its rows. */\nfunction answeredFields(fields: readonly Field[], into = new Map<string, Field>()): Map<string, Field> {\n for (const field of fields) {\n if (field.type === 'group' || field.type === 'page') answeredFields(field.fields ?? [], into)\n else if (field.type !== 'repeater') into.set(field.key, field)\n }\n return into\n}\n\n/**\n * A nullable yes-or-no column, as Data generates its control: a radio of\n * exactly \"true\" and \"false\" (formancy.ai-data's controls), whose answer is\n * one of those strings or null. A report that reads it as a boolean gets\n * true or false.\n */\nfunction isYesOrNo(field: Field): boolean {\n const values = (field.options ?? []).map((option) => option.value)\n return field.type === 'radio' && values.length === 2 && values.includes('true') && values.includes('false')\n}\n\n/** How the provider reads one dataset's fields from a form: which are lookups, by source, and which yes-or-no strings become booleans. */\nexport interface FieldPlan {\n readonly fields: readonly string[]\n readonly lookups: ReadonlyMap<string, string>\n readonly yesOrNo: ReadonlySet<string>\n}\n\n/**\n * What `published` says about reading `contract` from it, for this person:\n * every declared field readable, none an image, and how each is read.\n */\nexport function planFields(role: DatasetRole, contract: DatasetContract, published: PublishedForm): { plan: FieldPlan; errors: ProviderError[] } {\n const readable = new Set(published.readable)\n const fields = answeredFields(published.form.model.fields)\n const errors: ProviderError[] = []\n const lookups = new Map<string, string>()\n const yesOrNo = new Set<string>()\n for (const declared of contract.fields) {\n const path = `/${role}/${declared.id}`\n const field = fields.get(declared.id)\n if (declared.type === 'image') {\n errors.push({ path, code: 'unsupported-field', message: `${declared.id} is an image field, and a Formancy Data 0.1.0 form holds no approved asset to print` })\n } else if (field === undefined || !readable.has(declared.id)) {\n errors.push({ path, code: 'unreadable-field', message: `the form gives this person no field ${declared.id} to read: the form does not have it, or its policy does not let them read it` })\n } else if (typeof field.optionsSource === 'string') {\n lookups.set(declared.id, field.optionsSource)\n } else if (declared.type === 'boolean' && isYesOrNo(field)) {\n yesOrNo.add(declared.id)\n }\n }\n return { plan: { fields: contract.fields.map((field) => field.id), lookups, yesOrNo }, errors }\n}\n","/**\n * A report's data, read from Formancy Data 0.1.0's runtime plane through\n * `@formancy/data-client`, as the person whose token the client carries:\n * the header's one record, the detail rows a page at a time, and each\n * lookup's label. Everything that can be checked without a record -- the\n * binding, the fields the person may read, the parent -- is checked first,\n * and a refusal anywhere hands over nothing.\n *\n * The values are Data's, as Data gave them, with one translation: a\n * nullable yes-or-no's \"true\" and \"false\" become booleans. Whether each\n * fits its field is the runtime's to say, once (0010).\n */\nimport { LIST_PAGE_SIZE } from '@formancy/data-client'\nimport type { DataClient, FormRecord, Refusal } from '@formancy/data-client'\nimport { MAX_DETAIL_ROWS } from '@formancy/report-runtime'\nimport type { ReportData } from '@formancy/report-runtime'\nimport { validateReport } from '@formancy/report-spec'\nimport type { DatasetRole, ReportDefinition } from '@formancy/report-spec'\nimport { bindingErrors, planFields, ROLES } from './binding.js'\nimport type { DataBinding, DetailBinding, FieldPlan, HeaderBinding, ProviderError } from './binding.js'\n\nexport interface ReadOptions {\n /**\n * The most detail rows to read: a whole number from 1 to the runtime's\n * `MAX_DETAIL_ROWS`, which is the default. With more rows than that, the\n * data says it is incomplete, and a final render refuses it.\n */\n readonly cap?: number\n /** Stops the reads still to come; the call then rejects with the abort. */\n readonly signal?: AbortSignal\n}\n\nexport type ProviderRead = { readonly ok: true; readonly data: ReportData } | { readonly ok: false; readonly errors: readonly ProviderError[] }\n\ntype Answers = Record<string, unknown>\ntype Parent = { readonly field: string; readonly record: string }\n\nconst refused = (errors: readonly ProviderError[]): ProviderRead => ({ ok: false, errors })\n\n/** Data's refusal, as the provider passes it on: Data's sentence, status and code. */\nfunction fromRefusal(path: string, refusal: Refusal): ProviderError {\n return { path, code: 'refused', message: refusal.message, refusal: { status: refusal.status, code: refusal.code } }\n}\n\n/** The declared fields of one record, nothing else it holds, with yes-or-no strings read as booleans. */\nfunction pick(record: FormRecord, plan: FieldPlan): Answers {\n const answers: Answers = {}\n for (const field of plan.fields) {\n if (!Object.hasOwn(record.answers, field)) continue\n const value = record.answers[field]\n answers[field] = plan.yesOrNo.has(field) && (value === 'true' || value === 'false') ? value === 'true' : value\n }\n return answers\n}\n\n/** The parent the detail rows are narrowed to: given, or the header record by the one field the person's menu names. */\nasync function parentOf(client: DataClient, header: HeaderBinding | undefined, detail: DetailBinding, signal?: AbortSignal): Promise<Parent | undefined | ProviderError> {\n if (detail.parent !== 'header') return detail.parent\n const unknown = (message: string): ProviderError => ({ path: '/detail/parent', code: 'unknown-parent', message })\n if (header === undefined) return unknown(\"parent 'header' reads the header record's children, and the binding names no header record\")\n const menu = await client.forms(signal)\n if (!menu.ok) return fromRefusal('/detail/parent', menu)\n const children = menu.value.forms.find((form) => form.id === header.form)?.children ?? []\n const fields = children.filter((child) => child.form === detail.form).map((child) => child.field)\n const [field] = fields\n if (fields.length === 1 && field !== undefined) return { field, record: header.record }\n return unknown(\n fields.length === 0\n ? \"this person's menu does not list the detail form as a child of the header form\"\n : \"this person's menu lists the detail form under the header form by more than one field; name the field in parent\",\n )\n}\n\n/** Every detail row up to `cap`, a page at a time from offset 0, and whether Data said none follow. */\nasync function readRows(client: DataClient, detail: DetailBinding, parent: Parent | undefined, cap: number, signal?: AbortSignal): Promise<{ rows: FormRecord[]; complete: boolean } | ProviderError> {\n const rows: FormRecord[] = []\n // The offset moves by the page asked for, Data's own arithmetic: a row it\n // cannot address is still in its place (formancy.ai-data 0044).\n for (let offset = 0; offset < cap; ) {\n const limit = Math.min(LIST_PAGE_SIZE, cap - offset)\n const page = await client.list(detail.form, { ...(detail.sort === undefined ? {} : { sort: [...detail.sort] }), ...(parent === undefined ? {} : { parent }), offset, limit }, signal)\n if (!page.ok) return fromRefusal('/detail', page)\n rows.push(...page.value.rows.slice(0, limit))\n if (!page.value.hasMore) return { rows, complete: true }\n offset += limit\n }\n return { rows, complete: false }\n}\n\n/**\n * Each lookup value in `records` replaced by its label, asked of Data at\n * most a page's worth of tokens a request (formancy.ai-data 0044), each\n * token once. A token whose label Data did not give is an error naming the\n * field and where it first is, never the token.\n */\nasync function labelled(client: DataClient, role: DatasetRole, form: string, plan: FieldPlan, records: Answers[], signal?: AbortSignal): Promise<ProviderError[]> {\n const errors: ProviderError[] = []\n for (const [field, source] of plan.lookups) {\n const tokens = [...new Set(records.map((record) => record[field]).filter((value): value is string => typeof value === 'string'))]\n const labels = new Map<string, string>()\n for (let at = 0; at < tokens.length; at += LIST_PAGE_SIZE) {\n const resolved = await client.resolve(form, source, { operation: 'read', tokens: tokens.slice(at, at + LIST_PAGE_SIZE) }, signal)\n if (!resolved.ok) return [fromRefusal(`/${role}`, resolved)]\n for (const row of resolved.value) labels.set(row.token, row.label)\n }\n let unresolved = 0\n let first = -1\n records.forEach((record, index) => {\n const value = record[field]\n if (typeof value !== 'string') return\n const label = labels.get(value)\n if (label !== undefined) record[field] = label\n else if (unresolved++ === 0) first = index\n })\n if (unresolved > 0) {\n const path = role === 'header' ? `/header/${field}` : `/detail/${String(first)}/${field}`\n const message = unresolved === 1 ? `one value of ${field} names a record whose label this person may not see` : `${String(unresolved)} values of ${field} name records whose label this person may not see`\n errors.push({ path, code: 'unresolved-label', message })\n }\n }\n return errors\n}\n\n/**\n * The data `report` renders from, read from Formancy Data through `client`\n * where `binding` says, or every reason it was not. Its consistency is\n * `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and\n * each label are read at different moments. Rejects only with the abort\n * `options.signal` raised.\n */\nexport async function readReportData(client: DataClient, report: ReportDefinition, binding: DataBinding, options: ReadOptions = {}): Promise<ProviderRead> {\n const { signal } = options\n signal?.throwIfAborted()\n const checked = validateReport(report)\n if (!checked.valid) return refused([{ path: '', code: 'invalid-report', message: 'report-spec refuses this report; validateReport says why' }])\n const cap = options.cap ?? MAX_DETAIL_ROWS\n if (!Number.isInteger(cap) || cap < 1 || cap > MAX_DETAIL_ROWS) {\n return refused([{ path: '', code: 'invalid-cap', message: `a cap is a whole number of rows from 1 to ${String(MAX_DETAIL_ROWS)}` }])\n }\n const { datasets } = checked.report\n const unbound = bindingErrors(datasets, binding)\n if (unbound.length > 0) return refused(unbound)\n\n // Every form, and the parent, before any record: what can be refused\n // without reading the customer's data is refused without reading it.\n const plans = new Map<DatasetRole, FieldPlan>()\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const contract = datasets[role]\n const bound = binding[role]\n if (contract === undefined || bound === undefined) continue\n signal?.throwIfAborted()\n const published = await client.form(bound.form)\n if (!published.ok) return refused([fromRefusal(`/${role}`, published)])\n const { plan, errors: found } = planFields(role, contract, published.value)\n errors.push(...found)\n if (role === 'detail' && published.value.list === null) {\n errors.push({ path: '/detail', code: 'not-listable', message: 'the detail form offers this person no list of its records' })\n }\n plans.set(role, plan)\n }\n let parent: Parent | undefined\n if (binding.detail !== undefined) {\n const found = await parentOf(client, binding.header, binding.detail, signal)\n if (found !== undefined && 'code' in found) errors.push(found)\n else parent = found\n }\n if (errors.length > 0) return refused(errors)\n\n const headerPlan = plans.get('header')\n let header: Answers | undefined\n if (binding.header !== undefined && headerPlan !== undefined) {\n signal?.throwIfAborted()\n const record = await client.read(binding.header.form, binding.header.record)\n if (!record.ok) return refused([fromRefusal('/header', record)])\n header = pick(record.value, headerPlan)\n errors.push(...(await labelled(client, 'header', binding.header.form, headerPlan, [header], signal)))\n }\n const detailPlan = plans.get('detail')\n let detail: { rows: Answers[]; complete: boolean } | undefined\n if (binding.detail !== undefined && detailPlan !== undefined) {\n const read = await readRows(client, binding.detail, parent, cap, signal)\n if ('code' in read) return refused([read])\n detail = { rows: read.rows.map((row) => pick(row, detailPlan)), complete: read.complete }\n errors.push(...(await labelled(client, 'detail', binding.detail.form, detailPlan, detail.rows, signal)))\n }\n if (errors.length > 0) return refused(errors)\n\n return {\n ok: true,\n data: {\n ...(header === undefined ? {} : { header }),\n ...(detail === undefined ? {} : { detail: detail.rows }),\n completeness: detail === undefined ? { complete: true, captured: 0 } : { complete: detail.complete, captured: detail.rows.length, cap },\n consistency: 'best-effort',\n },\n }\n}\n"],"mappings":";;;;AAiCA,MAAa,uBAAuB;CAElC;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;AACF;AAmBA,MAAa,QAAgC,CAAC,UAAU,QAAQ;;AAGhE,SAAgB,cAAc,UAAoB,SAAuC;CACvF,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,SAAS,UAAU,KAAA;EACpC,MAAM,QAAQ,QAAQ,UAAU,KAAA;EAChC,IAAI,YAAY,CAAC,OAAO,OAAO,K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,CAAC,YAAY,WAAW,MAAM,CAAC,CAAC;EAC/D,SAAS,KAAK,OAAO,OAAO,UAAU;EACtC,OAAO,KAAK,GAAI,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,GAAG,MAAM,CAAE;CACtG;CACA,MAAM,aAAa,MAAM,IAAI,QAAQ;CACrC,IAAI;CACJ,IAAI,QAAQ,WAAW,KAAA,KAAa,eAAe,KAAA,GAAW;EAC5D,MAAM,OAAO,MAAM,SAAS,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,MAAM;EACvE,IAAI,UAAU,MAAM,OAAO,QAAQ,CAAC,IAAI,CAAC;EACzC,SAAS;GAAE,MAAM,KAAK,KAAK,KAAK,QAAQ,KAAK,KAAK,UAAU,CAAC;GAAG,UAAU,KAAK;EAAS;EACxF,OAAO,KAAK,GAAI,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,MAAM,CAAE;CACzG;CACA,IAAI,OAAO,SAAS,GAAG,OAAO,QAAQ,MAAM;CAE5C,OAAO;EACL,IAAI;EACJ,MAAM;GACJ,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;GACzC,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,KAAK;GACtD,cAAc,WAAW,KAAA,IAAY;IAAE,UAAU;IAAM,UAAU;GAAE,IAAI;IAAE,UAAU,OAAO;IAAU,UAAU,OAAO,KAAK;IAAQ;GAAI;GACtI,aAAa;EACf;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formancy/report-data-provider",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Formancy Report's Formancy Data provider: reads a published Data form's records, through @formancy/data-client 0.1.0 and the person's own token, into the data a report renders from, labelled best-effort. No framework, no Node.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"LICENSE.md",
|
|
17
|
+
"NOTICE"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@formancy/data-client": "0.1.0",
|
|
21
|
+
"@formancy/report-runtime": "0.2.0",
|
|
22
|
+
"@formancy/report-spec": "0.2.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
26
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
27
|
+
"publint": "^0.3.24",
|
|
28
|
+
"tsdown": "^0.23.0",
|
|
29
|
+
"typescript": "~6.0.3",
|
|
30
|
+
"unrun": "^0.3.1",
|
|
31
|
+
"vitest": "^5.0.1"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/sharkysan/formancy.ai-report.git",
|
|
39
|
+
"directory": "packages/report-data-provider"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/sharkysan/formancy.ai-report",
|
|
42
|
+
"bugs": "https://github.com/sharkysan/formancy.ai-report/issues",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"check:pkg": "publint && attw --pack . --profile esm-only"
|
|
49
|
+
}
|
|
6
50
|
}
|