@sheetxl/query 0.8.0-beta.1 → 0.8.0-beta.11

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.
Files changed (49) hide show
  1. package/browser/esm/index.mjs +4008 -1103
  2. package/node/esm/index.mjs +4301 -1346
  3. package/package.json +6 -7
  4. package/types/src/Tool.d.ts +38 -0
  5. package/types/src/api/_aliases.d.ts +16 -0
  6. package/types/src/api/_offered.d.ts +13 -0
  7. package/types/src/api/apiTool.d.ts +22 -0
  8. package/types/src/api/index.d.ts +4 -0
  9. package/types/src/api/lookupApi.d.ts +171 -0
  10. package/types/src/api/renderApi.d.ts +13 -0
  11. package/types/src/delta/describeDelta.d.ts +148 -0
  12. package/types/src/delta/index.d.ts +4 -0
  13. package/types/src/delta/readRunDelta.d.ts +21 -0
  14. package/types/src/delta/renderDelta.d.ts +20 -0
  15. package/types/src/encode/encodeCell.d.ts +19 -7
  16. package/types/src/grep/GrepTypes.d.ts +88 -42
  17. package/types/src/grep/grep.d.ts +4 -1
  18. package/types/src/index.d.ts +10 -0
  19. package/types/src/markdown/appendDependencies.d.ts +106 -0
  20. package/types/src/markdown/appendPivotTables.d.ts +22 -0
  21. package/types/src/markdown/appendSections.d.ts +57 -105
  22. package/types/src/markdown/caps.d.ts +4 -0
  23. package/types/src/markdown/describeAnomaly.d.ts +22 -0
  24. package/types/src/markdown/describeChart.d.ts +72 -0
  25. package/types/src/markdown/describeExternalCitation.d.ts +27 -0
  26. package/types/src/markdown/describeHistogram.d.ts +186 -0
  27. package/types/src/markdown/describeRegionPayload.d.ts +4 -4
  28. package/types/src/markdown/describeRule.d.ts +5 -5
  29. package/types/src/markdown/describeShape.d.ts +41 -0
  30. package/types/src/markdown/describeStyle.d.ts +7 -7
  31. package/types/src/markdown/findLabels.d.ts +19 -0
  32. package/types/src/markdown/index.d.ts +6 -1
  33. package/types/src/markdown/profileRegion.d.ts +56 -1
  34. package/types/src/markdown/registry.d.ts +18 -4
  35. package/types/src/markdown/renderCell.d.ts +14 -11
  36. package/types/src/markdown/renderCellRange.d.ts +3 -2
  37. package/types/src/markdown/renderFormula.d.ts +2 -2
  38. package/types/src/markdown/renderModules.d.ts +55 -0
  39. package/types/src/markdown/renderMovable.d.ts +83 -14
  40. package/types/src/markdown/renderNames.d.ts +2 -2
  41. package/types/src/markdown/renderPageLayout.d.ts +22 -0
  42. package/types/src/markdown/renderProtection.d.ts +81 -0
  43. package/types/src/markdown/renderRecords.d.ts +8 -0
  44. package/types/src/markdown/renderRegions.d.ts +1 -0
  45. package/types/src/markdown/renderStyle.d.ts +2 -2
  46. package/types/src/markdown/renderTable.d.ts +11 -3
  47. package/types/src/markdown/renderWorkbook.d.ts +33 -26
  48. package/types/src/markdown/{renderSheet.d.ts → renderWorksheet.d.ts} +10 -11
  49. package/browser/cjs/index.cjs +0 -26
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The cell layers `grep` can match against.
2
+ * The layers `grep` can match against.
3
3
  *
4
4
  * @remarks
5
5
  * These are *not* `ICell.Content`. That enum also carries `formats`, `tables`, `merges` and
@@ -8,19 +8,21 @@
8
8
  * The rule, which predicts any future member:
9
9
  * **a grep field is a layer whose text was authored by a person or is read by one.**
10
10
  *
11
- * `display`, `value` and `raw` are read; `formula`, `hyperlink` and `numberFormat` are authored.
11
+ * `display` and `value` are read; `formula`, `hyperlink` and `numberFormat` are authored.
12
12
  * A layer that fails the rule fails it because its payload has no canonical text — a fill's
13
13
  * "red" may be stored as `FF0000`, a theme slot, or an indexed palette entry, so any pattern
14
14
  * against it silently matches less than it claims: a confident wrong answer, which is worse
15
15
  * than a missing feature. Color wants *nearness*, not matching — that is selection by
16
16
  * attribute, and it belongs to the regions read.
17
17
  *
18
- * Two layers are deliberately absent for the same reason:
19
- * - `note` — `ICell.Content.Notes` is marked NOT IMPLEMENTED.
20
- * - `comment` — `IComment.Properties.content` is `any` pending `IRichText.JSON`, so any text
21
- * extractor written against it today would quietly miss the shapes it did not anticipate.
18
+ * The rule does not stop at the cell. A callout, a chart title, a comment and a defined name are
19
+ * all text a person wrote into the workbook, and none of it is in any cell — so `comment`,
20
+ * `shape`, `chart` and `name` are layers too, tagged the same way. A search that finds the cell
21
+ * reading `Fund Size` and misses the callout explaining it has answered a narrower question than
22
+ * the one asked.
22
23
  *
