@sheetxl/query 0.7.28-beta.4 → 0.8.0-beta.10
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/esm/index.mjs +3359 -1112
- package/node/esm/index.mjs +3637 -1352
- package/package.json +6 -7
- 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 +163 -0
- package/types/src/api/renderApi.d.ts +13 -0
- package/types/src/encode/encodeCell.d.ts +9 -7
- package/types/src/grep/GrepTypes.d.ts +88 -42
- 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 +42 -104
- 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 +4 -4
- package/types/src/markdown/describeRule.d.ts +5 -5
- package/types/src/markdown/describeShape.d.ts +41 -0
- package/types/src/markdown/describeStyle.d.ts +7 -7
- package/types/src/markdown/findLabels.d.ts +26 -0
- package/types/src/markdown/index.d.ts +4 -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 +14 -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 +83 -14
- package/types/src/markdown/renderNames.d.ts +2 -2
- package/types/src/markdown/renderProtection.d.ts +81 -0
- package/types/src/markdown/renderRecords.d.ts +8 -0
- package/types/src/markdown/renderRegions.d.ts +1 -0
- package/types/src/markdown/renderSheet.d.ts +6 -7
- package/types/src/markdown/renderStyle.d.ts +2 -2
- package/types/src/markdown/renderTable.d.ts +11 -3
- package/types/src/markdown/renderWorkbook.d.ts +33 -26
- package/browser/cjs/index.cjs +0 -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.
|
|
4
|
+
"version": "0.8.0-beta.10",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
10
|
"browser": "./browser/esm/index.mjs",
|
|
11
11
|
"node": "./node/esm/index.mjs",
|
|
12
|
-
"
|
|
13
|
-
"require": "./browser/cjs/index.cjs"
|
|
12
|
+
"default": "./browser/esm/index.mjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"types": "./types/index.d.ts",
|
|
17
16
|
"module": "./browser/esm/index.mjs",
|
|
18
|
-
"main": "./browser/
|
|
17
|
+
"main": "./browser/esm/index.mjs",
|
|
19
18
|
"sideEffects": false,
|
|
20
19
|
"engines": {
|
|
21
20
|
"node": ">=20 <21 || >=22"
|
|
@@ -43,10 +42,10 @@
|
|
|
43
42
|
"query"
|
|
44
43
|
],
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@sheetxl/primitives": "^0.
|
|
47
|
-
"@sheetxl/sdk": "^0.
|
|
45
|
+
"@sheetxl/primitives": "^0.8.0-beta.10",
|
|
46
|
+
"@sheetxl/sdk": "^0.8.0-beta.10"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^26.
|
|
49
|
+
"@types/node": "^26.6.4"
|
|
51
50
|
}
|
|
52
51
|
}
|
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,163 @@
|
|
|
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
|
+
/**
|
|
64
|
+
* `Type.member` where the API has no such thing — the type, the member, or both — answered
|
|
65
|
+
* with what is nearest rather than with a search for the member's name across every type.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* A dotted name is a claim about where something lives, and the claim is what the reader needs
|
|
69
|
+
* corrected: `ISheets.add` wants to hear that the collection is `ISheetCollection`, and
|
|
70
|
+
* `ICellRange.setStyle` that a range's style is reached through `getStyle()`. A bare search for
|
|
71
|
+
* `add` or `setStyle` lists every type that has one and leaves the claim standing.
|
|
72
|
+
*/
|
|
73
|
+
interface Miss {
|
|
74
|
+
readonly kind: 'miss';
|
|
75
|
+
/** The type as typed, and the index key it resolved to — `null` when no type matched. */
|
|
76
|
+
readonly owner: {
|
|
77
|
+
readonly text: string;
|
|
78
|
+
readonly key: string | null;
|
|
79
|
+
};
|
|
80
|
+
/** The member as typed. */
|
|
81
|
+
readonly text: string;
|
|
82
|
+
/** When the type is unknown: the nearest type names, those with the member first. */
|
|
83
|
+
readonly nearestTypes: readonly {
|
|
84
|
+
readonly key: string;
|
|
85
|
+
readonly hasMember: boolean;
|
|
86
|
+
}[];
|
|
87
|
+
/** When the type is known: its members nearest the name, inherited ones included. */
|
|
88
|
+
readonly nearest: readonly ScriptingApi.Member[];
|
|
89
|
+
/** Where SheetXL keeps a concept another API spells this way, when the name is one of those. */
|
|
90
|
+
readonly hints: readonly string[];
|
|
91
|
+
/** Types that do have a member of exactly this name. */
|
|
92
|
+
readonly elsewhere: readonly {
|
|
93
|
+
readonly key: string;
|
|
94
|
+
readonly member: ScriptingApi.Member;
|
|
95
|
+
}[];
|
|
96
|
+
/** `elsewhere` entries beyond the cap, not listed. */
|
|
97
|
+
readonly elsewhereOmitted: number;
|
|
98
|
+
}
|
|
99
|
+
type Result = Overview | Type | Member | Search | Miss;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The names an overview leads with — where a script's reach into a workbook starts.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* Advertising, not scope: every indexed name answers a lookup. These are the handful worth naming
|
|
106
|
+
* before the reader has asked for anything, in the order a script meets them.
|
|
107
|
+
*/
|
|
108
|
+
export declare const API_ENTRY_POINTS: readonly string[];
|
|
109
|
+
/**
|
|
110
|
+
* Resolves a name against the scripting API index.
|
|
111
|
+
*
|
|
112
|
+
* @param name A type (`ICellRange`), a member (`ICellRange.setValues`), a word to search for, or
|
|
113
|
+
* nothing for the overview. A leading `SheetXL.` is accepted and ignored — it is how the name is
|
|
114
|
+
* written in a script, and a name copied out of one should resolve.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* `Type.text` is tried as a nested type first (`ICellRange.Coords` is its own entry), then as a
|
|
118
|
+
* member, inherited ones included. Text that names no member exactly narrows the type's listing to
|
|
119
|
+
* the members containing it — `ICellRange.merge` answers with every merge-related member rather
|
|
120
|
+
* than with "not found".
|
|
121
|
+
*/
|
|
122
|
+
export declare function lookupApi(index: ScriptingApi.Index, name?: string): ApiLookup.Result;
|
|
123
|
+
/**
|
|
124
|
+
* The indexed type of a live SDK object, or `null` when it carries no brand the index knows.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* SDK objects answer `true` for an `isI<Name>` brand per interface they implement — the SDK's own
|
|
128
|
+
* convention for runtime type checks — so the brand names are the type names. An object usually
|
|
129
|
+
* carries several (a named range is an `INamedRange` AND an `ICellRange`); the most derived one
|
|
130
|
+
* wins, because its listing reaches the others through `extends` and the reverse is not true.
|
|
131
|
+
*/
|
|
132
|
+
export declare function apiTypeOf(index: ScriptingApi.Index, target: unknown): string | null;
|
|
133
|
+
/**
|
|
134
|
+
* The `api` lookup that answers a compiler finding — `` `api ICellRanges` lists its members. `` —
|
|
135
|
+
* or `null` when the finding names no SDK type.
|
|
136
|
+
*
|
|
137
|
+
* @param message A TypeScript diagnostic, e.g. `Property 'getValues' does not exist on type 'ICellRanges'.`
|
|
138
|
+
* @param command How the host spells the lookup — `sheetxl api` in a terminal, `api` for a tool
|
|
139
|
+
* call. The line is there to be typed, so it has to be typeable where it is shown.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* A wrong member is the moment the listing is wanted: the finding names the receiver's type, and
|
|
143
|
+
* the type is the one thing the lookup needs. Only a plain capitalized name is taken — a union, a
|
|
144
|
+
* generic or a primitive is not something the index answers for.
|
|
145
|
+
*/
|
|
146
|
+
export declare function apiPointerFor(message: string, command: string): string | null;
|
|
147
|
+
/**
|
|
148
|
+
* The members nearest a name the script used and the API does not have — the answer an `api`
|
|
149
|
+
* lookup would be asked for next, inline.
|
|
150
|
+
*
|
|
151
|
+
* @param message A compiler finding (`Property 'getFormat' does not exist on type 'ICellRange'.
|
|
152
|
+
* Did you mean 'getFormula'?`) or a run-time one (`r.getFormat is not a function`).
|
|
153
|
+
* @param command How the host spells the lookup, as for {@link apiPointerFor}.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* A compiler finding names the receiver, so its members are the candidates, TypeScript's own
|
|
157
|
+
* suggestion first. A run-time one names only the member, so every entry point's members are.
|
|
158
|
+
* A name another spreadsheet API uses for a concept SheetXL keeps elsewhere is answered with where
|
|
159
|
+
* (`getFormat` → the style). Returns `null` when nothing is near enough to be worth a line; the
|
|
160
|
+
* compiler finding's {@link apiPointerFor} still stands then.
|
|
161
|
+
*/
|
|
162
|
+
export declare function apiSuggestionsFor(index: ScriptingApi.Index, message: string, command: string): string | null;
|
|
163
|
+
//# 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
|
|
@@ -15,7 +15,7 @@ import { ICell, Scalar } from '@sheetxl/sdk';
|
|
|
15
15
|
*
|
|
16
16
|
* ---
|
|
17
17
|
*
|
|
18
|
-
* **Quarantine note.** `ICell.getText()` is the only SDK call this module makes, and it is on its
|
|
18
|
+
* **Quarantine note.** `ICell.getText()` is the only SDK text call this module makes, and it is on its
|
|
19
19
|
* way out — its contract fuses formatting, localization, csv escaping and this encoding into one
|
|
20
20
|
* method with no clear answer for large values. It is isolated to this file deliberately: when
|
|
21
21
|
* the SDK splits pure number formatting away from the encoding, exactly one file changes and no
|
|
@@ -35,12 +35,14 @@ export declare namespace CellEncoding {
|
|
|
35
35
|
*/
|
|
36
36
|
readonly Display: "display";
|
|
37
37
|
/**
|
|
38
|
-
* The
|
|
38
|
+
* The stored scalar — what `getValue()` returns, with no number format applied.
|
|
39
39
|
*
|
|
40
40
|
* @remarks
|
|
41
|
-
* `1234.5678` where {@link Mode.Display | display} shows `$1,234.57
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* `1234.5678` where {@link Mode.Display | display} shows `$1,234.57`, `0.04` where it shows
|
|
42
|
+
* `4%`, and a date as its serial. A reader wants one of two things: what the grid shows, or
|
|
43
|
+
* what a formula computes with. There is deliberately no layer in between — the formula
|
|
44
|
+
* bar's text (`4%` at full precision, dates kept) is the stored scalar restyled by the
|
|
45
|
+
* format's category, and both of those are already reported.
|
|
44
46
|
*/
|
|
45
47
|
readonly Value: "value";
|
|
46
48
|
};
|
|
@@ -137,8 +139,8 @@ export declare function encodeCell(cell: ICell, mode: CellEncoding.Mode): CellEn
|
|
|
137
139
|
* The counterpart to {@link encodeCell} for the stateless value layer (`IRange`, `Scalar[][]`),
|
|
138
140
|
* where there is no cell to ask for text and therefore **no number format to apply**. That is
|
|
139
141
|
* the whole difference: `0.04` encodes as `0.04` here and as `4%` through a cell that formats
|
|
140
|
-
* it. There is consequently no `mode` —
|
|
141
|
-
*
|
|
142
|
+
* it. There is consequently no `mode` — this is what {@link CellEncoding.Mode.Value} produces
|
|
143
|
+
* for a cell, and the only form a bare value has.
|
|
142
144
|
*
|
|
143
145
|
* Everything above formatting is identical, because it is the same contract: the `'` prefix on
|
|
144
146
|
* strings, `TRUE`/`FALSE`, error labels, blank elision.
|
|
@@ -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
|
|
@@ -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
|
|
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
|
-
*
|
|
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
|
/**
|
|
@@ -38,28 +40,18 @@ export type GrepField =
|
|
|
38
40
|
*/
|
|
39
41
|
'display'
|
|
40
42
|
/**
|
|
41
|
-
* The
|
|
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`
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
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) —
|
|
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
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
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
|
|
166
|
+
* Which layers to search.
|
|
138
167
|
*
|
|
139
|
-
* @defaultValue {@link GREP_FIELDS_DEFAULT} —
|
|
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
|
|
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
|
|
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
|
|
210
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
/**
|
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
|