office-open 0.10.15 → 0.12.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/README.md +29 -9
- package/dist/ai/index.d.mts +41 -723
- package/dist/ai/index.d.mts.map +1 -1
- package/dist/ai/index.mjs +129 -26
- package/dist/ai/index.mjs.map +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +142 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/convert/index.d.mts +96 -0
- package/dist/convert/index.d.mts.map +1 -0
- package/dist/convert/index.mjs +1730 -0
- package/dist/convert/index.mjs.map +1 -0
- package/dist/generate.d.mts +0 -1
- package/dist/generate.d.mts.map +1 -1
- package/dist/generate.mjs +3 -2
- package/dist/generate.mjs.map +1 -1
- package/dist/schemas/index.d.mts +29 -717
- package/dist/schemas/index.d.mts.map +1 -1
- package/dist/schemas/index.mjs +2 -20
- package/dist/schemas-DhCWsZ8v.mjs +48949 -0
- package/dist/schemas-DhCWsZ8v.mjs.map +1 -0
- package/dist/schemas-Dupoq6xM.d.mts +17 -0
- package/dist/schemas-Dupoq6xM.d.mts.map +1 -0
- package/package.json +24 -9
- package/schemas/docx.schema.json +28184 -0
- package/schemas/pptx.schema.json +13919 -0
- package/schemas/xlsx.schema.json +17345 -0
- package/dist/schemas/index.mjs.map +0 -1
- package/dist/xlsx-Bd0Vtakp.mjs +0 -275
- package/dist/xlsx-Bd0Vtakp.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> Everything for AI-native Office documents in one install — Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) generation from JSON, plus a CLI, Vercel AI SDK tools, and frozen JSON Schemas for LLM tool-calling.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- **
|
|
11
|
+
- **One Install** — Import from `office-open/docx`, `office-open/pptx`, `office-open/xlsx`; no Microsoft Office required
|
|
12
|
+
- **AI SDK Tools** — Vercel AI SDK compatible tools for `generate-docx`, `generate-pptx`, `generate-xlsx`, ready for AI agents and chatbots
|
|
13
|
+
- **JSON Schemas** — Draft-07 input validation for all document types, with on-demand schema slicing for LLM context budgets
|
|
12
14
|
- **CLI** — Generate files from JSON via `npx office-open`
|
|
13
|
-
- **AI SDK Tools** — Vercel AI SDK compatible tools for `generate-docx`, `generate-pptx`, `generate-xlsx`
|
|
14
|
-
- **Zod Schemas** — Input validation for all document types
|
|
15
15
|
- **Generate Function** — Type-agnostic `generate()` for dynamic document creation
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
@@ -57,6 +57,11 @@ const buffer = await generate({
|
|
|
57
57
|
npx office-open docx document.json "output.docx"
|
|
58
58
|
npx office-open pptx slides.json "output.pptx"
|
|
59
59
|
npx office-open xlsx spreadsheet.json "output.xlsx"
|
|
60
|
+
|
|
61
|
+
# Consult the JSON schemas (for AI agents and humans)
|
|
62
|
+
npx office-open schema index docx # indexed lookup entries by domain
|
|
63
|
+
npx office-open schema index docx --all # every definition name
|
|
64
|
+
npx office-open schema slice docx ParagraphOptions RunOptions # sub-schema for those types
|
|
60
65
|
```
|
|
61
66
|
|
|
62
67
|
### AI SDK Tools
|
|
@@ -72,16 +77,31 @@ const result = await generateText({
|
|
|
72
77
|
});
|
|
73
78
|
```
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
The generate tools carry skeleton input schemas (top-level shape + wrapper keys, ~5K tokens instead of the ~170K-token full schema); the `office-open-schema-lookup` tool fetches precise option schemas on demand.
|
|
81
|
+
|
|
82
|
+
Two more agent entry points live on the documentation site:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# MCP server for Claude Code, Cursor, and other MCP clients
|
|
86
|
+
claude mcp add --transport http office-open https://www.office-open.com/mcp
|
|
87
|
+
|
|
88
|
+
# Installable Agent Skill with curated API references
|
|
89
|
+
npx skills add https://www.office-open.com
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### JSON Schemas
|
|
76
93
|
|
|
77
94
|
```typescript
|
|
78
|
-
import { validateDocumentInput } from "office-open/schemas";
|
|
95
|
+
import { validateDocumentInput, sliceDocumentSchema } from "office-open/schemas";
|
|
79
96
|
|
|
80
97
|
try {
|
|
81
98
|
const validated = validateDocumentInput("docx", userInput);
|
|
82
99
|
} catch (e) {
|
|
83
|
-
//
|
|
100
|
+
// Aggregated validation errors with instance paths and messages
|
|
84
101
|
}
|
|
102
|
+
|
|
103
|
+
// Extract the dependency closure of specific option types
|
|
104
|
+
const slice = sliceDocumentSchema("docx", ["ParagraphOptions", "RunOptions"]);
|
|
85
105
|
```
|
|
86
106
|
|
|
87
107
|
### Import from Sub-Packages
|
|
@@ -91,7 +111,7 @@ import { generateDocument, parseDocument, patchDocument } from "office-open/docx
|
|
|
91
111
|
import { generatePresentation, parsePresentation, patchPresentation } from "office-open/pptx";
|
|
92
112
|
import { generateWorkbook, parseWorkbook, patchWorkbook } from "office-open/xlsx";
|
|
93
113
|
import { convertInchesToTwip } from "office-open/core";
|
|
94
|
-
import {
|
|
114
|
+
import { parse, stringify } from "office-open/xml";
|
|
95
115
|
```
|
|
96
116
|
|
|
97
117
|
## Sub-Exports
|
|
@@ -106,7 +126,7 @@ import { xml2js, js2xml } from "office-open/xml";
|
|
|
106
126
|
| `office-open/xml` | @office-open/xml |
|
|
107
127
|
| `office-open/generate` | `generate()` function |
|
|
108
128
|
| `office-open/ai` | Vercel AI SDK tools |
|
|
109
|
-
| `office-open/schemas` |
|
|
129
|
+
| `office-open/schemas` | JSON schemas, validation, and slicing |
|
|
110
130
|
|
|
111
131
|
## JSON Document Structures
|
|
112
132
|
|