23
- * Both are additive once the SDK shapes settle.
24
+ * There is no `note` field: a note is a comment that says so (`IComment.isNote`), and `comment`
25
+ * searches both.
24
26
  */
25
27
  export type GrepField =
26
28
  /**
@@ -38,28 +40,18 @@ export type GrepField =
38
40
  */
39
41
  'display'
40
42
  /**
41
- * The cell as the formula bar shows it — most formatting stripped, **category kept**.
43
+ * The stored scalar — what `getValue()` returns, with no number format applied.
42
44
  *
43
- * `1234.5678` where {@link GrepField | display} shows `$1,234.57` — but `40%` stays `40%`
44
- * and dates stay dates, because the formula bar keeps minimal formatting for percents,
45
- * dates and times (Excel's behavior, faithfully). This is *not* the underlying scalar:
46
- * a percent cell storing `0.4` reads `40%` here. The stored scalar is
47
- * {@link GrepField | raw}.
45
+ * `1234.5678` where {@link GrepField | display} shows `$1,234.57`, `0.4` where it shows `40%`,
46
+ * dates as serial numbers. This is the layer a cell report's `Value` line and the `IRange` /
47
+ * stats reads print, so it is the field that makes *those* printed values greppable — the
48
+ * round-trip that `display` provides for formatted reads. Not a default: serials and
49
+ * unrounded floats are noise until they are the question.
48
50
  *
49
51
  * Identical to `display` for every cell whose format only decorates (`General`, plain
50
- * text) — the default search dedupes that case per cell rather than reporting both.
52
+ * text) — a search of both dedupes that case per cell rather than reporting it twice.
51
53
  */
52
54
  | 'value'
53
- /**
54
- * The stored scalar, encoded bare — what the stateless value layer prints.
55
- *
56
- * `0.4` where {@link GrepField | value} shows `40%`; dates as serial numbers. This is the
57
- * layer `IRange` / stats reads print (they have no cell to format through), so it is the
58
- * field that makes *those* printed values greppable — the round-trip that `display`
59
- * provides for formatted reads. Not a default: serials and unrounded floats are noise
60
- * until they are the question.
61
- */
62
- | 'raw'
63
55
  /** Formula text, A1 style (`=SUM(A1:A10)`). Cells without a formula contribute nothing. */
64
56
  | 'formula'
65
57
  /** Hyperlink target — the address, not the display text (which is already `display`). */
@@ -72,14 +64,48 @@ export type GrepField =
72
64
  * cells are percentages" — the rendered `40%` is not. Matches cells with a *direct*
73
65
  * format, including value-less ones (a formatted-but-empty column is a real finding).
74
66
  */
75
- | 'numberFormat';
67
+ | 'numberFormat'
68
+ /**
69
+ * The comment or note on a cell, and every reply in its thread — each its own row.
70
+ *
71
+ * A cell layer like the others: the match is the commented cell, and a cell that matches in
72
+ * its display AND its comment is one cell. A comment on an empty cell is still found.
73
+ */
74
+ | 'comment'
75
+ /**
76
+ * The text written on a shape — a text box, a callout — and its alt text.
77
+ *
78
+ * The match is the shape, addressed by the cells it is anchored over (`F2:H6`), which is what
79
+ * `range.getMovables()` takes to get back to it.
80
+ */
81
+ | 'shape'
82
+ /**
83
+ * What a chart says in words: its title, its axis titles, the series names written into it,
84
+ * and its alt text. Addressed like a {@link GrepField | shape}.
85
+ *
86
+ * A series named by a cell (`=Sales!$C$3`) is not repeated here — that text is the cell's, and
87
+ * `display` already finds it there.
88
+ */
89
+ | 'chart'
90
+ /**
91
+ * Defined names and tables: the name, what it refers to (`=Summary!$B$4`, `=0.21`) and its
92
+ * comment.
93
+ *
94
+ * The match is the name, spelled as a formula writes it (`'EU Ops'!Rate` when sheet-scoped) —
95
+ * a name has no cell of its own. Under a {@link GrepArgs.scope | scope} a name is searched
96
+ * when it is scoped to a searched sheet or designates cells inside the searched range.
97
+ */
98
+ | 'name';
76
99
  export declare const GrepField: {
77
100
  readonly Display: "display";
78
101
  readonly Value: "value";
79
- readonly Raw: "raw";
80
102
  readonly Formula: "formula";
81
103
  readonly Hyperlink: "hyperlink";
82
104
  readonly NumberFormat: "numberFormat";
105
+ readonly Comment: "comment";
106
+ readonly Shape: "shape";
107
+ readonly Chart: "chart";
108
+ readonly Name: "name";
83
109
  };
