@reportwright/engine 0.0.0-stage → 0.11.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 +206 -0
- package/LICENSE +23 -0
- package/README.md +67 -2
- package/dist/index.js +20267 -0
- package/dist/index.js.map +6 -0
- package/dist/types/packages/engine/entry.d.ts +75 -0
- package/dist/types/src/designer/tableGen.d.ts +119 -0
- package/dist/types/src/engine/data/guard.d.ts +50 -0
- package/dist/types/src/engine/data/index.d.ts +120 -0
- package/dist/types/src/engine/data/odata.d.ts +35 -0
- package/dist/types/src/engine/data/xml.d.ts +108 -0
- package/dist/types/src/engine/expr/evaluate.d.ts +183 -0
- package/dist/types/src/engine/expr/format.d.ts +122 -0
- package/dist/types/src/engine/expr/javafmt.d.ts +26 -0
- package/dist/types/src/engine/expr/parser.d.ts +29 -0
- package/dist/types/src/engine/image.d.ts +107 -0
- package/dist/types/src/engine/index.d.ts +224 -0
- package/dist/types/src/engine/items/barcode.d.ts +121 -0
- package/dist/types/src/engine/items/cells.d.ts +11 -0
- package/dist/types/src/engine/items/chart-kit.d.ts +75 -0
- package/dist/types/src/engine/items/chart-more.d.ts +52 -0
- package/dist/types/src/engine/items/chart-round.d.ts +28 -0
- package/dist/types/src/engine/items/chart.d.ts +42 -0
- package/dist/types/src/engine/items/hpage.d.ts +33 -0
- package/dist/types/src/engine/items/index.d.ts +117 -0
- package/dist/types/src/engine/items/map.d.ts +11 -0
- package/dist/types/src/engine/items/paint.d.ts +138 -0
- package/dist/types/src/engine/items/pivot.d.ts +45 -0
- package/dist/types/src/engine/items/rich.d.ts +105 -0
- package/dist/types/src/engine/items/toc.d.ts +10 -0
- package/dist/types/src/engine/items/visuals.d.ts +5 -0
- package/dist/types/src/engine/layout.d.ts +24 -0
- package/dist/types/src/engine/paginate/index.d.ts +17 -0
- package/dist/types/src/engine/reuse.d.ts +120 -0
- package/dist/types/src/engine/schema/report.schema.d.ts +2421 -0
- package/dist/types/src/engine/schema/template.d.ts +212 -0
- package/dist/types/src/engine/schema/validate.d.ts +21 -0
- package/dist/types/src/engine/style.d.ts +70 -0
- package/dist/types/src/engine/text/fonts.d.ts +96 -0
- package/dist/types/src/engine/text/measure.d.ts +145 -0
- package/dist/types/src/engine/text/rich.d.ts +48 -0
- package/dist/types/src/engine/text/shaper.d.ts +20 -0
- package/dist/types/src/engine/units.d.ts +53 -0
- package/dist/types/src/engine/url.d.ts +23 -0
- package/dist/types/src/exporters/color.d.ts +9 -0
- package/dist/types/src/exporters/csv.d.ts +44 -0
- package/dist/types/src/exporters/deadline.d.ts +6 -0
- package/dist/types/src/exporters/docx.d.ts +19 -0
- package/dist/types/src/exporters/encrypt.d.ts +39 -0
- package/dist/types/src/exporters/figures.d.ts +112 -0
- package/dist/types/src/exporters/html.d.ts +24 -0
- package/dist/types/src/exporters/htmldata.d.ts +32 -0
- package/dist/types/src/exporters/pdf.d.ts +45 -0
- package/dist/types/src/exporters/pdfa.d.ts +31 -0
- package/dist/types/src/exporters/pdfua.d.ts +17 -0
- package/dist/types/src/exporters/png.d.ts +10 -0
- package/dist/types/src/exporters/pptx.d.ts +14 -0
- package/dist/types/src/exporters/regions.d.ts +30 -0
- package/dist/types/src/exporters/subset.d.ts +5 -0
- package/dist/types/src/exporters/svg.d.ts +26 -0
- package/dist/types/src/exporters/svgimage.d.ts +33 -0
- package/dist/types/src/exporters/xlsx.d.ts +61 -0
- package/dist/types/src/exporters/xlsxchart.d.ts +26 -0
- package/dist/types/src/exporters/xlsxwriter.d.ts +83 -0
- package/dist/types/src/importers/xml.d.ts +34 -0
- package/index.d.ts +3 -0
- package/package.json +78 -4
- package/pool/index.d.ts +23 -0
- package/pool/index.js +85 -0
- package/pool/worker.js +27 -0
- package/report.d.ts +638 -0
- package/schema.json +2517 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one allow-list for links the engine emits (url actions, rich text <a href>), checked on the exact
|
|
3
|
+
* string that is emitted. Browsers and PDF readers parse URLs leniently (they drop tabs and newlines before
|
|
4
|
+
* the scheme, read "\" as "/", take "https:x" and "//host" as absolute), so the rule is strict:
|
|
5
|
+
* - no character at or below U+0020, no DEL or C1 control, no backslash;
|
|
6
|
+
* - http:// or https:// with a host (double slash required), or mailto:;
|
|
7
|
+
* - a relative path that starts with one "/" (not "//").
|
|
8
|
+
* @param {unknown} v
|
|
9
|
+
* @returns {string|null} v itself when allowed, else null
|
|
10
|
+
*/
|
|
11
|
+
export function safeUrl(v: unknown): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* A drill-through's address in the ReportWright viewer: `<base>/viewer/<report>?<parameters>` (a list parameter
|
|
14
|
+
* repeats its name), checked by safeUrl; null without a base URL or a report. The HTML and PDF exports link to it.
|
|
15
|
+
* @param {string|undefined|null} base @param {{ report?: string, params?: Record<string, any> }} a @returns {string|null}
|
|
16
|
+
*/
|
|
17
|
+
export function drillUrl(base: string | undefined | null, a: {
|
|
18
|
+
report?: string;
|
|
19
|
+
params?: Record<string, any>;
|
|
20
|
+
}): string | null;
|
|
21
|
+
/** A URL as a PDF URI action may hold it: 7-bit ASCII (an international host as punycode, other characters
|
|
22
|
+
* percent-encoded). @param {string} href @returns {string} */
|
|
23
|
+
export function asciiUrl(href: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @returns {{r:number,g:number,b:number,a:number}|null} channels 0..1 */
|
|
2
|
+
export function parseColor(c: any): {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
a: number;
|
|
7
|
+
} | null;
|
|
8
|
+
/** Safe color for SVG/HTML attributes. */
|
|
9
|
+
export function cssColor(c: any): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV of the report's data: one header row and the detail rows of the main table (the one with the most detail rows),
|
|
3
|
+
* numbers without symbols or separators, dates in ISO form. Group headers, subtotals, totals and other tables are left
|
|
4
|
+
* out. layout: true gives the printed layout instead: every table with its name and every row (group lines, totals).
|
|
5
|
+
* @param {any} model @param {{ all?: boolean, layout?: boolean, locale?: string, currency?: string }} [o]
|
|
6
|
+
*/
|
|
7
|
+
export function exportCsv(model: any, { all, layout, locale, currency }?: {
|
|
8
|
+
all?: boolean;
|
|
9
|
+
layout?: boolean;
|
|
10
|
+
locale?: string;
|
|
11
|
+
currency?: string;
|
|
12
|
+
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* A CSV line from a region row (one value per column, empty where no cell starts). Shared by exportCsv and the streaming
|
|
15
|
+
* writer (writeCsvStream), so both write the same bytes.
|
|
16
|
+
* @param {{ timeZone?: string|null, locale?: string, currency?: string }} o
|
|
17
|
+
*/
|
|
18
|
+
export function csvLine({ timeZone, locale, currency }: {
|
|
19
|
+
timeZone?: string | null;
|
|
20
|
+
locale?: string;
|
|
21
|
+
currency?: string;
|
|
22
|
+
}): (ncols: any, row: any) => string;
|
|
23
|
+
/** The data CSV's header line: header rows stacked into one, a cell spanning columns naming each of them ("Who Id"). */
|
|
24
|
+
export function csvNames(ncols: any): {
|
|
25
|
+
/** @param {{ cells: any[] }} row */
|
|
26
|
+
add(row: {
|
|
27
|
+
cells: any[];
|
|
28
|
+
}): void;
|
|
29
|
+
line: () => string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The data CSV of a streaming plan (engine/stream.js), written as its rows come: the same bytes exportCsv writes for the
|
|
33
|
+
* model of that report. put(text) may return a promise (back-pressure): it is awaited.
|
|
34
|
+
* @param {{ columns: number[], timeZone: string|null, rows: () => AsyncGenerator<any> }} plan
|
|
35
|
+
* @param {(s: string) => any} put @param {{ locale?: string, currency?: string }} [o]
|
|
36
|
+
*/
|
|
37
|
+
export function writeCsvStream(plan: {
|
|
38
|
+
columns: number[];
|
|
39
|
+
timeZone: string | null;
|
|
40
|
+
rows: () => AsyncGenerator<any>;
|
|
41
|
+
}, put: (s: string) => any, { locale, currency }?: {
|
|
42
|
+
locale?: string;
|
|
43
|
+
currency?: string;
|
|
44
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An export bounded by opt.timeoutMs: past it the promise rejects with status 504. The work itself is not stopped
|
|
3
|
+
* (a server render runs in a worker that the pool terminates); the caller is not left waiting.
|
|
4
|
+
* @template T @param {Promise<T>} work @param {number|undefined} ms @returns {Promise<T>}
|
|
5
|
+
*/
|
|
6
|
+
export function withDeadline<T>(work: Promise<T>, ms: number | undefined): Promise<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Left, right or centre, from where the lines sit in their box. */
|
|
2
|
+
export function alignOf(it: any): "center" | "left" | "right" | "both";
|
|
3
|
+
/**
|
|
4
|
+
* @param {any} model render() output
|
|
5
|
+
* @param {{ title?: string, author?: string, lang?: string, fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
6
|
+
* rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null>, figures?: boolean }} [opt]
|
|
7
|
+
* fontStore: text in pictures as outlines (else the reader's fallback font); fetchImage: pictures by URL;
|
|
8
|
+
* rasterize: the PNG fallback of a picture (default: a canvas in a browser, sharp in Node); figures: false leaves them out.
|
|
9
|
+
* @returns {Promise<Uint8Array>}
|
|
10
|
+
*/
|
|
11
|
+
export function exportDocx(model: any, opt?: {
|
|
12
|
+
title?: string;
|
|
13
|
+
author?: string;
|
|
14
|
+
lang?: string;
|
|
15
|
+
fontStore?: any;
|
|
16
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
17
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
18
|
+
figures?: boolean;
|
|
19
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Algorithm 2.B: the hash of a password, a salt and (for the owner) the U string.
|
|
3
|
+
* @param {Uint8Array} pw @param {Uint8Array} salt @param {Uint8Array} udata
|
|
4
|
+
*/
|
|
5
|
+
export function hash2B(pw: Uint8Array, salt: Uint8Array, udata: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
|
|
6
|
+
/** A password as the handler wants it: NFKC (SASLprep's main step), UTF-8, at most 127 bytes. */
|
|
7
|
+
export function passwordBytes(pw: any, which: any): Uint8Array<ArrayBuffer>;
|
|
8
|
+
/** /P: reserved bits 7, 8 and 13–32 set, 1–2 clear; each permission allowed unless set to false. */
|
|
9
|
+
export function permissionsValue(perms?: {}): number;
|
|
10
|
+
/**
|
|
11
|
+
* Encrypt a pdf-lib document in place.
|
|
12
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
13
|
+
* @param {{ userPassword?: string, ownerPassword?: string, permissions?: Record<string, boolean> }} opt
|
|
14
|
+
*/
|
|
15
|
+
export function encryptPdf(doc: import("pdf-lib").PDFDocument, opt: {
|
|
16
|
+
userPassword?: string;
|
|
17
|
+
ownerPassword?: string;
|
|
18
|
+
permissions?: Record<string, boolean>;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* The `pdf` option of an API request or the CLI → encryptPdf options, or undefined for no password.
|
|
22
|
+
* Checks the shape (400 on anything else); the passwords themselves are checked in passwordBytes.
|
|
23
|
+
* @param {any} pdf { userPassword?, ownerPassword?, permissions?: { print?: boolean, … } }
|
|
24
|
+
*/
|
|
25
|
+
export function pdfEncryptOptions(pdf: any): {
|
|
26
|
+
userPassword: any;
|
|
27
|
+
ownerPassword: any;
|
|
28
|
+
permissions: any;
|
|
29
|
+
};
|
|
30
|
+
export namespace PERMISSION_BITS {
|
|
31
|
+
let print: number;
|
|
32
|
+
let modify: number;
|
|
33
|
+
let copy: number;
|
|
34
|
+
let annotate: number;
|
|
35
|
+
let fillForms: number;
|
|
36
|
+
let accessibility: number;
|
|
37
|
+
let assemble: number;
|
|
38
|
+
let printHighQuality: number;
|
|
39
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The figures of a page, in page order: { tag, items, at, box } (at: index of the first item). A figure's items are
|
|
3
|
+
* consecutive in the page. One tag id marks one figure, also in a model that went through JSON (a tag copy per item).
|
|
4
|
+
* @param {any[]} items page items
|
|
5
|
+
*/
|
|
6
|
+
export function figures(items: any[]): any[];
|
|
7
|
+
/** Bounding box of page items (links and bookmarks left out), or null. @param {any[]} items */
|
|
8
|
+
export function boxOf(items: any[]): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A conservative bounding box of SVG path data: every end and control point, and an arc's end ± its radii.
|
|
16
|
+
* @param {string} d
|
|
17
|
+
*/
|
|
18
|
+
export function pathBox(d: string): {
|
|
19
|
+
x0: number;
|
|
20
|
+
y0: number;
|
|
21
|
+
x1: number;
|
|
22
|
+
y1: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Text as glyph outlines (SVG path data), where the engine placed it. Plain lines advance by the glyphs' own widths
|
|
26
|
+
* (as the engine measured them); shaped runs place each glyph by ID.
|
|
27
|
+
* @param {any} it a text item @param {(key: string) => any} fontOf fontkit font or null
|
|
28
|
+
* @returns {string|null} null when a font is missing
|
|
29
|
+
*/
|
|
30
|
+
export function textOutline(it: any, fontOf: (key: string) => any): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The SVG of a figure: its items in their own box, text as outlines when the fonts are there.
|
|
33
|
+
* @param {{ items: any[], box: { x: number, y: number, w: number, h: number } }} fig
|
|
34
|
+
* @param {{ get: (key: string) => any } | null} [fontStore]
|
|
35
|
+
*/
|
|
36
|
+
export function figureSvg(fig: {
|
|
37
|
+
items: any[];
|
|
38
|
+
box: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
w: number;
|
|
42
|
+
h: number;
|
|
43
|
+
};
|
|
44
|
+
}, fontStore?: {
|
|
45
|
+
get: (key: string) => any;
|
|
46
|
+
} | null): string;
|
|
47
|
+
/**
|
|
48
|
+
* PNG bytes of an SVG, `scale` pixels per point: opt.rasterize when given (the caller's own), else a canvas in a
|
|
49
|
+
* browser, else sharp in Node (Next.js installs it). Null when none of them is there.
|
|
50
|
+
* @param {string} svg @param {number} w @param {number} h (points)
|
|
51
|
+
* @param {{ rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null>, scale?: number }} [opt]
|
|
52
|
+
* @returns {Promise<Uint8Array|null>}
|
|
53
|
+
*/
|
|
54
|
+
export function rasterize(svg: string, w: number, h: number, opt?: {
|
|
55
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
56
|
+
scale?: number;
|
|
57
|
+
}): Promise<Uint8Array | null>;
|
|
58
|
+
/**
|
|
59
|
+
* A figure as picture parts: { png?, svg?, jpeg?, w, h, x, y } (where and how big it is drawn, in points). A figure that is one picture (an image item, maybe in a box)
|
|
60
|
+
* keeps the picture's own bytes; anything else is drawn as SVG and rasterised.
|
|
61
|
+
* @param {any} fig @param {{ fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>, rasterize?: any }} opt
|
|
62
|
+
*/
|
|
63
|
+
export function figurePicture(fig: any, opt?: {
|
|
64
|
+
fontStore?: any;
|
|
65
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
66
|
+
rasterize?: any;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
[x: string]: any;
|
|
69
|
+
w: any;
|
|
70
|
+
h: any;
|
|
71
|
+
x: any;
|
|
72
|
+
y: any;
|
|
73
|
+
svg?: undefined;
|
|
74
|
+
png?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
svg: string;
|
|
77
|
+
png: Uint8Array<ArrayBufferLike>;
|
|
78
|
+
w: any;
|
|
79
|
+
h: any;
|
|
80
|
+
x: any;
|
|
81
|
+
y: any;
|
|
82
|
+
}>;
|
|
83
|
+
/** base64 of bytes (Node or browser). @param {Uint8Array} u8 */
|
|
84
|
+
export function b64(u8: Uint8Array): string;
|
|
85
|
+
/**
|
|
86
|
+
* The box a text item was painted in (paintBox: background rect, the text, its decoration lines, then the border
|
|
87
|
+
* lines or one rounded border rect), read back from the items around it: { fill, radius, sides: { top, right, bottom, left } }.
|
|
88
|
+
* @param {any[]} items @param {number} i the text item's index
|
|
89
|
+
*/
|
|
90
|
+
export function boxDecor(items: any[], i: number): {
|
|
91
|
+
fill: string;
|
|
92
|
+
radius: number;
|
|
93
|
+
sides: Record<string, any>;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The in-cell visuals of the tables on a page (sparklines, data bars, icons that a table cell draws; the engine does
|
|
97
|
+
* not tag those): shapes inside a table's rows that are not a cell's background. Each becomes a picture in its cell.
|
|
98
|
+
* Found by position: a visual in a row with no text cell at all is not found (it stays out).
|
|
99
|
+
* @param {any[]} items @param {Set<number>} used indexes already taken (marked here too)
|
|
100
|
+
* @param {Map<string, { cells: any[] }>} tables table key → its cell text items (with cell tags and clips)
|
|
101
|
+
* @returns {Map<string, Map<string, { items: any[], box: any }>>} table key → `${row}|${col}` → the visual
|
|
102
|
+
*/
|
|
103
|
+
export function cellVisuals(items: any[], used: Set<number>, tables: Map<string, {
|
|
104
|
+
cells: any[];
|
|
105
|
+
}>): Map<string, Map<string, {
|
|
106
|
+
items: any[];
|
|
107
|
+
box: any;
|
|
108
|
+
}>>;
|
|
109
|
+
/** Item kinds that are pictures in Word and PowerPoint (a heading tag alone is not). */
|
|
110
|
+
export const FIGURE_KINDS: Set<string>;
|
|
111
|
+
export function hexOrNull(c: any): string;
|
|
112
|
+
export function altOf(tag: any): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One self-contained HTML file: every page as inline SVG, fonts embedded as
|
|
3
|
+
* base64 (subset when a subsetter is given). URLs open, bookmark jumps and TOC entries scroll to their target, and
|
|
4
|
+
* drill-through opens the ReportWright viewer at drillBase (without one it is shown disabled).
|
|
5
|
+
* Unless static, a file whose report has tables also gets a Tables view (htmldata.js): the tables as HTML, re-sorted on
|
|
6
|
+
* their interactive-sort columns, groups opened and closed, rows filtered, by one inline script the file's CSP allows.
|
|
7
|
+
* @param {any} model
|
|
8
|
+
* @param {import('../engine/text/fonts.js').FontStore} fontStore
|
|
9
|
+
* @param {{ title?: string, drillBase?: string, subset?: (font: Uint8Array, cps: Iterable<number>, o?: { layout?: boolean }) => Promise<Uint8Array>,
|
|
10
|
+
* static?: boolean, locale?: string, currency?: string, lang?: string, strings?: Partial<typeof DATA_STRINGS> }} [opt]
|
|
11
|
+
*/
|
|
12
|
+
export function exportHtml(model: any, fontStore: import("../engine/text/fonts.js").FontStore, opt?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
drillBase?: string;
|
|
15
|
+
subset?: (font: Uint8Array, cps: Iterable<number>, o?: {
|
|
16
|
+
layout?: boolean;
|
|
17
|
+
}) => Promise<Uint8Array>;
|
|
18
|
+
static?: boolean;
|
|
19
|
+
locale?: string;
|
|
20
|
+
currency?: string;
|
|
21
|
+
lang?: string;
|
|
22
|
+
strings?: Partial<typeof DATA_STRINGS>;
|
|
23
|
+
}): any;
|
|
24
|
+
import { DATA_STRINGS } from './htmldata.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tables of a model as the view's data, or null (no tables, or too many rows).
|
|
3
|
+
* Each row: { k: kind, l: level, c: [[col, text, key, span]] } (key: a number, or text in lower case, for sorting).
|
|
4
|
+
* sort: the columns the report sorts on click (its interactive-sort header cells, matched by position).
|
|
5
|
+
* @param {any} model @param {{ locale?: string, currency?: string }} [o]
|
|
6
|
+
*/
|
|
7
|
+
export function tablesData(model: any, o?: {
|
|
8
|
+
locale?: string;
|
|
9
|
+
currency?: string;
|
|
10
|
+
}): {
|
|
11
|
+
name: string;
|
|
12
|
+
cols: any;
|
|
13
|
+
sort: any[];
|
|
14
|
+
rows: any;
|
|
15
|
+
}[];
|
|
16
|
+
/** sha256 of a text, base64 (a CSP hash). */
|
|
17
|
+
export function cspHash(text: any): Promise<string>;
|
|
18
|
+
/** Most rows a file carries for the Tables view (beyond it, the file stays pages only). */
|
|
19
|
+
export const MAX_DATA_ROWS: 20000;
|
|
20
|
+
export namespace DATA_STRINGS {
|
|
21
|
+
let pages: string;
|
|
22
|
+
let tables: string;
|
|
23
|
+
let all: string;
|
|
24
|
+
let filter: string;
|
|
25
|
+
let toggle: string;
|
|
26
|
+
let sortAsc: string;
|
|
27
|
+
let sortDesc: string;
|
|
28
|
+
}
|
|
29
|
+
/** The script of the Tables view (a constant: its hash goes in the file's CSP). @type {string} */
|
|
30
|
+
export const DATA_SCRIPT: string;
|
|
31
|
+
/** CSS of the bar and the Tables view. @type {string} */
|
|
32
|
+
export const DATA_CSS: string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page model → PDF bytes. Draws exactly the lines the engine made.
|
|
3
|
+
* @param {any} model render() output
|
|
4
|
+
* @param {import('../engine/text/fonts.js').FontStore} fontStore
|
|
5
|
+
* @param {{ title?: string, author?: string, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
6
|
+
* subset?: (font: Uint8Array, codePoints: Iterable<number>) => Promise<Uint8Array>,
|
|
7
|
+
* pdfa?: { icc?: Uint8Array }, prepare?: (doc: PDFDocument) => any, save?: object,
|
|
8
|
+
* encrypt?: { userPassword?: string, ownerPassword?: string, permissions?: Partial<Record<keyof typeof import('./encrypt.js').PERMISSION_BITS, boolean>> },
|
|
9
|
+
* tagged?: { lang?: string }, drillBase?: string, onWarning?: (message: string) => void, timeoutMs?: number,
|
|
10
|
+
* creationDate?: Date }} [opt]
|
|
11
|
+
* subset: a HarfBuzz subsetter (see subset.js). Without it, fonts embed in full.
|
|
12
|
+
* pdfa: make a PDF/A-2b file (needs an sRGB ICC profile). prepare: last change before saving
|
|
13
|
+
* (the server adds a signature placeholder there). save: extra pdf-lib save options.
|
|
14
|
+
* encrypt: { userPassword, ownerPassword, permissions } — AES-256 (see encrypt.js); not with pdfa or prepare.
|
|
15
|
+
* tagged: an accessible PDF (PDF/UA-1, see pdfua.js): structure tree, marked content, artifacts, language, title
|
|
16
|
+
* shown; with pdfa it is PDF/A-2a. Off, the file is exactly what it was.
|
|
17
|
+
* drillBase: the ReportWright server whose viewer a drill-through opens (a URI link); without it a drill-through
|
|
18
|
+
* is not a link. onWarning: what was left out (a damaged image). timeoutMs: the export's time limit (504).
|
|
19
|
+
* creationDate: the file's dates (UTC); else SOURCE_DATE_EPOCH when set; with either, the same report exports to the
|
|
20
|
+
* same bytes (encryption keeps its random key, so it does not).
|
|
21
|
+
*/
|
|
22
|
+
export function exportPdf(model: any, fontStore: import("../engine/text/fonts.js").FontStore, opt?: {
|
|
23
|
+
title?: string;
|
|
24
|
+
author?: string;
|
|
25
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
26
|
+
subset?: (font: Uint8Array, codePoints: Iterable<number>) => Promise<Uint8Array>;
|
|
27
|
+
pdfa?: {
|
|
28
|
+
icc?: Uint8Array;
|
|
29
|
+
};
|
|
30
|
+
prepare?: (doc: PDFDocument) => any;
|
|
31
|
+
save?: object;
|
|
32
|
+
encrypt?: {
|
|
33
|
+
userPassword?: string;
|
|
34
|
+
ownerPassword?: string;
|
|
35
|
+
permissions?: Partial<Record<keyof typeof import("./encrypt.js").PERMISSION_BITS, boolean>>;
|
|
36
|
+
};
|
|
37
|
+
tagged?: {
|
|
38
|
+
lang?: string;
|
|
39
|
+
};
|
|
40
|
+
drillBase?: string;
|
|
41
|
+
onWarning?: (message: string) => void;
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
creationDate?: Date;
|
|
44
|
+
}): any;
|
|
45
|
+
import { PDFDocument } from 'pdf-lib';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('pdf-lib').PDFDocument} doc call after all pages, fields and annotations are added
|
|
3
|
+
* @param {{ icc?: Uint8Array, title?: string, author?: string, created?: Date, conformance?: 'A'|'B', ua?: boolean, id?: string }} opt
|
|
4
|
+
* id: the file identifier as hex (derived from the content for a fixed date), else random
|
|
5
|
+
* icc: an RGB ICC profile (the sRGB one in public/icc). conformance A (PDF/A-2a) for a tagged file; ua: it is PDF/UA-1 too.
|
|
6
|
+
*/
|
|
7
|
+
export function makePdfA(doc: import("pdf-lib").PDFDocument, { icc, title, author, created, conformance, ua, id }?: {
|
|
8
|
+
icc?: Uint8Array;
|
|
9
|
+
title?: string;
|
|
10
|
+
author?: string;
|
|
11
|
+
created?: Date;
|
|
12
|
+
conformance?: "A" | "B";
|
|
13
|
+
ua?: boolean;
|
|
14
|
+
id?: string;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* The Info dictionary's CreationDate and ModDate for an instant, in UTC (D:…+00'00'): the same instant gives the
|
|
18
|
+
* same bytes in any time zone. pdf-lib's own setters write the local offset.
|
|
19
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
20
|
+
* @param {Date} when
|
|
21
|
+
*/
|
|
22
|
+
export function setInfoDates(doc: import("pdf-lib").PDFDocument, when: Date): void;
|
|
23
|
+
/**
|
|
24
|
+
* PDF/UA-1 without PDF/A: XMP metadata with the title and the PDF/UA identifier (the Info dictionary says the same).
|
|
25
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
26
|
+
*/
|
|
27
|
+
export function setUaMetadata(doc: import("pdf-lib").PDFDocument, { title, author, created }?: {
|
|
28
|
+
title?: string;
|
|
29
|
+
author?: any;
|
|
30
|
+
created?: Date;
|
|
31
|
+
}): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} model
|
|
3
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
4
|
+
*/
|
|
5
|
+
export function createTagger(model: any, doc: import("pdf-lib").PDFDocument): {
|
|
6
|
+
/**
|
|
7
|
+
* Marked content around item ii of page pi: the operator that opens it, or null (nothing is drawn for it).
|
|
8
|
+
* @returns {string|null}
|
|
9
|
+
*/
|
|
10
|
+
open(pi: any, ii: any, it: any): string | null;
|
|
11
|
+
/** A link annotation of item ii (or a field's widget): its structure element; returns its StructParent key. */
|
|
12
|
+
annot(pi: any, ii: any, ref: any, kind: any): void;
|
|
13
|
+
finish({ lang, title }?: {
|
|
14
|
+
lang?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a PNG cannot be embedded, or null when it can.
|
|
3
|
+
* @param {Uint8Array} b @returns {string|null}
|
|
4
|
+
*/
|
|
5
|
+
export function pngProblem(b: Uint8Array): string | null;
|
|
6
|
+
export namespace PNG_LIMITS {
|
|
7
|
+
let pixels: number;
|
|
8
|
+
let rawBytes: number;
|
|
9
|
+
let chunks: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} model render() output
|
|
3
|
+
* @param {{ title?: string, author?: string, lang?: string, fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
4
|
+
* rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null> }} [opt]
|
|
5
|
+
* @returns {Promise<Uint8Array>}
|
|
6
|
+
*/
|
|
7
|
+
export function exportPptx(model: any, opt?: {
|
|
8
|
+
title?: string;
|
|
9
|
+
author?: string;
|
|
10
|
+
lang?: string;
|
|
11
|
+
fontStore?: any;
|
|
12
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
13
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
14
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page model rendered without exportData (the default: a view, a plain PDF) has no table data and no cell tags:
|
|
3
|
+
* the exports that rebuild tables refuse it rather than write a file without its tables.
|
|
4
|
+
*/
|
|
5
|
+
export function needsTableData(model: any, what: any): void;
|
|
6
|
+
/** Merge table regions that share a name (a table repeated inside a list). */
|
|
7
|
+
export function mergedRegions(model: any): any[];
|
|
8
|
+
/**
|
|
9
|
+
* The visual lines of a text item, as strings. A justified line is one run per word on the same
|
|
10
|
+
* baseline; this joins them back (in x order) so text exports and search see whole lines.
|
|
11
|
+
* @param {{ lines: { x: number, y: number, text: string }[] }} it
|
|
12
|
+
* @returns {string[]}
|
|
13
|
+
*/
|
|
14
|
+
export function visualLines(it: {
|
|
15
|
+
lines: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
}): string[];
|
|
21
|
+
/**
|
|
22
|
+
* The visual lines of a page's text items, as strings. Rich text draws one text item per styled
|
|
23
|
+
* fragment (`rich: {id, l}`); the fragments of one box on one line (superscripts included) are joined in x order with
|
|
24
|
+
* nothing between them (they keep their own spaces). Other items give their visualLines().
|
|
25
|
+
* @param {any[]} items page-model items (anything that is not text is skipped)
|
|
26
|
+
* @returns {string[]}
|
|
27
|
+
*/
|
|
28
|
+
export function textRows(items: any[]): string[];
|
|
29
|
+
export function needsExportData(fmt: any, o?: {}): boolean;
|
|
30
|
+
export function isJustified(it: any): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @param {() => Promise<ArrayBuffer|Uint8Array>} loadWasm */
|
|
2
|
+
export function createSubsetter(loadWasm: () => Promise<ArrayBuffer | Uint8Array>): (font: Uint8Array, codePoints: Iterable<number>, opt?: {
|
|
3
|
+
glyphs?: Iterable<number>;
|
|
4
|
+
layout?: boolean;
|
|
5
|
+
}) => Promise<Uint8Array>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address a browser may load an image from, by the policy of the data fetches: a data:image URI or this server's
|
|
3
|
+
* own path as it is; an absolute http(s) URL only through this server's data proxy (/api/data/proxy: PW_PROXY_ALLOW
|
|
4
|
+
* hosts, never a private address); anything else (another scheme, //host) not at all. So a stored report cannot make
|
|
5
|
+
* its viewers' browsers call hosts of its choosing. @param {any} src @param {string} [proxyBase] the server's origin,
|
|
6
|
+
* for a file opened elsewhere (the HTML export)
|
|
7
|
+
*/
|
|
8
|
+
export function imageHref(src: any, proxyBase?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* box: draw only this part of the page (viewBox), as Word and PowerPoint figures do. outline: text as glyph outlines,
|
|
11
|
+
* from fontkit fonts (figures.js), for readers without the report's fonts.
|
|
12
|
+
* @param {{ background?: boolean, animate?: boolean, box?: { x: number, y: number, w: number, h: number }, outline?: ((key: string) => any) | null }} [opt]
|
|
13
|
+
*/
|
|
14
|
+
export function pageToSvg(page: any, w: any, h: any, { background, animate, box, outline, proxyBase }?: {
|
|
15
|
+
background?: boolean;
|
|
16
|
+
animate?: boolean;
|
|
17
|
+
box?: any;
|
|
18
|
+
outline?: any;
|
|
19
|
+
proxyBase?: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export function linkTitle(a: any): any;
|
|
22
|
+
/** @font-face rules for report fonts served from /fonts (uploaded ones from /fonts/custom). */
|
|
23
|
+
export function fontFaceCss(keys: any, base?: string): any;
|
|
24
|
+
/** Every font key a page model draws with (text items, their runs, form fields). */
|
|
25
|
+
export function fontKeysOf(model: any): any[];
|
|
26
|
+
export function fontFamilyCss(key: any): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A transform list, split on ")" and "(": linear, no backtracking. @param {string} s @returns {M} */
|
|
2
|
+
export function parseTransform(s: string): M;
|
|
3
|
+
/**
|
|
4
|
+
* Shapes of an SVG in its own user space (the root viewBox applied), with their paint resolved.
|
|
5
|
+
* @param {string} text
|
|
6
|
+
* @returns {{ w: number, h: number, shapes: { d: string, m: M, fill: any, stroke: any, sw: number, fo: number, so: number }[] } | null}
|
|
7
|
+
*/
|
|
8
|
+
export function parseSvg(text: string): {
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
shapes: {
|
|
12
|
+
d: string;
|
|
13
|
+
m: M;
|
|
14
|
+
fill: any;
|
|
15
|
+
stroke: any;
|
|
16
|
+
sw: number;
|
|
17
|
+
fo: number;
|
|
18
|
+
so: number;
|
|
19
|
+
}[];
|
|
20
|
+
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* Draw a parsed SVG into the box (PDF coordinates: x, y of the bottom-left corner), scaled by sx, sy.
|
|
23
|
+
* @param {any} page pdf-lib PDFPage
|
|
24
|
+
* @param {NonNullable<ReturnType<typeof parseSvg>>} svg
|
|
25
|
+
* @param {{ x: number, y: number, sx: number, sy: number }} at
|
|
26
|
+
*/
|
|
27
|
+
export function drawSvg(page: any, svg: NonNullable<ReturnType<typeof parseSvg>>, at: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
sx: number;
|
|
31
|
+
sy: number;
|
|
32
|
+
}): void;
|
|
33
|
+
export type M = [number, number, number, number, number, number];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report format → Excel number format. value: the cell's value, so a date gets a date format (N6: "d" is a date,
|
|
3
|
+
* not two decimals) and an en-IN number its own lakh grouping (N22: Excel's conditions cannot cover negatives).
|
|
4
|
+
* @param {string|null|undefined} fmt @param {string} [currencySymbol] @param {string} [locale] @param {any} [value]
|
|
5
|
+
*/
|
|
6
|
+
export function excelFormat(fmt: string | null | undefined, currencySymbol?: string, locale?: string, value?: any): any;
|
|
7
|
+
/** The currency symbol for a code in the report locale ("INR" → ₹), else the code. */
|
|
8
|
+
export function currencySymbol(iso: any, locale: any): any;
|
|
9
|
+
/** A column's values over the rows a total covers, kept as they pass: what subtotalFn needs, in O(1) memory. */
|
|
10
|
+
export function colStats(): {
|
|
11
|
+
vals: number;
|
|
12
|
+
nums: number;
|
|
13
|
+
sum: number;
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
first: any;
|
|
17
|
+
differ: boolean;
|
|
18
|
+
/** @param {any} v a region cell's value */
|
|
19
|
+
add(v: any): void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The SUBTOTAL function a total's shown value is, over its column's values (colStats), or null: 9 the sum, 2/3 the
|
|
23
|
+
* count (COUNTA when there is text), 1 the average, 5 the minimum, 4 the maximum, each within the format's precision.
|
|
24
|
+
* @param {{ value: any, format?: string }} c @param {ReturnType<typeof colStats>} st
|
|
25
|
+
*/
|
|
26
|
+
export function subtotalFn(c: {
|
|
27
|
+
value: any;
|
|
28
|
+
format?: string;
|
|
29
|
+
}, st: ReturnType<typeof colStats>): 1 | 2 | 3 | 4 | 5 | 9;
|
|
30
|
+
/** Excel's sheet names, unique in a workbook: no \\ / ? * [ ] :, no control characters, not starting or ending with ', at
|
|
31
|
+
* most 31 characters (28 here, room for a " 2"). suffix: kept whole (a split sheet's " (2)"). */
|
|
32
|
+
export function sheetNamer(): (n: any, suffix?: string) => string;
|
|
33
|
+
/** A region cell → an Excel cell: its value (dates as the report's wall clock), number format, bold and header fill. */
|
|
34
|
+
export function xlsxCell({ sym, locale, tz }: {
|
|
35
|
+
sym: any;
|
|
36
|
+
locale: any;
|
|
37
|
+
tz: any;
|
|
38
|
+
}): (c: any, header: boolean) => any;
|
|
39
|
+
/**
|
|
40
|
+
* Excel workbook in "data mode": one sheet per table, typed cells, number formats,
|
|
41
|
+
* bold header and group rows, and outline levels for grouped detail rows. Group and table totals that are a sum,
|
|
42
|
+
* count, average, minimum or maximum of their column are live SUBTOTAL formulas (formulas: false keeps values).
|
|
43
|
+
* Charts are native Excel charts; pictures go on a sheet of their own (PNG; needs a rasteriser, see figures.js).
|
|
44
|
+
* Written by xlsxwriter.js (no ExcelJS).
|
|
45
|
+
* @param {any} model render() output
|
|
46
|
+
* @param {{ currency?: string, title?: string, formulas?: boolean, pictures?: boolean, charts?: boolean, fontStore?: any, fonts?: any,
|
|
47
|
+
* fetchImage?: (src: string) => Promise<Uint8Array|null>, rasterize?: any, timeZone?: string }} [opt]
|
|
48
|
+
* @returns {Promise<Uint8Array>}
|
|
49
|
+
*/
|
|
50
|
+
export function exportXlsx(model: any, opt?: {
|
|
51
|
+
currency?: string;
|
|
52
|
+
title?: string;
|
|
53
|
+
formulas?: boolean;
|
|
54
|
+
pictures?: boolean;
|
|
55
|
+
charts?: boolean;
|
|
56
|
+
fontStore?: any;
|
|
57
|
+
fonts?: any;
|
|
58
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
59
|
+
rasterize?: any;
|
|
60
|
+
timeZone?: string;
|
|
61
|
+
}, legacy?: any): Promise<Uint8Array>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cells a chart's data takes on its sheet, from row 1: a header row, then one row per category (or point).
|
|
3
|
+
* @param {any} spec items[0].xchart (engine/items/chart.js nativeSpec)
|
|
4
|
+
* @returns {any[][]}
|
|
5
|
+
*/
|
|
6
|
+
export function chartTable(spec: any): any[][];
|
|
7
|
+
/**
|
|
8
|
+
* The chart part (xl/charts/chartN.xml) for a spec whose data starts at A1 of `sheet`.
|
|
9
|
+
* @param {any} spec @param {string} sheet
|
|
10
|
+
*/
|
|
11
|
+
export function chartXml(spec: any, sheet: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Add the charts to a workbook ExcelJS wrote. Each chart: { sheet (its sheet's name), spec, at: { col, row } } with
|
|
14
|
+
* its data at A1 of that sheet; the sheets have no drawing of their own.
|
|
15
|
+
* @param {Uint8Array} bytes @param {{ sheet: string, spec: any, at: { col: number, row: number } }[]} charts
|
|
16
|
+
* @returns {Uint8Array}
|
|
17
|
+
*/
|
|
18
|
+
export function addCharts(bytes: Uint8Array, charts: {
|
|
19
|
+
sheet: string;
|
|
20
|
+
spec: any;
|
|
21
|
+
at: {
|
|
22
|
+
col: number;
|
|
23
|
+
row: number;
|
|
24
|
+
};
|
|
25
|
+
}[]): Uint8Array;
|
|
26
|
+
export function esc(s: any): string;
|