@deckflow/deckuse 1.2.0 → 1.3.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.es.md +342 -0
- package/README.fr.md +342 -0
- package/README.ja.md +342 -0
- package/README.ko.md +342 -0
- package/README.md +401 -0
- package/README.pt-BR.md +342 -0
- package/README.ru.md +342 -0
- package/README.zh-CN.md +367 -0
- package/assets/default.docx +0 -0
- package/assets/default.pptx +0 -0
- package/dist/bin.js +183 -19
- package/dist/bin.js.map +1 -1
- package/dist/core/adapter.d.ts +24 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/adapter.js +20 -0
- package/dist/core/adapter.js.map +1 -0
- package/dist/core/executor.d.ts +24 -0
- package/dist/core/executor.d.ts.map +1 -0
- package/dist/core/executor.js +65 -0
- package/dist/core/executor.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/length.d.ts +27 -0
- package/dist/core/length.d.ts.map +1 -0
- package/dist/core/length.js +63 -0
- package/dist/core/length.js.map +1 -0
- package/dist/core/measure.d.ts +24 -0
- package/dist/core/measure.d.ts.map +1 -0
- package/dist/core/measure.js +79 -0
- package/dist/core/measure.js.map +1 -0
- package/dist/core/not-implemented.d.ts +3 -0
- package/dist/core/not-implemented.d.ts.map +1 -0
- package/dist/core/not-implemented.js +12 -0
- package/dist/core/not-implemented.js.map +1 -0
- package/dist/core/schema.d.ts +3035 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +798 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/default-template.d.ts +8 -0
- package/dist/default-template.d.ts.map +1 -0
- package/dist/default-template.js +29 -0
- package/dist/default-template.js.map +1 -0
- package/dist/docx/adapter.d.ts +29 -0
- package/dist/docx/adapter.d.ts.map +1 -0
- package/dist/docx/adapter.js +442 -0
- package/dist/docx/adapter.js.map +1 -0
- package/dist/docx/addressing.d.ts +18 -0
- package/dist/docx/addressing.d.ts.map +1 -0
- package/dist/docx/addressing.js +111 -0
- package/dist/docx/addressing.js.map +1 -0
- package/dist/docx/blank.d.ts +4 -0
- package/dist/docx/blank.d.ts.map +1 -0
- package/dist/docx/blank.js +75 -0
- package/dist/docx/blank.js.map +1 -0
- package/dist/docx/index-sync.d.ts +7 -0
- package/dist/docx/index-sync.d.ts.map +1 -0
- package/dist/docx/index-sync.js +24 -0
- package/dist/docx/index-sync.js.map +1 -0
- package/dist/docx/index.d.ts +5 -0
- package/dist/docx/index.d.ts.map +1 -0
- package/dist/docx/index.js +4 -0
- package/dist/docx/index.js.map +1 -0
- package/dist/docx/indexer.d.ts +41 -0
- package/dist/docx/indexer.d.ts.map +1 -0
- package/dist/docx/indexer.js +353 -0
- package/dist/docx/indexer.js.map +1 -0
- package/dist/docx/mutations.d.ts +5 -0
- package/dist/docx/mutations.d.ts.map +1 -0
- package/dist/docx/mutations.js +311 -0
- package/dist/docx/mutations.js.map +1 -0
- package/dist/docx/paragraphs.d.ts +26 -0
- package/dist/docx/paragraphs.d.ts.map +1 -0
- package/dist/docx/paragraphs.js +314 -0
- package/dist/docx/paragraphs.js.map +1 -0
- package/dist/docx/properties.d.ts +23 -0
- package/dist/docx/properties.d.ts.map +1 -0
- package/dist/docx/properties.js +414 -0
- package/dist/docx/properties.js.map +1 -0
- package/dist/docx/tables.d.ts +4 -0
- package/dist/docx/tables.d.ts.map +1 -0
- package/dist/docx/tables.js +64 -0
- package/dist/docx/tables.js.map +1 -0
- package/dist/docx/text-spans.d.ts +25 -0
- package/dist/docx/text-spans.d.ts.map +1 -0
- package/dist/docx/text-spans.js +142 -0
- package/dist/docx/text-spans.js.map +1 -0
- package/dist/docx/types.d.ts +27 -0
- package/dist/docx/types.d.ts.map +1 -0
- package/dist/docx/types.js +2 -0
- package/dist/docx/types.js.map +1 -0
- package/dist/docx/workspace.d.ts +20 -0
- package/dist/docx/workspace.d.ts.map +1 -0
- package/dist/docx/workspace.js +145 -0
- package/dist/docx/workspace.js.map +1 -0
- package/dist/docx/xml.d.ts +18 -0
- package/dist/docx/xml.d.ts.map +1 -0
- package/dist/docx/xml.js +87 -0
- package/dist/docx/xml.js.map +1 -0
- package/dist/edition-config/index.d.ts +25 -0
- package/dist/edition-config/index.d.ts.map +1 -0
- package/dist/edition-config/index.js +22 -0
- package/dist/edition-config/index.js.map +1 -0
- package/dist/edition.d.ts +2 -2
- package/dist/edition.d.ts.map +1 -1
- package/dist/edition.js +1 -1
- package/dist/edition.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +124 -32
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/key/index.d.ts +2 -0
- package/dist/key/index.d.ts.map +1 -0
- package/dist/key/index.js +3 -0
- package/dist/key/index.js.map +1 -0
- package/dist/monitor-daemon.d.ts +21 -8
- package/dist/monitor-daemon.d.ts.map +1 -1
- package/dist/monitor-daemon.js +189 -51
- package/dist/monitor-daemon.js.map +1 -1
- package/dist/monitor-registry.d.ts +34 -0
- package/dist/monitor-registry.d.ts.map +1 -0
- package/dist/monitor-registry.js +191 -0
- package/dist/monitor-registry.js.map +1 -0
- package/dist/monitor.js +1 -1
- package/dist/monitor.js.map +1 -1
- package/dist/numbers/index.d.ts +2 -0
- package/dist/numbers/index.d.ts.map +1 -0
- package/dist/numbers/index.js +3 -0
- package/dist/numbers/index.js.map +1 -0
- package/dist/opc/index.d.ts +90 -0
- package/dist/opc/index.d.ts.map +1 -0
- package/dist/opc/index.js +569 -0
- package/dist/opc/index.js.map +1 -0
- package/dist/pptx/adapter.d.ts +167 -0
- package/dist/pptx/adapter.d.ts.map +1 -0
- package/dist/pptx/adapter.js +807 -0
- package/dist/pptx/adapter.js.map +1 -0
- package/dist/pptx/addressing.d.ts +45 -0
- package/dist/pptx/addressing.d.ts.map +1 -0
- package/dist/pptx/addressing.js +428 -0
- package/dist/pptx/addressing.js.map +1 -0
- package/dist/pptx/align.d.ts +24 -0
- package/dist/pptx/align.d.ts.map +1 -0
- package/dist/pptx/align.js +112 -0
- package/dist/pptx/align.js.map +1 -0
- package/dist/pptx/chart-classify.d.ts +10 -0
- package/dist/pptx/chart-classify.d.ts.map +1 -0
- package/dist/pptx/chart-classify.js +58 -0
- package/dist/pptx/chart-classify.js.map +1 -0
- package/dist/pptx/chart.d.ts +42 -0
- package/dist/pptx/chart.d.ts.map +1 -0
- package/dist/pptx/chart.js +614 -0
- package/dist/pptx/chart.js.map +1 -0
- package/dist/pptx/edition-extension.d.ts +25 -0
- package/dist/pptx/edition-extension.d.ts.map +1 -0
- package/dist/pptx/edition-extension.js +10 -0
- package/dist/pptx/edition-extension.js.map +1 -0
- package/dist/pptx/edition.d.ts +20 -0
- package/dist/pptx/edition.d.ts.map +1 -0
- package/dist/pptx/edition.js +69 -0
- package/dist/pptx/edition.js.map +1 -0
- package/dist/pptx/elements.d.ts +12 -0
- package/dist/pptx/elements.d.ts.map +1 -0
- package/dist/pptx/elements.js +224 -0
- package/dist/pptx/elements.js.map +1 -0
- package/dist/pptx/hyperlink.d.ts +7 -0
- package/dist/pptx/hyperlink.d.ts.map +1 -0
- package/dist/pptx/hyperlink.js +81 -0
- package/dist/pptx/hyperlink.js.map +1 -0
- package/dist/pptx/index-sync.d.ts +7 -0
- package/dist/pptx/index-sync.d.ts.map +1 -0
- package/dist/pptx/index-sync.js +24 -0
- package/dist/pptx/index-sync.js.map +1 -0
- package/dist/pptx/index.d.ts +10 -0
- package/dist/pptx/index.d.ts.map +1 -0
- package/dist/pptx/index.js +7 -0
- package/dist/pptx/index.js.map +1 -0
- package/dist/pptx/indexer.d.ts +19 -0
- package/dist/pptx/indexer.d.ts.map +1 -0
- package/dist/pptx/indexer.js +319 -0
- package/dist/pptx/indexer.js.map +1 -0
- package/dist/pptx/layout-ref.d.ts +41 -0
- package/dist/pptx/layout-ref.d.ts.map +1 -0
- package/dist/pptx/layout-ref.js +145 -0
- package/dist/pptx/layout-ref.js.map +1 -0
- package/dist/pptx/media.d.ts +15 -0
- package/dist/pptx/media.d.ts.map +1 -0
- package/dist/pptx/media.js +145 -0
- package/dist/pptx/media.js.map +1 -0
- package/dist/pptx/mutations.d.ts +11 -0
- package/dist/pptx/mutations.d.ts.map +1 -0
- package/dist/pptx/mutations.js +1111 -0
- package/dist/pptx/mutations.js.map +1 -0
- package/dist/pptx/picture.d.ts +25 -0
- package/dist/pptx/picture.d.ts.map +1 -0
- package/dist/pptx/picture.js +118 -0
- package/dist/pptx/picture.js.map +1 -0
- package/dist/pptx/placeholder-role.d.ts +19 -0
- package/dist/pptx/placeholder-role.d.ts.map +1 -0
- package/dist/pptx/placeholder-role.js +71 -0
- package/dist/pptx/placeholder-role.js.map +1 -0
- package/dist/pptx/properties.d.ts +13 -0
- package/dist/pptx/properties.d.ts.map +1 -0
- package/dist/pptx/properties.js +587 -0
- package/dist/pptx/properties.js.map +1 -0
- package/dist/pptx/resolve-properties.d.ts +17 -0
- package/dist/pptx/resolve-properties.d.ts.map +1 -0
- package/dist/pptx/resolve-properties.js +571 -0
- package/dist/pptx/resolve-properties.js.map +1 -0
- package/dist/pptx/slide-size.d.ts +9 -0
- package/dist/pptx/slide-size.d.ts.map +1 -0
- package/dist/pptx/slide-size.js +29 -0
- package/dist/pptx/slide-size.js.map +1 -0
- package/dist/pptx/slides.d.ts +15 -0
- package/dist/pptx/slides.d.ts.map +1 -0
- package/dist/pptx/slides.js +236 -0
- package/dist/pptx/slides.js.map +1 -0
- package/dist/pptx/table-measure.d.ts +43 -0
- package/dist/pptx/table-measure.d.ts.map +1 -0
- package/dist/pptx/table-measure.js +70 -0
- package/dist/pptx/table-measure.js.map +1 -0
- package/dist/pptx/table.d.ts +23 -0
- package/dist/pptx/table.d.ts.map +1 -0
- package/dist/pptx/table.js +529 -0
- package/dist/pptx/table.js.map +1 -0
- package/dist/pptx/types.d.ts +27 -0
- package/dist/pptx/types.d.ts.map +1 -0
- package/dist/pptx/types.js +2 -0
- package/dist/pptx/types.js.map +1 -0
- package/dist/pptx/workspace.d.ts +23 -0
- package/dist/pptx/workspace.d.ts.map +1 -0
- package/dist/pptx/workspace.js +148 -0
- package/dist/pptx/workspace.js.map +1 -0
- package/dist/pptx/xml.d.ts +67 -0
- package/dist/pptx/xml.d.ts.map +1 -0
- package/dist/pptx/xml.js +355 -0
- package/dist/pptx/xml.js.map +1 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +14 -2
- package/dist/render.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspace/git.d.ts +7 -0
- package/dist/workspace/git.d.ts.map +1 -0
- package/dist/workspace/git.js +82 -0
- package/dist/workspace/git.js.map +1 -0
- package/dist/workspace/index.d.ts +7 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +7 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/lock.d.ts +3 -0
- package/dist/workspace/lock.d.ts.map +1 -0
- package/dist/workspace/lock.js +35 -0
- package/dist/workspace/lock.js.map +1 -0
- package/dist/workspace/metadata.d.ts +4 -0
- package/dist/workspace/metadata.d.ts.map +1 -0
- package/dist/workspace/metadata.js +21 -0
- package/dist/workspace/metadata.js.map +1 -0
- package/dist/workspace/operations.d.ts +14 -0
- package/dist/workspace/operations.d.ts.map +1 -0
- package/dist/workspace/operations.js +35 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/paths.d.ts +11 -0
- package/dist/workspace/paths.d.ts.map +1 -0
- package/dist/workspace/paths.js +12 -0
- package/dist/workspace/paths.js.map +1 -0
- package/dist/workspace/revision.d.ts +6 -0
- package/dist/workspace/revision.d.ts.map +1 -0
- package/dist/workspace/revision.js +15 -0
- package/dist/workspace/revision.js.map +1 -0
- package/dist/xlsx/index.d.ts +2 -0
- package/dist/xlsx/index.d.ts.map +1 -0
- package/dist/xlsx/index.js +3 -0
- package/dist/xlsx/index.js.map +1 -0
- package/package.json +48 -27
- package/schema/command.schema.json +2399 -0
- package/dist/.tsbuildinfo +0 -1
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const PROTOCOL_VERSION = '2.0';
|
|
3
|
+
export const protocolVersionSchema = z.literal(PROTOCOL_VERSION);
|
|
4
|
+
export const errorCodeSchema = z.enum([
|
|
5
|
+
'INVALID_COMMAND',
|
|
6
|
+
'UNSUPPORTED_VERSION',
|
|
7
|
+
'WORKSPACE_NOT_FOUND',
|
|
8
|
+
'DOCUMENT_NOT_FOUND',
|
|
9
|
+
'ELEMENT_NOT_FOUND',
|
|
10
|
+
'TARGET_NOT_FOUND',
|
|
11
|
+
'AMBIGUOUS_REFERENCE',
|
|
12
|
+
'AMBIGUOUS_NAME',
|
|
13
|
+
'FORMAT_NOT_SUPPORTED',
|
|
14
|
+
'FORMAT_NOT_IMPLEMENTED',
|
|
15
|
+
'VALIDATION_FAILED',
|
|
16
|
+
'TRANSACTION_CONFLICT',
|
|
17
|
+
'UNSUPPORTED_CAPABILITY',
|
|
18
|
+
'IO_ERROR',
|
|
19
|
+
'INTERNAL_ERROR',
|
|
20
|
+
]);
|
|
21
|
+
export const diagnosticSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
severity: z.enum(['info', 'warning', 'error']),
|
|
24
|
+
code: z.string().min(1),
|
|
25
|
+
message: z.string().min(1),
|
|
26
|
+
path: z.array(z.union([z.string(), z.number().int().nonnegative()])).optional(),
|
|
27
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
export const elementRefSchema = z
|
|
31
|
+
.object({
|
|
32
|
+
documentId: z.string().min(1),
|
|
33
|
+
elementId: z.string().min(1).optional(),
|
|
34
|
+
path: z.string().min(1).optional(),
|
|
35
|
+
revision: z.string().min(1).optional(),
|
|
36
|
+
})
|
|
37
|
+
.strict()
|
|
38
|
+
.refine((value) => value.elementId !== undefined || value.path !== undefined, {
|
|
39
|
+
message: 'elementId or path is required',
|
|
40
|
+
});
|
|
41
|
+
/** Phase-1 semantic address, e.g. slide:6/shape:7 or slide:6/shape:title/text */
|
|
42
|
+
export const targetPathSchema = z.string().min(1);
|
|
43
|
+
/** EMU number, or unit string (`120px`, `5%`, `1.5in`, …). Bare numbers are EMU. */
|
|
44
|
+
export const lengthValueSchema = z.union([z.number(), z.string().min(1)]);
|
|
45
|
+
export const transformSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
x: lengthValueSchema.optional(),
|
|
48
|
+
y: lengthValueSchema.optional(),
|
|
49
|
+
width: lengthValueSchema.optional(),
|
|
50
|
+
height: lengthValueSchema.optional(),
|
|
51
|
+
rotation: z.number().optional(),
|
|
52
|
+
flipHorizontal: z.boolean().optional(),
|
|
53
|
+
flipVertical: z.boolean().optional(),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
export const textRunSchema = z
|
|
57
|
+
.object({
|
|
58
|
+
text: z.string(),
|
|
59
|
+
fontSize: z.number().positive().optional(),
|
|
60
|
+
fontFamily: z.string().min(1).optional(),
|
|
61
|
+
textColor: z.string().min(1).optional(),
|
|
62
|
+
bold: z.boolean().optional(),
|
|
63
|
+
italic: z.boolean().optional(),
|
|
64
|
+
underline: z.boolean().optional(),
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
67
|
+
export const textBlockSchema = z
|
|
68
|
+
.object({
|
|
69
|
+
/** Plain paragraph text (single run). Ignored when `runs` is set. */
|
|
70
|
+
text: z.string().optional(),
|
|
71
|
+
/** Intra-paragraph runs with per-run styling. When set, preferred over `text`. */
|
|
72
|
+
runs: z.array(textRunSchema).min(1).optional(),
|
|
73
|
+
fontSize: z.number().positive().optional(),
|
|
74
|
+
fontFamily: z.string().min(1).optional(),
|
|
75
|
+
textColor: z.string().min(1).optional(),
|
|
76
|
+
bold: z.boolean().optional(),
|
|
77
|
+
italic: z.boolean().optional(),
|
|
78
|
+
underline: z.boolean().optional(),
|
|
79
|
+
align: z.enum(['l', 'ctr', 'r', 'just', 'left', 'center', 'right', 'justify']).optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict()
|
|
82
|
+
.superRefine((value, ctx) => {
|
|
83
|
+
if (value.runs === undefined && value.text === undefined) {
|
|
84
|
+
ctx.addIssue({
|
|
85
|
+
code: 'custom',
|
|
86
|
+
message: 'blocks[] entry requires text or runs',
|
|
87
|
+
path: ['text'],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
export const resolveModeSchema = z.enum(['effective', 'direct', 'both']);
|
|
92
|
+
export const writeScopeSchema = z.enum(['local', 'placeholder', 'layout', 'master', 'theme']);
|
|
93
|
+
const commandBase = {
|
|
94
|
+
version: protocolVersionSchema,
|
|
95
|
+
requestId: z.string().min(1).optional(),
|
|
96
|
+
};
|
|
97
|
+
const mutationBase = {
|
|
98
|
+
workspaceId: z.string().min(1),
|
|
99
|
+
transactionId: z.string().min(1),
|
|
100
|
+
dryRun: z.boolean().optional(),
|
|
101
|
+
expectRevision: z.union([z.string().min(1), z.number().int().positive()]).optional(),
|
|
102
|
+
reason: z.string().min(1).optional(),
|
|
103
|
+
};
|
|
104
|
+
const initCommandSchema = z
|
|
105
|
+
.object({
|
|
106
|
+
...commandBase,
|
|
107
|
+
type: z.literal('init'),
|
|
108
|
+
workspaceId: z.string().min(1),
|
|
109
|
+
format: z.string().min(1),
|
|
110
|
+
source: z.string().min(1),
|
|
111
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
const selectorObjectSchema = z
|
|
115
|
+
.object({
|
|
116
|
+
kind: z.string().min(1).optional(),
|
|
117
|
+
name: z.string().min(1).optional(),
|
|
118
|
+
text: z.string().min(1).optional(),
|
|
119
|
+
textRegex: z.string().min(1).optional(),
|
|
120
|
+
id: z.string().min(1).optional(),
|
|
121
|
+
slide: z.string().min(1).optional(),
|
|
122
|
+
hasText: z.boolean().optional(),
|
|
123
|
+
})
|
|
124
|
+
.strict();
|
|
125
|
+
export const selectorSchema = z.union([z.string().min(1), selectorObjectSchema]);
|
|
126
|
+
const statusCommandSchema = z
|
|
127
|
+
.object({
|
|
128
|
+
...commandBase,
|
|
129
|
+
type: z.literal('status'),
|
|
130
|
+
workspaceId: z.string().min(1),
|
|
131
|
+
})
|
|
132
|
+
.strict();
|
|
133
|
+
const listCommandSchema = z
|
|
134
|
+
.object({
|
|
135
|
+
...commandBase,
|
|
136
|
+
type: z.literal('list'),
|
|
137
|
+
workspaceId: z.string().min(1),
|
|
138
|
+
resource: z.enum([
|
|
139
|
+
'slides',
|
|
140
|
+
'shapes',
|
|
141
|
+
'layouts',
|
|
142
|
+
'masters',
|
|
143
|
+
'theme',
|
|
144
|
+
'paragraphs',
|
|
145
|
+
'tables',
|
|
146
|
+
'sections',
|
|
147
|
+
'styles',
|
|
148
|
+
'bookmarks',
|
|
149
|
+
]),
|
|
150
|
+
slide: z.number().int().positive().optional(),
|
|
151
|
+
})
|
|
152
|
+
.strict();
|
|
153
|
+
const getCommandSchema = z
|
|
154
|
+
.object({
|
|
155
|
+
...commandBase,
|
|
156
|
+
type: z.literal('get'),
|
|
157
|
+
workspaceId: z.string().min(1),
|
|
158
|
+
target: z.string().min(1),
|
|
159
|
+
resolve: resolveModeSchema.default('both'),
|
|
160
|
+
props: z.array(z.string().min(1)).optional(),
|
|
161
|
+
provenance: z.boolean().optional(),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
const searchCommandSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
...commandBase,
|
|
167
|
+
type: z.literal('search'),
|
|
168
|
+
workspaceId: z.string().min(1),
|
|
169
|
+
kind: z.enum(['text', 'shape']),
|
|
170
|
+
query: z.string().optional(),
|
|
171
|
+
name: z.string().min(1).optional(),
|
|
172
|
+
scope: z.string().min(1).optional(),
|
|
173
|
+
limit: z.number().int().positive().max(10000).default(100),
|
|
174
|
+
})
|
|
175
|
+
.strict();
|
|
176
|
+
const inspectCommandSchema = z
|
|
177
|
+
.object({
|
|
178
|
+
...commandBase,
|
|
179
|
+
type: z.literal('inspect'),
|
|
180
|
+
workspaceId: z.string().min(1),
|
|
181
|
+
target: z.string().min(1).optional(),
|
|
182
|
+
ref: elementRefSchema.optional(),
|
|
183
|
+
depth: z.number().int().min(0).max(100).default(1),
|
|
184
|
+
visualTree: z.boolean().optional(),
|
|
185
|
+
})
|
|
186
|
+
.strict();
|
|
187
|
+
const queryCommandSchema = z
|
|
188
|
+
.object({
|
|
189
|
+
...commandBase,
|
|
190
|
+
type: z.literal('query'),
|
|
191
|
+
workspaceId: z.string().min(1),
|
|
192
|
+
selector: selectorSchema,
|
|
193
|
+
limit: z.number().int().positive().max(10000).default(100),
|
|
194
|
+
})
|
|
195
|
+
.strict();
|
|
196
|
+
const getTextCommandSchema = z
|
|
197
|
+
.object({
|
|
198
|
+
...commandBase,
|
|
199
|
+
type: z.literal('getText'),
|
|
200
|
+
workspaceId: z.string().min(1),
|
|
201
|
+
ref: elementRefSchema,
|
|
202
|
+
})
|
|
203
|
+
.strict();
|
|
204
|
+
const setTextCommandSchema = z
|
|
205
|
+
.object({
|
|
206
|
+
...commandBase,
|
|
207
|
+
...mutationBase,
|
|
208
|
+
type: z.literal('setText'),
|
|
209
|
+
ref: elementRefSchema.optional(),
|
|
210
|
+
target: z.string().min(1).optional(),
|
|
211
|
+
text: z.string().optional(),
|
|
212
|
+
value: z.string().optional(),
|
|
213
|
+
/** Rich paragraphs: each block becomes one `a:p` with its own run style. */
|
|
214
|
+
blocks: z.array(textBlockSchema).min(1).optional(),
|
|
215
|
+
})
|
|
216
|
+
.strict()
|
|
217
|
+
.superRefine((value, ctx) => {
|
|
218
|
+
if (value.blocks === undefined && value.text === undefined && value.value === undefined) {
|
|
219
|
+
ctx.addIssue({
|
|
220
|
+
code: 'custom',
|
|
221
|
+
message: 'setText requires text, value, or blocks',
|
|
222
|
+
path: ['text'],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const replaceTextCommandSchema = z
|
|
227
|
+
.object({
|
|
228
|
+
...commandBase,
|
|
229
|
+
...mutationBase,
|
|
230
|
+
type: z.literal('replaceText'),
|
|
231
|
+
find: z.string().min(1),
|
|
232
|
+
replace: z.string(),
|
|
233
|
+
regex: z.boolean().optional(),
|
|
234
|
+
selector: selectorSchema.optional(),
|
|
235
|
+
limit: z.number().int().positive().max(10000).optional(),
|
|
236
|
+
})
|
|
237
|
+
.strict();
|
|
238
|
+
const setPropertiesCommandSchema = z
|
|
239
|
+
.object({
|
|
240
|
+
...commandBase,
|
|
241
|
+
...mutationBase,
|
|
242
|
+
type: z.literal('setProperties'),
|
|
243
|
+
ref: elementRefSchema.optional(),
|
|
244
|
+
target: z.string().min(1).optional(),
|
|
245
|
+
properties: z.record(z.string(), z.unknown()),
|
|
246
|
+
scope: writeScopeSchema.optional(),
|
|
247
|
+
})
|
|
248
|
+
.strict();
|
|
249
|
+
const setCommandSchema = z
|
|
250
|
+
.object({
|
|
251
|
+
...commandBase,
|
|
252
|
+
...mutationBase,
|
|
253
|
+
type: z.literal('set'),
|
|
254
|
+
target: z.string().min(1),
|
|
255
|
+
properties: z.record(z.string(), z.unknown()),
|
|
256
|
+
scope: writeScopeSchema.default('local'),
|
|
257
|
+
})
|
|
258
|
+
.strict();
|
|
259
|
+
const setTransformCommandSchema = z
|
|
260
|
+
.object({
|
|
261
|
+
...commandBase,
|
|
262
|
+
...mutationBase,
|
|
263
|
+
type: z.literal('setTransform'),
|
|
264
|
+
ref: elementRefSchema.optional(),
|
|
265
|
+
target: z.string().min(1).optional(),
|
|
266
|
+
transform: transformSchema,
|
|
267
|
+
})
|
|
268
|
+
.strict();
|
|
269
|
+
const xfrmSetCommandSchema = z
|
|
270
|
+
.object({
|
|
271
|
+
...commandBase,
|
|
272
|
+
...mutationBase,
|
|
273
|
+
type: z.literal('xfrmSet'),
|
|
274
|
+
target: z.string().min(1).optional(),
|
|
275
|
+
slide: z.number().int().positive().optional(),
|
|
276
|
+
shape: z.union([z.number().int().positive(), z.string().min(1)]).optional(),
|
|
277
|
+
x: lengthValueSchema.optional(),
|
|
278
|
+
y: lengthValueSchema.optional(),
|
|
279
|
+
width: lengthValueSchema.optional(),
|
|
280
|
+
height: lengthValueSchema.optional(),
|
|
281
|
+
rotation: z.number().optional(),
|
|
282
|
+
flipX: z.boolean().optional(),
|
|
283
|
+
flipY: z.boolean().optional(),
|
|
284
|
+
})
|
|
285
|
+
.strict();
|
|
286
|
+
const setTableLayoutCommandSchema = z
|
|
287
|
+
.object({
|
|
288
|
+
...commandBase,
|
|
289
|
+
...mutationBase,
|
|
290
|
+
type: z.literal('setTableLayout'),
|
|
291
|
+
target: targetPathSchema,
|
|
292
|
+
/** Frame height: `"auto"` uses content heuristics, or an absolute length. */
|
|
293
|
+
height: z.union([z.literal('auto'), lengthValueSchema]).optional(),
|
|
294
|
+
/** `content` = measure cells; `equal` = split frame height evenly across rows. */
|
|
295
|
+
redistribute: z.enum(['equal', 'content']).optional(),
|
|
296
|
+
})
|
|
297
|
+
.strict()
|
|
298
|
+
.superRefine((value, ctx) => {
|
|
299
|
+
if (value.height === undefined && value.redistribute === undefined) {
|
|
300
|
+
ctx.addIssue({
|
|
301
|
+
code: 'custom',
|
|
302
|
+
message: 'setTableLayout requires height and/or redistribute',
|
|
303
|
+
path: ['height'],
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
const zMoveCommandSchema = z
|
|
308
|
+
.object({
|
|
309
|
+
...commandBase,
|
|
310
|
+
...mutationBase,
|
|
311
|
+
type: z.literal('zMove'),
|
|
312
|
+
target: z.string().min(1),
|
|
313
|
+
above: z.string().min(1).optional(),
|
|
314
|
+
below: z.string().min(1).optional(),
|
|
315
|
+
toFront: z.boolean().optional(),
|
|
316
|
+
toBack: z.boolean().optional(),
|
|
317
|
+
})
|
|
318
|
+
.strict();
|
|
319
|
+
const alignElementsCommandSchema = z
|
|
320
|
+
.object({
|
|
321
|
+
...commandBase,
|
|
322
|
+
...mutationBase,
|
|
323
|
+
type: z.literal('alignElements'),
|
|
324
|
+
slide: z.number().int().positive(),
|
|
325
|
+
targets: z.array(z.string().min(1)).min(1),
|
|
326
|
+
mode: z.enum([
|
|
327
|
+
'left',
|
|
328
|
+
'right',
|
|
329
|
+
'top',
|
|
330
|
+
'bottom',
|
|
331
|
+
'center-h',
|
|
332
|
+
'center-v',
|
|
333
|
+
'distribute-h',
|
|
334
|
+
'distribute-v',
|
|
335
|
+
]),
|
|
336
|
+
gap: lengthValueSchema.optional(),
|
|
337
|
+
})
|
|
338
|
+
.strict();
|
|
339
|
+
const addCommandSchema = z
|
|
340
|
+
.object({
|
|
341
|
+
...commandBase,
|
|
342
|
+
...mutationBase,
|
|
343
|
+
type: z.literal('add'),
|
|
344
|
+
parent: elementRefSchema.optional(),
|
|
345
|
+
target: z.string().min(1).optional(),
|
|
346
|
+
element: z.record(z.string(), z.unknown()),
|
|
347
|
+
})
|
|
348
|
+
.strict();
|
|
349
|
+
const addSlideCommandSchema = z
|
|
350
|
+
.object({
|
|
351
|
+
...commandBase,
|
|
352
|
+
...mutationBase,
|
|
353
|
+
type: z.literal('addSlide'),
|
|
354
|
+
after: z.number().int().nonnegative().optional(),
|
|
355
|
+
/** Layout ref: index, layout:N, slide:N, display name, or basename. */
|
|
356
|
+
layout: z.string().min(1).optional(),
|
|
357
|
+
name: z.string().min(1).optional(),
|
|
358
|
+
})
|
|
359
|
+
.strict();
|
|
360
|
+
const setSlideLayoutCommandSchema = z
|
|
361
|
+
.object({
|
|
362
|
+
...commandBase,
|
|
363
|
+
...mutationBase,
|
|
364
|
+
type: z.literal('setSlideLayout'),
|
|
365
|
+
slide: z.number().int().positive(),
|
|
366
|
+
/** Layout ref: index, layout:N, slide:N, display name, or basename. */
|
|
367
|
+
layout: z.string().min(1),
|
|
368
|
+
})
|
|
369
|
+
.strict();
|
|
370
|
+
const chartDataSchema = z
|
|
371
|
+
.object({
|
|
372
|
+
title: z.string().optional(),
|
|
373
|
+
categories: z.array(z.string()).default([]),
|
|
374
|
+
series: z
|
|
375
|
+
.array(z
|
|
376
|
+
.object({
|
|
377
|
+
name: z.string().min(1),
|
|
378
|
+
values: z.array(z.number()),
|
|
379
|
+
color: z.string().min(1).optional(),
|
|
380
|
+
/** For combo charts: primary (left) or secondary (right) value axis. */
|
|
381
|
+
axis: z.enum(['primary', 'secondary']).optional(),
|
|
382
|
+
/** For combo charts: render this series as bar/column or line. */
|
|
383
|
+
chart: z.enum(['bar', 'column', 'line']).optional(),
|
|
384
|
+
})
|
|
385
|
+
.strict())
|
|
386
|
+
.min(1),
|
|
387
|
+
})
|
|
388
|
+
.strict();
|
|
389
|
+
const addShapeCommandSchema = z
|
|
390
|
+
.object({
|
|
391
|
+
...commandBase,
|
|
392
|
+
...mutationBase,
|
|
393
|
+
type: z.literal('addShape'),
|
|
394
|
+
slide: z.number().int().positive(),
|
|
395
|
+
shapeType: z.enum([
|
|
396
|
+
'text',
|
|
397
|
+
'rect',
|
|
398
|
+
'rounded-rect',
|
|
399
|
+
'ellipse',
|
|
400
|
+
'line',
|
|
401
|
+
'connector',
|
|
402
|
+
'elbow',
|
|
403
|
+
'elbow-connector',
|
|
404
|
+
'curved-connector',
|
|
405
|
+
'arrow',
|
|
406
|
+
'right-arrow',
|
|
407
|
+
'left-arrow',
|
|
408
|
+
'up-arrow',
|
|
409
|
+
'down-arrow',
|
|
410
|
+
'chevron',
|
|
411
|
+
'pentagon',
|
|
412
|
+
'trapezoid',
|
|
413
|
+
'triangle',
|
|
414
|
+
'rt-triangle',
|
|
415
|
+
'circular-arrow',
|
|
416
|
+
'curved-right-arrow',
|
|
417
|
+
'curved-left-arrow',
|
|
418
|
+
'image',
|
|
419
|
+
'group',
|
|
420
|
+
'table',
|
|
421
|
+
'chart',
|
|
422
|
+
'video',
|
|
423
|
+
'audio',
|
|
424
|
+
]),
|
|
425
|
+
name: z.string().min(1).optional(),
|
|
426
|
+
role: z.string().min(1).optional(),
|
|
427
|
+
x: lengthValueSchema.optional(),
|
|
428
|
+
y: lengthValueSchema.optional(),
|
|
429
|
+
width: lengthValueSchema.optional(),
|
|
430
|
+
height: lengthValueSchema.optional(),
|
|
431
|
+
/** Rounded-rect corner radius: 0–1 fraction of half the shorter side (OOXML adj). */
|
|
432
|
+
cornerRadius: z.number().min(0).max(1).optional(),
|
|
433
|
+
file: z.string().min(1).optional(),
|
|
434
|
+
text: z.string().optional(),
|
|
435
|
+
/** Rich paragraphs; when set, preferred over `text`. */
|
|
436
|
+
blocks: z.array(textBlockSchema).min(1).optional(),
|
|
437
|
+
/** Vertical text anchor: t|ctr|b (or top|middle|bottom). */
|
|
438
|
+
anchor: z.enum(['t', 'ctr', 'b', 'top', 'middle', 'bottom']).optional(),
|
|
439
|
+
/** Text wrapping: square (default) or none. */
|
|
440
|
+
wrap: z.enum(['square', 'none']).optional(),
|
|
441
|
+
fill: z
|
|
442
|
+
.union([
|
|
443
|
+
z.string().min(1),
|
|
444
|
+
z
|
|
445
|
+
.object({
|
|
446
|
+
color: z.string().min(1),
|
|
447
|
+
transparency: z.number().optional(),
|
|
448
|
+
type: z.literal('solid').optional(),
|
|
449
|
+
})
|
|
450
|
+
.strict(),
|
|
451
|
+
])
|
|
452
|
+
.optional(),
|
|
453
|
+
stroke: z
|
|
454
|
+
.union([
|
|
455
|
+
z.string().min(1),
|
|
456
|
+
z
|
|
457
|
+
.object({
|
|
458
|
+
color: z.string().min(1).optional(),
|
|
459
|
+
width: z.number().optional(),
|
|
460
|
+
dash: z.string().min(1).optional(),
|
|
461
|
+
headEnd: z.string().min(1).optional(),
|
|
462
|
+
tailEnd: z.string().min(1).optional(),
|
|
463
|
+
})
|
|
464
|
+
.strict(),
|
|
465
|
+
])
|
|
466
|
+
.optional(),
|
|
467
|
+
rows: z.array(z.array(z.string())).optional(),
|
|
468
|
+
/** Table visual preset. */
|
|
469
|
+
theme: z.enum(['minimal', 'zebra']).optional(),
|
|
470
|
+
/** Column alignments by index: l|ctr|r (or left|center|right). */
|
|
471
|
+
alignColumns: z.array(z.enum(['l', 'ctr', 'r', 'left', 'center', 'right'])).optional(),
|
|
472
|
+
chartType: z.enum(['bar', 'column', 'line', 'pie', 'combo']).optional(),
|
|
473
|
+
data: chartDataSchema.optional(),
|
|
474
|
+
showDataLabels: z.boolean().optional(),
|
|
475
|
+
})
|
|
476
|
+
.strict()
|
|
477
|
+
.superRefine((value, ctx) => {
|
|
478
|
+
if ((value.shapeType === 'image' || value.shapeType === 'video' || value.shapeType === 'audio') &&
|
|
479
|
+
!value.file) {
|
|
480
|
+
ctx.addIssue({
|
|
481
|
+
code: 'custom',
|
|
482
|
+
message: `--type ${value.shapeType} requires --file <path> (example: deckuse add shape --slide 1 --type ${value.shapeType} --file ./media)`,
|
|
483
|
+
path: ['file'],
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
if (value.shapeType === 'table' && !value.rows) {
|
|
487
|
+
ctx.addIssue({
|
|
488
|
+
code: 'custom',
|
|
489
|
+
message: '--type table requires --rows \'<json>\' (example: --rows \'[["A","B"],["1","2"]]\')',
|
|
490
|
+
path: ['rows'],
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
if (value.shapeType === 'chart') {
|
|
494
|
+
if (!value.chartType) {
|
|
495
|
+
ctx.addIssue({
|
|
496
|
+
code: 'custom',
|
|
497
|
+
message: '--type chart requires --chart-type <bar|column|line|pie|combo> (example: --chart-type column --data \'{"categories":["Q1"],"series":[{"name":"S1","values":[1]}]}\')',
|
|
498
|
+
path: ['chartType'],
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
if (!value.data) {
|
|
502
|
+
ctx.addIssue({
|
|
503
|
+
code: 'custom',
|
|
504
|
+
message: '--type chart requires --data \'<json>\' with categories + series (example: --data \'{"categories":["Q1","Q2"],"series":[{"name":"2024","values":[10,20]}]}\')',
|
|
505
|
+
path: ['data'],
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
if (value.chartType === 'combo' && value.data) {
|
|
509
|
+
const charts = new Set(value.data.series.map((s) => s.chart ?? 'column'));
|
|
510
|
+
if (!charts.has('line') || ![...charts].some((c) => c === 'bar' || c === 'column')) {
|
|
511
|
+
ctx.addIssue({
|
|
512
|
+
code: 'custom',
|
|
513
|
+
message: 'combo charts require at least one bar/column series and one line series (set series[].chart)',
|
|
514
|
+
path: ['data', 'series'],
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
const addParagraphCommandSchema = z
|
|
521
|
+
.object({
|
|
522
|
+
...commandBase,
|
|
523
|
+
...mutationBase,
|
|
524
|
+
type: z.literal('addParagraph'),
|
|
525
|
+
/** Insert after this target. Omit to append before the final sectPr. */
|
|
526
|
+
after: z.string().min(1).optional(),
|
|
527
|
+
/** Paragraph style id (for example Heading1). Wins over `level` when both are set. */
|
|
528
|
+
style: z.string().min(1).optional(),
|
|
529
|
+
/** Heading level 1–9, or 0 for Normal. Ignored when `style` is set. */
|
|
530
|
+
level: z.number().int().min(0).max(9).optional(),
|
|
531
|
+
/** Bookmark name so later commands in the same batch can target bookmark:<name>. */
|
|
532
|
+
name: z.string().min(1).optional(),
|
|
533
|
+
text: z.string().optional(),
|
|
534
|
+
/** Rich paragraphs; when set, preferred over `text`. The first block fills this paragraph. */
|
|
535
|
+
blocks: z.array(textBlockSchema).min(1).optional(),
|
|
536
|
+
})
|
|
537
|
+
.strict();
|
|
538
|
+
const addTableCommandSchema = z
|
|
539
|
+
.object({
|
|
540
|
+
...commandBase,
|
|
541
|
+
...mutationBase,
|
|
542
|
+
type: z.literal('addTable'),
|
|
543
|
+
after: z.string().min(1).optional(),
|
|
544
|
+
name: z.string().min(1).optional(),
|
|
545
|
+
rows: z.array(z.array(z.string())).min(1),
|
|
546
|
+
})
|
|
547
|
+
.strict();
|
|
548
|
+
const insertBreakCommandSchema = z
|
|
549
|
+
.object({
|
|
550
|
+
...commandBase,
|
|
551
|
+
...mutationBase,
|
|
552
|
+
type: z.literal('insertBreak'),
|
|
553
|
+
kind: z.enum(['page']).default('page'),
|
|
554
|
+
after: z.string().min(1).optional(),
|
|
555
|
+
})
|
|
556
|
+
.strict();
|
|
557
|
+
const removeCommandSchema = z
|
|
558
|
+
.object({
|
|
559
|
+
...commandBase,
|
|
560
|
+
...mutationBase,
|
|
561
|
+
type: z.literal('remove'),
|
|
562
|
+
ref: elementRefSchema.optional(),
|
|
563
|
+
target: z.string().min(1).optional(),
|
|
564
|
+
})
|
|
565
|
+
.strict();
|
|
566
|
+
const replacePictureCommandSchema = z
|
|
567
|
+
.object({
|
|
568
|
+
...commandBase,
|
|
569
|
+
...mutationBase,
|
|
570
|
+
type: z.literal('replacePicture'),
|
|
571
|
+
ref: elementRefSchema.optional(),
|
|
572
|
+
target: z.string().min(1).optional(),
|
|
573
|
+
path: z.string().min(1).optional(),
|
|
574
|
+
base64: z.string().min(1).optional(),
|
|
575
|
+
})
|
|
576
|
+
.strict();
|
|
577
|
+
const duplicateCommandSchema = z
|
|
578
|
+
.object({
|
|
579
|
+
...commandBase,
|
|
580
|
+
...mutationBase,
|
|
581
|
+
type: z.literal('duplicate'),
|
|
582
|
+
ref: elementRefSchema.optional(),
|
|
583
|
+
target: z.string().min(1).optional(),
|
|
584
|
+
parent: elementRefSchema.optional(),
|
|
585
|
+
index: z.number().int().nonnegative().optional(),
|
|
586
|
+
})
|
|
587
|
+
.strict();
|
|
588
|
+
const applyTransactionCommandSchema = z
|
|
589
|
+
.object({
|
|
590
|
+
...commandBase,
|
|
591
|
+
...mutationBase,
|
|
592
|
+
type: z.literal('applyTransaction'),
|
|
593
|
+
operations: z.array(z.record(z.string(), z.unknown())).min(1).max(1000),
|
|
594
|
+
})
|
|
595
|
+
.strict();
|
|
596
|
+
const exportCommandSchema = z
|
|
597
|
+
.object({
|
|
598
|
+
...commandBase,
|
|
599
|
+
type: z.literal('export'),
|
|
600
|
+
workspaceId: z.string().min(1),
|
|
601
|
+
output: z.string().min(1),
|
|
602
|
+
revision: z.union([z.string().min(1), z.number().int().positive()]).optional(),
|
|
603
|
+
/** When true, copy existing package.pptx without rebuilding from source/. */
|
|
604
|
+
fromPackage: z.boolean().optional(),
|
|
605
|
+
})
|
|
606
|
+
.strict();
|
|
607
|
+
const undoCommandSchema = z
|
|
608
|
+
.object({
|
|
609
|
+
...commandBase,
|
|
610
|
+
type: z.literal('undo'),
|
|
611
|
+
workspaceId: z.string().min(1),
|
|
612
|
+
steps: z.number().int().positive().max(1000).default(1),
|
|
613
|
+
})
|
|
614
|
+
.strict();
|
|
615
|
+
const historyCommandSchema = z
|
|
616
|
+
.object({
|
|
617
|
+
...commandBase,
|
|
618
|
+
type: z.literal('history'),
|
|
619
|
+
workspaceId: z.string().min(1),
|
|
620
|
+
limit: z.number().int().positive().max(10000).default(100),
|
|
621
|
+
offset: z.number().int().nonnegative().max(1000000).default(0),
|
|
622
|
+
slide: z.number().int().positive().optional(),
|
|
623
|
+
})
|
|
624
|
+
.strict();
|
|
625
|
+
const validateCommandSchema = z
|
|
626
|
+
.object({
|
|
627
|
+
...commandBase,
|
|
628
|
+
type: z.literal('validate'),
|
|
629
|
+
workspaceId: z.string().min(1),
|
|
630
|
+
level: z.enum(['fast', 'full']).default('full'),
|
|
631
|
+
package: z.boolean().optional(),
|
|
632
|
+
relationships: z.boolean().optional(),
|
|
633
|
+
ids: z.boolean().optional(),
|
|
634
|
+
render: z.boolean().optional(),
|
|
635
|
+
slide: z.number().int().positive().optional(),
|
|
636
|
+
})
|
|
637
|
+
.strict();
|
|
638
|
+
export const atomicCommandSchema = z.discriminatedUnion('type', [
|
|
639
|
+
setTextCommandSchema,
|
|
640
|
+
replaceTextCommandSchema,
|
|
641
|
+
setTransformCommandSchema,
|
|
642
|
+
setPropertiesCommandSchema,
|
|
643
|
+
setCommandSchema,
|
|
644
|
+
xfrmSetCommandSchema,
|
|
645
|
+
setTableLayoutCommandSchema,
|
|
646
|
+
zMoveCommandSchema,
|
|
647
|
+
alignElementsCommandSchema,
|
|
648
|
+
addCommandSchema,
|
|
649
|
+
addSlideCommandSchema,
|
|
650
|
+
setSlideLayoutCommandSchema,
|
|
651
|
+
addShapeCommandSchema,
|
|
652
|
+
addParagraphCommandSchema,
|
|
653
|
+
addTableCommandSchema,
|
|
654
|
+
insertBreakCommandSchema,
|
|
655
|
+
removeCommandSchema,
|
|
656
|
+
replacePictureCommandSchema,
|
|
657
|
+
duplicateCommandSchema,
|
|
658
|
+
]);
|
|
659
|
+
const batchCommandSchema = z
|
|
660
|
+
.object({
|
|
661
|
+
...commandBase,
|
|
662
|
+
...mutationBase,
|
|
663
|
+
type: z.literal('batch'),
|
|
664
|
+
atomic: z.boolean().default(true),
|
|
665
|
+
commands: z.array(atomicCommandSchema).min(1).max(1000),
|
|
666
|
+
})
|
|
667
|
+
.strict();
|
|
668
|
+
export const commandSchema = z.discriminatedUnion('type', [
|
|
669
|
+
initCommandSchema,
|
|
670
|
+
statusCommandSchema,
|
|
671
|
+
listCommandSchema,
|
|
672
|
+
getCommandSchema,
|
|
673
|
+
searchCommandSchema,
|
|
674
|
+
inspectCommandSchema,
|
|
675
|
+
queryCommandSchema,
|
|
676
|
+
getTextCommandSchema,
|
|
677
|
+
setTextCommandSchema,
|
|
678
|
+
replaceTextCommandSchema,
|
|
679
|
+
setTransformCommandSchema,
|
|
680
|
+
setPropertiesCommandSchema,
|
|
681
|
+
setCommandSchema,
|
|
682
|
+
xfrmSetCommandSchema,
|
|
683
|
+
zMoveCommandSchema,
|
|
684
|
+
alignElementsCommandSchema,
|
|
685
|
+
addCommandSchema,
|
|
686
|
+
addSlideCommandSchema,
|
|
687
|
+
setSlideLayoutCommandSchema,
|
|
688
|
+
addShapeCommandSchema,
|
|
689
|
+
addParagraphCommandSchema,
|
|
690
|
+
addTableCommandSchema,
|
|
691
|
+
insertBreakCommandSchema,
|
|
692
|
+
removeCommandSchema,
|
|
693
|
+
replacePictureCommandSchema,
|
|
694
|
+
duplicateCommandSchema,
|
|
695
|
+
applyTransactionCommandSchema,
|
|
696
|
+
batchCommandSchema,
|
|
697
|
+
exportCommandSchema,
|
|
698
|
+
undoCommandSchema,
|
|
699
|
+
historyCommandSchema,
|
|
700
|
+
validateCommandSchema,
|
|
701
|
+
]);
|
|
702
|
+
export const commandJsonSchema = z.toJSONSchema(commandSchema, {
|
|
703
|
+
target: 'draft-2020-12',
|
|
704
|
+
reused: 'ref',
|
|
705
|
+
});
|
|
706
|
+
export const propertyValueSchema = z
|
|
707
|
+
.object({
|
|
708
|
+
effective: z.unknown().nullable(),
|
|
709
|
+
direct: z.unknown().nullable(),
|
|
710
|
+
inherited: z.boolean(),
|
|
711
|
+
source: z
|
|
712
|
+
.object({
|
|
713
|
+
scope: z.enum(['local', 'placeholder', 'layout', 'master', 'theme', 'default']),
|
|
714
|
+
target: z.string().min(1).optional(),
|
|
715
|
+
path: z.string().min(1).optional(),
|
|
716
|
+
})
|
|
717
|
+
.strict()
|
|
718
|
+
.optional(),
|
|
719
|
+
unit: z.string().min(1).optional(),
|
|
720
|
+
})
|
|
721
|
+
.strict();
|
|
722
|
+
export const commandEnvelopeSchema = z
|
|
723
|
+
.object({
|
|
724
|
+
ok: z.boolean(),
|
|
725
|
+
command: z.string().min(1),
|
|
726
|
+
revision: z.number().int().nonnegative().optional(),
|
|
727
|
+
commit: z.string().min(1).optional(),
|
|
728
|
+
branch: z.string().min(1).optional(),
|
|
729
|
+
affectedSlides: z.array(z.number().int().positive()).optional(),
|
|
730
|
+
changedTargets: z.array(z.string().min(1)).optional(),
|
|
731
|
+
changedParts: z.array(z.string().min(1)).optional(),
|
|
732
|
+
warnings: z.array(z.string()).optional(),
|
|
733
|
+
data: z.unknown().optional(),
|
|
734
|
+
error: z
|
|
735
|
+
.object({
|
|
736
|
+
code: z.string().min(1),
|
|
737
|
+
message: z.string().min(1),
|
|
738
|
+
target: z.string().min(1).optional(),
|
|
739
|
+
hint: z.string().min(1).optional(),
|
|
740
|
+
})
|
|
741
|
+
.strict()
|
|
742
|
+
.optional(),
|
|
743
|
+
})
|
|
744
|
+
.strict();
|
|
745
|
+
export const initResultSchema = z
|
|
746
|
+
.object({
|
|
747
|
+
workspaceId: z.string().min(1),
|
|
748
|
+
format: z.string().min(1),
|
|
749
|
+
source: z.string().min(1),
|
|
750
|
+
revision: z.union([z.string().min(1), z.number().int().positive()]),
|
|
751
|
+
elementCount: z.number().int().nonnegative(),
|
|
752
|
+
})
|
|
753
|
+
.strict();
|
|
754
|
+
export const workspaceManifestSchema = z
|
|
755
|
+
.object({
|
|
756
|
+
schemaVersion: protocolVersionSchema,
|
|
757
|
+
workspaceId: z.string().min(1),
|
|
758
|
+
format: z.string().min(1),
|
|
759
|
+
source: z.string().min(1),
|
|
760
|
+
revision: z.string().min(1),
|
|
761
|
+
createdAt: z.iso.datetime(),
|
|
762
|
+
updatedAt: z.iso.datetime(),
|
|
763
|
+
adapterVersion: z.string().min(1),
|
|
764
|
+
files: z.array(z
|
|
765
|
+
.object({
|
|
766
|
+
path: z.string().min(1),
|
|
767
|
+
mediaType: z.string().min(1).optional(),
|
|
768
|
+
checksum: z.string().min(1),
|
|
769
|
+
})
|
|
770
|
+
.strict()),
|
|
771
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
772
|
+
})
|
|
773
|
+
.strict();
|
|
774
|
+
export const ok = (value, diagnostics = []) => ({
|
|
775
|
+
ok: true,
|
|
776
|
+
value,
|
|
777
|
+
diagnostics,
|
|
778
|
+
});
|
|
779
|
+
export const err = (code, message, diagnostics = [], extra = {}) => ({
|
|
780
|
+
ok: false,
|
|
781
|
+
error: {
|
|
782
|
+
code,
|
|
783
|
+
message,
|
|
784
|
+
...(diagnostics.length > 0 ? { diagnostics } : {}),
|
|
785
|
+
...(extra.target ? { target: extra.target } : {}),
|
|
786
|
+
...(extra.hint ? { hint: extra.hint } : {}),
|
|
787
|
+
},
|
|
788
|
+
diagnostics,
|
|
789
|
+
});
|
|
790
|
+
export const revisionAsNumber = (revision) => {
|
|
791
|
+
if (revision === undefined)
|
|
792
|
+
return undefined;
|
|
793
|
+
if (typeof revision === 'number')
|
|
794
|
+
return Number.isFinite(revision) ? revision : undefined;
|
|
795
|
+
const n = Number(revision);
|
|
796
|
+
return Number.isInteger(n) && n >= 0 ? n : undefined;
|
|
797
|
+
};
|
|
798
|
+
//# sourceMappingURL=schema.js.map
|