84
110
  /** Every field, in the order they are searched and reported. */
85
111
  export declare const GREP_FIELDS: readonly GrepField[];
@@ -87,12 +113,15 @@ export declare const GREP_FIELDS: readonly GrepField[];
87
113
  * The default field set.
88
114
  *
89
115
  * @remarks
90
- * What you can see, what the formula bar shows, and what is structurally behind both.
91
- * `value` is a default *because* the search dedupes it: for the majority of cells it is
92
- * byte-identical to `display` and is suppressed per cell, so it only surfaces where it
93
- * carries new information — `1234.5678` behind `$1,234.57`. A duplicate hit costs an agent
94
- * a second look for no new information; a missing layer costs a silent zero-hit miss on
95
- * full-precision searches, which is worse.
116
+ * What you can see and what is structurally behind it. `value` is opt-in: a search is almost
117
+ * always for text as the grid shows it, and the stored scalar in a default search makes every
118
+ * numeric pattern hit date serials and unrounded floats nobody was looking at. The search that
119
+ * wants it — a full-precision number copied from a stats read or a cell report's `Value` line —
120
+ * knows it does, and asks with `fields: ['value']`.
121
+ *
122
+ * The layers off the grid are defaults. A caller who has to ask for `shape` already knows the
123
+ * callout is there; the search that needs it is the one that does not. They cost one pass over a
124
+ * sheet's objects, not over its cells.
96
125
  */
97
126
  export declare const GREP_FIELDS_DEFAULT: readonly GrepField[];
98
127
  /** What a grep result should carry. */
