ask-marcel-office-cli 1.0.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/README.md +153 -384
- package/dist/cli.js +13222 -94112
- package/dist/commands.json +1500 -135
- package/dist/composition/build-deps.d.ts +13 -0
- package/dist/composition/cli.d.ts +8 -0
- package/dist/domain/iso-datetime.d.ts +30 -0
- package/dist/domain/utilities/archive-status.d.ts +18 -0
- package/dist/domain/utilities/site-url-classifier.d.ts +15 -0
- package/dist/index.js +10912 -92275
- package/dist/infra/auth.d.ts +56 -3
- package/dist/infra/browser-auth.d.ts +100 -10
- package/dist/infra/graph-client.d.ts +40 -0
- package/dist/infra/legacy-doc-extractor.d.ts +14 -0
- package/dist/infra/msg-reader-adapter.d.ts +83 -0
- package/dist/infra/network-error.d.ts +9 -0
- package/dist/infra/ooxml-media-extractor.d.ts +27 -0
- package/dist/infra/ooxml-zip-adapter.d.ts +28 -0
- package/dist/infra/pdf-image-extractor.d.ts +18 -0
- package/dist/infra/pdf-text-extractor.d.ts +41 -0
- package/dist/infra/png-encode.d.ts +15 -0
- package/dist/infra/sheetjs-adapter.d.ts +1 -1
- package/dist/infra/system-browser-auth.d.ts +35 -0
- package/dist/infra/system-browser-loader.d.ts +3 -0
- package/dist/infra/token-callback-server.d.ts +31 -0
- package/dist/infra/zip-reader.d.ts +32 -0
- package/dist/presenter/error-hints.d.ts +41 -0
- package/dist/presenter/output.d.ts +2 -1
- package/dist/use-cases/commands/build-command.d.ts +30 -8
- package/dist/use-cases/commands/command-types.d.ts +53 -1
- package/dist/use-cases/commands/convert-calendar-event-attachment-to-markdown.d.ts +15 -0
- package/dist/use-cases/commands/{download-drive-item-version-as-pdf.d.ts → convert-calendar-event-attachment-to-pdf.d.ts} +2 -3
- package/dist/use-cases/commands/convert-drive-item-zip.d.ts +26 -0
- package/dist/use-cases/commands/convert-local-file.d.ts +37 -0
- package/dist/use-cases/commands/convert-mail-attachment-to-markdown.d.ts +7 -1
- package/dist/use-cases/commands/convert-mail-attachment-to-pdf.d.ts +2 -1
- package/dist/use-cases/commands/convert-mail-attachment-zip.d.ts +24 -0
- package/dist/use-cases/commands/convert-mail-to-markdown.d.ts +8 -0
- package/dist/use-cases/commands/create-mail-draft.d.ts +22 -0
- package/dist/use-cases/commands/doc-to-markdown.d.ts +14 -0
- package/dist/use-cases/commands/docs-render.d.ts +7 -2
- package/dist/use-cases/commands/docs.d.ts +44 -1
- package/dist/use-cases/commands/docx-comment-anchors.d.ts +22 -0
- package/dist/use-cases/commands/docx-metadata-to-markdown.d.ts +3 -0
- package/dist/use-cases/commands/docx-metadata.d.ts +69 -0
- package/dist/use-cases/commands/docx-to-markdown.d.ts +8 -3
- package/dist/use-cases/commands/download-drive-item-as-markdown.d.ts +9 -0
- package/dist/use-cases/commands/download-drive-item-version.d.ts +21 -0
- package/dist/use-cases/commands/{download-drive-item-version-as-markdown.d.ts → extract-drive-item-images.d.ts} +0 -1
- package/dist/use-cases/commands/extract-local-file-images.d.ts +21 -0
- package/dist/use-cases/commands/{download-drive-item-version-content.d.ts → extract-mail-attachment-images.d.ts} +2 -3
- package/dist/use-cases/commands/extract-sharepoint-links-in-documents.d.ts +33 -0
- package/dist/use-cases/commands/extract-sharepoint-links-in-mail.d.ts +1 -8
- package/dist/use-cases/commands/fetch-raw-bytes.d.ts +2 -1
- package/dist/use-cases/commands/file-counts.d.ts +7 -0
- package/dist/use-cases/commands/filter-archived-sites.d.ts +17 -0
- package/dist/use-cases/commands/find-chats-with-user.d.ts +10 -0
- package/dist/use-cases/commands/first-sentence.d.ts +12 -0
- package/dist/use-cases/commands/get-chat.d.ts +1 -5
- package/dist/use-cases/commands/get-excel-chart-image.d.ts +20 -0
- package/dist/use-cases/commands/get-excel-used-range.d.ts +7 -2
- package/dist/use-cases/commands/get-onenote-page-as-markdown.d.ts +8 -0
- package/dist/use-cases/commands/get-teams-chat-message.d.ts +9 -0
- package/dist/use-cases/commands/get-todo-task.d.ts +9 -2
- package/dist/use-cases/commands/image-extraction.d.ts +10 -0
- package/dist/use-cases/commands/iso-datetime-schema.d.ts +21 -0
- package/dist/use-cases/commands/link-shape.d.ts +13 -0
- package/dist/use-cases/commands/list-accessible-drives.d.ts +14 -0
- package/dist/use-cases/commands/list-calendar-event-attachments.d.ts +14 -0
- package/dist/use-cases/commands/list-calendar-view-delta.d.ts +2 -2
- package/dist/use-cases/commands/list-teams-chat-history.d.ts +16 -0
- package/dist/use-cases/commands/list-teams-chat-messages.d.ts +8 -0
- package/dist/use-cases/commands/list-teams-chats-with-messages.d.ts +9 -0
- package/dist/use-cases/commands/mail-quote-stripper.d.ts +25 -0
- package/dist/use-cases/commands/markdown-dispatch.d.ts +29 -0
- package/dist/use-cases/commands/markdown-pipeline.d.ts +6 -2
- package/dist/use-cases/commands/media-files.d.ts +20 -0
- package/dist/use-cases/commands/msg-to-markdown.d.ts +28 -0
- package/dist/use-cases/commands/odf-content-to-markdown.d.ts +5 -0
- package/dist/use-cases/commands/odf-metadata-to-markdown.d.ts +3 -0
- package/dist/use-cases/commands/odf-metadata.d.ts +26 -0
- package/dist/use-cases/commands/odf-to-markdown.d.ts +17 -0
- package/dist/use-cases/commands/office-extensions.d.ts +13 -0
- package/dist/use-cases/commands/office-to-markdown.d.ts +6 -2
- package/dist/use-cases/commands/onenote-metadata.d.ts +21 -0
- package/dist/use-cases/commands/onenote-resource-embedder.d.ts +3 -0
- package/dist/use-cases/commands/ooxml-metadata-to-markdown.d.ts +16 -0
- package/dist/use-cases/commands/ooxml-metadata.d.ts +23 -0
- package/dist/use-cases/commands/ooxml-xml-walker.d.ts +36 -0
- package/dist/use-cases/commands/option-descriptions.d.ts +5 -0
- package/dist/use-cases/commands/output-path.d.ts +23 -0
- package/dist/use-cases/commands/pdf-to-markdown.d.ts +19 -0
- package/dist/use-cases/commands/pptx-comments.d.ts +24 -0
- package/dist/use-cases/commands/pptx-metadata-to-markdown.d.ts +3 -0
- package/dist/use-cases/commands/pptx-metadata.d.ts +33 -0
- package/dist/use-cases/commands/pptx-slides.d.ts +17 -0
- package/dist/use-cases/commands/pptx-to-markdown.d.ts +7 -0
- package/dist/use-cases/commands/read-mail-attachment.d.ts +15 -0
- package/dist/use-cases/commands/resolve-calendar-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-drive-share-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-mail-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-teams-link.d.ts +8 -0
- package/dist/use-cases/commands/search-all-accessible-sites.d.ts +12 -0
- package/dist/use-cases/commands/search-index-total.d.ts +3 -0
- package/dist/use-cases/commands/search-sharepoint-sites-by-name.d.ts +3 -2
- package/dist/use-cases/commands/sharepoint-link-extractor.d.ts +17 -12
- package/dist/use-cases/commands/text-passthrough.d.ts +15 -2
- package/dist/use-cases/commands/todo-parse-uri-rewrite.d.ts +7 -0
- package/dist/use-cases/commands/update-mail-draft.d.ts +22 -0
- package/dist/use-cases/commands/version-id.d.ts +7 -6
- package/dist/use-cases/commands/xlsx-comments.d.ts +29 -0
- package/dist/use-cases/commands/xlsx-metadata-to-markdown.d.ts +3 -0
- package/dist/use-cases/commands/xlsx-metadata.d.ts +39 -0
- package/dist/use-cases/commands/xlsx-to-markdown.d.ts +9 -2
- package/dist/use-cases/commands/zip-archive-to-markdown.d.ts +30 -0
- package/dist/use-cases/ports/filesystem.d.ts +10 -0
- package/docs/COMMANDS.md +259 -0
- package/docs/USAGE.md +266 -0
- package/docs/commands.json +1500 -135
- package/package.json +16 -8
- /package/dist/use-cases/commands/{download-onedrive-file-content.d.ts → download-drive-item-content.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate Graph / substrate / CLI / validation errors into actionable hints.
|
|
3
|
+
*
|
|
4
|
+
* Audit Jane-session §2: bare `error: ErrorInvalidIdMalformed: Id is
|
|
5
|
+
* malformed.` had no remedy for the LLM — it had to guess where the bad ID
|
|
6
|
+
* came from. This module is the centralised "what should I do about this"
|
|
7
|
+
* lookup: pattern-match the error code (or, as a fallback, a substring of
|
|
8
|
+
* the message) and surface a one-line hint plus a `source` classifier so
|
|
9
|
+
* the LLM can branch on whether the failure is server-side, substrate-side,
|
|
10
|
+
* CLI-side, or a Zod validation rejection. Surfaced through the standard
|
|
11
|
+
* error envelope in both `--output json` (as `hint` / `source` fields) and
|
|
12
|
+
* `--output text` (as `hint:` / `source:` lines under the existing `error:`
|
|
13
|
+
* line).
|
|
14
|
+
*
|
|
15
|
+
* Audit Jane-session §2 follow-up: the four error-envelope variants are
|
|
16
|
+
* - `graph` — public Microsoft Graph API at /v1.0/
|
|
17
|
+
* - `substrate` — Microsoft-internal chat substrates (chatsvcagg / IC3).
|
|
18
|
+
* Tagged at the infra layer with `substrateHttp{N}_{name}`.
|
|
19
|
+
* - `cli` — CLI itself (Commander parser, CLI rewrites of Graph
|
|
20
|
+
* errors via `cli_rewrite_*` and `cli_reject_*` codes)
|
|
21
|
+
* - `validation` — Zod schema validation from use-cases (no `code` — pure
|
|
22
|
+
* message-pattern fallback)
|
|
23
|
+
*
|
|
24
|
+
* Rule precedence: specific code matchers run FIRST, then message-pattern
|
|
25
|
+
* fallbacks. The generic-validation rule sits LAST so it never overrides a
|
|
26
|
+
* code-based remedy.
|
|
27
|
+
*
|
|
28
|
+
* The table is intentionally small and biased toward HIGH-FREQUENCY errors
|
|
29
|
+
* an LLM actually hits. Adding more entries is cheap; the lookup is O(n)
|
|
30
|
+
* on a tiny n.
|
|
31
|
+
*/
|
|
32
|
+
export type ErrorSource = 'graph' | 'substrate' | 'cli' | 'validation';
|
|
33
|
+
export type ErrorHint = {
|
|
34
|
+
readonly hint: string;
|
|
35
|
+
readonly source: ErrorSource;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* First matching rule wins. Returns `undefined` when nothing in the table
|
|
39
|
+
* matches — caller renders the bare error (the historical shape).
|
|
40
|
+
*/
|
|
41
|
+
export declare const findErrorHint: (message: string, code: string | undefined) => ErrorHint | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../use-cases/ports/logger.js';
|
|
2
|
+
import type { ErrorSource } from './error-hints.js';
|
|
2
3
|
type OutputFormat = 'text' | 'json';
|
|
3
4
|
declare const render: (data: unknown, logger: Logger, format: OutputFormat) => void;
|
|
4
|
-
declare const renderError: (message: string, format: OutputFormat, errorCode?: string) => void;
|
|
5
|
+
declare const renderError: (message: string, format: OutputFormat, errorCode?: string, explicitSource?: ErrorSource, retryAfterSeconds?: number) => void;
|
|
5
6
|
export { render, renderError };
|
|
6
7
|
export type { OutputFormat };
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { Command } from './command-types.js';
|
|
3
3
|
import { type ODataKey } from './odata-query.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options accepted by every builder that knows about `$select` (i.e. every
|
|
6
|
+
* builder except `buildCommand` / `buildElevatedCommand`, which take no OData
|
|
7
|
+
* passthroughs at all). `defaultSelect`, when set and the user did NOT pass
|
|
8
|
+
* `--select`, is injected into the OData query string so default invocations
|
|
9
|
+
* return a slim projection instead of a 50 KB resource. User-supplied
|
|
10
|
+
* `--select` always wins. Audit Jane-session §A: pairs the `list-mail-attachments`
|
|
11
|
+
* pattern with the builder layer so the 6 heaviest endpoints stop returning
|
|
12
|
+
* the full Graph resource by default.
|
|
13
|
+
*/
|
|
14
|
+
type SelectDefaults = {
|
|
15
|
+
readonly defaultSelect?: string;
|
|
16
|
+
};
|
|
4
17
|
declare const buildCommand: (pathFn: (params: Record<string, string>) => string, schema: z.ZodType) => Pick<Command, "schema" | "execute">;
|
|
5
18
|
declare const buildElevatedCommand: (pathFn: (params: Record<string, string>) => string, schema: z.ZodType) => Pick<Command, "schema" | "execute">;
|
|
6
|
-
declare const buildListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape
|
|
7
|
-
declare const buildElevatedListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape
|
|
19
|
+
declare const buildListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
20
|
+
declare const buildElevatedListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
8
21
|
/**
|
|
9
22
|
* Single-resource GET that supports the OData `$select` and `$expand` query
|
|
10
23
|
* parameters. Mirrors `buildListCommand` but exposes only the two flags that
|
|
@@ -13,14 +26,23 @@ declare const buildElevatedListCommand: <Shape extends z.ZodRawShape>(pathFn: (p
|
|
|
13
26
|
* the fields it needs (e.g. `--select id,subject`) instead of swallowing a
|
|
14
27
|
* 50 KB resource just to read a subject line.
|
|
15
28
|
*/
|
|
16
|
-
declare const buildSelectableCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape
|
|
29
|
+
declare const buildSelectableCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
30
|
+
/**
|
|
31
|
+
* Elevated-token twin of `buildSelectableCommand`. Use for single-resource
|
|
32
|
+
* GETs on endpoints that require the M365ChatClient identity (e.g. `/chats/{id}`)
|
|
33
|
+
* AND benefit from `$select`/`$expand` projection. The basic `buildElevatedCommand`
|
|
34
|
+
* builder takes no OData passthroughs — use this when the endpoint honours
|
|
35
|
+
* field projection, so an LLM can avoid pulling the whole resource just to
|
|
36
|
+
* read a topic or chatType.
|
|
37
|
+
*/
|
|
38
|
+
declare const buildElevatedSelectableCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
17
39
|
/**
|
|
18
40
|
* Collection GET that supports ONLY `$filter` and `$select` — for endpoints
|
|
19
41
|
* Microsoft documents as rejecting the other OData passthroughs (`/teams/{id}/channels`
|
|
20
42
|
* is the canonical case: Graph returns BadRequest on `$top`, `$skip`, `$orderby`,
|
|
21
43
|
* `$expand`). Advertising the unsupported flags would be a usability lie.
|
|
22
44
|
*/
|
|
23
|
-
declare const buildFilterSelectListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape
|
|
45
|
+
declare const buildFilterSelectListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
24
46
|
/**
|
|
25
47
|
* Collection GET on an endpoint that supports the usual OData passthroughs
|
|
26
48
|
* EXCEPT `$skip` (e.g. `/me/drive/recent`, `/sites/{id}/lists`,
|
|
@@ -28,7 +50,7 @@ declare const buildFilterSelectListCommand: <Shape extends z.ZodRawShape>(pathFn
|
|
|
28
50
|
* `invalidRequest: $skip is not supported on this API.`; the CLI mirrors
|
|
29
51
|
* by dropping `--skip` from the advertised flag set.
|
|
30
52
|
*/
|
|
31
|
-
declare const buildNoSkipListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape
|
|
53
|
+
declare const buildNoSkipListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
32
54
|
/**
|
|
33
55
|
* Collection GET that supports an EXPLICIT subset of OData passthroughs.
|
|
34
56
|
* Use for endpoints where Graph silently drops some flags — passing
|
|
@@ -37,12 +59,12 @@ declare const buildNoSkipListCommand: <Shape extends z.ZodRawShape>(pathFn: (par
|
|
|
37
59
|
* (`buildNoSkipListCommand`, `buildFilterSelectListCommand`) are
|
|
38
60
|
* specializations; this is the generic escape hatch.
|
|
39
61
|
*/
|
|
40
|
-
declare const buildPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K
|
|
62
|
+
declare const buildPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
41
63
|
/**
|
|
42
64
|
* Elevated-token twin of `buildPickODataListCommand`. Use for endpoints that
|
|
43
65
|
* require the M365ChatClient identity (e.g. `/me/chats`, `/chats/{}/members`)
|
|
44
66
|
* AND honour only a subset of OData passthroughs — the chats family rejects
|
|
45
67
|
* `$orderby` / `$expand` with `BadRequest`, so the picker is the right tool.
|
|
46
68
|
*/
|
|
47
|
-
declare const buildElevatedPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K
|
|
48
|
-
export { buildCommand, buildElevatedCommand, buildElevatedListCommand, buildElevatedPickODataListCommand, buildFilterSelectListCommand, buildListCommand, buildNoSkipListCommand, buildPickODataListCommand, buildSelectableCommand, };
|
|
69
|
+
declare const buildElevatedPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
70
|
+
export { buildCommand, buildElevatedCommand, buildElevatedListCommand, buildElevatedPickODataListCommand, buildElevatedSelectableCommand, buildFilterSelectListCommand, buildListCommand, buildNoSkipListCommand, buildPickODataListCommand, buildSelectableCommand, };
|
|
@@ -3,7 +3,7 @@ import type { Result } from '../../domain/result.js';
|
|
|
3
3
|
import type { GraphClient } from '../../infra/graph-client.js';
|
|
4
4
|
type CommandSchema = z.ZodType;
|
|
5
5
|
type CommandExecute = (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, import('../../infra/graph-client.js').GraphError>>;
|
|
6
|
-
type CommandCategory = '
|
|
6
|
+
type CommandCategory = 'drive' | 'excel' | 'sharepoint' | 'tasks' | 'mail' | 'notes' | 'user' | 'calendar' | 'chats' | 'teams' | 'meta' | 'lifecycle';
|
|
7
7
|
type CommandHttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
8
8
|
type CommandOptionAlias = {
|
|
9
9
|
readonly name: string;
|
|
@@ -80,6 +80,14 @@ type PaginationStrategy =
|
|
|
80
80
|
type CommandMeta = {
|
|
81
81
|
readonly summary: string;
|
|
82
82
|
readonly category: CommandCategory;
|
|
83
|
+
/**
|
|
84
|
+
* Deprecated former command names kept working as commander-level aliases for
|
|
85
|
+
* back-compat after a rename (e.g. `download-onedrive-file-content` →
|
|
86
|
+
* `download-drive-item-content`). The canonical registry key is what `--help`
|
|
87
|
+
* and the manifest list first; each alias here is also accepted on the CLI and
|
|
88
|
+
* surfaced in the manifest so an LLM that learned the old name still resolves.
|
|
89
|
+
*/
|
|
90
|
+
readonly commandAliases?: ReadonlyArray<string>;
|
|
83
91
|
readonly graphMethod: CommandHttpMethod;
|
|
84
92
|
readonly graphPathTemplate: string;
|
|
85
93
|
readonly graphDocsUrl: string;
|
|
@@ -107,6 +115,14 @@ type CommandMeta = {
|
|
|
107
115
|
* commands will time out.
|
|
108
116
|
*/
|
|
109
117
|
readonly needsElevatedToken?: true;
|
|
118
|
+
/**
|
|
119
|
+
* `true` if the command needs a Teams substrate token (chatsvcagg or ic3,
|
|
120
|
+
* captured at login from `teams.microsoft.com`) — the Teams chat-content
|
|
121
|
+
* commands. Like `needsElevatedToken`, an LLM should check this before
|
|
122
|
+
* invoking and warm up an interactive `login`; a headless or stale session
|
|
123
|
+
* times out on these (the non-interactive silent-SSO limitation, QA-011).
|
|
124
|
+
*/
|
|
125
|
+
readonly needsSubstrateToken?: true;
|
|
110
126
|
/**
|
|
111
127
|
* `true` if the command returns inlined bytes (`{contentType, size, base64}`
|
|
112
128
|
* or `{contentType, size, text}`) and is therefore a valid target for the
|
|
@@ -115,10 +131,46 @@ type CommandMeta = {
|
|
|
115
131
|
* as a string literal. Audit round-8 Wave E2.
|
|
116
132
|
*/
|
|
117
133
|
readonly producesBytes?: true;
|
|
134
|
+
/**
|
|
135
|
+
* `true` if the command returns a `media` array (`{ count, media: [{ path,
|
|
136
|
+
* contentType, sizeBytes, base64 }] }`) and is therefore a valid target for
|
|
137
|
+
* the global `--output-dir` flag, which writes each image to a directory.
|
|
138
|
+
* Parallel to `producesBytes` (single-file `--output-path`).
|
|
139
|
+
*/
|
|
140
|
+
readonly producesMedia?: true;
|
|
141
|
+
/**
|
|
142
|
+
* `true` if the command performs a write (mutation) against Microsoft Graph
|
|
143
|
+
* rather than a read/search. Today only the two mail-draft commands
|
|
144
|
+
* (`create-mail-draft` = POST, `update-mail-draft` = PATCH) — both produce an
|
|
145
|
+
* UNSENT draft and cannot send. The CLI composition derives its read-only
|
|
146
|
+
* top-level `--help` narrative from this flag (mutating commands vs search
|
|
147
|
+
* POSTs) instead of hardcoding command names, and the manifest/`help-json`
|
|
148
|
+
* surface it so an LLM can tell at a glance which commands change state.
|
|
149
|
+
* Audit 2026-06-15 (F-03).
|
|
150
|
+
*/
|
|
151
|
+
readonly mutates?: true;
|
|
152
|
+
/**
|
|
153
|
+
* Stability tier of the command. Omitted from manifest entries when the
|
|
154
|
+
* command is `'stable'` (the implicit default), surfaced only on
|
|
155
|
+
* `'experimental'` commands so an LLM can prefer stable siblings when they
|
|
156
|
+
* exist. `'experimental'` today means the command rides a Microsoft-internal
|
|
157
|
+
* substrate (chatsvcagg / IC3) that is not in the public Graph API and can
|
|
158
|
+
* break on a Teams web-client update — the docstring "Best-effort, may break
|
|
159
|
+
* on Microsoft client updates" warnings now have a structured pair.
|
|
160
|
+
* Audit Jane-session §6.
|
|
161
|
+
*/
|
|
162
|
+
readonly stability?: 'experimental';
|
|
118
163
|
};
|
|
119
164
|
type Command = {
|
|
120
165
|
readonly schema: CommandSchema;
|
|
121
166
|
readonly execute: CommandExecute;
|
|
122
167
|
readonly meta: CommandMeta;
|
|
168
|
+
/**
|
|
169
|
+
* Present on the rare command whose input is the LOCAL filesystem instead of
|
|
170
|
+
* Graph (`convert-local-file`). The CLI routes execution here, passing its
|
|
171
|
+
* composition-selected FileSystem; `execute` stays as the registry-typed
|
|
172
|
+
* fallback that redirects library consumers to this variant.
|
|
173
|
+
*/
|
|
174
|
+
readonly executeLocal?: (fs: import('../ports/filesystem.js').FileSystem, params: Record<string, string>) => Promise<Result<unknown, import('../../infra/graph-client.js').GraphError>>;
|
|
123
175
|
};
|
|
124
176
|
export type { ArgumentHint, Command, CommandCategory, CommandExecute, CommandHttpMethod, CommandMeta, CommandOptionAlias, CommandOptionMeta, CommandPositionalArgumentMeta, CommandSchema, PaginationStrategy, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Result } from '../../domain/result.js';
|
|
3
|
+
import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
4
|
+
import type { CommandMeta } from './command-types.js';
|
|
5
|
+
declare const schema: z.ZodObject<{
|
|
6
|
+
eventId: z.ZodString;
|
|
7
|
+
attachmentId: z.ZodString;
|
|
8
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
true: "true";
|
|
10
|
+
false: "false";
|
|
11
|
+
}>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
14
|
+
declare const meta: CommandMeta;
|
|
15
|
+
export { execute, meta, schema };
|
|
@@ -3,9 +3,8 @@ import type { Result } from '../../domain/result.js';
|
|
|
3
3
|
import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
4
4
|
import type { CommandMeta } from './command-types.js';
|
|
5
5
|
declare const schema: z.ZodObject<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
versionId: z.ZodString;
|
|
6
|
+
eventId: z.ZodString;
|
|
7
|
+
attachmentId: z.ZodString;
|
|
9
8
|
}, z.core.$strip>;
|
|
10
9
|
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
11
10
|
declare const meta: CommandMeta;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Result } from '../../domain/result.js';
|
|
3
|
+
import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
4
|
+
import type { CommandMeta } from './command-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Unzips a `.zip` from a OneDrive / SharePoint item and runs each contained
|
|
7
|
+
* file through the same local conversion pipelines the `*-as-markdown` commands
|
|
8
|
+
* use — so an agent reading "the project handover archive" doesn't have to shell
|
|
9
|
+
* out to `unzip` and convert each file separately. Office files (docx/xlsx/pptx/
|
|
10
|
+
* odt/ods/odp + variants) become markdown; legacy OLE .xls / .doc are extracted
|
|
11
|
+
* too (.ppt is noted, no pure-JS path); plain-text entries are decoded inline;
|
|
12
|
+
* PDFs have their text layer extracted; everything else (images, binaries, nested
|
|
13
|
+
* archives — plus scanned/image-only PDFs and legacy .ppt) is listed with a note
|
|
14
|
+
* rather than failing the whole archive.
|
|
15
|
+
*/
|
|
16
|
+
declare const schema: z.ZodObject<{
|
|
17
|
+
driveId: z.ZodString;
|
|
18
|
+
itemId: z.ZodString;
|
|
19
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
true: "true";
|
|
21
|
+
false: "false";
|
|
22
|
+
}>>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
25
|
+
declare const meta: CommandMeta;
|
|
26
|
+
export { execute, meta, schema };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Result } from '../../domain/result.js';
|
|
3
|
+
import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
4
|
+
import type { FileSystem } from '../ports/filesystem.js';
|
|
5
|
+
import type { CommandMeta } from './command-types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Convert a file ON DISK to markdown through the same `bytesToMarkdown`
|
|
8
|
+
* dispatch every Graph-backed markdown command uses — the only command whose
|
|
9
|
+
* input never touches Microsoft Graph (works offline, no login). The fetch
|
|
10
|
+
* step was always the Graph-bound part; conversion is pure bytes-in/markdown-out.
|
|
11
|
+
*
|
|
12
|
+
* A `.zip` routes through the shared archive core (each entry converted, GBK
|
|
13
|
+
* entry names decoded); everything else goes through the single-file dispatch.
|
|
14
|
+
* What it can NOT do locally: `format=pdf` conversions (Graph renders those
|
|
15
|
+
* server-side) and Loop/Fluid/Whiteboard (`format=html`, same reason).
|
|
16
|
+
*
|
|
17
|
+
* This is the one registry command executed via `executeLocal(fs, params)` —
|
|
18
|
+
* the CLI wires its FileSystem in automatically (see `cli.ts`). The Graph-shaped
|
|
19
|
+
* `execute` exists because the public `commands` registry type requires it; it
|
|
20
|
+
* redirects library consumers to `executeLocal`.
|
|
21
|
+
*/
|
|
22
|
+
declare const schema: z.ZodObject<{
|
|
23
|
+
path: z.ZodString;
|
|
24
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
true: "true";
|
|
26
|
+
false: "false";
|
|
27
|
+
}>>;
|
|
28
|
+
inlineImages: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
true: "true";
|
|
30
|
+
false: "false";
|
|
31
|
+
}>>;
|
|
32
|
+
maxCells: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
declare const executeLocal: (fs: FileSystem, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
35
|
+
declare const execute: (_graph: GraphClient, _params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
36
|
+
declare const meta: CommandMeta;
|
|
37
|
+
export { execute, executeLocal, meta, schema };
|
|
@@ -5,7 +5,13 @@ import type { CommandMeta } from './command-types.js';
|
|
|
5
5
|
declare const schema: z.ZodObject<{
|
|
6
6
|
messageId: z.ZodString;
|
|
7
7
|
attachmentId: z.ZodString;
|
|
8
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
true: "true";
|
|
10
|
+
false: "false";
|
|
11
|
+
}>>;
|
|
8
12
|
}, z.core.$strip>;
|
|
13
|
+
declare const convertFetchedAttachment: (graph: GraphClient, a: Record<string, unknown>, includeMetadata: boolean) => Promise<Result<unknown, GraphError>> | Result<unknown, GraphError>;
|
|
14
|
+
declare const convertAttachmentToMarkdown: (graph: GraphClient, attachmentPath: string, includeMetadata: boolean) => Promise<Result<unknown, GraphError>>;
|
|
9
15
|
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
10
16
|
declare const meta: CommandMeta;
|
|
11
|
-
export { execute, meta, schema };
|
|
17
|
+
export { convertAttachmentToMarkdown, convertFetchedAttachment, execute, meta, schema };
|
|
@@ -6,6 +6,7 @@ declare const schema: z.ZodObject<{
|
|
|
6
6
|
messageId: z.ZodString;
|
|
7
7
|
attachmentId: z.ZodString;
|
|
8
8
|
}, z.core.$strip>;
|
|
9
|
+
declare const convertAttachmentToPdf: (graph: GraphClient, attachmentPath: string) => Promise<Result<unknown, GraphError>>;
|
|
9
10
|
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
10
11
|
declare const meta: CommandMeta;
|
|
11
|
-
export { execute, meta, schema };
|
|
12
|
+
export { convertAttachmentToPdf, execute, meta, schema };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Result } from '../../domain/result.js';
|
|
3
|
+
import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
4
|
+
import type { CommandMeta } from './command-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Unzips a `.zip` Outlook mail attachment and converts every contained file in one
|
|
7
|
+
* call — the mail-side mirror of `convert-drive-item-zip`. Without it, reading a
|
|
8
|
+
* zipped vendor deck meant: `get-mail-attachment --output-path x.zip` → manual
|
|
9
|
+
* `unzip` (with `-O GBK` for Chinese names) → convert each file. This collapses all
|
|
10
|
+
* of that into one command: it pulls the fileAttachment bytes, unzips them (legacy
|
|
11
|
+
* GBK / CP437 entry names are decoded, not mojibaked, in the shared zip reader), and
|
|
12
|
+
* runs each entry through the same conversion dispatch the markdown commands use.
|
|
13
|
+
*/
|
|
14
|
+
declare const schema: z.ZodObject<{
|
|
15
|
+
messageId: z.ZodString;
|
|
16
|
+
attachmentId: z.ZodString;
|
|
17
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
true: "true";
|
|
19
|
+
false: "false";
|
|
20
|
+
}>>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
23
|
+
declare const meta: CommandMeta;
|
|
24
|
+
export { execute, meta, schema };
|
|
@@ -4,6 +4,14 @@ import type { GraphClient, GraphError } from '../../infra/graph-client.js';
|
|
|
4
4
|
import type { CommandMeta } from './command-types.js';
|
|
5
5
|
declare const schema: z.ZodObject<{
|
|
6
6
|
messageId: z.ZodString;
|
|
7
|
+
inlineImages: z.ZodOptional<z.ZodEnum<{
|
|
8
|
+
true: "true";
|
|
9
|
+
false: "false";
|
|
10
|
+
}>>;
|
|
11
|
+
keepQuoted: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
true: "true";
|
|
13
|
+
false: "false";
|
|
14
|
+
}>>;
|
|
7
15
|
}, z.core.$strip>;
|
|
8
16
|
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
9
17
|
declare const meta: CommandMeta;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Command, CommandMeta } from './command-types.js';
|
|
3
|
+
declare const schema: z.ZodObject<{
|
|
4
|
+
subject: z.ZodString;
|
|
5
|
+
bodyContent: z.ZodString;
|
|
6
|
+
bodyContentType: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
Text: "Text";
|
|
8
|
+
HTML: "HTML";
|
|
9
|
+
}>>;
|
|
10
|
+
toRecipients: z.ZodString;
|
|
11
|
+
ccRecipients: z.ZodOptional<z.ZodString>;
|
|
12
|
+
bccRecipients: z.ZodOptional<z.ZodString>;
|
|
13
|
+
importance: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
Low: "Low";
|
|
15
|
+
Normal: "Normal";
|
|
16
|
+
High: "High";
|
|
17
|
+
}>>;
|
|
18
|
+
mailFolderId: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
declare const execute: Command['execute'];
|
|
21
|
+
declare const meta: CommandMeta;
|
|
22
|
+
export { execute, meta, schema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Result } from '../../domain/result.js';
|
|
2
|
+
import type { GraphError } from '../../infra/graph-client.js';
|
|
3
|
+
type DocTextEnvelope = {
|
|
4
|
+
readonly contentType: 'text/plain';
|
|
5
|
+
readonly size: number;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Convert a legacy Word .doc to a plain-text envelope by extracting its body text
|
|
10
|
+
* (via word-extractor). Output is text/plain, not markdown — legacy .doc carries
|
|
11
|
+
* no structure this CLI recovers. A parse failure propagates as the infra api_error.
|
|
12
|
+
*/
|
|
13
|
+
declare const docToMarkdown: (bytes: Uint8Array) => Promise<Result<DocTextEnvelope, GraphError>>;
|
|
14
|
+
export { docToMarkdown };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CommandCategory, CommandMeta } from './command-types.js';
|
|
1
|
+
import type { CommandCategory, CommandMeta, PaginationStrategy } from './command-types.js';
|
|
2
2
|
export type CommandManifestEntry = {
|
|
3
3
|
readonly name: string;
|
|
4
4
|
readonly summary: string;
|
|
5
5
|
readonly category: CommandCategory;
|
|
6
|
+
readonly commandAliases?: CommandMeta['commandAliases'];
|
|
6
7
|
readonly graphMethod: CommandMeta['graphMethod'];
|
|
7
8
|
readonly graphPathTemplate: string;
|
|
8
9
|
readonly graphDocsUrl: string;
|
|
@@ -16,8 +17,12 @@ export type CommandManifestEntry = {
|
|
|
16
17
|
readonly scopesRequired?: CommandMeta['scopesRequired'];
|
|
17
18
|
readonly needsElevatedToken?: CommandMeta['needsElevatedToken'];
|
|
18
19
|
readonly producesBytes?: CommandMeta['producesBytes'];
|
|
20
|
+
readonly producesMedia?: CommandMeta['producesMedia'];
|
|
21
|
+
readonly mutates?: CommandMeta['mutates'];
|
|
22
|
+
readonly stability?: CommandMeta['stability'];
|
|
19
23
|
};
|
|
20
|
-
export declare const
|
|
24
|
+
export declare const paginationHintFor: (strategy: PaginationStrategy | undefined) => string;
|
|
25
|
+
export declare const PAGINATION_HINT = "Paginated by Microsoft Graph. The CLI hoists `@odata.nextLink` out of `data` to the **top-level `nextLink`** field of the response envelope. Pass that URL to `next-page --url <link>` and repeat until the field is absent. Do NOT look for `data[\"@odata.nextLink\"]` \u2014 the presenter strips it from `data` so the cursor is always at envelope level.";
|
|
21
26
|
export type CommandManifest = {
|
|
22
27
|
readonly package: string;
|
|
23
28
|
readonly version: string;
|
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
import type { Result } from '../../domain/result.js';
|
|
2
|
-
import type { Command } from './command-types.js';
|
|
2
|
+
import type { CommandCategory, Command, CommandMeta } from './command-types.js';
|
|
3
3
|
import type { CommandManifest } from './docs-render.js';
|
|
4
4
|
export type DocsError = {
|
|
5
5
|
type: 'unknown_command';
|
|
6
6
|
readonly name: string;
|
|
7
7
|
readonly available: ReadonlyArray<string>;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Terse manifest entry — only the fields an LLM needs to *discover* a command
|
|
11
|
+
* (i.e. "does this CLI do X?"). Drops `options`, `example`, `graphPathTemplate`,
|
|
12
|
+
* `graphDocsUrl`, `responseShape`, `bodyTemplate`, `paginationStrategy`,
|
|
13
|
+
* `scopesRequired` — everything the LLM only needs once it's already decided
|
|
14
|
+
* to invoke. `stability` is kept (it's a discovery-time concern: LLMs prefer
|
|
15
|
+
* stable siblings when they exist, so they need to see the tag at discovery
|
|
16
|
+
* time, not after a second full-manifest fetch). Audit Jane-session §B/§6.
|
|
17
|
+
*/
|
|
18
|
+
export type TerseManifestEntry = {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly summary: string;
|
|
21
|
+
readonly category: CommandCategory;
|
|
22
|
+
readonly stability?: CommandMeta['stability'];
|
|
23
|
+
};
|
|
24
|
+
export type TerseManifest = {
|
|
25
|
+
readonly package: string;
|
|
26
|
+
readonly version: string;
|
|
27
|
+
readonly generatedAt: string;
|
|
28
|
+
readonly commands: ReadonlyArray<TerseManifestEntry>;
|
|
29
|
+
};
|
|
30
|
+
export type ManifestFilterError = {
|
|
31
|
+
readonly type: 'unknown_category';
|
|
32
|
+
readonly category: string;
|
|
33
|
+
readonly available: ReadonlyArray<string>;
|
|
34
|
+
};
|
|
9
35
|
export declare const buildManifest: (registry: Readonly<Record<string, Command>>, packageName: string, version: string, now?: () => Date) => CommandManifest;
|
|
36
|
+
/**
|
|
37
|
+
* Terse manifest — `{ name, summary, category }` per command. Roughly 95%
|
|
38
|
+
* smaller than the full manifest (no options/example/Graph endpoint per entry).
|
|
39
|
+
* Use `help-json --terse` to surface this to an LLM as the discovery view.
|
|
40
|
+
*/
|
|
41
|
+
export declare const buildTerseManifest: (registry: Readonly<Record<string, Command>>, packageName: string, version: string, now?: () => Date) => TerseManifest;
|
|
42
|
+
/**
|
|
43
|
+
* Filter a `CommandManifest` (or terse variant) down to a single category.
|
|
44
|
+
* Returns `err({ type: 'unknown_category', ... })` if the requested category
|
|
45
|
+
* isn't a known one — the CLI surfaces this through the standard error
|
|
46
|
+
* envelope rather than silently returning an empty list.
|
|
47
|
+
*/
|
|
48
|
+
export declare const filterManifestByCategory: <M extends {
|
|
49
|
+
readonly commands: ReadonlyArray<{
|
|
50
|
+
readonly category: CommandCategory;
|
|
51
|
+
}>;
|
|
52
|
+
}>(manifest: M, category: string) => Result<M, ManifestFilterError>;
|
|
10
53
|
export declare const renderSingleCommand: (registry: Readonly<Record<string, Command>>, name: string) => Result<string, DocsError>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Correlates each docx comment to the body text it annotates. In
|
|
3
|
+
* `word/document.xml` a comment's anchored span is bracketed by empty marker
|
|
4
|
+
* elements `<w:commentRangeStart w:id="N"/> …runs… <w:commentRangeEnd w:id="N"/>`,
|
|
5
|
+
* keyed by the same `w:id` the comment in `word/comments.xml` carries. mammoth
|
|
6
|
+
* strips those markers from its HTML, so to fold the comment's context into the
|
|
7
|
+
* markdown we read document.xml directly.
|
|
8
|
+
*
|
|
9
|
+
* The shared walker (ooxml-xml-walker) groups same-named siblings and loses
|
|
10
|
+
* cross-element order, which would scramble which runs fall inside a range. So,
|
|
11
|
+
* like odf-content-to-markdown, this parses with `preserveOrder` and walks the
|
|
12
|
+
* ordered tree, tracking the set of currently-open comment ids and appending
|
|
13
|
+
* each `<w:t>` run's text to every open range. Handles overlapping / nested
|
|
14
|
+
* ranges (more than one open at once). Pure (string → Map); no IO.
|
|
15
|
+
*/
|
|
16
|
+
type Node = Record<string, unknown>;
|
|
17
|
+
declare const tagOf: (node: Node) => string | undefined;
|
|
18
|
+
declare const attr: (node: Node, name: string) => string;
|
|
19
|
+
declare const leafText: (children: ReadonlyArray<Node>) => string;
|
|
20
|
+
declare const clamp: (span: string) => string;
|
|
21
|
+
declare const extractCommentAnchors: (documentXml: string | undefined) => ReadonlyMap<string, string>;
|
|
22
|
+
export { attr, clamp, extractCommentAnchors, leafText, tagOf };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Result } from '../../domain/result.js';
|
|
2
|
+
import type { GraphError } from '../../infra/graph-client.js';
|
|
3
|
+
import type { CustomProp, ExternalRel } from './ooxml-metadata.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pulls the side-channel content out of a .docx zip — every text-bearing
|
|
6
|
+
* surface mammoth drops on the floor: core / app / custom doc properties,
|
|
7
|
+
* people registry, external hyperlinks, comments, tracked changes (ins + del),
|
|
8
|
+
* hidden text (w:vanish), text-box / shape text (w:txbxContent), header/footer
|
|
9
|
+
* body prose, field instructions (MERGEFIELD / HYPERLINK / DOCVARIABLE), bookmarks.
|
|
10
|
+
*
|
|
11
|
+
* The package-level parts (docProps/*, every *.rels) come from the shared
|
|
12
|
+
* ooxml-metadata module; this file owns only the docx-body-specific parts.
|
|
13
|
+
*
|
|
14
|
+
* Pure use-case logic — no IO. The zip is opened upstream via the infra
|
|
15
|
+
* adapter; this module just walks parsed XML trees. Try/catch lives in
|
|
16
|
+
* the infra adapter, not here.
|
|
17
|
+
*/
|
|
18
|
+
type CoreProps = Readonly<Record<string, string>>;
|
|
19
|
+
type AppProps = Readonly<Record<string, string>>;
|
|
20
|
+
type Person = {
|
|
21
|
+
readonly author: string;
|
|
22
|
+
readonly providerId: string;
|
|
23
|
+
readonly userId: string;
|
|
24
|
+
};
|
|
25
|
+
type Comment = {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly author: string;
|
|
28
|
+
readonly initials: string;
|
|
29
|
+
readonly date: string;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly anchor?: string;
|
|
32
|
+
};
|
|
33
|
+
type TrackedChange = {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly author: string;
|
|
36
|
+
readonly date: string;
|
|
37
|
+
readonly text: string;
|
|
38
|
+
};
|
|
39
|
+
type Field = {
|
|
40
|
+
readonly source: string;
|
|
41
|
+
readonly instruction: string;
|
|
42
|
+
};
|
|
43
|
+
type Bookmark = {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly name: string;
|
|
46
|
+
};
|
|
47
|
+
type HeaderFooter = {
|
|
48
|
+
readonly part: string;
|
|
49
|
+
readonly text: string;
|
|
50
|
+
};
|
|
51
|
+
type DocxMetadata = {
|
|
52
|
+
readonly core: CoreProps;
|
|
53
|
+
readonly app: AppProps;
|
|
54
|
+
readonly custom: ReadonlyArray<CustomProp>;
|
|
55
|
+
readonly people: ReadonlyArray<Person>;
|
|
56
|
+
readonly externalRels: ReadonlyArray<ExternalRel>;
|
|
57
|
+
readonly comments: ReadonlyArray<Comment>;
|
|
58
|
+
readonly insertions: ReadonlyArray<TrackedChange>;
|
|
59
|
+
readonly deletions: ReadonlyArray<TrackedChange>;
|
|
60
|
+
readonly hiddenText: ReadonlyArray<string>;
|
|
61
|
+
readonly textBoxes: ReadonlyArray<string>;
|
|
62
|
+
readonly headersFooters: ReadonlyArray<HeaderFooter>;
|
|
63
|
+
readonly fields: ReadonlyArray<Field>;
|
|
64
|
+
readonly bookmarks: ReadonlyArray<Bookmark>;
|
|
65
|
+
readonly macros: ReadonlyArray<string>;
|
|
66
|
+
};
|
|
67
|
+
declare const extractDocxMetadata: (bytes: Uint8Array) => Promise<Result<DocxMetadata, GraphError>>;
|
|
68
|
+
export { extractDocxMetadata };
|
|
69
|
+
export type { Bookmark, Comment, CustomProp, DocxMetadata, ExternalRel, Field, HeaderFooter, Person, TrackedChange };
|
|
@@ -5,7 +5,12 @@ type MarkdownEnvelope = {
|
|
|
5
5
|
readonly size: number;
|
|
6
6
|
readonly text: string;
|
|
7
7
|
};
|
|
8
|
+
type DocxToMarkdownOptions = {
|
|
9
|
+
readonly includeMetadata?: boolean;
|
|
10
|
+
readonly inlineImages?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const stripInlineImages: (markdown: string) => string;
|
|
8
13
|
declare const promoteFirstRowToThead: (html: string) => string;
|
|
9
|
-
declare const docxToMarkdown: (bytes: Uint8Array) => Promise<Result<MarkdownEnvelope, GraphError>>;
|
|
10
|
-
export { docxToMarkdown, promoteFirstRowToThead };
|
|
11
|
-
export type { MarkdownEnvelope };
|
|
14
|
+
declare const docxToMarkdown: (bytes: Uint8Array, opts?: DocxToMarkdownOptions) => Promise<Result<MarkdownEnvelope, GraphError>>;
|
|
15
|
+
export { docxToMarkdown, promoteFirstRowToThead, stripInlineImages };
|
|
16
|
+
export type { DocxToMarkdownOptions, MarkdownEnvelope };
|
|
@@ -5,6 +5,15 @@ import type { CommandMeta } from './command-types.js';
|
|
|
5
5
|
declare const schema: z.ZodObject<{
|
|
6
6
|
driveId: z.ZodString;
|
|
7
7
|
itemId: z.ZodString;
|
|
8
|
+
includeMetadata: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
true: "true";
|
|
10
|
+
false: "false";
|
|
11
|
+
}>>;
|
|
12
|
+
inlineImages: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
true: "true";
|
|
14
|
+
false: "false";
|
|
15
|
+
}>>;
|
|
16
|
+
maxCells: z.ZodOptional<z.ZodString>;
|
|
8
17
|
}, z.core.$strip>;
|
|
9
18
|
declare const execute: (graph: GraphClient, params: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
10
19
|
declare const meta: CommandMeta;
|