@sheetxl/query 0.8.0-beta.1 → 0.8.0-beta.3
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/browser/cjs/index.cjs +44 -25
- package/browser/esm/index.mjs +3094 -1131
- package/node/esm/index.mjs +3331 -1334
- package/package.json +3 -3
- package/types/src/Tool.d.ts +38 -0
- package/types/src/api/apiTool.d.ts +22 -0
- package/types/src/api/index.d.ts +4 -0
- package/types/src/api/lookupApi.d.ts +127 -0
- package/types/src/api/renderApi.d.ts +13 -0
- package/types/src/grep/GrepTypes.d.ts +75 -17
- package/types/src/grep/grep.d.ts +4 -1
- package/types/src/index.d.ts +9 -0
- package/types/src/markdown/appendDependencies.d.ts +106 -0
- package/types/src/markdown/appendPivotTables.d.ts +22 -0
- package/types/src/markdown/appendSections.d.ts +37 -108
- package/types/src/markdown/describeChart.d.ts +72 -0
- package/types/src/markdown/describeHistogram.d.ts +186 -0
- package/types/src/markdown/describeRegionPayload.d.ts +1 -1
- package/types/src/markdown/findLabels.d.ts +26 -0
- package/types/src/markdown/index.d.ts +3 -0
- package/types/src/markdown/profileRegion.d.ts +56 -1
- package/types/src/markdown/registry.d.ts +11 -2
- package/types/src/markdown/renderCell.d.ts +13 -11
- package/types/src/markdown/renderCellRange.d.ts +3 -2
- package/types/src/markdown/renderModules.d.ts +55 -0
- package/types/src/markdown/renderMovable.d.ts +69 -13
- package/types/src/markdown/renderNames.d.ts +2 -2
- package/types/src/markdown/renderProtection.d.ts +81 -0
- package/types/src/markdown/renderRegions.d.ts +1 -0
- package/types/src/markdown/renderSheet.d.ts +6 -7
- package/types/src/markdown/renderTable.d.ts +11 -3
- package/types/src/markdown/renderWorkbook.d.ts +33 -26
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/query",
|
|
3
3
|
"description": "SheetXL - Workbook read surface and renderers (grep, reports) — capabilities declared once, adapted by any host surface",
|
|
4
|
-
"version": "0.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.3",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"query"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@sheetxl/primitives": "^0.8.0-beta.
|
|
47
|
-
"@sheetxl/sdk": "^0.8.0-beta.
|
|
46
|
+
"@sheetxl/primitives": "^0.8.0-beta.3",
|
|
47
|
+
"@sheetxl/sdk": "^0.8.0-beta.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^26.1.2"
|
package/types/src/Tool.d.ts
CHANGED
|
@@ -104,5 +104,43 @@ export declare namespace Tool {
|
|
|
104
104
|
*/
|
|
105
105
|
render(result: R): string | Promise<string>;
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* A capability that reads the INSTALL rather than a workbook — the API reference.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* A separate shape rather than a {@link Descriptor} with an ignored argument, because what a
|
|
112
|
+
* surface wraps around a descriptor is exactly the part that does not apply: naming a workbook on
|
|
113
|
+
* a terminal, routing to a session over MCP. A reference answers the same with no workbook open
|
|
114
|
+
* and no session created, and a surface that demanded either would be asking for something the
|
|
115
|
+
* capability never reads.
|
|
116
|
+
*
|
|
117
|
+
* Everything else holds as it does for a descriptor: defined once, adapted mechanically, text
|
|
118
|
+
* agent-facing and English, defaults applied by the tool.
|
|
119
|
+
*/
|
|
120
|
+
interface Reference<A = any, R = any> {
|
|
121
|
+
/** Tool name and subcommand — the same word on every surface. */
|
|
122
|
+
readonly name: string;
|
|
123
|
+
/** One or two lines, agent-facing, English. */
|
|
124
|
+
readonly description: string;
|
|
125
|
+
readonly params: readonly Param[];
|
|
126
|
+
run(args: A): Promise<R>;
|
|
127
|
+
/** The default agent-facing rendering of a result. */
|
|
128
|
+
render(result: R, options?: RenderOptions): string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* What a surface tells a renderer about itself.
|
|
132
|
+
*/
|
|
133
|
+
interface RenderOptions {
|
|
134
|
+
/**
|
|
135
|
+
* How THIS surface spells the capability's own command — `sheetxl api`, `.api`. Defaults to the
|
|
136
|
+
* bare name, which is the spelling of a tool call.
|
|
137
|
+
*
|
|
138
|
+
* @remarks
|
|
139
|
+
* An answer that points at a follow-up ("everything on the type: …") is printing something to
|
|
140
|
+
* be typed, and the same capability is typed differently on each surface. This is the one
|
|
141
|
+
* affordance a renderer cannot work out for itself.
|
|
142
|
+
*/
|
|
143
|
+
readonly command?: string;
|
|
144
|
+
}
|
|
107
145
|
}
|
|
108
146
|
//# sourceMappingURL=Tool.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Tool } from '../Tool';
|
|
2
|
+
import { ApiLookup } from './lookupApi';
|
|
3
|
+
export interface ApiArgs {
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Looks a name up in the scripting API — see {@link lookupApi} for what a name may be.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A member answer carries its full declaration, sliced out of `scripting.d.ts` by the span the
|
|
11
|
+
* index recorded. That is the only lookup that reads the declarations at all: a type listing or a
|
|
12
|
+
* search is answered from the index alone, which is the point of having one.
|
|
13
|
+
*
|
|
14
|
+
* Declarations that cannot be read leave the member answer with its index line rather than failing
|
|
15
|
+
* it; the signature is still the answer to "how do I call this".
|
|
16
|
+
*/
|
|
17
|
+
export declare function describeApi(name?: string): Promise<ApiLookup.Result>;
|
|
18
|
+
/**
|
|
19
|
+
* The API reference: what a script can call, from the declarations it is type-checked against.
|
|
20
|
+
*/
|
|
21
|
+
export declare const apiTool: Tool.Reference<ApiArgs, ApiLookup.Result>;
|
|
22
|
+
//# sourceMappingURL=apiTool.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ScriptingApi } from '@sheetxl/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* What a name resolved to in the scripting API index.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* One query string, four answers, decided by what the name matches — the caller never says which
|
|
7
|
+
* it wants. Nothing → the {@link ApiLookup.Overview}; a type → its members; `Type.member` → that
|
|
8
|
+
* member in full; anything else → a name {@link ApiLookup.Search}.
|
|
9
|
+
*/
|
|
10
|
+
export declare namespace ApiLookup {
|
|
11
|
+
/** A type {@link Type} extends, with where to read its members. */
|
|
12
|
+
interface Base {
|
|
13
|
+
/** As written in the `extends` clause, type arguments included. */
|
|
14
|
+
readonly text: string;
|
|
15
|
+
/** The index key it resolved to, or `null` for a type outside the index (`Iterable`, `Omit`). */
|
|
16
|
+
readonly key: string | null;
|
|
17
|
+
readonly memberCount: number;
|
|
18
|
+
}
|
|
19
|
+
interface Overview {
|
|
20
|
+
readonly kind: 'overview';
|
|
21
|
+
/** How many names the index holds. */
|
|
22
|
+
readonly total: number;
|
|
23
|
+
readonly entryPoints: readonly {
|
|
24
|
+
readonly key: string;
|
|
25
|
+
readonly entry: ScriptingApi.Entry;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
interface Type {
|
|
29
|
+
readonly kind: 'type';
|
|
30
|
+
readonly key: string;
|
|
31
|
+
readonly entry: ScriptingApi.Entry;
|
|
32
|
+
readonly bases: readonly Base[];
|
|
33
|
+
/** The member substring the listing was narrowed by, when `Type.<text>` named no exact member. */
|
|
34
|
+
readonly filter?: string;
|
|
35
|
+
/** The entry's own members, narrowed by {@link filter} when present. */
|
|
36
|
+
readonly members: readonly ScriptingApi.Member[];
|
|
37
|
+
}
|
|
38
|
+
interface Member {
|
|
39
|
+
readonly kind: 'member';
|
|
40
|
+
/** The type that was asked about. */
|
|
41
|
+
readonly key: string;
|
|
42
|
+
/** The type that DECLARES the member — a base of {@link key} when the member is inherited. */
|
|
43
|
+
readonly declaredOn: string;
|
|
44
|
+
/** Every overload, in declaration order. */
|
|
45
|
+
readonly members: readonly ScriptingApi.Member[];
|
|
46
|
+
/**
|
|
47
|
+
* Each overload's full declaration, documentation included, parallel to {@link members}.
|
|
48
|
+
* Filled by the caller that has `scripting.d.ts` to slice; a lookup alone leaves it unset.
|
|
49
|
+
*/
|
|
50
|
+
sources?: readonly string[];
|
|
51
|
+
}
|
|
52
|
+
interface Search {
|
|
53
|
+
readonly kind: 'search';
|
|
54
|
+
readonly query: string;
|
|
55
|
+
readonly types: readonly string[];
|
|
56
|
+
readonly members: readonly {
|
|
57
|
+
readonly key: string;
|
|
58
|
+
readonly member: ScriptingApi.Member;
|
|
59
|
+
}[];
|
|
60
|
+
/** Matches beyond the caps, not listed. */
|
|
61
|
+
readonly omitted: number;
|
|
62
|
+
}
|
|
63
|
+
type Result = Overview | Type | Member | Search;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The names an overview leads with — where a script's reach into a workbook starts.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* Advertising, not scope: every indexed name answers a lookup. These are the handful worth naming
|
|
70
|
+
* before the reader has asked for anything, in the order a script meets them.
|
|
71
|
+
*/
|
|
72
|
+
export declare const API_ENTRY_POINTS: readonly string[];
|
|
73
|
+
/**
|
|
74
|
+
* Resolves a name against the scripting API index.
|
|
75
|
+
*
|
|
76
|
+
* @param name A type (`ICellRange`), a member (`ICellRange.setValues`), a word to search for, or
|
|
77
|
+
* nothing for the overview. A leading `SheetXL.` is accepted and ignored — it is how the name is
|
|
78
|
+
* written in a script, and a name copied out of one should resolve.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* `Type.text` is tried as a nested type first (`ICellRange.Coords` is its own entry), then as a
|
|
82
|
+
* member, inherited ones included. Text that names no member exactly narrows the type's listing to
|
|
83
|
+
* the members containing it — `ICellRange.merge` answers with every merge-related member rather
|
|
84
|
+
* than with "not found".
|
|
85
|
+
*/
|
|
86
|
+
export declare function lookupApi(index: ScriptingApi.Index, name?: string): ApiLookup.Result;
|
|
87
|
+
/**
|
|
88
|
+
* The indexed type of a live SDK object, or `null` when it carries no brand the index knows.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* SDK objects answer `true` for an `isI<Name>` brand per interface they implement — the SDK's own
|
|
92
|
+
* convention for runtime type checks — so the brand names are the type names. An object usually
|
|
93
|
+
* carries several (a named range is an `INamedRange` AND an `ICellRange`); the most derived one
|
|
94
|
+
* wins, because its listing reaches the others through `extends` and the reverse is not true.
|
|
95
|
+
*/
|
|
96
|
+
export declare function apiTypeOf(index: ScriptingApi.Index, target: unknown): string | null;
|
|
97
|
+
/**
|
|
98
|
+
* The `api` lookup that answers a compiler finding — `` `api ICellRanges` lists its members. `` —
|
|
99
|
+
* or `null` when the finding names no SDK type.
|
|
100
|
+
*
|
|
101
|
+
* @param message A TypeScript diagnostic, e.g. `Property 'getValues' does not exist on type 'ICellRanges'.`
|
|
102
|
+
* @param command How the host spells the lookup — `sheetxl api` in a terminal, `api` for a tool
|
|
103
|
+
* call. The line is there to be typed, so it has to be typeable where it is shown.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* A wrong member is the moment the listing is wanted: the finding names the receiver's type, and
|
|
107
|
+
* the type is the one thing the lookup needs. Only a plain capitalized name is taken — a union, a
|
|
108
|
+
* generic or a primitive is not something the index answers for.
|
|
109
|
+
*/
|
|
110
|
+
export declare function apiPointerFor(message: string, command: string): string | null;
|
|
111
|
+
/**
|
|
112
|
+
* The members nearest a name the script used and the API does not have — the answer an `api`
|
|
113
|
+
* lookup would be asked for next, inline.
|
|
114
|
+
*
|
|
115
|
+
* @param message A compiler finding (`Property 'getFormat' does not exist on type 'ICellRange'.
|
|
116
|
+
* Did you mean 'getFormula'?`) or a run-time one (`r.getFormat is not a function`).
|
|
117
|
+
* @param command How the host spells the lookup, as for {@link apiPointerFor}.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* A compiler finding names the receiver, so its members are the candidates, TypeScript's own
|
|
121
|
+
* suggestion first. A run-time one names only the member, so every entry point's members are.
|
|
122
|
+
* A name another spreadsheet API uses for a concept SheetXL keeps elsewhere is answered with where
|
|
123
|
+
* (`getFormat` → the style). Returns `null` when nothing is near enough to be worth a line; the
|
|
124
|
+
* compiler finding's {@link apiPointerFor} still stands then.
|
|
125
|
+
*/
|
|
126
|
+
export declare function apiSuggestionsFor(index: ScriptingApi.Index, message: string, command: string): string | null;
|
|
127
|
+
//# sourceMappingURL=lookupApi.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Tool } from '../Tool';
|
|
2
|
+
import { ApiLookup } from './lookupApi';
|
|
3
|
+
/**
|
|
4
|
+
* Renders an API lookup as its agent-facing text.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Every answer ends by naming the next lookup, and that line is there to be typed. So it is
|
|
8
|
+
* written the way the surface showing it spells the command ({@link Tool.RenderOptions.command}):
|
|
9
|
+
* `sheetxl api ICellRange` in a terminal, `.api ICellRange` in a session. One neutral spelling for
|
|
10
|
+
* all of them is wrong on most of them — `api IWorkbook` typed into a session is a syntax error.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderApi(result: ApiLookup.Result, options?: Tool.RenderOptions): string;
|
|
13
|
+
//# sourceMappingURL=renderApi.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
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
|
|
@@ -15,12 +15,14 @@
|
|
|
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
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
-
*
|
|
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
|
/**
|
|
@@ -72,7 +74,38 @@ export type GrepField =
|
|
|
72
74
|
* cells are percentages" — the rendered `40%` is not. Matches cells with a *direct*
|
|
73
75
|
* format, including value-less ones (a formatted-but-empty column is a real finding).
|
|
74
76
|
*/
|
|
75
|
-
| 'numberFormat'
|
|
77
|
+
| 'numberFormat'
|
|
78
|
+
/**
|
|
79
|
+
* The comment or note on a cell, and every reply in its thread — each its own row.
|
|
80
|
+
*
|
|
81
|
+
* A cell layer like the others: the match is the commented cell, and a cell that matches in
|
|
82
|
+
* its display AND its comment is one cell. A comment on an empty cell is still found.
|
|
83
|
+
*/
|
|
84
|
+
| 'comment'
|
|
85
|
+
/**
|
|
86
|
+
* The text written on a shape — a text box, a callout — and its alt text.
|
|
87
|
+
*
|
|
88
|
+
* The match is the shape, addressed by the cells it is anchored over (`F2:H6`), which is what
|
|
89
|
+
* `range.getMovables()` takes to get back to it.
|
|
90
|
+
*/
|
|
91
|
+
| 'shape'
|
|
92
|
+
/**
|
|
93
|
+
* What a chart says in words: its title, its axis titles, the series names written into it,
|
|
94
|
+
* and its alt text. Addressed like a {@link GrepField | shape}.
|
|
95
|
+
*
|
|
96
|
+
* A series named by a cell (`=Sales!$C$3`) is not repeated here — that text is the cell's, and
|
|
97
|
+
* `display` already finds it there.
|
|
98
|
+
*/
|
|
99
|
+
| 'chart'
|
|
100
|
+
/**
|
|
101
|
+
* Defined names and tables: the name, what it refers to (`=Summary!$B$4`, `=0.21`) and its
|
|
102
|
+
* comment.
|
|
103
|
+
*
|
|
104
|
+
* The match is the name, spelled as a formula writes it (`'EU Ops'!Rate` when sheet-scoped) —
|
|
105
|
+
* a name has no cell of its own. Under a {@link GrepArgs.scope | scope} a name is searched
|
|
106
|
+
* when it is scoped to a searched sheet or designates cells inside the searched range.
|
|
107
|
+
*/
|
|
108
|
+
| 'name';
|
|
76
109
|
export declare const GrepField: {
|
|
77
110
|
readonly Display: "display";
|
|
78
111
|
readonly Value: "value";
|
|
@@ -80,6 +113,10 @@ export declare const GrepField: {
|
|
|
80
113
|
readonly Formula: "formula";
|
|
81
114
|
readonly Hyperlink: "hyperlink";
|
|
82
115
|
readonly NumberFormat: "numberFormat";
|
|
116
|
+
readonly Comment: "comment";
|
|
117
|
+
readonly Shape: "shape";
|
|
118
|
+
readonly Chart: "chart";
|
|
119
|
+
readonly Name: "name";
|
|
83
120
|
};
|
|
84
121
|
/** Every field, in the order they are searched and reported. */
|
|
85
122
|
export declare const GREP_FIELDS: readonly GrepField[];
|
|
@@ -93,6 +130,10 @@ export declare const GREP_FIELDS: readonly GrepField[];
|
|
|
93
130
|
* carries new information — `1234.5678` behind `$1,234.57`. A duplicate hit costs an agent
|
|
94
131
|
* a second look for no new information; a missing layer costs a silent zero-hit miss on
|
|
95
132
|
* full-precision searches, which is worse.
|
|
133
|
+
*
|
|
134
|
+
* The layers off the grid are defaults by the same argument. A caller who has to ask for
|
|
135
|
+
* `shape` already knows the callout is there; the search that needs it is the one that does
|
|
136
|
+
* not. They cost one pass over a sheet's objects, not over its cells.
|
|
96
137
|
*/
|
|
97
138
|
export declare const GREP_FIELDS_DEFAULT: readonly GrepField[];
|
|
98
139
|
/** What a grep result should carry. */
|
|
@@ -134,9 +175,10 @@ export interface GrepArgs {
|
|
|
134
175
|
*/
|
|
135
176
|
pattern: string;
|
|
136
177
|
/**
|
|
137
|
-
* Which
|
|
178
|
+
* Which layers to search.
|
|
138
179
|
*
|
|
139
|
-
* @defaultValue {@link GREP_FIELDS_DEFAULT} —
|
|
180
|
+
* @defaultValue {@link GREP_FIELDS_DEFAULT} —
|
|
181
|
+
* `['display', 'value', 'formula', 'comment', 'shape', 'chart', 'name']`
|
|
140
182
|
*/
|
|
141
183
|
fields?: readonly GrepField[];
|
|
142
184
|
/**
|
|
@@ -166,11 +208,11 @@ export interface GrepArgs {
|
|
|
166
208
|
*/
|
|
167
209
|
word?: boolean;
|
|
168
210
|
/**
|
|
169
|
-
* Invert the match — report cells where **no** requested field matched (`rg -v`).
|
|
211
|
+
* Invert the match — report cells and objects where **no** requested field matched (`rg -v`).
|
|
170
212
|
*
|
|
171
213
|
* @remarks
|
|
172
|
-
* Scoped to
|
|
173
|
-
* reported (an empty cell is not a finding, and "every blank cell" is not an answer).
|
|
214
|
+
* Scoped to what grep visits: a cell or object must have text in at least one requested field
|
|
215
|
+
* to be reported (an empty cell is not a finding, and "every blank cell" is not an answer).
|
|
174
216
|
* Reported rows carry the first requested field that has text, as the evidence line.
|
|
175
217
|
*/
|
|
176
218
|
invert?: boolean;
|
|
@@ -200,14 +242,16 @@ export interface GrepArgs {
|
|
|
200
242
|
*/
|
|
201
243
|
hidden?: boolean;
|
|
202
244
|
/**
|
|
203
|
-
* Stop after this many
|
|
245
|
+
* Stop after this many matches — cells and objects together. Truncation is always reported,
|
|
246
|
+
* never silent.
|
|
204
247
|
*
|
|
205
248
|
* @defaultValue 200 — a grep result returns into a context window, not a terminal stream,
|
|
206
249
|
* so unbounded output is a cost the caller did not ask for. `0` removes the cap.
|
|
207
250
|
*
|
|
208
251
|
* @remarks
|
|
209
|
-
* Counts **cells**, not match rows — a cell matching in two fields is one unit of
|
|
210
|
-
*
|
|
252
|
+
* Counts **cells and objects**, not match rows — a cell matching in two fields is one unit of
|
|
253
|
+
* budget, and so is a chart matching in its title and an axis.
|
|
254
|
+
* The search looks one match past the cap, so a result that ends exactly at `maxCount` is
|
|
211
255
|
* only reported truncated when a further match actually exists.
|
|
212
256
|
*/
|
|
213
257
|
maxCount?: number;
|
|
@@ -240,6 +284,10 @@ export interface GrepMatchContext {
|
|
|
240
284
|
* order.
|
|
241
285
|
*
|
|
242
286
|
* @remarks
|
|
287
|
+
* Text that is not in a cell keeps the same shape. A shape or a chart is an entry per matched
|
|
288
|
+
* text, addressed by the cells it is anchored over, after its sheet's cells; a defined name is an
|
|
289
|
+
* entry addressed by the name itself, after every sheet.
|
|
290
|
+
*
|
|
243
291
|
* Deliberately not coalesced into blocks: uniform runs of identical values are *regions* — a
|
|
244
292
|
* payload feature splits where the value changes, so the regions read already owns that shape,
|
|
245
293
|
* in 2-D and with the full partition to rank against. Grep answering cell-grain and regions
|
|
@@ -248,9 +296,15 @@ export interface GrepMatchContext {
|
|
|
248
296
|
* renderer merely groups by it.
|
|
249
297
|
*/
|
|
250
298
|
export interface GrepMatch {
|
|
251
|
-
/**
|
|
299
|
+
/**
|
|
300
|
+
* Sheet name — for a `name` match, the sheet the name is scoped to, or `''` for a
|
|
301
|
+
* workbook-scoped one.
|
|
302
|
+
*/
|
|
252
303
|
sheet: string;
|
|
253
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* A1 cell address within the sheet; the anchor range (`F2:H6`) for a shape or chart; the name
|
|
306
|
+
* itself for a defined name. Qualified with `sheet`, each is something a follow-up call takes.
|
|
307
|
+
*/
|
|
254
308
|
address: string;
|
|
255
309
|
/**
|
|
256
310
|
* Which layer matched.
|
|
@@ -272,6 +326,8 @@ export interface GrepSheetMatches {
|
|
|
272
326
|
sheet: string;
|
|
273
327
|
/** Distinct cells that produced at least one match in this sheet. */
|
|
274
328
|
cells: number;
|
|
329
|
+
/** Shapes and charts on this sheet that produced at least one match. */
|
|
330
|
+
objects: number;
|
|
275
331
|
}
|
|
276
332
|
/** The result of a {@link grep}. */
|
|
277
333
|
export interface GrepResult {
|
|
@@ -283,6 +339,8 @@ export interface GrepResult {
|
|
|
283
339
|
matches: readonly GrepMatch[];
|
|
284
340
|
/** Distinct cells that produced at least one match. */
|
|
285
341
|
cellCount: number;
|
|
342
|
+
/** Shapes, charts and names that produced at least one match. */
|
|
343
|
+
objectCount: number;
|
|
286
344
|
/** Per-sheet counts, in search order — only sheets with at least one match appear. */
|
|
287
345
|
sheets: readonly GrepSheetMatches[];
|
|
288
346
|
/**
|
package/types/src/grep/grep.d.ts
CHANGED
|
@@ -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
|
|
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
|
*
|
package/types/src/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ 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';
|
|
6
7
|
/**
|
|
7
8
|
* The read surface, defined once.
|
|
@@ -17,4 +18,12 @@ export * from './markdown';
|
|
|
17
18
|
* reason). A capability joins this list only when it is not a one-line run idiom.
|
|
18
19
|
*/
|
|
19
20
|
export declare const TOOLS: readonly Tool.Descriptor[];
|
|
21
|
+
/**
|
|
22
|
+
* The reference surface — capabilities that read the install rather than a workbook.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Registered by every host surface exactly as {@link TOOLS} is, minus the part that names a
|
|
26
|
+
* workbook. See {@link Tool.Reference}.
|
|
27
|
+
*/
|
|
28
|
+
export declare const REFERENCES: readonly Tool.Reference[];
|
|
20
29
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ICellRange, ICellRanges, IRange, ISheet } 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?: ISheet | 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
|