@@ -134,9 +163,10 @@ export interface GrepArgs {
134
163
  */
135
164
  pattern: string;
136
165
  /**
137
- * Which cell layers to search.
166
+ * Which layers to search.
138
167
  *
139
- * @defaultValue {@link GREP_FIELDS_DEFAULT} — `['display', 'value', 'formula']`
168
+ * @defaultValue {@link GREP_FIELDS_DEFAULT} —
169
+ * `['display', 'formula', 'comment', 'shape', 'chart', 'name']`
140
170
  */
141
171
  fields?: readonly GrepField[];
142
172
  /**
@@ -166,11 +196,11 @@ export interface GrepArgs {
166
196
  */
167
197
  word?: boolean;
168
198
  /**
169
- * Invert the match — report cells where **no** requested field matched (`rg -v`).
199
+ * Invert the match — report cells and objects where **no** requested field matched (`rg -v`).
170
200
  *
171
201
  * @remarks
172
- * Scoped to cells grep visits: a cell must have text in at least one requested field to be
173
- * reported (an empty cell is not a finding, and "every blank cell" is not an answer).
202
+ * Scoped to what grep visits: a cell or object must have text in at least one requested field
203
+ * to be reported (an empty cell is not a finding, and "every blank cell" is not an answer).
174
204
  * Reported rows carry the first requested field that has text, as the evidence line.
175
205
  */
176
206
  invert?: boolean;
@@ -200,14 +230,16 @@ export interface GrepArgs {
200
230
  */
201
231
  hidden?: boolean;
202
232
  /**
203
- * Stop after this many matching cells. Truncation is always reported, never silent.
233
+ * Stop after this many matches — cells and objects together. Truncation is always reported,
234
+ * never silent.
204
235
  *
205
236
  * @defaultValue 200 — a grep result returns into a context window, not a terminal stream,
206
237
  * so unbounded output is a cost the caller did not ask for. `0` removes the cap.
207
238
  *
208
239
  * @remarks
209
- * Counts **cells**, not match rows — a cell matching in two fields is one unit of budget.
210
- * The search looks one cell past the cap, so a result that ends exactly at `maxCount` is
240
+ * Counts **cells and objects**, not match rows — a cell matching in two fields is one unit of
241
+ * budget, and so is a chart matching in its title and an axis.
242
+ * The search looks one match past the cap, so a result that ends exactly at `maxCount` is
211
243
  * only reported truncated when a further match actually exists.
212
244
  */
213
245
  maxCount?: number;
@@ -240,6 +272,10 @@ export interface GrepMatchContext {
240
272
  * order.
241
273
  *
242
274
  * @remarks
275
+ * Text that is not in a cell keeps the same shape. A shape or a chart is an entry per matched
276
+ * text, addressed by the cells it is anchored over, after its sheet's cells; a defined name is an
277
+ * entry addressed by the name itself, after every sheet.
278
+ *
243
279
  * Deliberately not coalesced into blocks: uniform runs of identical values are *regions* — a
244
280
  * payload feature splits where the value changes, so the regions read already owns that shape,
245
281
  * in 2-D and with the full partition to rank against. Grep answering cell-grain and regions
@@ -248,9 +284,15 @@ export interface GrepMatchContext {
248
284
  * renderer merely groups by it.
249
285
  */
250
286
  export interface GrepMatch {
251
- /** Sheet name. */
287
+ /**
288
+ * Sheet name — for a `name` match, the sheet the name is scoped to, or `''` for a
289
+ * workbook-scoped one.
290
+ */
252
291
  sheet: string;
253
- /** A1 cell address within the sheet. */
292
+ /**
293
+ * A1 cell address within the sheet; the anchor range (`F2:H6`) for a shape or chart; the name
294
+ * itself for a defined name. Qualified with `sheet`, each is something a follow-up call takes.
295
+ */
254
296
  address: string;
255
297
  /**
256
298
  * Which layer matched.
@@ -272,6 +314,8 @@ export interface GrepSheetMatches {
272
314
  sheet: string;
273
315
  /** Distinct cells that produced at least one match in this sheet. */
274
316
  cells: number;
317
+ /** Shapes and charts on this sheet that produced at least one match. */
318
+ objects: number;
275
319
  }
276
320
  /** The result of a {@link grep}. */
277
321
  export interface GrepResult {
@@ -283,6 +327,8 @@ export interface GrepResult {
283
327
  matches: readonly GrepMatch[];
284
328
  /** Distinct cells that produced at least one match. */
285
329
  cellCount: number;
330
+ /** Shapes, charts and names that produced at least one match. */
331
+ objectCount: number;
286
332
  /** Per-sheet counts, in search order — only sheets with at least one match appear. */
287
333
  sheets: readonly GrepSheetMatches[];
288
334
  /**
@@ -1,9 +1,12 @@
1
1
  import { IWorkbook } from '@sheetxl/sdk';
2
2
  import { GrepArgs, GrepResult } from './GrepTypes';
3
3
  /**
4
- * Searches a workbook's cell contents by pattern.
4
+ * Searches a workbook's text by pattern — its cells, and what is written off the grid.
5
5
  *
6
6
  * @remarks
7
+ * Per sheet: the cells in reading order (a comment rides its cell), then the shapes and charts
8
+ * in reading order of their anchors. Defined names follow every sheet, since they belong to none.
9
+ *
7
10
  * Deliberately shaped after ripgrep — args, defaults and vocabulary are pretrained, and every
8
11
  * novel idiom is paid for in error loops.
9
12
  *
@@ -2,7 +2,9 @@ import { Tool } from './Tool';
2
2
  export * from './Tool';
3
3
  export * from './encode';
4
4
  export * from './grep';
5
+ export * from './api';
5
6
  export * from './markdown';
7
+ export * from './delta';
6
8
  /**
7
9
  * The read surface, defined once.
8
10
  *
@@ -17,4 +19,12 @@ export * from './markdown';
17
19
  * reason). A capability joins this list only when it is not a one-line run idiom.
18
20
  */
19
21
  export declare const TOOLS: readonly Tool.Descriptor[];
22
+ /**
23
+ * The reference surface — capabilities that read the install rather than a workbook.
24
+ *
25
+ * @remarks
26
+ * Registered by every host surface exactly as {@link TOOLS} is, minus the part that names a
27
+ * workbook. See {@link Tool.Reference}.
28
+ */
29
+ export declare const REFERENCES: readonly Tool.Reference[];
20
30
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,106 @@
1
+ import { ICellRange, ICellRanges, IRange, IWorksheet } from '@sheetxl/sdk';
2
+ import { MarkdownBuilder } from './MarkdownBuilder';
3
+ /**
4
+ * Options for the dependency sections.
5
+ */
6
+ export interface AppendDependencyOptions {
7
+ /**
8
+ * Rows each tree prints before the rest of the graph is left to the flat call.
9
+ *
10
+ * @remarks
11
+ * A line budget, not a depth cut: the tree is filled level by level, so a budget that runs out
12
+ * drops the deepest nodes first, and every node with unshown children says how many.
13
+ *
14
+ * @defaultValue 12
15
+ */
16
+ maxTreeRows?: number;
17
+ }
18
+ /** The calculation-graph surface shared by {@link ICell}, {@link ICellRange} and a defined name. */
19
+ export interface DependencySource {
20
+ getDirectPrecedents(): Promise<ICellRanges | null>;
21
+ getPrecedents(): Promise<ICellRanges | null>;
22
+ getDirectDependents(): Promise<ICellRanges | null>;
23
+ getDependents(): Promise<ICellRanges | null>;
24
+ }
25
+ /**
26
+ * How the caller wants empty sections and sheet crossings reported.
27
+ *
28
+ * @remarks
29
+ * Not a render option — these are facts about the SUBJECT that only the calling report knows. A
30
+ * formula cell with no dependents is an output and `Dependents (0)` says so; a text label with no
31
+ * dependents is just a label, and the same heading would be noise on every one of them.
32
+ */
33
+ export interface DependencyContext {
34
+ /** Print `## Precedents (0)` rather than omitting the section. */
35
+ zeroPrecedents?: boolean;
36
+ /** Print `## Dependents (0)` rather than omitting the section. */
37
+ zeroDependents?: boolean;
38
+ /** The sheet the report is about; members elsewhere are listed as crossings. */
39
+ home?: IWorksheet | null;
40
+ /** The cells the report is about, when it is about cells: charts that plot them are dependents too. */
41
+ subject?: ICellRange | null;
42
+ }
43
+ /**
44
+ * Appends the `Precedents` and `Dependents` sections for anything that exposes the calculation
45
+ * graph — a cell, a range or a name, which answer the same questions with the same shape.
46
+ *
47
+ * @remarks
48
+ * **The heading carries the reach; the tree beneath shows the path.** The flat reach
49
+ * (`getPrecedents()` / `getDependents()`) is what the engine already holds for recalculation, so
50
+ * its size costs one call: `(239 cells · 216 inputs · depth 6 · 9 areas)`. That is the answer to
51
+ * the common question — how much does this read, how much reads it — without any code. The tree
52
+ * is the explanation, and it is budgeted by rows (see {@link AppendDependencyOptions.maxTreeRows}).
53
+ *
54
+ * `inputs` are the typed (non-formula) cells in the precedent reach — the values a change to the
55
+ * model is actually made in. `outputs` are the dependents nothing else reads — the reported
56
+ * figures a change here ends up in, which is why they are listed by address and row label.
57
+ *
58
+ * `depth` is the longest chain of hops, which is the number of levels the full tree would have.
59
+ * It is the one measure the engine does not hold, so it is a walk, bounded, and stated as a lower
60
+ * bound (`depth ≥ n`) when the bound fires.
61
+ */
62
+ export declare function appendDependencies(md: MarkdownBuilder, target: DependencySource, options?: AppendDependencyOptions, context?: DependencyContext): Promise<void>;
63
+ /**
64
+ * `row "Net Earnings" col "JUN"` — the labels of a single-cell node that is not itself text.
65
+ *
66
+ * @remarks
67
+ * `G33 21.7 =+G30-G32` does not say what G33 is; its labels do. Read with {@link findLabel}, so the
68
+ * rule is the cell report's. `origin` is the subject the tree hangs from: a label the node shares
69
+ * with it — the same row, the same column — is left off, since the reader already has it.
70
+ */
71
+ export declare function describeNodeLabels(range: ICellRange, origin?: Readonly<IRange.Coords> | null): string;
72
+ /**
73
+ * How a graph member LABELS itself: its address, the sheet it lives on, and whether it is a name.
74
+ *
75
+ * @remarks
76
+ * Shared by the tree and the flat {@link ICellRanges} listing, so the two cannot label the same
77
+ * member differently — the flat list is the tree's rows without the hop structure, and a reader
78
+ * comparing them is comparing the same text.
79
+ *
80
+ * A name member leads with its NAME: its address is only an anchor, and two names authored from
81
+ * the same cell would otherwise print as identical, anonymous cells.
82
+ *
83
+ * The address comes back **unqualified**. A listing standing on one sheet says so once, in its
84
+ * heading; a qualifier goes back on every row only when the collection spans sheets, which is the
85
+ * caller's decision because only the caller has seen every member. A trailing `!` is `#REF!`, not
86
+ * a qualifier, so it is left whole.
87
+ */
88
+ export declare function describeNodeLabel(range: ICellRange): {
89
+ address: string;
90
+ sheet: string;
91
+ isName: boolean;
92
+ };
93
+ /**
94
+ * A node's payload: the value for a single cell, the size for a range.
95
+ *
96
+ * @remarks
97
+ * The whole point of walking as a tree rather than listing addresses — `1,204,880` beside
98
+ * `Model!O30` is what makes the chain readable as a model rather than as a set of coordinates.
99
+ * A formula node shows its expression too, because at that point the node explains itself.
100
+ *
101
+ * Shared with the flat {@link ICellRanges} listing (`renderRanges`) for the same reason
102
+ * {@link describeNodeLabel} is: the flat list is these rows without the hop structure, so the two
103
+ * shapes cannot be allowed to drift into describing one member two ways.
104
+ */
105
+ export declare function describeNode(range: ICellRange): string;
106
+ //# sourceMappingURL=appendDependencies.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { IPivotTable } from '@sheetxl/sdk';
2
+ import { MarkdownBuilder } from './MarkdownBuilder';
3
+ /**
4
+ * Where a pivot table is laid out, as the address its markup declares — or `''`.
5
+ *
6
+ * @remarks
7
+ * Read from {@link IPivotTable.getXML} because the table has no model yet and that markup is the
8
+ * documented way to what it does not expose. The address is as the file wrote it: it does not
9
+ * follow rows and columns inserted since, which is the table's own stated limit and not this
10
+ * report's.
11
+ */
12
+ export declare const describePivotLocation: (pivot: IPivotTable) => string;
13
+ /**
14
+ * `## Pivot Tables (2)` over ` A3:D20 PivotTable1` rows.
15
+ *
16
+ * @remarks
17
+ * A pivot table's output is ordinary cells, so `Contentful` already lists the block — as numbers
18
+ * and labels, with nothing to say they are a summary of data held elsewhere and will be
19
+ * overwritten by the next refresh in Excel. This section is what says so.
20
+ */
21
+ export declare function appendPivotTables(md: MarkdownBuilder, pivots: readonly IPivotTable[]): void;
22
+ //# sourceMappingURL=appendPivotTables.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ICellRange, IAnchored, ICellRanges, INamed } from '@sheetxl/sdk';
1
+ import { ICellRange, IAnchored, ICellRanges, ICellRegion, INamed, IWorksheet } from '@sheetxl/sdk';
2
2
  import { MarkdownBuilder } from './MarkdownBuilder';
3
3
  /**
4
4
  * Options for the feature sections.
@@ -13,7 +13,7 @@ export interface AppendFeatureOptions {
13
13
  * A **reporting** filter, not a query one. Partitioning by feature is what
14
14
  * {@link ICellRange.getRegions} is for and this does not duplicate it — it decides which of
15
15
  * those partitions a report bothers to print, which is why it lives on the renderer and not on
16
- * the range. `--features fill,border` on a sheet with forty formatted regions is the
16
+ * the range. `--features fill,borders` on a sheet with forty formatted regions is the
17
17
  * difference between an answer and a haystack.
18
18
  *
19
19
  * The scalar kinds are accepted and reach `Counts`; they have no partition to list, so they
@@ -69,7 +69,7 @@ export interface AppendFeatureOptions {
69
69
  */
70
70
  export declare const REPORTED_FEATURES: readonly ICellRange.Feature[];
71
71
  /**
72
- * Parses a comma-separated feature list — the `--features fill,border` flag's value.
72
+ * Parses a comma-separated feature list — the `--features fill,borders` flag's value.
73
73
  *
74
74
  * @remarks
75
75
  * Matching is case-insensitive against the enum's values, so `Fill`, `fill` and `numberFormat`
@@ -92,7 +92,7 @@ export declare const describeExtent: (range: ICellRange) => string;
92
92
  */
93
93
  export declare const describeSheetName: (name: string | null | undefined) => string;
94
94
  /**
95
- * `wb.getSheet("My Sheet")` — the range's sheet as a callable expression.
95
+ * `wb.getWorksheet("My Sheet")` — the range's sheet as a callable expression.
96
96
  *
97
97
  * @remarks
98
98
  * Not {@link describeSheetName}: that quotes for the *formula* language (`'My Sheet'!A1`), and a
@@ -118,28 +118,25 @@ export declare const describeQualifiedExtent: (range: ICellRange) => string;
118
118
  * Appends the `Kind` section — what the contentful cells ARE, kind by kind.
119
119
  *
120
120
  * @remarks
121
- * The heading carries the contentful count; the fact lines are the scalar kinds. This replaced
122
- * the old `Counts` section, which mixed two vocabularies: the kinds (which have no partition to
123
- * list) and the features (which do, and now carry their cell counts on their own section
124
- * headings). What remains here is exactly the value-shape question — "5 cells: 3 strings, 2
125
- * numbers".
121
+ * The heading carries the contentful count; the lines are the census, largest first, and they
122
+ * sum to it — see {@link countKinds}, which the workbook's `content` row reads too, so a sheet is
123
+ * described in the same words and the same numbers at both altitudes. Features are not here: each
124
+ * has a partition to list, and carries its cell count on its own section heading.
126
125
  *
127
- * Read off `range.getStats().getTypedCounts()` — the same single value-scan `renderStats` and
128
- * `profileKinds` already read — rather than `getCounts()`: `getCounts([Feature.Number, ...])` is a
129
- * SECOND, independent value-scan inside the engine (`Sheet._featureCounts`'s own comment says so
130
- * — "the scalar kinds ... count from values in one pass"), answering the identical question. One
131
- * scan, one source of truth, and `RichData` is no longer a silent zero — it falls out of the same
132
- * typed counts for free, where the old `Feature`-keyed list had nowhere to carry it (`Feature` has
133
- * no `RichData` member).
134
- *
135
- * `Date` is the one line still read through a dedicated pass — `countDates`, a value scan via
136
- * `getInteropType()`. It is not a `ScalarType` at all — it is numeric value ∩ date-category
137
- * format — and `Feature.DateFormat` alone would overcount (a blank or text cell carrying that
138
- * format is not a date). A date cell counts as both `Number` and `Date`, so the lines need not
139
- * sum to the heading. Zero kinds are elided, and blanks appear nowhere — empty is not a kind of
140
- * content.
126
+ * Zero kinds are elided, and blanks appear nowhere — empty is not a kind of content.
141
127
  */
142
128
  export declare function appendKinds(md: MarkdownBuilder, range: ICellRange): void;
129
+ /**
130
+ * The role census: per role (`ICellRange.Feature.Role`), how many cells and the font colors they
131
+ * are written in — `input 36 · #0000FF 34 · #000000 2`.
132
+ *
133
+ * @remarks
134
+ * The pairing the `styleRole` check reads, laid out for the reader: the check names a link in
135
+ * the wrong color and says nothing about a typed cell, whose color reads like the data beside it,
136
+ * so the census carries the constants' colors and the reader judges them with the counts in
137
+ * hand. A color is the authored font color (`#RRGGBB`), the Normal style's where none is authored.
138
+ */
139
+ export declare function appendRoles(md: MarkdownBuilder, range: ICellRange): void;
143
140
  /**
144
141
  * Appends one section per feature partition, headed by the feature's own name.
145
142
  *
@@ -161,6 +158,21 @@ export declare function appendKinds(md: MarkdownBuilder, range: ICellRange): voi
161
158
  * sees which before paying for a drill.
162
159
  */
163
160
  export declare function appendRegions(md: MarkdownBuilder, range: ICellRange, options?: AppendFeatureOptions): void;
161
+ /**
162
+ * The blocks of content in `range` — occupancy, cut where an authored table begins and ends.
163
+ *
164
+ * @remarks
165
+ * Occupancy alone yields maximal SOLID rectangles, and a table is not one: a title sitting over
166
+ * its first column makes that column run one cell longer than the rest, so the table came back as
167
+ * `C3:J111` plus a `B2:B111` list — two blocks, neither of them the table, at a size the `Tables`
168
+ * section contradicts. A table's edge is a boundary its author drew, so the partition honors it:
169
+ * the table is one block, at its own extent, and the title is a 1×1 above it.
170
+ *
171
+ * Refinement only ever cuts at a table's edge, so a sheet with no tables partitions exactly as
172
+ * occupancy does. A refined partition yields every region carrying EITHER feature, so a blank cell
173
+ * inside a table comes back too; a region is uniform, which makes its anchor the test.
174
+ */
175
+ export declare const contentfulBlocks: (range: ICellRange) => ICellRegion[];
164
176
  /**
165
177
  * Options for {@link appendNames}.
166
178
  */
@@ -246,91 +258,16 @@ export declare const describeQualifiedName: (named: INamed) => string;
246
258
  * `Hidden` and `Comment` appear only when some row has one — per block. `false` on every visible
247
259
  * row is token noise, and blank-means-normal is how these reports already speak.
248
260
  */
249
- export declare function appendNames(md: MarkdownBuilder, names: readonly INamed[], options?: AppendNamesOptions): void;
250
- /**
251
- * Options for the dependency trees.
252
- */
253
- export interface AppendDependencyOptions {
254
- /**
255
- * How many hops from the subject to walk.
256
- *
257
- * @defaultValue 3
258
- */
259
- maxDepth?: number;
260
- /**
261
- * Cap on nodes per tree; the tree notes truncation when exceeded.
262
- *
263
- * @defaultValue 50
264
- */
265
- maxNodes?: number;
266
- }
267
- /** The calculation-graph surface shared by {@link ICell} and {@link ICellRange}. */
268
- export interface DependencySource {
269
- getDirectPrecedents(): ICellRanges | null;
270
- getPrecedents(): ICellRanges | null;
271
- getDirectDependents(): ICellRanges | null;
272
- getDependents(): ICellRanges | null;
273
- }
261
+ export declare function appendNames(md: MarkdownBuilder, names: readonly INamed[], options?: AppendNamesOptions): Promise<void>;
274
262
  /**
275
- * Appends the `Precedents` and `Dependents` trees for anything that exposes the calculation
276
- * graph — a cell or a range, which answer the same questions with the same shape.
263
+ * The outline in a line — `rows 2 levels, 3 groups (1 collapsed) · columns 1 level, 1 group` —
264
+ * or `null` when nothing is grouped.
277
265
  *
278
266
  * @remarks
279
- * **A tree, walked one hop at a time, rather than a `direct`/`all` pair.** The flat form gives
280
- * the two ends of the chain and throws away everything between them: `D6` reading `B2:D4`
281
- * "eventually" does not say whether that is one indirection or nine, and the shape is the thing a
282
- * reader is actually trying to see. Repeated `getDirect*` calls cost the same as one `getAll*`
283
- * — the graph is indexed either way — so the tree is strictly more answer for the same work.
284
- *
285
- * Each node carries its **payload at the right altitude**: a single cell shows its value, a
286
- * multi-cell range shows its size. A range node is not expanded into cells; that is the same
287
- * expansion the region rules exist to prevent.
288
- *
289
- * Bounded three ways, each stated in the output rather than applied silently — depth, node count,
290
- * and revisits.
291
- *
292
- * **The two kinds of revisit get different marks, and that distinction is the point.** A node
293
- * reached twice by different branches is a re-convergence: completely normal in any model, and
294
- * marked `↑ shown above`. A node reached again while it is still on the current path is a
295
- * genuine cycle — a defect, or a deliberate iterative calculation — and is marked `↺ circular`.
296
- * One glyph for both would bury the second inside a busy tree, and it is the one finding here
297
- * that cannot afford to be missed.
298
- */
299
- export declare function appendDependencies(md: MarkdownBuilder, target: DependencySource, options?: AppendDependencyOptions): void;
300
- /**
301
- * How a graph member LABELS itself: its address, the sheet it lives on, and whether it is a name.
302
- *
303
- * @remarks
304
- * Shared by the tree and the flat {@link ICellRanges} listing, so the two cannot label the same
305
- * member differently — the flat list is the tree's rows without the hop structure, and a reader
306
- * comparing them is comparing the same text.
307
- *
308
- * A name member leads with its NAME: its address is only an anchor, and two names authored from
309
- * the same cell would otherwise print as identical, anonymous cells.
310
- *
311
- * The address comes back **unqualified**. A listing standing on one sheet says so once, in its
312
- * heading; a qualifier goes back on every row only when the collection spans sheets, which is the
313
- * caller's decision because only the caller has seen every member. A trailing `!` is `#REF!`, not
314
- * a qualifier, so it is left whole.
267
+ * Counts only: the groups themselves (level, span, summary, collapsed) are `IOutline.getGroups`,
268
+ * which is also what a script reads, so the report routes there instead of listing them.
315
269
  */
316
- export declare function describeNodeLabel(range: ICellRange): {
317
- address: string;
318
- sheet: string;
319
- isName: boolean;
320
- };
321
- /**
322
- * A node's payload: the value for a single cell, the size for a range.
323
- *
324
- * @remarks
325
- * The whole point of walking as a tree rather than listing addresses — `1,204,880` beside
326
- * `Model!O30` is what makes the chain readable as a model rather than as a set of coordinates.
327
- * A formula node shows its expression too, because at that point the node explains itself.
328
- *
329
- * Shared with the flat {@link ICellRanges} listing (`renderRanges`) for the same reason
330
- * {@link describeNodeLabel} is: the flat list is these rows without the hop structure, so the two
331
- * shapes cannot be allowed to drift into describing one member two ways.
332
- */
333
- export declare function describeNode(range: ICellRange): string;
270
+ export declare function describeOutline(sheet: IWorksheet): string | null;
334
271
  /**
335
272
  * One rule listing — `## Conditional Formats (2)` over ` A1:D10 > 100 → fill #FFFF00` rows.
336
273
  *
@@ -346,6 +283,21 @@ export declare function describeNode(range: ICellRange): string;
346
283
  * listing would hide the very relationship `stop if true` is read against.
347
284
  */
348
285
  export declare function appendRules<T extends IAnchored>(md: MarkdownBuilder, heading: string, items: readonly T[], describe: (item: T) => string): void;
286
+ /**
287
+ * The defined names whose target region intersects `range`, by name.
288
+ *
289
+ * @remarks
290
+ * Asked of the sheet's collection by address rather than resolved name by name here: the
291
+ * collection scope-checks (a name pointing at `Sheet2!A1:D4` overlaps this sheet's `A1:D4` as
292
+ * coordinates and is a different region entirely), and it resolves what the names designate as
293
+ * ONE step. A legacy file carries thousands of names nothing reads; asked one at a time, each
294
+ * compiled on its own, and a cell report over such a file ran out of memory. Defined names only — a
295
+ * table's name has its own section.
296
+ *
297
+ * @param includeOwned Also admit this sheet's private names that designate no region
298
+ * (`TaxRate = 0.21`), which have nothing to intersect and belong to the sheet by ownership.
299
+ */
300
+ export declare function findNames(range: ICellRange, includeOwned?: boolean): INamed[];
349
301
  /**
350
302
  * Appends the sheet-level objects that intersect `range`: named ranges, hidden headers, tables,
351
303
  * conditional formats and data validations.
@@ -360,5 +312,5 @@ export declare function appendRules<T extends IAnchored>(md: MarkdownBuilder, he
360
312
  * token cost on the common path, and it buries the sections that do carry something. Absence is
361
313
  * already how these reports say "not here".
362
314
  */
363
- export declare function appendSheetObjects(md: MarkdownBuilder, range: ICellRange): void;
315
+ export declare function appendSheetObjects(md: MarkdownBuilder, range: ICellRange): Promise<void>;
364
316
  //# sourceMappingURL=appendSections.d.ts.map
@@ -21,4 +21,8 @@
21
21
  * that would have to read further to find out.
22
22
  */
23
23
  export declare const pageWithLookahead: (total: number, pageSize: number) => number;
24
+ /** `ICellRange.getValues()`'s default `maxSize`: a range over it is too big to copy out in one read. */
25
+ export declare const GET_VALUES_LIMIT = 10000;
26
+ /** The value sample a report prints for a range over {@link GET_VALUES_LIMIT}. */
27
+ export declare const OVERSIZED_SAMPLE_CELLS = 200;
24
28
  //# sourceMappingURL=caps.d.ts.map