office-open 0.0.0 → 0.6.9
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/LICENSE +21 -0
- package/dist/ai/index.d.mts +222 -0
- package/dist/ai/index.d.mts.map +1 -0
- package/dist/ai/index.mjs +55 -0
- package/dist/ai/index.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +70 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/core.d.mts +1 -0
- package/dist/core.mjs +2 -0
- package/dist/docx.d.mts +1 -0
- package/dist/docx.mjs +2 -0
- package/dist/generate.d.mts +15 -0
- package/dist/generate.d.mts.map +1 -0
- package/dist/generate.mjs +40 -0
- package/dist/generate.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/pptx.d.mts +1 -0
- package/dist/pptx.mjs +2 -0
- package/dist/schemas/index.d.mts +206 -0
- package/dist/schemas/index.d.mts.map +1 -0
- package/dist/schemas/index.mjs +2 -0
- package/dist/schemas-BbRmv4RW.mjs +125 -0
- package/dist/schemas-BbRmv4RW.mjs.map +1 -0
- package/dist/xlsx.d.mts +1 -0
- package/dist/xlsx.mjs +2 -0
- package/dist/xml.d.mts +1 -0
- package/dist/xml.mjs +2 -0
- package/package.json +98 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Demo Macro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
//#region src/ai/index.d.ts
|
|
2
|
+
declare const docxTool: import("ai").Tool<{
|
|
3
|
+
[x: string]: unknown;
|
|
4
|
+
sections: {
|
|
5
|
+
[x: string]: unknown;
|
|
6
|
+
children: (string | Record<string, unknown>)[];
|
|
7
|
+
properties?: Record<string, unknown> | undefined;
|
|
8
|
+
headers?: Record<string, unknown> | undefined;
|
|
9
|
+
footers?: Record<string, unknown> | undefined;
|
|
10
|
+
}[];
|
|
11
|
+
title?: string | undefined;
|
|
12
|
+
subject?: string | undefined;
|
|
13
|
+
creator?: string | undefined;
|
|
14
|
+
keywords?: string | undefined;
|
|
15
|
+
description?: string | undefined;
|
|
16
|
+
lastModifiedBy?: string | undefined;
|
|
17
|
+
revision?: number | undefined;
|
|
18
|
+
externalStyles?: string | undefined;
|
|
19
|
+
styles?: Record<string, unknown> | undefined;
|
|
20
|
+
numbering?: Record<string, unknown> | undefined;
|
|
21
|
+
comments?: Record<string, unknown> | undefined;
|
|
22
|
+
bibliography?: Record<string, unknown> | undefined;
|
|
23
|
+
footnotes?: Record<string, Record<string, unknown>> | undefined;
|
|
24
|
+
endnotes?: Record<string, Record<string, unknown>> | undefined;
|
|
25
|
+
background?: Record<string, unknown> | undefined;
|
|
26
|
+
features?: Record<string, unknown> | undefined;
|
|
27
|
+
compatabilityModeVersion?: number | undefined;
|
|
28
|
+
compatibility?: Record<string, unknown> | undefined;
|
|
29
|
+
customProperties?: Record<string, unknown>[] | undefined;
|
|
30
|
+
evenAndOddHeaderAndFooters?: boolean | undefined;
|
|
31
|
+
defaultTabStop?: number | undefined;
|
|
32
|
+
fonts?: Record<string, unknown>[] | undefined;
|
|
33
|
+
hyphenation?: Record<string, unknown> | undefined;
|
|
34
|
+
characterSpacingControl?: string | undefined;
|
|
35
|
+
view?: string | undefined;
|
|
36
|
+
zoom?: Record<string, unknown> | undefined;
|
|
37
|
+
writeProtection?: Record<string, unknown> | undefined;
|
|
38
|
+
displayBackgroundShape?: boolean | undefined;
|
|
39
|
+
embedTrueTypeFonts?: boolean | undefined;
|
|
40
|
+
embedSystemFonts?: boolean | undefined;
|
|
41
|
+
saveSubsetFonts?: boolean | undefined;
|
|
42
|
+
docVars?: Record<string, unknown>[] | undefined;
|
|
43
|
+
colorSchemeMapping?: unknown;
|
|
44
|
+
}, {
|
|
45
|
+
base64: string;
|
|
46
|
+
mimeType: string;
|
|
47
|
+
}>;
|
|
48
|
+
declare const pptxTool: import("ai").Tool<{
|
|
49
|
+
[x: string]: unknown;
|
|
50
|
+
slides: {
|
|
51
|
+
[x: string]: unknown;
|
|
52
|
+
children: (string | Record<string, unknown>)[];
|
|
53
|
+
background?: Record<string, unknown> | undefined;
|
|
54
|
+
transition?: Record<string, unknown> | undefined;
|
|
55
|
+
notes?: string | undefined;
|
|
56
|
+
layout?: string | undefined;
|
|
57
|
+
master?: string | undefined;
|
|
58
|
+
comments?: Record<string, unknown>[] | undefined;
|
|
59
|
+
headerFooter?: Record<string, unknown> | undefined;
|
|
60
|
+
}[];
|
|
61
|
+
size?: "16:9" | "4:3" | {
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
} | undefined;
|
|
65
|
+
masters?: Record<string, unknown>[] | undefined;
|
|
66
|
+
show?: Record<string, unknown> | undefined;
|
|
67
|
+
title?: string | undefined;
|
|
68
|
+
subject?: string | undefined;
|
|
69
|
+
creator?: string | undefined;
|
|
70
|
+
keywords?: string | undefined;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
lastModifiedBy?: string | undefined;
|
|
73
|
+
revision?: number | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
base64: string;
|
|
76
|
+
mimeType: string;
|
|
77
|
+
}>;
|
|
78
|
+
declare const xlsxTool: import("ai").Tool<{
|
|
79
|
+
[x: string]: unknown;
|
|
80
|
+
worksheets: {
|
|
81
|
+
[x: string]: unknown;
|
|
82
|
+
name?: string | undefined;
|
|
83
|
+
children?: {
|
|
84
|
+
[x: string]: unknown;
|
|
85
|
+
cells?: (string | number | boolean | Record<string, unknown>)[] | undefined;
|
|
86
|
+
height?: number | undefined;
|
|
87
|
+
hidden?: boolean | undefined;
|
|
88
|
+
rowNumber?: number | undefined;
|
|
89
|
+
}[] | undefined;
|
|
90
|
+
columns?: Record<string, unknown>[] | undefined;
|
|
91
|
+
mergeCells?: Record<string, unknown>[] | undefined;
|
|
92
|
+
freezePanes?: Record<string, unknown> | undefined;
|
|
93
|
+
autoFilter?: string | undefined;
|
|
94
|
+
images?: Record<string, unknown>[] | undefined;
|
|
95
|
+
charts?: Record<string, unknown>[] | undefined;
|
|
96
|
+
dataValidations?: Record<string, unknown>[] | undefined;
|
|
97
|
+
conditionalFormats?: Record<string, unknown>[] | undefined;
|
|
98
|
+
}[];
|
|
99
|
+
title?: string | undefined;
|
|
100
|
+
subject?: string | undefined;
|
|
101
|
+
creator?: string | undefined;
|
|
102
|
+
keywords?: string | undefined;
|
|
103
|
+
description?: string | undefined;
|
|
104
|
+
lastModifiedBy?: string | undefined;
|
|
105
|
+
revision?: number | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
base64: string;
|
|
108
|
+
mimeType: string;
|
|
109
|
+
}>;
|
|
110
|
+
declare const officeOpenTools: {
|
|
111
|
+
readonly "generate-docx": import("ai").Tool<{
|
|
112
|
+
[x: string]: unknown;
|
|
113
|
+
sections: {
|
|
114
|
+
[x: string]: unknown;
|
|
115
|
+
children: (string | Record<string, unknown>)[];
|
|
116
|
+
properties?: Record<string, unknown> | undefined;
|
|
117
|
+
headers?: Record<string, unknown> | undefined;
|
|
118
|
+
footers?: Record<string, unknown> | undefined;
|
|
119
|
+
}[];
|
|
120
|
+
title?: string | undefined;
|
|
121
|
+
subject?: string | undefined;
|
|
122
|
+
creator?: string | undefined;
|
|
123
|
+
keywords?: string | undefined;
|
|
124
|
+
description?: string | undefined;
|
|
125
|
+
lastModifiedBy?: string | undefined;
|
|
126
|
+
revision?: number | undefined;
|
|
127
|
+
externalStyles?: string | undefined;
|
|
128
|
+
styles?: Record<string, unknown> | undefined;
|
|
129
|
+
numbering?: Record<string, unknown> | undefined;
|
|
130
|
+
comments?: Record<string, unknown> | undefined;
|
|
131
|
+
bibliography?: Record<string, unknown> | undefined;
|
|
132
|
+
footnotes?: Record<string, Record<string, unknown>> | undefined;
|
|
133
|
+
endnotes?: Record<string, Record<string, unknown>> | undefined;
|
|
134
|
+
background?: Record<string, unknown> | undefined;
|
|
135
|
+
features?: Record<string, unknown> | undefined;
|
|
136
|
+
compatabilityModeVersion?: number | undefined;
|
|
137
|
+
compatibility?: Record<string, unknown> | undefined;
|
|
138
|
+
customProperties?: Record<string, unknown>[] | undefined;
|
|
139
|
+
evenAndOddHeaderAndFooters?: boolean | undefined;
|
|
140
|
+
defaultTabStop?: number | undefined;
|
|
141
|
+
fonts?: Record<string, unknown>[] | undefined;
|
|
142
|
+
hyphenation?: Record<string, unknown> | undefined;
|
|
143
|
+
characterSpacingControl?: string | undefined;
|
|
144
|
+
view?: string | undefined;
|
|
145
|
+
zoom?: Record<string, unknown> | undefined;
|
|
146
|
+
writeProtection?: Record<string, unknown> | undefined;
|
|
147
|
+
displayBackgroundShape?: boolean | undefined;
|
|
148
|
+
embedTrueTypeFonts?: boolean | undefined;
|
|
149
|
+
embedSystemFonts?: boolean | undefined;
|
|
150
|
+
saveSubsetFonts?: boolean | undefined;
|
|
151
|
+
docVars?: Record<string, unknown>[] | undefined;
|
|
152
|
+
colorSchemeMapping?: unknown;
|
|
153
|
+
}, {
|
|
154
|
+
base64: string;
|
|
155
|
+
mimeType: string;
|
|
156
|
+
}>;
|
|
157
|
+
readonly "generate-pptx": import("ai").Tool<{
|
|
158
|
+
[x: string]: unknown;
|
|
159
|
+
slides: {
|
|
160
|
+
[x: string]: unknown;
|
|
161
|
+
children: (string | Record<string, unknown>)[];
|
|
162
|
+
background?: Record<string, unknown> | undefined;
|
|
163
|
+
transition?: Record<string, unknown> | undefined;
|
|
164
|
+
notes?: string | undefined;
|
|
165
|
+
layout?: string | undefined;
|
|
166
|
+
master?: string | undefined;
|
|
167
|
+
comments?: Record<string, unknown>[] | undefined;
|
|
168
|
+
headerFooter?: Record<string, unknown> | undefined;
|
|
169
|
+
}[];
|
|
170
|
+
size?: "16:9" | "4:3" | {
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
} | undefined;
|
|
174
|
+
masters?: Record<string, unknown>[] | undefined;
|
|
175
|
+
show?: Record<string, unknown> | undefined;
|
|
176
|
+
title?: string | undefined;
|
|
177
|
+
subject?: string | undefined;
|
|
178
|
+
creator?: string | undefined;
|
|
179
|
+
keywords?: string | undefined;
|
|
180
|
+
description?: string | undefined;
|
|
181
|
+
lastModifiedBy?: string | undefined;
|
|
182
|
+
revision?: number | undefined;
|
|
183
|
+
}, {
|
|
184
|
+
base64: string;
|
|
185
|
+
mimeType: string;
|
|
186
|
+
}>;
|
|
187
|
+
readonly "generate-xlsx": import("ai").Tool<{
|
|
188
|
+
[x: string]: unknown;
|
|
189
|
+
worksheets: {
|
|
190
|
+
[x: string]: unknown;
|
|
191
|
+
name?: string | undefined;
|
|
192
|
+
children?: {
|
|
193
|
+
[x: string]: unknown;
|
|
194
|
+
cells?: (string | number | boolean | Record<string, unknown>)[] | undefined;
|
|
195
|
+
height?: number | undefined;
|
|
196
|
+
hidden?: boolean | undefined;
|
|
197
|
+
rowNumber?: number | undefined;
|
|
198
|
+
}[] | undefined;
|
|
199
|
+
columns?: Record<string, unknown>[] | undefined;
|
|
200
|
+
mergeCells?: Record<string, unknown>[] | undefined;
|
|
201
|
+
freezePanes?: Record<string, unknown> | undefined;
|
|
202
|
+
autoFilter?: string | undefined;
|
|
203
|
+
images?: Record<string, unknown>[] | undefined;
|
|
204
|
+
charts?: Record<string, unknown>[] | undefined;
|
|
205
|
+
dataValidations?: Record<string, unknown>[] | undefined;
|
|
206
|
+
conditionalFormats?: Record<string, unknown>[] | undefined;
|
|
207
|
+
}[];
|
|
208
|
+
title?: string | undefined;
|
|
209
|
+
subject?: string | undefined;
|
|
210
|
+
creator?: string | undefined;
|
|
211
|
+
keywords?: string | undefined;
|
|
212
|
+
description?: string | undefined;
|
|
213
|
+
lastModifiedBy?: string | undefined;
|
|
214
|
+
revision?: number | undefined;
|
|
215
|
+
}, {
|
|
216
|
+
base64: string;
|
|
217
|
+
mimeType: string;
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
220
|
+
//#endregion
|
|
221
|
+
export { docxTool, officeOpenTools, pptxTool, xlsxTool };
|
|
222
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/ai/index.ts"],"mappings":";cAQa,QAAA,eAAQ,IAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsBR,QAAA,eAAQ,IAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsBR,QAAA,eAAQ,IAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsBR,eAAA;EAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { generate } from "../generate.mjs";
|
|
2
|
+
import { a as docxSchema, i as pptxSchema, n as validateDocumentInput, r as xlsxSchema } from "../schemas-BbRmv4RW.mjs";
|
|
3
|
+
import { tool } from "ai";
|
|
4
|
+
//#region src/ai/index.ts
|
|
5
|
+
const docxTool = tool({
|
|
6
|
+
description: "Generate a .docx Word document. The input is the document options directly — must include a 'sections' array. Each section has 'children' (paragraphs, tables, etc.). Paragraphs use { paragraph: { children: [{ text: '...' }] }}, tables use { table: { rows: [...] } }. Optional metadata: title, creator, subject, styles, numbering, comments, footnotes, endnotes, background, features.",
|
|
7
|
+
inputSchema: docxSchema,
|
|
8
|
+
execute: async (options) => {
|
|
9
|
+
return {
|
|
10
|
+
base64: await generate({
|
|
11
|
+
type: "docx",
|
|
12
|
+
options: validateDocumentInput("docx", options),
|
|
13
|
+
outputType: "base64"
|
|
14
|
+
}),
|
|
15
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const pptxTool = tool({
|
|
20
|
+
description: "Generate a .pptx PowerPoint presentation. The input is the document options directly — must include a 'slides' array. Each slide has 'children' (shapes, pictures, tables, charts, groups, etc.). Shapes use { shape: { x, y, width, height, text?, fill?, ... } }. Optional: size ('16:9' or '4:3' or { width, height }), title, creator, masters, show.",
|
|
21
|
+
inputSchema: pptxSchema,
|
|
22
|
+
execute: async (options) => {
|
|
23
|
+
return {
|
|
24
|
+
base64: await generate({
|
|
25
|
+
type: "pptx",
|
|
26
|
+
options: validateDocumentInput("pptx", options),
|
|
27
|
+
outputType: "base64"
|
|
28
|
+
}),
|
|
29
|
+
mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const xlsxTool = tool({
|
|
34
|
+
description: "Generate a .xlsx Excel spreadsheet. The input is the document options directly — must include a 'worksheets' array. Each worksheet has 'children' (NOT 'rows') — an array of row objects, each with 'cells'. Cell values: string, number, boolean. Use 'style' for formatting. Optional: columns, mergeCells, freezePanes, autoFilter, images, charts, dataValidations, conditionalFormats.",
|
|
35
|
+
inputSchema: xlsxSchema,
|
|
36
|
+
execute: async (options) => {
|
|
37
|
+
return {
|
|
38
|
+
base64: await generate({
|
|
39
|
+
type: "xlsx",
|
|
40
|
+
options: validateDocumentInput("xlsx", options),
|
|
41
|
+
outputType: "base64"
|
|
42
|
+
}),
|
|
43
|
+
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const officeOpenTools = {
|
|
48
|
+
"generate-docx": docxTool,
|
|
49
|
+
"generate-pptx": pptxTool,
|
|
50
|
+
"generate-xlsx": xlsxTool
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { docxTool, officeOpenTools, pptxTool, xlsxTool };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/ai/index.ts"],"sourcesContent":["import { tool } from \"ai\";\n\nimport { generate } from \"../generate\";\nimport { validateDocumentInput } from \"../schemas\";\nimport { docxSchema } from \"../schemas/docx\";\nimport { pptxSchema } from \"../schemas/pptx\";\nimport { xlsxSchema } from \"../schemas/xlsx\";\n\nexport const docxTool = tool({\n description:\n \"Generate a .docx Word document. \" +\n \"The input is the document options directly — must include a 'sections' array. \" +\n \"Each section has 'children' (paragraphs, tables, etc.). \" +\n \"Paragraphs use { paragraph: { children: [{ text: '...' }] }}, tables use { table: { rows: [...] } }. \" +\n \"Optional metadata: title, creator, subject, styles, numbering, comments, footnotes, endnotes, background, features.\",\n inputSchema: docxSchema,\n execute: async (options) => {\n const validated = validateDocumentInput(\"docx\", options);\n const base64 = (await generate({\n type: \"docx\",\n options: validated,\n outputType: \"base64\",\n })) as string;\n return {\n base64,\n mimeType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n };\n },\n});\n\nexport const pptxTool = tool({\n description:\n \"Generate a .pptx PowerPoint presentation. \" +\n \"The input is the document options directly — must include a 'slides' array. \" +\n \"Each slide has 'children' (shapes, pictures, tables, charts, groups, etc.). \" +\n \"Shapes use { shape: { x, y, width, height, text?, fill?, ... } }. \" +\n \"Optional: size ('16:9' or '4:3' or { width, height }), title, creator, masters, show.\",\n inputSchema: pptxSchema,\n execute: async (options) => {\n const validated = validateDocumentInput(\"pptx\", options);\n const base64 = (await generate({\n type: \"pptx\",\n options: validated,\n outputType: \"base64\",\n })) as string;\n return {\n base64,\n mimeType: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n };\n },\n});\n\nexport const xlsxTool = tool({\n description:\n \"Generate a .xlsx Excel spreadsheet. \" +\n \"The input is the document options directly — must include a 'worksheets' array. \" +\n \"Each worksheet has 'children' (NOT 'rows') — an array of row objects, each with 'cells'. \" +\n \"Cell values: string, number, boolean. Use 'style' for formatting. \" +\n \"Optional: columns, mergeCells, freezePanes, autoFilter, images, charts, dataValidations, conditionalFormats.\",\n inputSchema: xlsxSchema,\n execute: async (options) => {\n const validated = validateDocumentInput(\"xlsx\", options);\n const base64 = (await generate({\n type: \"xlsx\",\n options: validated,\n outputType: \"base64\",\n })) as string;\n return {\n base64,\n mimeType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n };\n },\n});\n\nexport const officeOpenTools = {\n \"generate-docx\": docxTool,\n \"generate-pptx\": pptxTool,\n \"generate-xlsx\": xlsxTool,\n} as const;\n"],"mappings":";;;;AAQA,MAAa,WAAW,KAAK;CAC3B,aACE;CAKF,aAAa;CACb,SAAS,OAAO,YAAY;EAO1B,OAAO;GACL,QAAA,MANoB,SAAS;IAC7B,MAAM;IACN,SAHgB,sBAAsB,QAAQ,OAG7B;IACjB,YAAY;GACd,CAAC;GAGC,UAAU;EACZ;CACF;AACF,CAAC;AAED,MAAa,WAAW,KAAK;CAC3B,aACE;CAKF,aAAa;CACb,SAAS,OAAO,YAAY;EAO1B,OAAO;GACL,QAAA,MANoB,SAAS;IAC7B,MAAM;IACN,SAHgB,sBAAsB,QAAQ,OAG7B;IACjB,YAAY;GACd,CAAC;GAGC,UAAU;EACZ;CACF;AACF,CAAC;AAED,MAAa,WAAW,KAAK;CAC3B,aACE;CAKF,aAAa;CACb,SAAS,OAAO,YAAY;EAO1B,OAAO;GACL,QAAA,MANoB,SAAS;IAC7B,MAAM;IACN,SAHgB,sBAAsB,QAAQ,OAG7B;IACjB,YAAY;GACd,CAAC;GAGC,UAAU;EACZ;CACF;AACF,CAAC;AAED,MAAa,kBAAkB;CAC7B,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;AACnB"}
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { generateToFile, parseInput } from "./generate.mjs";
|
|
2
|
+
import { n as validateDocumentInput } from "./schemas-BbRmv4RW.mjs";
|
|
3
|
+
import { defineCommand, runMain } from "citty";
|
|
4
|
+
//#region src/cli.ts
|
|
5
|
+
function createConvertCommand(type, defaultExt) {
|
|
6
|
+
return defineCommand({
|
|
7
|
+
meta: {
|
|
8
|
+
name: type,
|
|
9
|
+
description: `Generate a .${defaultExt} file from JSON`
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
input: {
|
|
13
|
+
type: "positional",
|
|
14
|
+
description: "JSON string or path to JSON file",
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
output: {
|
|
18
|
+
type: "positional",
|
|
19
|
+
description: `Output file path (default: output.${defaultExt})`,
|
|
20
|
+
required: false
|
|
21
|
+
},
|
|
22
|
+
"input-file": {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "Read JSON from file (alternative to positional input)",
|
|
25
|
+
alias: ["i"]
|
|
26
|
+
},
|
|
27
|
+
"output-file": {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Output file path (alternative to positional output)",
|
|
30
|
+
alias: ["o"]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
async run({ args }) {
|
|
34
|
+
const jsonInput = args.input ?? args["input-file"];
|
|
35
|
+
const outputPath = args.output ?? args["output-file"] ?? `output.${defaultExt}`;
|
|
36
|
+
const docType = type;
|
|
37
|
+
await generateToFile(outputPath, {
|
|
38
|
+
type: docType,
|
|
39
|
+
options: validateDocumentInput(docType, await parseInput(jsonInput))
|
|
40
|
+
});
|
|
41
|
+
console.log(`Generated: ${outputPath}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
runMain(defineCommand({
|
|
46
|
+
meta: {
|
|
47
|
+
name: "office-open",
|
|
48
|
+
version: "0.6.8",
|
|
49
|
+
description: "Generate Office files (.docx, .pptx, .xlsx) from JSON"
|
|
50
|
+
},
|
|
51
|
+
subCommands: {
|
|
52
|
+
docx: createConvertCommand("docx", "docx"),
|
|
53
|
+
pptx: createConvertCommand("pptx", "pptx"),
|
|
54
|
+
xlsx: createConvertCommand("xlsx", "xlsx")
|
|
55
|
+
},
|
|
56
|
+
args: { type: {
|
|
57
|
+
type: "enum",
|
|
58
|
+
description: "File type to generate",
|
|
59
|
+
options: [
|
|
60
|
+
"docx",
|
|
61
|
+
"pptx",
|
|
62
|
+
"xlsx"
|
|
63
|
+
]
|
|
64
|
+
} },
|
|
65
|
+
async run() {}
|
|
66
|
+
}));
|
|
67
|
+
//#endregion
|
|
68
|
+
export {};
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["import { defineCommand, runMain } from \"citty\";\n\nimport { generateToFile, parseInput } from \"./generate\";\nimport { validateDocumentInput } from \"./schemas\";\n\nfunction createConvertCommand(type: string, defaultExt: string) {\n return defineCommand({\n meta: {\n name: type,\n description: `Generate a .${defaultExt} file from JSON`,\n },\n args: {\n input: {\n type: \"positional\",\n description: \"JSON string or path to JSON file\",\n required: true,\n },\n output: {\n type: \"positional\",\n description: `Output file path (default: output.${defaultExt})`,\n required: false,\n },\n \"input-file\": {\n type: \"string\",\n description: \"Read JSON from file (alternative to positional input)\",\n alias: [\"i\"],\n },\n \"output-file\": {\n type: \"string\",\n description: \"Output file path (alternative to positional output)\",\n alias: [\"o\"],\n },\n },\n async run({ args }) {\n const jsonInput = (args.input ?? args[\"input-file\"]) as string;\n const outputPath = (args.output ?? args[\"output-file\"] ?? `output.${defaultExt}`) as string;\n const docType = type as \"docx\" | \"pptx\" | \"xlsx\";\n\n const docOptions = await parseInput(jsonInput);\n const validated = validateDocumentInput(docType, docOptions);\n await generateToFile(outputPath, {\n type: docType,\n options: validated,\n });\n console.log(`Generated: ${outputPath}`);\n },\n });\n}\n\nconst mainCommand = defineCommand({\n meta: {\n name: \"office-open\",\n version: \"0.6.8\",\n description: \"Generate Office files (.docx, .pptx, .xlsx) from JSON\",\n },\n subCommands: {\n docx: createConvertCommand(\"docx\", \"docx\"),\n pptx: createConvertCommand(\"pptx\", \"pptx\"),\n xlsx: createConvertCommand(\"xlsx\", \"xlsx\"),\n },\n args: {\n type: {\n type: \"enum\",\n description: \"File type to generate\",\n options: [\"docx\", \"pptx\", \"xlsx\"],\n },\n },\n async run() {\n // citty shows usage when no subcommand is matched\n },\n});\n\nvoid runMain(mainCommand);\n"],"mappings":";;;;AAKA,SAAS,qBAAqB,MAAc,YAAoB;CAC9D,OAAO,cAAc;EACnB,MAAM;GACJ,MAAM;GACN,aAAa,eAAe,WAAW;EACzC;EACA,MAAM;GACJ,OAAO;IACL,MAAM;IACN,aAAa;IACb,UAAU;GACZ;GACA,QAAQ;IACN,MAAM;IACN,aAAa,qCAAqC,WAAW;IAC7D,UAAU;GACZ;GACA,cAAc;IACZ,MAAM;IACN,aAAa;IACb,OAAO,CAAC,GAAG;GACb;GACA,eAAe;IACb,MAAM;IACN,aAAa;IACb,OAAO,CAAC,GAAG;GACb;EACF;EACA,MAAM,IAAI,EAAE,QAAQ;GAClB,MAAM,YAAa,KAAK,SAAS,KAAK;GACtC,MAAM,aAAc,KAAK,UAAU,KAAK,kBAAkB,UAAU;GACpE,MAAM,UAAU;GAIhB,MAAM,eAAe,YAAY;IAC/B,MAAM;IACN,SAHgB,sBAAsB,SAAS,MADxB,WAAW,SAAS,CAI1B;GACnB,CAAC;GACD,QAAQ,IAAI,cAAc,YAAY;EACxC;CACF,CAAC;AACH;AAyBK,QAvBe,cAAc;CAChC,MAAM;EACJ,MAAM;EACN,SAAS;EACT,aAAa;CACf;CACA,aAAa;EACX,MAAM,qBAAqB,QAAQ,MAAM;EACzC,MAAM,qBAAqB,QAAQ,MAAM;EACzC,MAAM,qBAAqB,QAAQ,MAAM;CAC3C;CACA,MAAM,EACJ,MAAM;EACJ,MAAM;EACN,aAAa;EACb,SAAS;GAAC;GAAQ;GAAQ;EAAM;CAClC,EACF;CACA,MAAM,MAAM,CAEZ;AACF,CAEuB,CAAC"}
|
package/dist/core.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@office-open/core";
|
package/dist/core.mjs
ADDED
package/dist/docx.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@office-open/docx";
|
package/dist/docx.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OutputType, OutputType as OutputType$1 } from "@office-open/core";
|
|
2
|
+
|
|
3
|
+
//#region src/generate.d.ts
|
|
4
|
+
type GenerateType = "docx" | "pptx" | "xlsx";
|
|
5
|
+
interface GenerateOptions {
|
|
6
|
+
readonly type: GenerateType;
|
|
7
|
+
readonly options: Record<string, unknown>;
|
|
8
|
+
readonly outputType?: OutputType$1;
|
|
9
|
+
}
|
|
10
|
+
declare function generate(options: GenerateOptions): Promise<unknown>;
|
|
11
|
+
declare function parseInput(input: string): Promise<Record<string, unknown>>;
|
|
12
|
+
declare function generateToFile(outputPath: string, options: GenerateOptions): Promise<void>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { GenerateOptions, GenerateType, type OutputType, generate, generateToFile, parseInput };
|
|
15
|
+
//# sourceMappingURL=generate.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.mts","names":[],"sources":["../src/generate.ts"],"mappings":";;;KAYY,YAAA;AAAA,UAEK,eAAA;EAAA,SACN,IAAA,EAAM,YAAA;EAAA,SACN,OAAA,EAAS,MAAA;EAAA,SACT,UAAA,GAAa,YAAA;AAAA;AAAA,iBAwBF,QAAA,CAAS,OAAA,EAAS,eAAA,GAAkB,OAAO;AAAA,iBAO3C,UAAA,CAAW,KAAA,WAAgB,OAAO,CAAC,MAAA;AAAA,iBASnC,cAAA,CAAe,UAAA,UAAoB,OAAA,EAAS,eAAA,GAAkB,OAAO"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { Document, Packer } from "@office-open/docx";
|
|
3
|
+
import { Packer as Packer$1, Presentation } from "@office-open/pptx";
|
|
4
|
+
import { Packer as Packer$2, Workbook } from "@office-open/xlsx";
|
|
5
|
+
//#region src/generate.ts
|
|
6
|
+
const PACKERS = {
|
|
7
|
+
docx: {
|
|
8
|
+
newFile: (opts) => new Document(opts),
|
|
9
|
+
pack: (file, type) => Packer.pack(file, type)
|
|
10
|
+
},
|
|
11
|
+
pptx: {
|
|
12
|
+
newFile: (opts) => new Presentation(opts),
|
|
13
|
+
pack: (file, type) => Packer$1.pack(file, type)
|
|
14
|
+
},
|
|
15
|
+
xlsx: {
|
|
16
|
+
newFile: (opts) => new Workbook(opts),
|
|
17
|
+
pack: (file, type) => Packer$2.pack(file, type)
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
async function generate(options) {
|
|
21
|
+
const { type, options: docOptions, outputType = "nodebuffer" } = options;
|
|
22
|
+
const { newFile, pack } = PACKERS[type];
|
|
23
|
+
return pack(newFile(docOptions), outputType);
|
|
24
|
+
}
|
|
25
|
+
async function parseInput(input) {
|
|
26
|
+
const trimmed = input.trim();
|
|
27
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return JSON.parse(trimmed);
|
|
28
|
+
const content = await readFile(trimmed, "utf-8");
|
|
29
|
+
return JSON.parse(content);
|
|
30
|
+
}
|
|
31
|
+
async function generateToFile(outputPath, options) {
|
|
32
|
+
await writeFile(outputPath, await generate({
|
|
33
|
+
...options,
|
|
34
|
+
outputType: "nodebuffer"
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { generate, generateToFile, parseInput };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=generate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.mjs","names":["DocxPacker","PptxPacker","XlsxPacker"],"sources":["../src/generate.ts"],"sourcesContent":["import { readFile, writeFile } from \"node:fs/promises\";\n\nimport type { OutputType } from \"@office-open/core\";\nexport { type OutputType } from \"@office-open/core\";\n\nimport { Document, Packer as DocxPacker } from \"@office-open/docx\";\nimport type { PropertiesOptions } from \"@office-open/docx\";\nimport { Presentation, Packer as PptxPacker } from \"@office-open/pptx\";\nimport type { PresentationOptions } from \"@office-open/pptx\";\nimport { Workbook, Packer as XlsxPacker } from \"@office-open/xlsx\";\nimport type { WorkbookOptions } from \"@office-open/xlsx\";\n\nexport type GenerateType = \"docx\" | \"pptx\" | \"xlsx\";\n\nexport interface GenerateOptions {\n readonly type: GenerateType;\n readonly options: Record<string, unknown>;\n readonly outputType?: OutputType;\n}\n\nconst PACKERS = {\n docx: {\n newFile: (opts: unknown) => new Document(opts as unknown as PropertiesOptions),\n pack: (file: unknown, type: OutputType) => DocxPacker.pack(file as Document, type),\n },\n pptx: {\n newFile: (opts: unknown) => new Presentation(opts as unknown as PresentationOptions),\n pack: (file: unknown, type: OutputType) => PptxPacker.pack(file as Presentation, type),\n },\n xlsx: {\n newFile: (opts: unknown) => new Workbook(opts as unknown as WorkbookOptions),\n pack: (file: unknown, type: OutputType) => XlsxPacker.pack(file as Workbook, type),\n },\n} as const satisfies Record<\n GenerateType,\n {\n newFile: (opts: unknown) => unknown;\n pack: (file: unknown, type: OutputType) => Promise<unknown>;\n }\n>;\n\nexport async function generate(options: GenerateOptions): Promise<unknown> {\n const { type, options: docOptions, outputType = \"nodebuffer\" as OutputType } = options;\n const { newFile, pack } = PACKERS[type];\n const file = newFile(docOptions);\n return pack(file, outputType);\n}\n\nexport async function parseInput(input: string): Promise<Record<string, unknown>> {\n const trimmed = input.trim();\n if (trimmed.startsWith(\"{\") || trimmed.startsWith(\"[\")) {\n return JSON.parse(trimmed) as Record<string, unknown>;\n }\n const content = await readFile(trimmed, \"utf-8\");\n return JSON.parse(content) as Record<string, unknown>;\n}\n\nexport async function generateToFile(outputPath: string, options: GenerateOptions): Promise<void> {\n const buffer = (await generate({ ...options, outputType: \"nodebuffer\" })) as Buffer;\n await writeFile(outputPath, buffer);\n}\n"],"mappings":";;;;;AAoBA,MAAM,UAAU;CACd,MAAM;EACJ,UAAU,SAAkB,IAAI,SAAS,IAAoC;EAC7E,OAAO,MAAe,SAAqBA,OAAW,KAAK,MAAkB,IAAI;CACnF;CACA,MAAM;EACJ,UAAU,SAAkB,IAAI,aAAa,IAAsC;EACnF,OAAO,MAAe,SAAqBC,SAAW,KAAK,MAAsB,IAAI;CACvF;CACA,MAAM;EACJ,UAAU,SAAkB,IAAI,SAAS,IAAkC;EAC3E,OAAO,MAAe,SAAqBC,SAAW,KAAK,MAAkB,IAAI;CACnF;AACF;AAQA,eAAsB,SAAS,SAA4C;CACzE,MAAM,EAAE,MAAM,SAAS,YAAY,aAAa,iBAA+B;CAC/E,MAAM,EAAE,SAAS,SAAS,QAAQ;CAElC,OAAO,KADM,QAAQ,UACN,GAAG,UAAU;AAC9B;AAEA,eAAsB,WAAW,OAAiD;CAChF,MAAM,UAAU,MAAM,KAAK;CAC3B,IAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,WAAW,GAAG,GACnD,OAAO,KAAK,MAAM,OAAO;CAE3B,MAAM,UAAU,MAAM,SAAS,SAAS,OAAO;CAC/C,OAAO,KAAK,MAAM,OAAO;AAC3B;AAEA,eAAsB,eAAe,YAAoB,SAAyC;CAEhG,MAAM,UAAU,YAAY,MADN,SAAS;EAAE,GAAG;EAAS,YAAY;CAAa,CAAC,CACrC;AACpC"}
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
package/dist/pptx.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@office-open/pptx";
|
package/dist/pptx.mjs
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas/docx.d.ts
|
|
4
|
+
declare const docxSchema: z.ZodObject<{
|
|
5
|
+
sections: z.ZodArray<z.ZodObject<{
|
|
6
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
|
+
children: z.ZodArray<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
8
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
9
|
+
footers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
+
}, z.core.$loose>>;
|
|
11
|
+
title: z.ZodOptional<z.ZodString>;
|
|
12
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
13
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
14
|
+
keywords: z.ZodOptional<z.ZodString>;
|
|
15
|
+
description: z.ZodOptional<z.ZodString>;
|
|
16
|
+
lastModifiedBy: z.ZodOptional<z.ZodString>;
|
|
17
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
externalStyles: z.ZodOptional<z.ZodString>;
|
|
19
|
+
styles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
+
numbering: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
+
comments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
22
|
+
bibliography: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
23
|
+
footnotes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
24
|
+
endnotes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
25
|
+
background: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
features: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
|
+
compatabilityModeVersion: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
compatibility: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
+
customProperties: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
30
|
+
evenAndOddHeaderAndFooters: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
defaultTabStop: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
fonts: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
33
|
+
hyphenation: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
34
|
+
characterSpacingControl: z.ZodOptional<z.ZodString>;
|
|
35
|
+
view: z.ZodOptional<z.ZodString>;
|
|
36
|
+
zoom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
37
|
+
writeProtection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
38
|
+
displayBackgroundShape: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
embedTrueTypeFonts: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
embedSystemFonts: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
saveSubsetFonts: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
docVars: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
43
|
+
colorSchemeMapping: z.ZodOptional<z.ZodUnknown>;
|
|
44
|
+
}, z.core.$loose>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/schemas/pptx.d.ts
|
|
47
|
+
declare const pptxSchema: z.ZodObject<{
|
|
48
|
+
slides: z.ZodArray<z.ZodObject<{
|
|
49
|
+
children: z.ZodArray<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
50
|
+
background: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
51
|
+
transition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
52
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
53
|
+
layout: z.ZodOptional<z.ZodString>;
|
|
54
|
+
master: z.ZodOptional<z.ZodString>;
|
|
55
|
+
comments: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
56
|
+
headerFooter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
+
}, z.core.$loose>>;
|
|
58
|
+
size: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
59
|
+
"16:9": "16:9";
|
|
60
|
+
"4:3": "4:3";
|
|
61
|
+
}>, z.ZodObject<{
|
|
62
|
+
width: z.ZodNumber;
|
|
63
|
+
height: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>]>>;
|
|
65
|
+
masters: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
66
|
+
show: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
67
|
+
title: z.ZodOptional<z.ZodString>;
|
|
68
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
69
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
70
|
+
keywords: z.ZodOptional<z.ZodString>;
|
|
71
|
+
description: z.ZodOptional<z.ZodString>;
|
|
72
|
+
lastModifiedBy: z.ZodOptional<z.ZodString>;
|
|
73
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
}, z.core.$loose>;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/schemas/xlsx.d.ts
|
|
77
|
+
declare const xlsxSchema: z.ZodObject<{
|
|
78
|
+
worksheets: z.ZodArray<z.ZodObject<{
|
|
79
|
+
name: z.ZodOptional<z.ZodString>;
|
|
80
|
+
children: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
81
|
+
cells: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>]>>>;
|
|
82
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
84
|
+
rowNumber: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
}, z.core.$loose>>>;
|
|
86
|
+
columns: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
87
|
+
mergeCells: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
88
|
+
freezePanes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
autoFilter: z.ZodOptional<z.ZodString>;
|
|
90
|
+
images: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
91
|
+
charts: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
92
|
+
dataValidations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
93
|
+
conditionalFormats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
94
|
+
}, z.core.$loose>>;
|
|
95
|
+
title: z.ZodOptional<z.ZodString>;
|
|
96
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
97
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
98
|
+
keywords: z.ZodOptional<z.ZodString>;
|
|
99
|
+
description: z.ZodOptional<z.ZodString>;
|
|
100
|
+
lastModifiedBy: z.ZodOptional<z.ZodString>;
|
|
101
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
}, z.core.$loose>;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/schemas/index.d.ts
|
|
105
|
+
declare const SCHEMAS: {
|
|
106
|
+
readonly docx: import("zod").ZodObject<{
|
|
107
|
+
sections: import("zod").ZodArray<import("zod").ZodObject<{
|
|
108
|
+
properties: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
109
|
+
children: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>, import("zod").ZodString]>>;
|
|
110
|
+
headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
111
|
+
footers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
112
|
+
}, import("zod/v4/core").$loose>>;
|
|
113
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
114
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
115
|
+
creator: import("zod").ZodOptional<import("zod").ZodString>;
|
|
116
|
+
keywords: import("zod").ZodOptional<import("zod").ZodString>;
|
|
117
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
118
|
+
lastModifiedBy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
119
|
+
revision: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
120
|
+
externalStyles: import("zod").ZodOptional<import("zod").ZodString>;
|
|
121
|
+
styles: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
122
|
+
numbering: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
123
|
+
comments: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
124
|
+
bibliography: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
125
|
+
footnotes: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
126
|
+
endnotes: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
127
|
+
background: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
128
|
+
features: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
129
|
+
compatabilityModeVersion: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
130
|
+
compatibility: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
131
|
+
customProperties: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
132
|
+
evenAndOddHeaderAndFooters: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
133
|
+
defaultTabStop: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
134
|
+
fonts: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
135
|
+
hyphenation: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
136
|
+
characterSpacingControl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
137
|
+
view: import("zod").ZodOptional<import("zod").ZodString>;
|
|
138
|
+
zoom: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
139
|
+
writeProtection: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
140
|
+
displayBackgroundShape: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
141
|
+
embedTrueTypeFonts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
142
|
+
embedSystemFonts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
143
|
+
saveSubsetFonts: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
144
|
+
docVars: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
145
|
+
colorSchemeMapping: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
146
|
+
}, import("zod/v4/core").$loose>;
|
|
147
|
+
readonly pptx: import("zod").ZodObject<{
|
|
148
|
+
slides: import("zod").ZodArray<import("zod").ZodObject<{
|
|
149
|
+
children: import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>, import("zod").ZodString]>>;
|
|
150
|
+
background: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
151
|
+
transition: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
152
|
+
notes: import("zod").ZodOptional<import("zod").ZodString>;
|
|
153
|
+
layout: import("zod").ZodOptional<import("zod").ZodString>;
|
|
154
|
+
master: import("zod").ZodOptional<import("zod").ZodString>;
|
|
155
|
+
comments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
156
|
+
headerFooter: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
157
|
+
}, import("zod/v4/core").$loose>>;
|
|
158
|
+
size: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
159
|
+
"16:9": "16:9";
|
|
160
|
+
"4:3": "4:3";
|
|
161
|
+
}>, import("zod").ZodObject<{
|
|
162
|
+
width: import("zod").ZodNumber;
|
|
163
|
+
height: import("zod").ZodNumber;
|
|
164
|
+
}, import("zod/v4/core").$strip>]>>;
|
|
165
|
+
masters: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
166
|
+
show: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
167
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
168
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
169
|
+
creator: import("zod").ZodOptional<import("zod").ZodString>;
|
|
170
|
+
keywords: import("zod").ZodOptional<import("zod").ZodString>;
|
|
171
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
172
|
+
lastModifiedBy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
173
|
+
revision: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
174
|
+
}, import("zod/v4/core").$loose>;
|
|
175
|
+
readonly xlsx: import("zod").ZodObject<{
|
|
176
|
+
worksheets: import("zod").ZodArray<import("zod").ZodObject<{
|
|
177
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
178
|
+
children: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
179
|
+
cells: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<[import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>, import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean]>]>>>;
|
|
180
|
+
height: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
181
|
+
hidden: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
182
|
+
rowNumber: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
183
|
+
}, import("zod/v4/core").$loose>>>;
|
|
184
|
+
columns: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
185
|
+
mergeCells: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
186
|
+
freezePanes: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
187
|
+
autoFilter: import("zod").ZodOptional<import("zod").ZodString>;
|
|
188
|
+
images: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
189
|
+
charts: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
190
|
+
dataValidations: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
191
|
+
conditionalFormats: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>>;
|
|
192
|
+
}, import("zod/v4/core").$loose>>;
|
|
193
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
194
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
195
|
+
creator: import("zod").ZodOptional<import("zod").ZodString>;
|
|
196
|
+
keywords: import("zod").ZodOptional<import("zod").ZodString>;
|
|
197
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
198
|
+
lastModifiedBy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
199
|
+
revision: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
200
|
+
}, import("zod/v4/core").$loose>;
|
|
201
|
+
};
|
|
202
|
+
type DocumentType = "docx" | "pptx" | "xlsx";
|
|
203
|
+
declare function validateDocumentInput(type: DocumentType, data: unknown): Record<string, unknown>;
|
|
204
|
+
//#endregion
|
|
205
|
+
export { DocumentType, SCHEMAS, docxSchema, pptxSchema, validateDocumentInput, xlsxSchema };
|
|
206
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/schemas/docx.ts","../../src/schemas/pptx.ts","../../src/schemas/xlsx.ts","../../src/schemas/index.ts"],"mappings":";;;cAIa,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCAV,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCAV,UAAA,EAAU,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCIV,OAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAMD,YAAA;AAAA,iBAEI,qBAAA,CAAsB,IAAA,EAAM,YAAA,EAAc,IAAA,YAAgB,MAAM"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/schemas/docx.ts
|
|
3
|
+
const anyObject$2 = z.record(z.string(), z.unknown()).describe("JSON object");
|
|
4
|
+
const docxSchema = z.object({
|
|
5
|
+
sections: z.array(z.object({
|
|
6
|
+
properties: anyObject$2.optional(),
|
|
7
|
+
children: z.array(anyObject$2.or(z.string())).describe("Section content: paragraphs ({ paragraph: {...} }), tables ({ table: {...} }), images, TOCs, etc."),
|
|
8
|
+
headers: anyObject$2.optional(),
|
|
9
|
+
footers: anyObject$2.optional()
|
|
10
|
+
}).passthrough()).describe("Document sections (required)"),
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
subject: z.string().optional(),
|
|
13
|
+
creator: z.string().optional(),
|
|
14
|
+
keywords: z.string().optional(),
|
|
15
|
+
description: z.string().optional(),
|
|
16
|
+
lastModifiedBy: z.string().optional(),
|
|
17
|
+
revision: z.number().optional(),
|
|
18
|
+
externalStyles: z.string().optional(),
|
|
19
|
+
styles: anyObject$2.optional(),
|
|
20
|
+
numbering: anyObject$2.optional(),
|
|
21
|
+
comments: anyObject$2.optional(),
|
|
22
|
+
bibliography: anyObject$2.optional(),
|
|
23
|
+
footnotes: z.record(z.string(), anyObject$2).optional(),
|
|
24
|
+
endnotes: z.record(z.string(), anyObject$2).optional(),
|
|
25
|
+
background: anyObject$2.optional(),
|
|
26
|
+
features: anyObject$2.optional(),
|
|
27
|
+
compatabilityModeVersion: z.number().optional(),
|
|
28
|
+
compatibility: anyObject$2.optional(),
|
|
29
|
+
customProperties: z.array(anyObject$2).optional(),
|
|
30
|
+
evenAndOddHeaderAndFooters: z.boolean().optional(),
|
|
31
|
+
defaultTabStop: z.number().optional(),
|
|
32
|
+
fonts: z.array(anyObject$2).optional(),
|
|
33
|
+
hyphenation: anyObject$2.optional(),
|
|
34
|
+
characterSpacingControl: z.string().optional(),
|
|
35
|
+
view: z.string().optional(),
|
|
36
|
+
zoom: anyObject$2.optional(),
|
|
37
|
+
writeProtection: anyObject$2.optional(),
|
|
38
|
+
displayBackgroundShape: z.boolean().optional(),
|
|
39
|
+
embedTrueTypeFonts: z.boolean().optional(),
|
|
40
|
+
embedSystemFonts: z.boolean().optional(),
|
|
41
|
+
saveSubsetFonts: z.boolean().optional(),
|
|
42
|
+
docVars: z.array(anyObject$2).optional(),
|
|
43
|
+
colorSchemeMapping: z.unknown().optional()
|
|
44
|
+
}).passthrough();
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/schemas/pptx.ts
|
|
47
|
+
const anyObject$1 = z.record(z.string(), z.unknown()).describe("JSON object");
|
|
48
|
+
const pptxSchema = z.object({
|
|
49
|
+
slides: z.array(z.object({
|
|
50
|
+
children: z.array(anyObject$1.or(z.string())).describe("Slide content: shapes ({ shape: {...} }), pictures ({ picture: {...} }), tables, charts, groups, lines, etc."),
|
|
51
|
+
background: anyObject$1.optional(),
|
|
52
|
+
transition: anyObject$1.optional(),
|
|
53
|
+
notes: z.string().optional(),
|
|
54
|
+
layout: z.string().optional(),
|
|
55
|
+
master: z.string().optional(),
|
|
56
|
+
comments: z.array(anyObject$1).optional(),
|
|
57
|
+
headerFooter: anyObject$1.optional()
|
|
58
|
+
}).passthrough()).describe("Presentation slides (required)"),
|
|
59
|
+
size: z.union([z.enum(["16:9", "4:3"]), z.object({
|
|
60
|
+
width: z.number(),
|
|
61
|
+
height: z.number()
|
|
62
|
+
})]).optional().describe("Slide size: \"16:9\", \"4:3\", or { width, height }"),
|
|
63
|
+
masters: z.array(anyObject$1).optional().describe("Slide master definitions"),
|
|
64
|
+
show: anyObject$1.optional(),
|
|
65
|
+
title: z.string().optional(),
|
|
66
|
+
subject: z.string().optional(),
|
|
67
|
+
creator: z.string().optional(),
|
|
68
|
+
keywords: z.string().optional(),
|
|
69
|
+
description: z.string().optional(),
|
|
70
|
+
lastModifiedBy: z.string().optional(),
|
|
71
|
+
revision: z.number().optional()
|
|
72
|
+
}).passthrough();
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/schemas/xlsx.ts
|
|
75
|
+
const anyObject = z.record(z.string(), z.unknown()).describe("JSON object");
|
|
76
|
+
const xlsxSchema = z.object({
|
|
77
|
+
worksheets: z.array(z.object({
|
|
78
|
+
name: z.string().optional().describe("Sheet display name"),
|
|
79
|
+
children: z.array(z.object({
|
|
80
|
+
cells: z.array(anyObject.or(z.union([
|
|
81
|
+
z.string(),
|
|
82
|
+
z.number(),
|
|
83
|
+
z.boolean()
|
|
84
|
+
]))).optional(),
|
|
85
|
+
height: z.number().optional(),
|
|
86
|
+
hidden: z.boolean().optional(),
|
|
87
|
+
rowNumber: z.number().optional()
|
|
88
|
+
}).passthrough()).optional().describe("Worksheet rows, each with \"cells\" array. NOTE: use \"children\" not \"rows\""),
|
|
89
|
+
columns: z.array(anyObject).optional(),
|
|
90
|
+
mergeCells: z.array(anyObject).optional(),
|
|
91
|
+
freezePanes: anyObject.optional(),
|
|
92
|
+
autoFilter: z.string().optional(),
|
|
93
|
+
images: z.array(anyObject).optional(),
|
|
94
|
+
charts: z.array(anyObject).optional(),
|
|
95
|
+
dataValidations: z.array(anyObject).optional(),
|
|
96
|
+
conditionalFormats: z.array(anyObject).optional()
|
|
97
|
+
}).passthrough()).describe("Workbook worksheets (required)"),
|
|
98
|
+
title: z.string().optional(),
|
|
99
|
+
subject: z.string().optional(),
|
|
100
|
+
creator: z.string().optional(),
|
|
101
|
+
keywords: z.string().optional(),
|
|
102
|
+
description: z.string().optional(),
|
|
103
|
+
lastModifiedBy: z.string().optional(),
|
|
104
|
+
revision: z.number().optional()
|
|
105
|
+
}).passthrough();
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/schemas/index.ts
|
|
108
|
+
const SCHEMAS = {
|
|
109
|
+
docx: docxSchema,
|
|
110
|
+
pptx: pptxSchema,
|
|
111
|
+
xlsx: xlsxSchema
|
|
112
|
+
};
|
|
113
|
+
function validateDocumentInput(type, data) {
|
|
114
|
+
const result = SCHEMAS[type].safeParse(data);
|
|
115
|
+
if (!result.success) {
|
|
116
|
+
const issue = result.error.issues[0];
|
|
117
|
+
const path = issue.path.join(".");
|
|
118
|
+
throw new Error(`Invalid ${type} options${path ? ` at "${path}"` : ""}: ${issue.message}`);
|
|
119
|
+
}
|
|
120
|
+
return result.data;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { docxSchema as a, pptxSchema as i, validateDocumentInput as n, xlsxSchema as r, SCHEMAS as t };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=schemas-BbRmv4RW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas-BbRmv4RW.mjs","names":["anyObject","anyObject"],"sources":["../src/schemas/docx.ts","../src/schemas/pptx.ts","../src/schemas/xlsx.ts","../src/schemas/index.ts"],"sourcesContent":["import { z } from \"zod\";\n\nconst anyObject = z.record(z.string(), z.unknown()).describe(\"JSON object\");\n\nexport const docxSchema = z\n .object({\n sections: z\n .array(\n z\n .object({\n properties: anyObject.optional(),\n children: z\n .array(anyObject.or(z.string()))\n .describe(\n \"Section content: paragraphs ({ paragraph: {...} }), tables ({ table: {...} }), images, TOCs, etc.\",\n ),\n headers: anyObject.optional(),\n footers: anyObject.optional(),\n })\n .passthrough(),\n )\n .describe(\"Document sections (required)\"),\n title: z.string().optional(),\n subject: z.string().optional(),\n creator: z.string().optional(),\n keywords: z.string().optional(),\n description: z.string().optional(),\n lastModifiedBy: z.string().optional(),\n revision: z.number().optional(),\n externalStyles: z.string().optional(),\n styles: anyObject.optional(),\n numbering: anyObject.optional(),\n comments: anyObject.optional(),\n bibliography: anyObject.optional(),\n footnotes: z.record(z.string(), anyObject).optional(),\n endnotes: z.record(z.string(), anyObject).optional(),\n background: anyObject.optional(),\n features: anyObject.optional(),\n compatabilityModeVersion: z.number().optional(),\n compatibility: anyObject.optional(),\n customProperties: z.array(anyObject).optional(),\n evenAndOddHeaderAndFooters: z.boolean().optional(),\n defaultTabStop: z.number().optional(),\n fonts: z.array(anyObject).optional(),\n hyphenation: anyObject.optional(),\n characterSpacingControl: z.string().optional(),\n view: z.string().optional(),\n zoom: anyObject.optional(),\n writeProtection: anyObject.optional(),\n displayBackgroundShape: z.boolean().optional(),\n embedTrueTypeFonts: z.boolean().optional(),\n embedSystemFonts: z.boolean().optional(),\n saveSubsetFonts: z.boolean().optional(),\n docVars: z.array(anyObject).optional(),\n colorSchemeMapping: z.unknown().optional(),\n })\n .passthrough();\n","import { z } from \"zod\";\n\nconst anyObject = z.record(z.string(), z.unknown()).describe(\"JSON object\");\n\nexport const pptxSchema = z\n .object({\n slides: z\n .array(\n z\n .object({\n children: z\n .array(anyObject.or(z.string()))\n .describe(\n \"Slide content: shapes ({ shape: {...} }), pictures ({ picture: {...} }), tables, charts, groups, lines, etc.\",\n ),\n background: anyObject.optional(),\n transition: anyObject.optional(),\n notes: z.string().optional(),\n layout: z.string().optional(),\n master: z.string().optional(),\n comments: z.array(anyObject).optional(),\n headerFooter: anyObject.optional(),\n })\n .passthrough(),\n )\n .describe(\"Presentation slides (required)\"),\n size: z\n .union([z.enum([\"16:9\", \"4:3\"]), z.object({ width: z.number(), height: z.number() })])\n .optional()\n .describe('Slide size: \"16:9\", \"4:3\", or { width, height }'),\n masters: z.array(anyObject).optional().describe(\"Slide master definitions\"),\n show: anyObject.optional(),\n title: z.string().optional(),\n subject: z.string().optional(),\n creator: z.string().optional(),\n keywords: z.string().optional(),\n description: z.string().optional(),\n lastModifiedBy: z.string().optional(),\n revision: z.number().optional(),\n })\n .passthrough();\n","import { z } from \"zod\";\n\nconst anyObject = z.record(z.string(), z.unknown()).describe(\"JSON object\");\n\nexport const xlsxSchema = z\n .object({\n worksheets: z\n .array(\n z\n .object({\n name: z.string().optional().describe(\"Sheet display name\"),\n children: z\n .array(\n z\n .object({\n cells: z\n .array(anyObject.or(z.union([z.string(), z.number(), z.boolean()])))\n .optional(),\n height: z.number().optional(),\n hidden: z.boolean().optional(),\n rowNumber: z.number().optional(),\n })\n .passthrough(),\n )\n .optional()\n .describe('Worksheet rows, each with \"cells\" array. NOTE: use \"children\" not \"rows\"'),\n columns: z.array(anyObject).optional(),\n mergeCells: z.array(anyObject).optional(),\n freezePanes: anyObject.optional(),\n autoFilter: z.string().optional(),\n images: z.array(anyObject).optional(),\n charts: z.array(anyObject).optional(),\n dataValidations: z.array(anyObject).optional(),\n conditionalFormats: z.array(anyObject).optional(),\n })\n .passthrough(),\n )\n .describe(\"Workbook worksheets (required)\"),\n title: z.string().optional(),\n subject: z.string().optional(),\n creator: z.string().optional(),\n keywords: z.string().optional(),\n description: z.string().optional(),\n lastModifiedBy: z.string().optional(),\n revision: z.number().optional(),\n })\n .passthrough();\n","import { docxSchema } from \"./docx\";\nimport { pptxSchema } from \"./pptx\";\nimport { xlsxSchema } from \"./xlsx\";\n\nexport { docxSchema } from \"./docx\";\nexport { pptxSchema } from \"./pptx\";\nexport { xlsxSchema } from \"./xlsx\";\n\nexport const SCHEMAS = {\n docx: docxSchema,\n pptx: pptxSchema,\n xlsx: xlsxSchema,\n} as const;\n\nexport type DocumentType = \"docx\" | \"pptx\" | \"xlsx\";\n\nexport function validateDocumentInput(type: DocumentType, data: unknown): Record<string, unknown> {\n const result = SCHEMAS[type].safeParse(data);\n if (!result.success) {\n const issue = result.error.issues[0];\n const path = issue.path.join(\".\");\n throw new Error(`Invalid ${type} options${path ? ` at \"${path}\"` : \"\"}: ${issue.message}`);\n }\n return result.data as Record<string, unknown>;\n}\n"],"mappings":"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"}
|
package/dist/xlsx.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@office-open/xlsx";
|
package/dist/xlsx.mjs
ADDED
package/dist/xml.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@office-open/xml";
|
package/dist/xml.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,103 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "office-open",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "0.6.9",
|
|
4
|
+
"description": "Generate Office files (.docx, .pptx, .xlsx) from JSON — CLI, AI SDK tools, and unified re-exports",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ai",
|
|
7
|
+
"cli",
|
|
8
|
+
"docx",
|
|
9
|
+
"llm",
|
|
10
|
+
"office",
|
|
11
|
+
"office-open",
|
|
12
|
+
"ooxml",
|
|
13
|
+
"pptx",
|
|
14
|
+
"xlsx"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://www.office-open.com",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/DemoMacro/office-open/issues"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Demo Macro",
|
|
23
|
+
"email": "abc@imst.xyz",
|
|
24
|
+
"url": "https://imst.xyz/"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/DemoMacro/office-open.git"
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"office-open": "dist/cli.mjs"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "dist/index.mjs",
|
|
38
|
+
"types": "dist/index.d.mts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.mts",
|
|
42
|
+
"import": "./dist/index.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./docx": {
|
|
45
|
+
"types": "./dist/docx.d.mts",
|
|
46
|
+
"import": "./dist/docx.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./pptx": {
|
|
49
|
+
"types": "./dist/pptx.d.mts",
|
|
50
|
+
"import": "./dist/pptx.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./xlsx": {
|
|
53
|
+
"types": "./dist/xlsx.d.mts",
|
|
54
|
+
"import": "./dist/xlsx.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./core": {
|
|
57
|
+
"types": "./dist/core.d.mts",
|
|
58
|
+
"import": "./dist/core.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./xml": {
|
|
61
|
+
"types": "./dist/xml.d.mts",
|
|
62
|
+
"import": "./dist/xml.mjs"
|
|
63
|
+
},
|
|
64
|
+
"./ai": {
|
|
65
|
+
"types": "./dist/ai/index.d.mts",
|
|
66
|
+
"import": "./dist/ai/index.mjs"
|
|
67
|
+
},
|
|
68
|
+
"./generate": {
|
|
69
|
+
"types": "./dist/generate.d.mts",
|
|
70
|
+
"import": "./dist/generate.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./schemas": {
|
|
73
|
+
"types": "./dist/schemas/index.d.mts",
|
|
74
|
+
"import": "./dist/schemas/index.mjs"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"citty": "0.2.2",
|
|
79
|
+
"zod": "4.4.3",
|
|
80
|
+
"@office-open/core": "0.6.9",
|
|
81
|
+
"@office-open/docx": "0.6.9",
|
|
82
|
+
"@office-open/xml": "0.6.9",
|
|
83
|
+
"@office-open/xlsx": "0.6.9",
|
|
84
|
+
"@office-open/pptx": "0.6.9"
|
|
85
|
+
},
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"ai": "^6.0.0"
|
|
88
|
+
},
|
|
89
|
+
"peerDependenciesMeta": {
|
|
90
|
+
"ai": {
|
|
91
|
+
"optional": true
|
|
92
|
+
}
|
|
93
|
+
},
|
|
9
94
|
"scripts": {
|
|
10
|
-
"
|
|
95
|
+
"dev": "basis build --stub",
|
|
96
|
+
"build": "vp pack",
|
|
97
|
+
"test": "vp test run",
|
|
98
|
+
"check": "vp check --fix",
|
|
99
|
+
"demo:docx": "node dist/cli.mjs docx demo/1-basic-docx.json \"My Document.docx\"",
|
|
100
|
+
"demo:pptx": "node dist/cli.mjs pptx demo/1-basic-pptx.json \"My Presentation.pptx\"",
|
|
101
|
+
"demo:xlsx": "node dist/cli.mjs xlsx demo/1-basic-xlsx.json \"My Workbook.xlsx\""
|
|
11
102
|
}
|
|
12
103
|
}
|