@quario/csv 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/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to @quario/csv are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-08-27
11
+
12
+ ### Added
13
+
14
+ - **CSV records in render order.** A bare interpolation stays typed text (a
15
+ number's decimal, a Date as ISO 8601 UTC); everything else is display text,
16
+ then an apostrophe on formula-like cells, then RFC 4180 quoting. The
17
+ unlicensed marking is a trailing line, so record 1 stays the report's.
package/LICENSE ADDED
@@ -0,0 +1,219 @@
1
+ # Quario License Agreement
2
+
3
+ > **In short:** Quario is commercial software with visible source.
4
+ > Evaluate it free for as long as you like. Evaluation output is
5
+ > watermarked. Anything else needs a per-developer license, after
6
+ > which deployment is unlimited and royalty-free. This summary is not
7
+ > the license; the full terms below govern.
8
+
9
+ Version 1.0, August 2026
10
+
11
+ This agreement is between you and Webstronauts, trading as Quario,
12
+ established in the Netherlands ("we", "us"), and governs the Software
13
+ defined below.
14
+
15
+ Quario is commercial software. Its packages ship with readable source
16
+ code, but it is not open source. No rights are granted beyond those in
17
+ this agreement.
18
+
19
+ ## 1. Definitions
20
+
21
+ - The **Software** is any software we publish under the Quario name,
22
+ including the `quario` and `@quario/*` packages, except where a
23
+ product states its own terms. Each release states the edition of this
24
+ agreement that governs it.
25
+ - **You** means the individual exercising rights under this agreement
26
+ and, where that individual acts for a company or other organization,
27
+ that organization. In that case the organization is the licensee, and
28
+ the rights and limits in this agreement apply to it as a whole.
29
+ - An **Application** is software you create that incorporates the
30
+ Software and adds substantial functionality beyond it. A
31
+ licensee-operated service that embeds the Software and renders
32
+ reports for your End Users is an Application under this agreement,
33
+ even if it does little more than render.
34
+ - A **Developer** is any individual (employee or contractor working on
35
+ your behalf) who writes or maintains code that uses the Software's
36
+ APIs, or who creates or maintains report definitions for use with the
37
+ Software. That includes people who never install or run the Software
38
+ themselves, when their definitions are rendered by a service that
39
+ embeds it.
40
+ - A **Seat** is a paid license for one named Developer, purchased from
41
+ us or an authorized reseller.
42
+ - **End Users** are people who interact with the Software only through
43
+ an Application: running it, viewing the reports it produces, or
44
+ supplying parameters or other input to existing report definitions
45
+ the Application provides. Creating or maintaining report definitions
46
+ makes someone a Developer. End Users do not purchase a license; their
47
+ rights come from section 5.
48
+
49
+ ## 2. Acceptance
50
+
51
+ This file is our standing offer. Anyone who exercises the evaluation
52
+ rights in section 3 accepts them, subject to their conditions. All
53
+ other rights arise when Seats are purchased. Where a purchase is made
54
+ for an organization, the person completing it confirms that they are
55
+ authorized to accept this agreement on the organization's behalf, and
56
+ acceptance covers the whole organization. If you do not accept this
57
+ agreement, do not use the Software.
58
+
59
+ ## 3. Evaluation
60
+
61
+ You may download, install, and use the Software free of charge to
62
+ evaluate it: assessing whether it suits your purposes, and building
63
+ prototypes or proofs of concept. Evaluation covers the full feature
64
+ set, needs no key, and has no fixed time limit. The Software marks
65
+ evaluation output as described in section 6.
66
+
67
+ Evaluation is limited to assessment: you may not distribute any
68
+ Application containing the Software, use the Software in live business
69
+ operations, or expose it in services offered to third parties. The
70
+ moment your use goes beyond evaluating the Software, it requires Seats
71
+ under section 4.
72
+
73
+ ## 4. Developer licenses
74
+
75
+ Any use of the Software beyond section 3 requires a Seat for every
76
+ Developer, whether or not an Application has shipped. With those Seats
77
+ in place:
78
+
79
+ - Each licensed Developer may install and use the Software on any number
80
+ of machines for developing Applications.
81
+ - Automated build, test, and CI systems do not consume Seats.
82
+ - Seats are per named individual. They may be reassigned when a
83
+ Developer stops working with the Software, but not shared or pooled
84
+ between concurrently active Developers. Contractors' work for you is
85
+ covered by your Seats; work they do for other clients is not.
86
+
87
+ ## 5. Distribution and runtime
88
+
89
+ With Seats under section 4 in place, you may deploy and operate your
90
+ Applications yourself, and distribute the Software as an embedded part
91
+ of them, **royalty-free**: no additional fees or per-deployment
92
+ licenses are required for any number of servers, copies, or End Users.
93
+ You may embed your license key in an Application and ship it at no
94
+ charge, so section 6 does not mark that Application's output.
95
+
96
+ For that purpose, we grant you the right to pass through to each End
97
+ User, and to anyone who distributes or operates your Application on your
98
+ behalf, a limited, non-exclusive, non-transferable right to execute the
99
+ Software only as embedded in the Application. You must not permit them
100
+ to extract the Software from the Application or use it to develop
101
+ software of their own.
102
+
103
+ If you operate a service that embeds the Software and renders reports
104
+ for your End Users, that service is an Application under section 1. You
105
+ may run it royalty-free under this section, and you may put your license
106
+ key in it as in any Application. Calling applications that only request
107
+ renders from it need not incorporate the Software. People who use those
108
+ applications only as End Users under section 1 get the pass-through
109
+ rights above.
110
+
111
+ You may not:
112
+
113
+ - distribute the Software on its own, or as part of a product whose
114
+ primary purpose is to provide report-engine, report-design, or
115
+ document-generation capability to third-party developers;
116
+ - expose the Software's APIs to third parties as a development tool or
117
+ service that substitutes for those parties buying their own Seats. A
118
+ licensee-operated service that embeds the Software and renders for
119
+ your own End Users falls outside that ban;
120
+ - fork, mirror, repackage, rename, or wrap the Software, or republish
121
+ it on any package registry or code-hosting platform, other than as
122
+ embedded in an Application.
123
+
124
+ For as long as this agreement is in force, you may not create any tool,
125
+ library, product, or service that competes with the Software or any
126
+ other Quario product, whether the competition is direct or indirect;
127
+ this restriction does not survive termination. You may not remove or
128
+ alter copyright or license notices in the Software. If your Application
129
+ is itself a closed development product for third-party developers (OEM
130
+ redistribution), contact us for separate terms.
131
+
132
+ ## 6. License keys and output marking
133
+
134
+ The Software accepts a license key that evidences your Seats under
135
+ section 4. Key checks run offline.
136
+
137
+ Without a valid key, or with a key whose validity period does not cover
138
+ the installed version's release date, the Software runs with its full
139
+ feature set but marks its output as unlicensed. Using a key you are not
140
+ entitled to is a material breach of this agreement.
141
+
142
+ You may not remove, disable, or circumvent the key check or the output
143
+ marking, or distribute anything that does.
144
+
145
+ ## 7. Term, updates, and perpetual fallback
146
+
147
+ Seats are sold as an annual subscription. While the subscription is
148
+ active, licensed Developers receive all Software versions we release,
149
+ and support for the Software through our issue tracker and by email. We
150
+ provide support with commercially reasonable effort; we do not guarantee
151
+ specific response times.
152
+
153
+ If the subscription lapses, your license to the versions released during
154
+ your subscription is **perpetual, for the number of Seats held at the
155
+ lapse**: up to that many Developers may keep using those versions, and
156
+ your Applications may keep shipping them, forever, at no further cost.
157
+ Versions released after the lapse require renewal. We encode this rule
158
+ in purchased keys: a key remains valid for every version released
159
+ during its validity period, with no end date.
160
+
161
+ ## 8. Source availability
162
+
163
+ The Software's packages ship with readable source code so that you can
164
+ review and debug what you run. Readable source does not grant extra
165
+ rights: this agreement governs all use of the source, and you may
166
+ publish the Software (modified or not) only as part of an Application
167
+ under section 5.
168
+
169
+ ## 9. Ownership, trademarks, and feedback
170
+
171
+ We license the Software; we retain all intellectual property rights in
172
+ it. Report definitions, data, and output you create with the Software
173
+ are yours. "Quario" and the Quario logo are our trademarks; this
174
+ agreement grants no rights to use them beyond identifying the Software.
175
+ If you send us feedback or suggestions, we may use them without
176
+ obligation.
177
+
178
+ ## 10. Warranty and liability
179
+
180
+ We provide the Software as is. To the fullest extent the law allows, we
181
+ disclaim all warranties and conditions, express or implied, including
182
+ merchantability, fitness for a particular purpose, and non-infringement.
183
+
184
+ To the fullest extent the law allows: we are not liable for indirect or
185
+ consequential damages, loss of profits, loss of data, or business
186
+ interruption; and our total aggregate liability under this agreement is
187
+ limited to the greater of EUR 100 and the fees you paid us in the
188
+ twelve months preceding the event giving rise to the claim. These
189
+ limitations do not apply where the damage results from the intent or
190
+ deliberate recklessness (opzet of bewuste roekeloosheid) of us or our
191
+ management, or where mandatory law does not permit them.
192
+
193
+ ## 11. Termination and survival
194
+
195
+ If you materially breach this agreement, we may terminate it by notice.
196
+ If the breach can be remedied, we will first allow 30 days from that
197
+ notice to remedy it, and termination takes effect only if the breach
198
+ remains. On termination, the licenses granted here end.
199
+ Perpetual-fallback rights under section 7 survive termination only if
200
+ they arose from a lapse that predates the breach, and section 5
201
+ survives with them to the extent needed to keep exercising them.
202
+ Sections 8 through 12 survive any termination.
203
+
204
+ ## 12. General
205
+
206
+ Dutch law governs this agreement. Disputes go to the competent court for
207
+ our registered office. You may not assign this agreement without our
208
+ consent, except to a successor of your whole business; we may assign it
209
+ to a successor of ours. If a provision is unenforceable, the remainder
210
+ stays in force. Failure to enforce a provision does not waive it. This
211
+ agreement, together with your order for Seats, is the entire agreement
212
+ about the Software, unless we agree otherwise in writing.
213
+
214
+ ---
215
+
216
+ **Purchasing and contact:** <contact@getquario.com> ·
217
+ <https://getquario.com>
218
+
219
+ Copyright © 2026 Webstronauts. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # @quario/csv
2
+
3
+ **The CSV render target for [quario](https://www.npmjs.com/package/quario).** Renders a report
4
+ definition to CSV records with typed fields: a bare number stays a number's decimal, a Date
5
+ stays ISO 8601 UTC, and text that would open as a spreadsheet formula is neutralized.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install quario @quario/csv
11
+ ```
12
+
13
+ The engine is a peer dependency, installed beside the target. ESM-only, Node 22+, and
14
+ browser-ready through any standards-based ESM bundler. The renderer returns a string; you
15
+ encode the file.
16
+
17
+ ## Quick start
18
+
19
+ ```js
20
+ import { writeFileSync } from "node:fs";
21
+ import { csv } from "@quario/csv";
22
+ import { quario } from "quario";
23
+
24
+ const schema = {
25
+ data: "$.orders[*]",
26
+ detail: {
27
+ columns: [
28
+ { header: "Product", value: "{{ @.product }}" },
29
+ { header: "Price", value: "{{ @.price }}" },
30
+ ],
31
+ },
32
+ };
33
+
34
+ const data = {
35
+ orders: [
36
+ { product: "Desk", price: 250 },
37
+ { product: "Chair", price: 120 },
38
+ { product: "Lamp", price: 40 },
39
+ ],
40
+ };
41
+
42
+ const report = quario().report(schema);
43
+ const records = await report.render(csv(), data);
44
+
45
+ writeFileSync("sales.csv", records);
46
+ ```
47
+
48
+ A licensed render of that table-only report:
49
+
50
+ ```
51
+ Product,Price
52
+ Desk,250
53
+ Chair,120
54
+ Lamp,40
55
+ ```
56
+
57
+ Any schema the other targets render works here unchanged. A CSV file has no pages, so page
58
+ bands are ignored. Interpolate the bare value, not a formatter, when you want a typed field:
59
+ `{{ @.amount }}` writes `1000`; `{{ currency(@.amount) }}` writes text.
60
+
61
+ ## API
62
+
63
+ ### `csv()`
64
+
65
+ The target factory takes no options and returns the target you pass to `render`.
66
+ `report()` compiles once and `report.render(csv(), data)` resolves the string. Compile at
67
+ startup, render per request. Definition problems throw at `report()`, at compile time.
68
+
69
+ ```js
70
+ const report = quario().report(schema, funcs);
71
+ const records = await report.render(csv(), data);
72
+ ```
73
+
74
+ The compiled report carries `stream` (the raw event generator), `names`, `functions`, and
75
+ `paths`, like every quario report. Engine-level options (`query` budgets, the license key)
76
+ live on the instance, and `q.license` settles with the verification result.
77
+
78
+ Rendering is asynchronous and hands the loop back between batches, so a large report never
79
+ blocks the host. Render-time failures reject with located errors.
80
+
81
+ ## Mapping
82
+
83
+ The banded walk flattened as records in render order: report-header items, then per group
84
+ instance its header items, nested content, and footer items, then the table's header record,
85
+ data records, and total record, then report-footer items. Grouping exists as that order
86
+ alone. Group boundaries add no records of their own, and `break: "page"` and `reset: "page"`
87
+ are ignored. This target is unpaginated: `report-start.page` band closures are ignored.
88
+
89
+ Each item takes one record with one field. A report that is one table and no other bands has
90
+ its column headers as record 1; any other band makes the file ragged.
91
+
92
+ ### Typed fields
93
+
94
+ A cell whose value is one bare interpolation writes its pre-stringify value as text: a finite
95
+ number as ECMAScript ToString, a boolean as `true`/`false`, a `Date` as ISO 8601 UTC. Every
96
+ other cell joins to display text with `text()`, then the injection guard, then RFC 4180
97
+ quoting.
98
+
99
+ **Display-text fields that would open as spreadsheet formulas are mangled.** A leading `=`,
100
+ `+`, `-`, `@`, TAB, or CR gets an apostrophe. A consumer that parses the file back does not
101
+ round-trip those fields. The XLSX target does the opposite: it writes an inert string and
102
+ does not mangle.
103
+
104
+ A hidden cell keeps its column slot as an empty field.
105
+
106
+ ### Unread
107
+
108
+ `style`, column `width`, page columns, page bands, and images: nothing looks at them. An
109
+ image emits no record.
110
+
111
+ ### Text shape
112
+
113
+ No BOM. Records separated by LF, not CRLF. The string ends with a newline. Quoting follows
114
+ RFC 4180; the line ending does not.
115
+
116
+ ## Unlicensed marking
117
+
118
+ An unlicensed render writes the wording from `report-start.marking` as one trailing line, one
119
+ field, through the same quote and guard as any field. A licensed render omits it. The line's
120
+ presence is normative. That a parser who stops before EOF will see it is best-effort.
121
+
122
+ ## Determinism
123
+
124
+ Same schema and data produce an identical string.
125
+
126
+ ## License
127
+
128
+ Commercial software with readable source. Free, unlimited, watermarked evaluation; per-developer
129
+ licenses at [getquario.com](https://getquario.com). See the bundled LICENSE.
130
+
131
+ Pass your license key once, on the instance; it is verified offline:
132
+
133
+ ```js
134
+ const q = quario({ license: "quario_..." });
135
+ await q.license; // { licensed: true, licensee: "Acme BV", id: "1-ACME" }
136
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { Target } from "quario";
2
+
3
+ /**
4
+ * The CSV render target:
5
+ * `quario().report(schema).render(csv(), data)` resolves the records
6
+ * described in SCHEMA.md ("The CSV target").
7
+ */
8
+ export function csv(): Target<"csv", Promise<string>>;
package/lib/index.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @quario/csv — the CSV render target: a pure consumer of the engine's
3
+ * public event stream, passed to a compiled report's `render`, flattening the
4
+ * banded walk onto records in render order. A cell that is one bare
5
+ * interpolation keeps a typed string (a number stays decimal, a Date ISO 8601
6
+ * UTC); every other cell is display text, then the formula-injection guard,
7
+ * then RFC 4180 quoting. Styles, widths, page bands, and images go unread.
8
+ * The unlicensed marking is a trailing line, so record 1 stays the report's.
9
+ */
10
+ import { text, typed, walk } from "quario";
11
+
12
+ /** Formula guard, then RFC 4180 quoting. Typed fields skip this.
13
+ * @type {(s: string) => string} */
14
+ let format = (s) => {
15
+ if (/^[=+\-@\t\r]/.test(s)) s = "'" + s;
16
+ return /[",\n\r]/.test(s) ? '"' + s.replaceAll('"', '""') + '"' : s;
17
+ };
18
+
19
+ /** @type {(cell: { tokens: any[] }) => string} */
20
+ let field = (cell) => {
21
+ let value = typed(cell.tokens);
22
+ if (value === undefined) return format(text(cell.tokens));
23
+ return value instanceof Date ? value.toISOString() : String(value);
24
+ };
25
+
26
+ /**
27
+ * The CSV render target:
28
+ * `quario().report(schema).render(csv(), data)` resolves the records as a
29
+ * string (the host encodes the file). Rendering runs the engine's `walk`
30
+ * driver over the handlers below, so large reports stay cooperative.
31
+ *
32
+ * @returns {{name: "csv", compile: (stream: any) => (data?: any) => Promise<string>}}
33
+ * The target (see SCHEMA.md, "Instances and targets").
34
+ */
35
+ export function csv() {
36
+ return {
37
+ name: "csv",
38
+ compile: (stream) => async (data) => {
39
+ let out = "";
40
+ /** @type {string | undefined} */
41
+ let marking;
42
+ let record = (/** @type {any} */ event) => {
43
+ out += event.cells.map(field).join(",") + "\n";
44
+ };
45
+ await walk(stream(data), {
46
+ "report-start": (event) => {
47
+ if (event.marking) marking = event.marking;
48
+ },
49
+ item: (event) => {
50
+ out += field(event) + "\n";
51
+ },
52
+ "table-start": (event) => {
53
+ out +=
54
+ event.columns.map((/** @type {any} */ column) => field(column.header)).join(",") + "\n";
55
+ },
56
+ row: record,
57
+ "total-row": record,
58
+ });
59
+ if (marking) out += format(marking) + "\n";
60
+ return out;
61
+ },
62
+ };
63
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@quario/csv",
3
+ "version": "0.1.0",
4
+ "description": "The CSV render target for quario — in the makings, not yet released",
5
+ "homepage": "https://getquario.com",
6
+ "license": "SEE LICENSE IN LICENSE",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/getquario/quario.git",
10
+ "directory": "packages/csv"
11
+ },
12
+ "files": [
13
+ "CHANGELOG.md",
14
+ "lib"
15
+ ],
16
+ "type": "module",
17
+ "types": "lib/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./lib/index.d.ts",
21
+ "default": "./lib/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "check": "npm run size && npm test && npm run test:browser",
30
+ "size": "size-limit",
31
+ "test": "npm run test:unit && npm run test:types",
32
+ "test:browser": "node test/browser/setup.js",
33
+ "test:types": "tsc && attw --pack . --profile esm-only",
34
+ "test:unit": "node --disallow-code-generation-from-strings --test --test-concurrency=1 test/*.test.js",
35
+ "prepack": "node -e \"require('fs').copyFileSync('../../LICENSE','LICENSE')\"",
36
+ "postpack": "node -e \"require('fs').rmSync('LICENSE',{force:true})\""
37
+ },
38
+ "devDependencies": {
39
+ "@arethetypeswrong/cli": "^0.18.3",
40
+ "@size-limit/preset-small-lib": "^13.0.3",
41
+ "quario": "^0.1.0",
42
+ "size-limit": "^13.0.3",
43
+ "typescript": "^7.0.2"
44
+ },
45
+ "peerDependencies": {
46
+ "quario": "^0.1.0"
47
+ },
48
+ "size-limit": [
49
+ {
50
+ "path": "lib/index.js",
51
+ "limit": "1 kB",
52
+ "ignore": [
53
+ "quario"
54
+ ]
55
+ }
56
+ ],
57
+ "engines": {
58
+ "node": ">=22.0.0"
59
+ }
60
+ }