@embedpdf/engine-core 3.0.0-next.14 → 3.0.0-next.16
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/dist/AnnotationList-DcyhF2kU.d.cts +27691 -0
- package/dist/AnnotationList-DcyhF2kU.d.ts +27691 -0
- package/dist/Change-Ct-dB8D5.cjs +1133 -0
- package/dist/Change-Ct-dB8D5.cjs.map +1 -0
- package/dist/Change-tMR34hTU.js +978 -0
- package/dist/Change-tMR34hTU.js.map +1 -0
- package/dist/DocumentRenderService-9IjSQEIU.cjs +121 -0
- package/dist/DocumentRenderService-9IjSQEIU.cjs.map +1 -0
- package/dist/DocumentRenderService-DFrZ9wfW.js +86 -0
- package/dist/DocumentRenderService-DFrZ9wfW.js.map +1 -0
- package/dist/{DocumentSecurityService-Ca6EK3-3.d.ts → DocumentSecurityService-D2zA4NKi.d.cts} +100 -112
- package/dist/{DocumentSecurityService-CIx1MT0T.d.cts → DocumentSecurityService-YJV9df8P.d.ts} +100 -112
- package/dist/LocalDocumentHandle-D02FMm-Z.cjs +53 -0
- package/dist/LocalDocumentHandle-D02FMm-Z.cjs.map +1 -0
- package/dist/LocalDocumentHandle-DAPdaOt_.js +30 -0
- package/dist/LocalDocumentHandle-DAPdaOt_.js.map +1 -0
- package/dist/LocalEngine-DBt2-GWF.d.ts +1649 -0
- package/dist/LocalEngine-IA9zh3Jh.d.cts +1649 -0
- package/dist/PageInsertBlankInput-CXHAM7l6.cjs +17 -0
- package/dist/PageInsertBlankInput-CXHAM7l6.cjs.map +1 -0
- package/dist/PageInsertBlankInput-DhVYVJ_S.js +12 -0
- package/dist/PageInsertBlankInput-DhVYVJ_S.js.map +1 -0
- package/dist/authority-BFp6XM04.cjs +2997 -0
- package/dist/authority-BFp6XM04.cjs.map +1 -0
- package/dist/authority-PuxpGFhJ.js +2506 -0
- package/dist/authority-PuxpGFhJ.js.map +1 -0
- package/dist/builders-DV62HA3I.js +165 -0
- package/dist/builders-DV62HA3I.js.map +1 -0
- package/dist/builders-DgTAj_tP.cjs +188 -0
- package/dist/builders-DgTAj_tP.cjs.map +1 -0
- package/dist/calibrate-DJbi1wuK.cjs +3012 -0
- package/dist/calibrate-DJbi1wuK.cjs.map +1 -0
- package/dist/calibrate-nQFgCuki.js +2461 -0
- package/dist/calibrate-nQFgCuki.js.map +1 -0
- package/dist/charmap-Cprti1ta.js +239 -0
- package/dist/charmap-Cprti1ta.js.map +1 -0
- package/dist/charmap-aYlefQP9.cjs +304 -0
- package/dist/charmap-aYlefQP9.cjs.map +1 -0
- package/dist/conformance.cjs +18146 -5258
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +1024 -170
- package/dist/conformance.d.ts +1024 -170
- package/dist/conformance.js +18148 -5309
- package/dist/conformance.js.map +1 -1
- package/dist/format-Bp3QFSH1.cjs +574 -0
- package/dist/format-Bp3QFSH1.cjs.map +1 -0
- package/dist/format-Dgg428Kb.js +461 -0
- package/dist/format-Dgg428Kb.js.map +1 -0
- package/dist/index.cjs +342 -116
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -5
- package/dist/pageRefs-B3ur7Ckm.cjs +51 -0
- package/dist/pageRefs-B3ur7Ckm.cjs.map +1 -0
- package/dist/pageRefs-DkbuxSCV.js +40 -0
- package/dist/pageRefs-DkbuxSCV.js.map +1 -0
- package/dist/public.cjs +59 -0
- package/dist/public.d.cts +5 -0
- package/dist/public.d.ts +5 -0
- package/dist/public.js +9 -0
- package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs +3646 -0
- package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs.map +1 -0
- package/dist/resolveAnnotationDraft-CUpf0SMh.js +3167 -0
- package/dist/resolveAnnotationDraft-CUpf0SMh.js.map +1 -0
- package/dist/{resolver-inAVzsWt.js → resolver-BBggAxQc.js} +298 -145
- package/dist/resolver-BBggAxQc.js.map +1 -0
- package/dist/{resolver-CYVNV4hn.cjs → resolver-BWSWSF6R.cjs} +351 -144
- package/dist/resolver-BWSWSF6R.cjs.map +1 -0
- package/dist/runtime-BaDKjxiu.d.ts +1959 -0
- package/dist/runtime-CWEuiwbk.d.cts +1959 -0
- package/dist/runtime.cjs +986 -297
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +5 -1372
- package/dist/runtime.d.ts +5 -1372
- package/dist/runtime.js +634 -179
- package/dist/runtime.js.map +1 -1
- package/dist/schema-6S2VmlAj.js +2087 -0
- package/dist/schema-6S2VmlAj.js.map +1 -0
- package/dist/schema-miH6tWQC.cjs +3046 -0
- package/dist/schema-miH6tWQC.cjs.map +1 -0
- package/dist/schemas-BE2QGOit.js +1851 -0
- package/dist/schemas-BE2QGOit.js.map +1 -0
- package/dist/schemas-DljJR9ut.cjs +2798 -0
- package/dist/schemas-DljJR9ut.cjs.map +1 -0
- package/dist/subtype-CG4WpIRj.js +129 -0
- package/dist/subtype-CG4WpIRj.js.map +1 -0
- package/dist/subtype-aDt5TFmK.cjs +158 -0
- package/dist/subtype-aDt5TFmK.cjs.map +1 -0
- package/dist/validation.cjs +578 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.d.cts +174 -0
- package/dist/validation.d.ts +174 -0
- package/dist/validation.js +571 -0
- package/dist/validation.js.map +1 -0
- package/dist/value-BFS1R8ek.cjs +435 -0
- package/dist/value-BFS1R8ek.cjs.map +1 -0
- package/dist/value-Dhc8eYcx.js +340 -0
- package/dist/value-Dhc8eYcx.js.map +1 -0
- package/dist/viewport-CHG9qQUb.cjs +671 -0
- package/dist/viewport-CHG9qQUb.cjs.map +1 -0
- package/dist/viewport-DQR5LyX3.js +540 -0
- package/dist/viewport-DQR5LyX3.js.map +1 -0
- package/dist/wire.cjs +1242 -420
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +14840 -830
- package/dist/wire.d.ts +14840 -830
- package/dist/wire.js +985 -261
- package/dist/wire.js.map +1 -1
- package/package.json +10 -1
- package/dist/AbortError-DwuHPK_I.js +0 -27
- package/dist/AbortError-DwuHPK_I.js.map +0 -1
- package/dist/AbortError-P0RU0Mgg.cjs +0 -38
- package/dist/AbortError-P0RU0Mgg.cjs.map +0 -1
- package/dist/AnnotationListSnapshot-D9R5n2Kf.d.cts +0 -7101
- package/dist/AnnotationListSnapshot-D9R5n2Kf.d.ts +0 -7101
- package/dist/Engine-EWWHhEIi.d.ts +0 -1277
- package/dist/Engine-FNaAEjfb.d.cts +0 -1277
- package/dist/derive-BbsDk_Kz.cjs +0 -880
- package/dist/derive-BbsDk_Kz.cjs.map +0 -1
- package/dist/derive-DAFJolWu.js +0 -647
- package/dist/derive-DAFJolWu.js.map +0 -1
- package/dist/format-Bbphf4zR.js +0 -435
- package/dist/format-Bbphf4zR.js.map +0 -1
- package/dist/format-D_epWlob.cjs +0 -518
- package/dist/format-D_epWlob.cjs.map +0 -1
- package/dist/resolver-CYVNV4hn.cjs.map +0 -1
- package/dist/resolver-inAVzsWt.js.map +0 -1
- package/dist/schemas-CFQGvWiu.js +0 -3243
- package/dist/schemas-CFQGvWiu.js.map +0 -1
- package/dist/schemas-D0g6tKa9.cjs +0 -4694
- package/dist/schemas-D0g6tKa9.cjs.map +0 -1
- package/dist/viewport-BWeNHZmb.cjs +0 -3503
- package/dist/viewport-BWeNHZmb.cjs.map +0 -1
- package/dist/viewport-CvMcadfQ.js +0 -3072
- package/dist/viewport-CvMcadfQ.js.map +0 -1
|
@@ -0,0 +1,2087 @@
|
|
|
1
|
+
import { c as STANDARD_FONTS, n as validNumberFormat } from "./format-Dgg428Kb.js";
|
|
2
|
+
import { i as PdfAnnotationSubtypeCode } from "./subtype-CG4WpIRj.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/identity/PageRef.schema.ts
|
|
5
|
+
/** Wire form of `PageRef` — see the type. */
|
|
6
|
+
const PageRefSchema = z.object({
|
|
7
|
+
kind: z.literal("objectNumber"),
|
|
8
|
+
objectNumber: z.number().int().positive()
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/geometry/schemas.ts
|
|
12
|
+
/**
|
|
13
|
+
* Zod schemas for engine PDF-document geometry. Exported from `wire.ts` only
|
|
14
|
+
* (never from `shared.ts`/`runtime`) so the zod-free runtime stays zod-free.
|
|
15
|
+
*/
|
|
16
|
+
const PdfPointSchema = z.object({
|
|
17
|
+
x: z.number(),
|
|
18
|
+
y: z.number()
|
|
19
|
+
});
|
|
20
|
+
const LinePointsSchema = z.object({
|
|
21
|
+
start: PdfPointSchema,
|
|
22
|
+
end: PdfPointSchema
|
|
23
|
+
});
|
|
24
|
+
/** `/CL` callout leader line — two points (straight) or three (knee-jointed). */
|
|
25
|
+
const CalloutLineSchema = z.union([z.tuple([PdfPointSchema, PdfPointSchema]), z.tuple([
|
|
26
|
+
PdfPointSchema,
|
|
27
|
+
PdfPointSchema,
|
|
28
|
+
PdfPointSchema
|
|
29
|
+
])]);
|
|
30
|
+
/** `/InkList` — an array of strokes, each an array of points. */
|
|
31
|
+
const InkListSchema = z.array(z.array(PdfPointSchema));
|
|
32
|
+
/** A rect's edges are finite, as `isFinitePdfRect` checks them on the page. */
|
|
33
|
+
const PdfRectSchema = z.object({
|
|
34
|
+
left: z.number().finite(),
|
|
35
|
+
bottom: z.number().finite(),
|
|
36
|
+
right: z.number().finite(),
|
|
37
|
+
top: z.number().finite()
|
|
38
|
+
});
|
|
39
|
+
const PdfSizeSchema = z.object({
|
|
40
|
+
width: z.number().nonnegative(),
|
|
41
|
+
height: z.number().nonnegative()
|
|
42
|
+
});
|
|
43
|
+
const PdfQuadSchema = z.object({
|
|
44
|
+
upperLeft: PdfPointSchema,
|
|
45
|
+
upperRight: PdfPointSchema,
|
|
46
|
+
lowerLeft: PdfPointSchema,
|
|
47
|
+
lowerRight: PdfPointSchema
|
|
48
|
+
});
|
|
49
|
+
const PdfRotationSchema = z.union([
|
|
50
|
+
z.literal(0),
|
|
51
|
+
z.literal(90),
|
|
52
|
+
z.literal(180),
|
|
53
|
+
z.literal(270)
|
|
54
|
+
]);
|
|
55
|
+
const PagePointSchema = z.object({
|
|
56
|
+
x: z.number(),
|
|
57
|
+
y: z.number()
|
|
58
|
+
});
|
|
59
|
+
/** A box is finite, as a rect is (`PdfRectSchema`). */
|
|
60
|
+
const PageBoxSchema = z.object({
|
|
61
|
+
x: z.number().finite(),
|
|
62
|
+
y: z.number().finite(),
|
|
63
|
+
width: z.number().finite().nonnegative(),
|
|
64
|
+
height: z.number().finite().nonnegative()
|
|
65
|
+
});
|
|
66
|
+
const PageQuadSchema = z.object({
|
|
67
|
+
upperLeft: PagePointSchema,
|
|
68
|
+
upperRight: PagePointSchema,
|
|
69
|
+
lowerLeft: PagePointSchema,
|
|
70
|
+
lowerRight: PagePointSchema
|
|
71
|
+
});
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/annotation/base.schema.ts
|
|
74
|
+
/** @deprecated Use `PdfPointSchema` from `../geometry/schemas`. */
|
|
75
|
+
const PointSchema = PdfPointSchema;
|
|
76
|
+
/** @deprecated Use `PdfRectSchema` from `../geometry/schemas`. */
|
|
77
|
+
const RectSchema = PdfRectSchema;
|
|
78
|
+
const ColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/, "expected a color as '#rrggbb'");
|
|
79
|
+
const AnnotationBorderStyleSchema = z.enum([
|
|
80
|
+
"solid",
|
|
81
|
+
"dashed",
|
|
82
|
+
"beveled",
|
|
83
|
+
"inset"
|
|
84
|
+
]);
|
|
85
|
+
const WidgetBorderStyleSchema = z.enum([
|
|
86
|
+
"solid",
|
|
87
|
+
"dashed",
|
|
88
|
+
"beveled",
|
|
89
|
+
"inset",
|
|
90
|
+
"underline"
|
|
91
|
+
]);
|
|
92
|
+
const WidgetCheckStyleSchema = z.enum([
|
|
93
|
+
"check",
|
|
94
|
+
"cross",
|
|
95
|
+
"star",
|
|
96
|
+
"circle",
|
|
97
|
+
"square",
|
|
98
|
+
"diamond"
|
|
99
|
+
]);
|
|
100
|
+
/** What a write takes for a border that isn't a widget's. */
|
|
101
|
+
const DrawnBorderStyleSchema = z.enum(["solid", "dashed"]);
|
|
102
|
+
const LineEndingSchema = z.enum([
|
|
103
|
+
"none",
|
|
104
|
+
"square",
|
|
105
|
+
"circle",
|
|
106
|
+
"diamond",
|
|
107
|
+
"open-arrow",
|
|
108
|
+
"closed-arrow",
|
|
109
|
+
"butt",
|
|
110
|
+
"r-open-arrow",
|
|
111
|
+
"r-closed-arrow",
|
|
112
|
+
"slash"
|
|
113
|
+
]);
|
|
114
|
+
const LineEndingsSchema = z.object({
|
|
115
|
+
start: LineEndingSchema,
|
|
116
|
+
end: LineEndingSchema
|
|
117
|
+
});
|
|
118
|
+
const StandardFontSchema = z.enum(STANDARD_FONTS);
|
|
119
|
+
const TextAlignmentSchema = z.enum([
|
|
120
|
+
"left",
|
|
121
|
+
"center",
|
|
122
|
+
"right"
|
|
123
|
+
]);
|
|
124
|
+
const FreeTextIntentSchema = z.enum([
|
|
125
|
+
"free-text",
|
|
126
|
+
"free-text-callout",
|
|
127
|
+
"free-text-typewriter"
|
|
128
|
+
]);
|
|
129
|
+
/** The intents a write makes: a typewriter is only sent back as read. */
|
|
130
|
+
const FreeTextIntentWriteSchema = z.enum(["free-text", "free-text-callout"]);
|
|
131
|
+
const VerticalAlignmentSchema = z.enum([
|
|
132
|
+
"top",
|
|
133
|
+
"middle",
|
|
134
|
+
"bottom"
|
|
135
|
+
]);
|
|
136
|
+
const CaretIntentSchema = z.literal("replace");
|
|
137
|
+
const StrikeoutIntentSchema = z.literal("strikeout-text-edit");
|
|
138
|
+
const InkIntentSchema = z.literal("ink-highlight");
|
|
139
|
+
const BlendModeSchema = z.enum([
|
|
140
|
+
"normal",
|
|
141
|
+
"multiply",
|
|
142
|
+
"screen",
|
|
143
|
+
"overlay",
|
|
144
|
+
"darken",
|
|
145
|
+
"lighten",
|
|
146
|
+
"color-dodge",
|
|
147
|
+
"color-burn",
|
|
148
|
+
"hard-light",
|
|
149
|
+
"soft-light",
|
|
150
|
+
"difference",
|
|
151
|
+
"exclusion",
|
|
152
|
+
"hue",
|
|
153
|
+
"saturation",
|
|
154
|
+
"color",
|
|
155
|
+
"luminosity"
|
|
156
|
+
]);
|
|
157
|
+
const AnnotationRefSchema = z.discriminatedUnion("kind", [z.object({
|
|
158
|
+
kind: z.literal("objectNumber"),
|
|
159
|
+
page: PageRefSchema,
|
|
160
|
+
objectNumber: z.number().int().positive()
|
|
161
|
+
}), z.object({
|
|
162
|
+
kind: z.literal("baseIndex"),
|
|
163
|
+
page: PageRefSchema,
|
|
164
|
+
baseIndex: z.number().int().nonnegative()
|
|
165
|
+
})]);
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/dto/PdfDestination.schema.ts
|
|
168
|
+
const page = PageRefSchema;
|
|
169
|
+
/** Spec-nullable axis value: absent and `null` both mean "retain current". */
|
|
170
|
+
const axis = z.number().nullable().optional();
|
|
171
|
+
/**
|
|
172
|
+
* Runtime schema for {@link PdfDestination}. Lives beside its DTO in `dto/`
|
|
173
|
+
* so every destination-shaped surface (link targets, action-node payloads,
|
|
174
|
+
* the document `openDestination`) shares one schema without an import cycle
|
|
175
|
+
* through the annotation tree.
|
|
176
|
+
*/
|
|
177
|
+
const PdfDestinationSchema = z.discriminatedUnion("kind", [
|
|
178
|
+
z.object({
|
|
179
|
+
kind: z.literal("xyz"),
|
|
180
|
+
page,
|
|
181
|
+
left: axis,
|
|
182
|
+
top: axis,
|
|
183
|
+
zoom: axis
|
|
184
|
+
}),
|
|
185
|
+
z.object({
|
|
186
|
+
kind: z.literal("fit"),
|
|
187
|
+
page
|
|
188
|
+
}),
|
|
189
|
+
z.object({
|
|
190
|
+
kind: z.literal("fitH"),
|
|
191
|
+
page,
|
|
192
|
+
top: axis
|
|
193
|
+
}),
|
|
194
|
+
z.object({
|
|
195
|
+
kind: z.literal("fitV"),
|
|
196
|
+
page,
|
|
197
|
+
left: axis
|
|
198
|
+
}),
|
|
199
|
+
z.object({
|
|
200
|
+
kind: z.literal("fitR"),
|
|
201
|
+
page,
|
|
202
|
+
left: z.number(),
|
|
203
|
+
bottom: z.number(),
|
|
204
|
+
right: z.number(),
|
|
205
|
+
top: z.number()
|
|
206
|
+
}),
|
|
207
|
+
z.object({
|
|
208
|
+
kind: z.literal("fitB"),
|
|
209
|
+
page
|
|
210
|
+
}),
|
|
211
|
+
z.object({
|
|
212
|
+
kind: z.literal("fitBH"),
|
|
213
|
+
page,
|
|
214
|
+
top: axis
|
|
215
|
+
}),
|
|
216
|
+
z.object({
|
|
217
|
+
kind: z.literal("fitBV"),
|
|
218
|
+
page,
|
|
219
|
+
left: axis
|
|
220
|
+
})
|
|
221
|
+
]);
|
|
222
|
+
/** A destination in page space: measured from the top-left of its page's visible box. */
|
|
223
|
+
const PageDestinationSchema = z.discriminatedUnion("kind", [
|
|
224
|
+
z.object({
|
|
225
|
+
kind: z.literal("xyz"),
|
|
226
|
+
page,
|
|
227
|
+
x: axis,
|
|
228
|
+
y: axis,
|
|
229
|
+
zoom: axis
|
|
230
|
+
}),
|
|
231
|
+
z.object({
|
|
232
|
+
kind: z.literal("fit"),
|
|
233
|
+
page
|
|
234
|
+
}),
|
|
235
|
+
z.object({
|
|
236
|
+
kind: z.literal("fitH"),
|
|
237
|
+
page,
|
|
238
|
+
y: axis
|
|
239
|
+
}),
|
|
240
|
+
z.object({
|
|
241
|
+
kind: z.literal("fitV"),
|
|
242
|
+
page,
|
|
243
|
+
x: axis
|
|
244
|
+
}),
|
|
245
|
+
z.object({
|
|
246
|
+
kind: z.literal("fitR"),
|
|
247
|
+
page,
|
|
248
|
+
x: z.number(),
|
|
249
|
+
y: z.number(),
|
|
250
|
+
width: z.number().nonnegative(),
|
|
251
|
+
height: z.number().nonnegative()
|
|
252
|
+
}),
|
|
253
|
+
z.object({
|
|
254
|
+
kind: z.literal("fitB"),
|
|
255
|
+
page
|
|
256
|
+
}),
|
|
257
|
+
z.object({
|
|
258
|
+
kind: z.literal("fitBH"),
|
|
259
|
+
page,
|
|
260
|
+
y: axis
|
|
261
|
+
}),
|
|
262
|
+
z.object({
|
|
263
|
+
kind: z.literal("fitBV"),
|
|
264
|
+
page,
|
|
265
|
+
x: axis
|
|
266
|
+
})
|
|
267
|
+
]);
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/annotation/kinds/link/values.ts
|
|
270
|
+
/** A link target's two schemas, a read and a write, for destinations of one kind. */
|
|
271
|
+
function linkTargetSchemasFor(destination) {
|
|
272
|
+
const goto = z.object({
|
|
273
|
+
kind: z.literal("goto"),
|
|
274
|
+
destination
|
|
275
|
+
});
|
|
276
|
+
const uri = z.object({
|
|
277
|
+
kind: z.literal("uri"),
|
|
278
|
+
uri: z.string()
|
|
279
|
+
});
|
|
280
|
+
const read = z.discriminatedUnion("kind", [
|
|
281
|
+
goto,
|
|
282
|
+
uri,
|
|
283
|
+
z.object({
|
|
284
|
+
kind: z.literal("goto-remote"),
|
|
285
|
+
file: z.string()
|
|
286
|
+
}),
|
|
287
|
+
z.object({
|
|
288
|
+
kind: z.literal("launch"),
|
|
289
|
+
path: z.string()
|
|
290
|
+
}),
|
|
291
|
+
z.object({ kind: z.literal("javascript") }),
|
|
292
|
+
z.object({
|
|
293
|
+
kind: z.literal("named"),
|
|
294
|
+
name: z.string()
|
|
295
|
+
}),
|
|
296
|
+
z.object({ kind: z.literal("unsupported") })
|
|
297
|
+
]);
|
|
298
|
+
/** Drafts and patches author `goto`, `uri` and the standard named verbs; see {@link PdfLinkTargetWritable}. */
|
|
299
|
+
const named = z.object({
|
|
300
|
+
kind: z.literal("named"),
|
|
301
|
+
name: z.enum([
|
|
302
|
+
"NextPage",
|
|
303
|
+
"PrevPage",
|
|
304
|
+
"FirstPage",
|
|
305
|
+
"LastPage"
|
|
306
|
+
])
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
read,
|
|
310
|
+
write: z.discriminatedUnion("kind", [
|
|
311
|
+
goto,
|
|
312
|
+
uri,
|
|
313
|
+
named
|
|
314
|
+
])
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const PAGE_SPACE$1 = linkTargetSchemasFor(PageDestinationSchema);
|
|
318
|
+
const FILE_SPACE = linkTargetSchemasFor(PdfDestinationSchema);
|
|
319
|
+
/** A link's target: a destination in page space. */
|
|
320
|
+
const PdfLinkTargetSchema = PAGE_SPACE$1.read;
|
|
321
|
+
/** What a create or an update may set as a link's target. */
|
|
322
|
+
const PdfLinkTargetWritableSchema = PAGE_SPACE$1.write;
|
|
323
|
+
/** A link's target as the engine reads the file: a destination in the file's coordinates. */
|
|
324
|
+
const FileLinkTargetSchema = FILE_SPACE.read;
|
|
325
|
+
const FileLinkTargetWritableSchema = FILE_SPACE.write;
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/dto/PdfAction.schema.ts
|
|
328
|
+
const PdfActionTargetRefSchema = z.discriminatedUnion("kind", [z.object({
|
|
329
|
+
kind: z.literal("name"),
|
|
330
|
+
name: z.string()
|
|
331
|
+
}), z.object({
|
|
332
|
+
kind: z.literal("objectNumber"),
|
|
333
|
+
objectNumber: z.number().int().positive()
|
|
334
|
+
})]);
|
|
335
|
+
const SubmitFormFlagsSchema = z.object({
|
|
336
|
+
raw: z.number().int().nonnegative(),
|
|
337
|
+
exclude: z.boolean(),
|
|
338
|
+
includeNoValueFields: z.boolean(),
|
|
339
|
+
format: z.enum([
|
|
340
|
+
"fdf",
|
|
341
|
+
"html",
|
|
342
|
+
"xfdf",
|
|
343
|
+
"pdf"
|
|
344
|
+
]),
|
|
345
|
+
method: z.enum(["post", "get"]),
|
|
346
|
+
submitCoordinates: z.boolean(),
|
|
347
|
+
includeAppendSaves: z.boolean(),
|
|
348
|
+
includeAnnotations: z.boolean(),
|
|
349
|
+
canonicalFormat: z.boolean(),
|
|
350
|
+
exclNonUserAnnots: z.boolean(),
|
|
351
|
+
exclFKey: z.boolean(),
|
|
352
|
+
embedForm: z.boolean()
|
|
353
|
+
});
|
|
354
|
+
/**
|
|
355
|
+
* The action schemas for one kind of destination: in the file's coordinates
|
|
356
|
+
* or in page space. Everything but a `goto`'s destination is the same.
|
|
357
|
+
*/
|
|
358
|
+
function actionSchemasFor(destination) {
|
|
359
|
+
/** Fields every node arm repeats — zod 3's discriminatedUnion needs plain
|
|
360
|
+
* object options, so the recursion (`next`) lives inline per arm and the
|
|
361
|
+
* whole union sits behind one `z.lazy`. */
|
|
362
|
+
const nodeCommon = {
|
|
363
|
+
subtype: z.string(),
|
|
364
|
+
next: z.array(z.lazy(() => node))
|
|
365
|
+
};
|
|
366
|
+
const arm = (type, shape = {}) => z.object({
|
|
367
|
+
type: z.literal(type),
|
|
368
|
+
...nodeCommon,
|
|
369
|
+
...shape
|
|
370
|
+
});
|
|
371
|
+
const arms = [
|
|
372
|
+
arm("javascript", { script: z.string() }),
|
|
373
|
+
arm("goto", { destination }),
|
|
374
|
+
arm("uri", {
|
|
375
|
+
uri: z.string(),
|
|
376
|
+
isMap: z.boolean()
|
|
377
|
+
}),
|
|
378
|
+
arm("named", { name: z.string() }),
|
|
379
|
+
arm("hide", {
|
|
380
|
+
targets: z.array(PdfActionTargetRefSchema),
|
|
381
|
+
hide: z.boolean()
|
|
382
|
+
}),
|
|
383
|
+
arm("reset-form", {
|
|
384
|
+
fields: z.array(PdfActionTargetRefSchema).nullable(),
|
|
385
|
+
exclude: z.boolean()
|
|
386
|
+
}),
|
|
387
|
+
arm("goto-remote", { filePath: z.string() }),
|
|
388
|
+
arm("goto-embedded", { filePath: z.string() }),
|
|
389
|
+
arm("launch", { filePath: z.string() }),
|
|
390
|
+
arm("rendition", { script: z.string().optional() }),
|
|
391
|
+
arm("submit-form", { payload: z.object({
|
|
392
|
+
url: z.string(),
|
|
393
|
+
fields: z.array(PdfActionTargetRefSchema).nullable(),
|
|
394
|
+
flags: SubmitFormFlagsSchema,
|
|
395
|
+
charSet: z.string().optional()
|
|
396
|
+
}).optional() }),
|
|
397
|
+
arm("thread"),
|
|
398
|
+
arm("sound"),
|
|
399
|
+
arm("movie"),
|
|
400
|
+
arm("import-data"),
|
|
401
|
+
arm("set-ocg-state"),
|
|
402
|
+
arm("transition"),
|
|
403
|
+
arm("goto-3d-view"),
|
|
404
|
+
arm("unknown")
|
|
405
|
+
];
|
|
406
|
+
const node = z.lazy(() => z.discriminatedUnion("type", [...arms]));
|
|
407
|
+
const tree = z.object({
|
|
408
|
+
root: node.nullable(),
|
|
409
|
+
incomplete: z.boolean(),
|
|
410
|
+
warningFlags: z.number().int().nonnegative(),
|
|
411
|
+
warnings: z.array(z.enum([
|
|
412
|
+
"cycle-dropped",
|
|
413
|
+
"malformed-next",
|
|
414
|
+
"incomplete",
|
|
415
|
+
"payload-dropped"
|
|
416
|
+
]))
|
|
417
|
+
});
|
|
418
|
+
return {
|
|
419
|
+
arms,
|
|
420
|
+
node,
|
|
421
|
+
tree,
|
|
422
|
+
fieldActions: z.object({
|
|
423
|
+
keystroke: tree.optional(),
|
|
424
|
+
format: tree.optional(),
|
|
425
|
+
validate: tree.optional(),
|
|
426
|
+
calculate: tree.optional()
|
|
427
|
+
}),
|
|
428
|
+
pageActions: z.object({
|
|
429
|
+
open: tree.optional(),
|
|
430
|
+
close: tree.optional()
|
|
431
|
+
}),
|
|
432
|
+
annotationActions: z.object({
|
|
433
|
+
activate: tree.optional(),
|
|
434
|
+
cursorEnter: tree.optional(),
|
|
435
|
+
cursorExit: tree.optional(),
|
|
436
|
+
mouseDown: tree.optional(),
|
|
437
|
+
mouseUp: tree.optional(),
|
|
438
|
+
focus: tree.optional(),
|
|
439
|
+
blur: tree.optional(),
|
|
440
|
+
pageOpen: tree.optional(),
|
|
441
|
+
pageClose: tree.optional(),
|
|
442
|
+
pageVisible: tree.optional(),
|
|
443
|
+
pageInvisible: tree.optional()
|
|
444
|
+
}),
|
|
445
|
+
documentActions: z.object({
|
|
446
|
+
nameTreeScripts: z.array(z.object({
|
|
447
|
+
name: z.string(),
|
|
448
|
+
action: tree
|
|
449
|
+
})),
|
|
450
|
+
openAction: tree.nullable(),
|
|
451
|
+
openDestination: destination.nullable().default(null),
|
|
452
|
+
willClose: tree.optional(),
|
|
453
|
+
willSave: tree.optional(),
|
|
454
|
+
didSave: tree.optional(),
|
|
455
|
+
willPrint: tree.optional(),
|
|
456
|
+
didPrint: tree.optional()
|
|
457
|
+
}).superRefine((snapshot, context) => {
|
|
458
|
+
if (snapshot.openAction !== null && (snapshot.openDestination ?? null) !== null) context.addIssue({
|
|
459
|
+
code: z.ZodIssueCode.custom,
|
|
460
|
+
message: "openAction and openDestination are mutually exclusive",
|
|
461
|
+
path: ["openDestination"]
|
|
462
|
+
});
|
|
463
|
+
})
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
const PAGE_SPACE = actionSchemasFor(PageDestinationSchema);
|
|
467
|
+
const PDF_SPACE = actionSchemasFor(PdfDestinationSchema);
|
|
468
|
+
/**
|
|
469
|
+
* The write schemas for one kind of destination: an action a write makes,
|
|
470
|
+
* and a widget's actions patch.
|
|
471
|
+
*/
|
|
472
|
+
function actionWriteSchemasFor(destination) {
|
|
473
|
+
const next = () => ({ next: z.array(z.lazy(() => node)).optional() });
|
|
474
|
+
const arms = [
|
|
475
|
+
z.object({
|
|
476
|
+
type: z.literal("javascript"),
|
|
477
|
+
script: z.string(),
|
|
478
|
+
...next()
|
|
479
|
+
}),
|
|
480
|
+
z.object({
|
|
481
|
+
type: z.literal("goto"),
|
|
482
|
+
destination,
|
|
483
|
+
...next()
|
|
484
|
+
}),
|
|
485
|
+
z.object({
|
|
486
|
+
type: z.literal("uri"),
|
|
487
|
+
uri: z.string().min(1),
|
|
488
|
+
...next()
|
|
489
|
+
}),
|
|
490
|
+
z.object({
|
|
491
|
+
type: z.literal("named"),
|
|
492
|
+
name: z.string().min(1),
|
|
493
|
+
...next()
|
|
494
|
+
}),
|
|
495
|
+
z.object({
|
|
496
|
+
type: z.literal("hide"),
|
|
497
|
+
targets: z.array(PdfActionTargetRefSchema).min(1),
|
|
498
|
+
hide: z.boolean(),
|
|
499
|
+
...next()
|
|
500
|
+
}),
|
|
501
|
+
z.object({
|
|
502
|
+
type: z.literal("reset-form"),
|
|
503
|
+
fields: z.array(PdfActionTargetRefSchema).nullable(),
|
|
504
|
+
exclude: z.boolean(),
|
|
505
|
+
...next()
|
|
506
|
+
}),
|
|
507
|
+
z.object({
|
|
508
|
+
type: z.literal("submit-form"),
|
|
509
|
+
url: z.string().min(1),
|
|
510
|
+
fields: z.array(PdfActionTargetRefSchema).nullable(),
|
|
511
|
+
flags: z.number().int().nonnegative().optional(),
|
|
512
|
+
...next()
|
|
513
|
+
})
|
|
514
|
+
];
|
|
515
|
+
const node = z.lazy(() => z.discriminatedUnion("type", [...arms]));
|
|
516
|
+
const event = () => node.nullable().optional();
|
|
517
|
+
return {
|
|
518
|
+
node,
|
|
519
|
+
widgetActions: z.object({
|
|
520
|
+
activate: event(),
|
|
521
|
+
cursorEnter: event(),
|
|
522
|
+
cursorExit: event(),
|
|
523
|
+
mouseDown: event(),
|
|
524
|
+
mouseUp: event(),
|
|
525
|
+
focus: event(),
|
|
526
|
+
blur: event(),
|
|
527
|
+
pageOpen: event(),
|
|
528
|
+
pageClose: event(),
|
|
529
|
+
pageVisible: event(),
|
|
530
|
+
pageInvisible: event()
|
|
531
|
+
}).strict()
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
const PAGE_SPACE_WRITES = actionWriteSchemasFor(PageDestinationSchema);
|
|
535
|
+
const PDF_SPACE_WRITES = actionWriteSchemasFor(PdfDestinationSchema);
|
|
536
|
+
/** An action a write makes, its destinations in page space. */
|
|
537
|
+
const PdfActionWriteSchema = PAGE_SPACE_WRITES.node;
|
|
538
|
+
/** A widget's actions to write, by event, their destinations in page space. */
|
|
539
|
+
const WidgetActionsPatchSchema = PAGE_SPACE_WRITES.widgetActions;
|
|
540
|
+
/** A widget's actions to write, as the engine writes the file: destinations in its coordinates. */
|
|
541
|
+
const FileWidgetActionsPatchSchema = PDF_SPACE_WRITES.widgetActions;
|
|
542
|
+
const PdfActionNodeSchema = PAGE_SPACE.node;
|
|
543
|
+
/** The `/S` vocabulary, derived from the union arms so it cannot drift. */
|
|
544
|
+
const PdfActionTypeSchema = z.enum(PAGE_SPACE.arms.map((option) => option.shape.type.value));
|
|
545
|
+
const PdfActionTreeSchema = PAGE_SPACE.tree;
|
|
546
|
+
const PdfFieldActionsSchema = PAGE_SPACE.fieldActions;
|
|
547
|
+
const PdfPageActionsSchema = PAGE_SPACE.pageActions;
|
|
548
|
+
const DocumentActionsSnapshotSchema = PAGE_SPACE.documentActions;
|
|
549
|
+
/** An annotation's actions (`/A`, `/AA`), their destinations in page space. */
|
|
550
|
+
const PdfAnnotationActionsSchema = PAGE_SPACE.annotationActions;
|
|
551
|
+
/** An annotation's actions as the engine reads the file: destinations in the file's coordinates. */
|
|
552
|
+
const FileAnnotationActionsSchema = PDF_SPACE.annotationActions;
|
|
553
|
+
/**
|
|
554
|
+
* A field event's script: JavaScript all through. Any other action type is
|
|
555
|
+
* refused here, at the boundary.
|
|
556
|
+
*/
|
|
557
|
+
const FieldScriptWriteSchema = z.lazy(() => z.object({
|
|
558
|
+
type: z.literal("javascript"),
|
|
559
|
+
script: z.string(),
|
|
560
|
+
next: z.array(FieldScriptWriteSchema).optional()
|
|
561
|
+
}));
|
|
562
|
+
/** A field's scripts to write, by event: a script sets one, `null` removes it. */
|
|
563
|
+
const FieldActionsPatchSchema = z.object({
|
|
564
|
+
keystroke: FieldScriptWriteSchema.nullable().optional(),
|
|
565
|
+
format: FieldScriptWriteSchema.nullable().optional(),
|
|
566
|
+
validate: FieldScriptWriteSchema.nullable().optional(),
|
|
567
|
+
calculate: FieldScriptWriteSchema.nullable().optional()
|
|
568
|
+
});
|
|
569
|
+
/**
|
|
570
|
+
* Stable public component names for generators that project the action wire
|
|
571
|
+
* model into OpenAPI or another schema format. Keep reusable boundaries here;
|
|
572
|
+
* individual action arms remain owned by `PdfActionNodeSchema`.
|
|
573
|
+
*/
|
|
574
|
+
const PdfActionWireComponents = {
|
|
575
|
+
PdfActionTargetRef: PdfActionTargetRefSchema,
|
|
576
|
+
PageDestination: PageDestinationSchema,
|
|
577
|
+
PdfActionNode: PdfActionNodeSchema,
|
|
578
|
+
PdfActionTree: PdfActionTreeSchema,
|
|
579
|
+
PdfFieldActions: PdfFieldActionsSchema,
|
|
580
|
+
PdfPageActions: PdfPageActionsSchema,
|
|
581
|
+
PdfAnnotationActions: PdfAnnotationActionsSchema,
|
|
582
|
+
DocumentActionsSnapshot: DocumentActionsSnapshotSchema,
|
|
583
|
+
FieldScriptWrite: FieldScriptWriteSchema,
|
|
584
|
+
FieldActionsPatch: FieldActionsPatchSchema,
|
|
585
|
+
PdfActionWrite: PdfActionWriteSchema,
|
|
586
|
+
WidgetActionsPatch: WidgetActionsPatchSchema
|
|
587
|
+
};
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/annotation/declaration.ts
|
|
590
|
+
function createField(read, write, traits) {
|
|
591
|
+
const next = (changed) => createField(read, write, {
|
|
592
|
+
...traits,
|
|
593
|
+
...changed
|
|
594
|
+
});
|
|
595
|
+
return {
|
|
596
|
+
read,
|
|
597
|
+
write,
|
|
598
|
+
traits,
|
|
599
|
+
nullable: () => next({
|
|
600
|
+
readNullable: true,
|
|
601
|
+
writeNullable: true
|
|
602
|
+
}),
|
|
603
|
+
nullableOnRead: () => next({ readNullable: true }),
|
|
604
|
+
optional: () => next({ required: false }),
|
|
605
|
+
createOnly: () => next({ createOnly: true }),
|
|
606
|
+
readBack: () => next({ readBack: true }),
|
|
607
|
+
space: (space) => next({ space }),
|
|
608
|
+
writes: (schema) => createField(read, schema, traits)
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const ownedBy = (owner, required) => ({
|
|
612
|
+
owner,
|
|
613
|
+
readNullable: false,
|
|
614
|
+
writeNullable: false,
|
|
615
|
+
required,
|
|
616
|
+
createOnly: false,
|
|
617
|
+
readBack: false,
|
|
618
|
+
space: "none"
|
|
619
|
+
});
|
|
620
|
+
/** Field builders for {@link defineKind}. */
|
|
621
|
+
const field = {
|
|
622
|
+
/** Written by the caller. Required on create until marked `optional()`. */
|
|
623
|
+
data: (schema) => createField(schema, schema, ownedBy("data", true)),
|
|
624
|
+
/** Stamped by the engine from the session's identity. */
|
|
625
|
+
attribution: (schema) => createField(schema, schema, ownedBy("attribution", false)),
|
|
626
|
+
/** Written only by the engine. */
|
|
627
|
+
engine: (schema) => createField(schema, schema, ownedBy("engine", false)),
|
|
628
|
+
/** Read from the PDF and kept in place, but not writable. */
|
|
629
|
+
preserved: (schema) => createField(schema, schema, ownedBy("preserved", false))
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* The page-space schema of a field that holds a box or destinations, whose
|
|
633
|
+
* shape differs from the file's: a box is `{ x, y, width, height }`, and a
|
|
634
|
+
* destination is measured from its page's top-left. Every other place has
|
|
635
|
+
* the same shape in both spaces.
|
|
636
|
+
*/
|
|
637
|
+
const PAGE_SPACE_SCHEMAS = {
|
|
638
|
+
box: {
|
|
639
|
+
read: PageBoxSchema,
|
|
640
|
+
write: PageBoxSchema
|
|
641
|
+
},
|
|
642
|
+
linkTarget: {
|
|
643
|
+
read: PdfLinkTargetSchema,
|
|
644
|
+
write: PdfLinkTargetWritableSchema
|
|
645
|
+
},
|
|
646
|
+
actions: {
|
|
647
|
+
read: PdfAnnotationActionsSchema,
|
|
648
|
+
write: WidgetActionsPatchSchema
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
/** The zod shapes of a kind's fields, each field's schemas given by `schemasOf`. */
|
|
652
|
+
function shapesOf(subtype, fields, schemasOf) {
|
|
653
|
+
const read = { subtype: z.literal(subtype) };
|
|
654
|
+
const create = { subtype: z.literal(subtype) };
|
|
655
|
+
const update = { subtype: z.literal(subtype).optional() };
|
|
656
|
+
const readBackWrites = {};
|
|
657
|
+
for (const [name, spec] of Object.entries(fields)) {
|
|
658
|
+
const { owner, readNullable, writeNullable, required, readBack } = spec.traits;
|
|
659
|
+
const schemas = schemasOf(spec);
|
|
660
|
+
read[name] = readNullable ? schemas.read.nullable() : schemas.read;
|
|
661
|
+
if (owner === "data") {
|
|
662
|
+
const write = writeNullable ? schemas.write.nullable() : schemas.write;
|
|
663
|
+
create[name] = required ? write : write.optional();
|
|
664
|
+
const readBackUpdate = schemas.read === schemas.write ? readNullable || writeNullable ? schemas.write.nullable() : schemas.write : z.union([write, read[name]]);
|
|
665
|
+
update[name] = (readBack ? readBackUpdate : write).optional();
|
|
666
|
+
if (readBack) readBackWrites[name] = write;
|
|
667
|
+
} else {
|
|
668
|
+
create[name] = readBack ? read[name].optional() : z.unknown().optional();
|
|
669
|
+
update[name] = readBack ? read[name].optional() : z.unknown().optional();
|
|
670
|
+
if (readBack) readBackWrites[name] = null;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return {
|
|
674
|
+
read,
|
|
675
|
+
create,
|
|
676
|
+
update,
|
|
677
|
+
readBackWrites
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Declares an annotation kind from its fields and the resources it takes
|
|
682
|
+
* beside its data. Fields are declared as the file holds them; the page-space
|
|
683
|
+
* schemas follow from what each field holds (`space`).
|
|
684
|
+
*/
|
|
685
|
+
function defineKind(subtype, fields, resources = {}) {
|
|
686
|
+
const file = shapesOf(subtype, fields, (spec) => spec);
|
|
687
|
+
const page = shapesOf(subtype, fields, (spec) => PAGE_SPACE_SCHEMAS[spec.traits.space] ?? spec);
|
|
688
|
+
return {
|
|
689
|
+
subtype,
|
|
690
|
+
fields,
|
|
691
|
+
resources,
|
|
692
|
+
readSchema: z.object(page.read),
|
|
693
|
+
createSchema: z.object(page.create).strict(),
|
|
694
|
+
updateSchema: z.object(page.update).strict(),
|
|
695
|
+
fileSchemas: {
|
|
696
|
+
read: z.object(file.read),
|
|
697
|
+
create: z.object(file.create).strict(),
|
|
698
|
+
update: z.object(file.update).strict()
|
|
699
|
+
},
|
|
700
|
+
readBackWrites: file.readBackWrites,
|
|
701
|
+
shapes: {
|
|
702
|
+
read: page.read,
|
|
703
|
+
create: page.create,
|
|
704
|
+
update: page.update
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/dto/IsoDateTime.schema.ts
|
|
710
|
+
/** ISO 8601 with an offset (`Z` or `±HH:mm`) or without one. */
|
|
711
|
+
const IsoDateTimeSchema = z.string().datetime({
|
|
712
|
+
offset: true,
|
|
713
|
+
local: true
|
|
714
|
+
});
|
|
715
|
+
/**
|
|
716
|
+
* A moment in a write. JSON carries the string; a `Date` only ever arrives
|
|
717
|
+
* in-process (the local engine), and becomes that string on the wire.
|
|
718
|
+
*/
|
|
719
|
+
const DateInputSchema = z.union([IsoDateTimeSchema, z.date()]);
|
|
720
|
+
//#endregion
|
|
721
|
+
//#region src/dto/Measure.schema.ts
|
|
722
|
+
const float = z.number().finite().refine((n) => Number.isFinite(Math.fround(n)), "Outside PDF float range");
|
|
723
|
+
const point = z.object({
|
|
724
|
+
x: float,
|
|
725
|
+
y: float
|
|
726
|
+
}).strict();
|
|
727
|
+
const positive = float.refine((n) => Math.fround(n) > 0, "Must be positive in PDF float precision");
|
|
728
|
+
const PdfNumberFormatSchema = z.object({
|
|
729
|
+
unit: z.string(),
|
|
730
|
+
conversion: float.optional(),
|
|
731
|
+
fraction: z.enum([
|
|
732
|
+
"decimal",
|
|
733
|
+
"fraction",
|
|
734
|
+
"round",
|
|
735
|
+
"truncate"
|
|
736
|
+
]).optional(),
|
|
737
|
+
precision: z.number().int().optional(),
|
|
738
|
+
fixed: z.boolean().optional(),
|
|
739
|
+
thousands: z.string().optional(),
|
|
740
|
+
decimal: z.string().optional(),
|
|
741
|
+
prefixSpacing: z.string().optional(),
|
|
742
|
+
suffixSpacing: z.string().optional(),
|
|
743
|
+
labelPosition: z.enum(["suffix", "prefix"]).optional()
|
|
744
|
+
});
|
|
745
|
+
const PdfMeasureSchema = z.object({
|
|
746
|
+
subtype: z.literal("rectilinear"),
|
|
747
|
+
ratio: z.string().optional(),
|
|
748
|
+
x: z.array(PdfNumberFormatSchema),
|
|
749
|
+
y: z.array(PdfNumberFormatSchema).optional(),
|
|
750
|
+
distance: z.array(PdfNumberFormatSchema),
|
|
751
|
+
area: z.array(PdfNumberFormatSchema),
|
|
752
|
+
angle: z.array(PdfNumberFormatSchema).optional(),
|
|
753
|
+
slope: z.array(PdfNumberFormatSchema).optional(),
|
|
754
|
+
origin: point.optional(),
|
|
755
|
+
cyx: float.optional()
|
|
756
|
+
});
|
|
757
|
+
const writableFormat = PdfNumberFormatSchema.extend({
|
|
758
|
+
conversion: positive,
|
|
759
|
+
precision: z.number().int().min(1).max(2147483647).optional()
|
|
760
|
+
}).refine(validNumberFormat, "Invalid number format precision");
|
|
761
|
+
const PdfMeasureWriteSchema = PdfMeasureSchema.extend({
|
|
762
|
+
x: z.array(writableFormat),
|
|
763
|
+
y: z.array(writableFormat).optional(),
|
|
764
|
+
distance: z.array(writableFormat),
|
|
765
|
+
area: z.array(writableFormat),
|
|
766
|
+
angle: z.array(writableFormat).optional(),
|
|
767
|
+
slope: z.array(writableFormat).optional(),
|
|
768
|
+
cyx: positive.optional()
|
|
769
|
+
});
|
|
770
|
+
const geoMeasure = z.object({ subtype: z.literal("geospatial") });
|
|
771
|
+
const unknownMeasure = z.object({ subtype: z.literal("unknown") });
|
|
772
|
+
const PdfForeignMeasureSchema = z.union([geoMeasure, unknownMeasure]);
|
|
773
|
+
const PageScaleInputSchema = z.object({ measure: PdfMeasureWriteSchema.nullable() });
|
|
774
|
+
const PdfMeasurementSchema = z.discriminatedUnion("subtype", [
|
|
775
|
+
PdfMeasureSchema,
|
|
776
|
+
geoMeasure,
|
|
777
|
+
unknownMeasure
|
|
778
|
+
]);
|
|
779
|
+
const PageMeasurementViewportSchema = z.object({
|
|
780
|
+
bbox: PageBoxSchema,
|
|
781
|
+
name: z.string().nullable(),
|
|
782
|
+
measure: PdfMeasurementSchema.nullable(),
|
|
783
|
+
owned: z.boolean()
|
|
784
|
+
});
|
|
785
|
+
/** See `PageMeasurementViewportList`. */
|
|
786
|
+
const PageMeasurementViewportListSchema = z.object({ viewports: z.array(PageMeasurementViewportSchema) });
|
|
787
|
+
const LineIntentSchema = z.enum(["line-arrow", "line-dimension"]);
|
|
788
|
+
const PolygonIntentSchema = z.enum(["polygon-cloud", "polygon-dimension"]);
|
|
789
|
+
const PolylineIntentSchema = z.literal("polyline-dimension");
|
|
790
|
+
const offset = z.object({
|
|
791
|
+
along: float,
|
|
792
|
+
perpendicular: float
|
|
793
|
+
}).strict();
|
|
794
|
+
const LineDimensionCaptionSchema = z.object({
|
|
795
|
+
enabled: z.boolean(),
|
|
796
|
+
position: z.enum(["inline", "top"]).optional(),
|
|
797
|
+
offset: offset.optional()
|
|
798
|
+
}).strict();
|
|
799
|
+
const ShapeDimensionCaptionSchema = z.object({
|
|
800
|
+
enabled: z.boolean(),
|
|
801
|
+
center: point.optional()
|
|
802
|
+
}).strict();
|
|
803
|
+
const LineCaptionPatchSchema = z.object({
|
|
804
|
+
enabled: z.boolean().optional(),
|
|
805
|
+
position: z.enum(["inline", "top"]).nullable().optional(),
|
|
806
|
+
offset: offset.nullable().optional()
|
|
807
|
+
}).strict();
|
|
808
|
+
const ShapeCaptionPatchSchema = z.object({
|
|
809
|
+
enabled: z.boolean().optional(),
|
|
810
|
+
center: point.nullable().optional()
|
|
811
|
+
}).strict();
|
|
812
|
+
const LineLeaderSchema = z.object({
|
|
813
|
+
length: float,
|
|
814
|
+
extension: float.refine((n) => n >= 0).optional(),
|
|
815
|
+
offset: float.refine((n) => n >= 0).optional()
|
|
816
|
+
}).strict();
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/annotation/kinds/shared-fields.ts
|
|
819
|
+
/** `/IRT` and `/RT`: the annotation this one replies to, and how it relates to it. */
|
|
820
|
+
const AnnotationReplySchema = z.object({
|
|
821
|
+
to: AnnotationRefSchema,
|
|
822
|
+
type: z.enum(["reply", "group"])
|
|
823
|
+
});
|
|
824
|
+
/** A write may leave out `type`: an absent `/RT` means `'reply'` (ISO 32000-2 §12.5.6.2). */
|
|
825
|
+
const AnnotationReplyWriteSchema = z.object({
|
|
826
|
+
to: AnnotationRefSchema,
|
|
827
|
+
type: z.enum(["reply", "group"]).optional()
|
|
828
|
+
});
|
|
829
|
+
/** A standard font name or a registered font key; the writer resolves which. */
|
|
830
|
+
const FontNameSchema = z.string().min(1);
|
|
831
|
+
/** One `/F` bit (ISO 32000-2 §12.5.3); every bit defaults to off. */
|
|
832
|
+
const flag = () => field.data(z.boolean()).optional();
|
|
833
|
+
/** Fields every annotation kind has. */
|
|
834
|
+
const annotationBaseFields = {
|
|
835
|
+
ref: field.engine(AnnotationRefSchema),
|
|
836
|
+
page: field.engine(PageRefSchema),
|
|
837
|
+
/**
|
|
838
|
+
* Whether the file holds its appearance (`/AP /N`). Without one, every
|
|
839
|
+
* viewer draws the annotation from its fields: the engine in memory, never
|
|
840
|
+
* written.
|
|
841
|
+
*/
|
|
842
|
+
hasAppearance: field.engine(z.boolean()),
|
|
843
|
+
/**
|
|
844
|
+
* `/AS`: which state of its appearance the annotation shows, when the
|
|
845
|
+
* appearance has states (a check box's `Off` and its on state); `null`
|
|
846
|
+
* when it names none. The appearance images are labelled with the same
|
|
847
|
+
* names, so this picks the one to show.
|
|
848
|
+
*/
|
|
849
|
+
appearanceState: field.engine(z.string()).nullable(),
|
|
850
|
+
nm: field.data(z.string()).nullable().optional().createOnly(),
|
|
851
|
+
rect: field.data(PdfRectSchema).space("box"),
|
|
852
|
+
contents: field.data(z.string()).nullable().optional(),
|
|
853
|
+
subject: field.data(z.string()).nullable().optional(),
|
|
854
|
+
blendMode: field.data(BlendModeSchema).optional(),
|
|
855
|
+
invisible: flag(),
|
|
856
|
+
hidden: flag(),
|
|
857
|
+
print: flag(),
|
|
858
|
+
noZoom: flag(),
|
|
859
|
+
noRotate: flag(),
|
|
860
|
+
noView: flag(),
|
|
861
|
+
readOnly: flag(),
|
|
862
|
+
locked: flag(),
|
|
863
|
+
toggleNoView: flag(),
|
|
864
|
+
lockedContents: flag(),
|
|
865
|
+
reply: field.data(AnnotationReplySchema).writes(AnnotationReplyWriteSchema).nullable().optional(),
|
|
866
|
+
/** `/Popup`, kept in sync by the engine from the popup's `parent`. */
|
|
867
|
+
popup: field.engine(AnnotationRefSchema).nullable(),
|
|
868
|
+
/** `/EMBD_Metadata/GroupID`: the group that owns the annotation. */
|
|
869
|
+
groupId: field.data(z.string().min(1)).nullable().optional(),
|
|
870
|
+
author: field.attribution(z.string()).nullable(),
|
|
871
|
+
/** `/CreationDate`. */
|
|
872
|
+
createdAt: field.attribution(IsoDateTimeSchema).writes(DateInputSchema).nullable(),
|
|
873
|
+
/** `/M`. */
|
|
874
|
+
modifiedAt: field.attribution(IsoDateTimeSchema).writes(DateInputSchema).nullable(),
|
|
875
|
+
userId: field.attribution(z.string()).nullable(),
|
|
876
|
+
createdBy: field.attribution(z.string()).nullable(),
|
|
877
|
+
/** `/EMBD_Metadata/UpdatedBy`. */
|
|
878
|
+
modifiedBy: field.attribution(z.string()).nullable(),
|
|
879
|
+
/** The session that restored this annotation's attribution in an import. */
|
|
880
|
+
importedBy: field.engine(z.string()).nullable(),
|
|
881
|
+
/** `/A` and `/AA`. */
|
|
882
|
+
actions: field.preserved(FileAnnotationActionsSchema).nullable().space("actions")
|
|
883
|
+
};
|
|
884
|
+
const colorStyleFields = {
|
|
885
|
+
color: field.data(ColorSchema).optional(),
|
|
886
|
+
opacity: field.data(z.number().min(0).max(1)).optional()
|
|
887
|
+
};
|
|
888
|
+
const geometryStyleFields = {
|
|
889
|
+
...colorStyleFields,
|
|
890
|
+
strokeWidth: field.data(z.number().nonnegative()).optional(),
|
|
891
|
+
/** `beveled` and `inset` are read from other apps' files and kept; only widgets draw them. */
|
|
892
|
+
borderStyle: field.data(AnnotationBorderStyleSchema).writes(DrawnBorderStyleSchema).readBack().optional(),
|
|
893
|
+
dashArray: field.data(z.array(z.number().nonnegative())).nullable().optional()
|
|
894
|
+
};
|
|
895
|
+
const filledStyleFields = {
|
|
896
|
+
...geometryStyleFields,
|
|
897
|
+
interiorColor: field.data(ColorSchema).nullable().optional()
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* `rect` where another field gives the shape (a box, points, quads): where
|
|
901
|
+
* the annotation sits on the page, the upright box around all it draws. The
|
|
902
|
+
* engine works it out from the shape, so a create's `rect` is worked out
|
|
903
|
+
* again. An update's `rect` other than the one read puts the shape there
|
|
904
|
+
* (`shapeForRect`); the rect read, sent back, changes nothing.
|
|
905
|
+
*/
|
|
906
|
+
const drawnRectFields = { rect: field.engine(PdfRectSchema).readBack().space("box") };
|
|
907
|
+
/**
|
|
908
|
+
* The turn of a kind drawn from points (line, polyline, polygon, ink): the
|
|
909
|
+
* points are upright, and the turn takes them about the middle of their box,
|
|
910
|
+
* as a square turns about its box.
|
|
911
|
+
*/
|
|
912
|
+
const pointsTurnFields = {
|
|
913
|
+
/** Degrees clockwise, about the middle of the points' box. */
|
|
914
|
+
rotation: field.data(z.number()).nullable().optional() };
|
|
915
|
+
/**
|
|
916
|
+
* A kind drawn about a box that can turn: square, circle, free text, stamp
|
|
917
|
+
* and caret. The caller gives the box and the turn; `rect` takes in the
|
|
918
|
+
* turned box and what the drawing adds around it (a cloudy border's bumps, a
|
|
919
|
+
* callout's line and arrow).
|
|
920
|
+
*
|
|
921
|
+
* A create gives `box`, or `rect` with a quarter turn: where the turned box
|
|
922
|
+
* stands on the page, which pins the box down (`pdfQuarterTurnBox`). At any
|
|
923
|
+
* other angle many boxes share one rect, so a create by `rect` is refused.
|
|
924
|
+
*/
|
|
925
|
+
const boxFields = {
|
|
926
|
+
...drawnRectFields,
|
|
927
|
+
/** The shape's own box, before any turn: a callout's text box. */
|
|
928
|
+
box: field.data(PdfRectSchema).space("box").optional(),
|
|
929
|
+
/** Degrees clockwise, about the middle of `box`. */
|
|
930
|
+
rotation: field.data(z.number()).nullable().optional()
|
|
931
|
+
};
|
|
932
|
+
/**
|
|
933
|
+
* A widget's frame and its turn: the box its contents are laid out in, and
|
|
934
|
+
* a quarter turn (`/MK /R`, which the file holds counterclockwise), so every
|
|
935
|
+
* viewer can lay an upright editor over it. `rect` is where the widget
|
|
936
|
+
* stands on the page, the box turned. A create gives `box` or `rect`, as a
|
|
937
|
+
* box kind's does.
|
|
938
|
+
*/
|
|
939
|
+
const widgetBoxFields = {
|
|
940
|
+
...drawnRectFields,
|
|
941
|
+
/** The box the contents are laid out in, before the turn: `rect` with its sides swapped under 90 and 270. */
|
|
942
|
+
box: field.data(PdfRectSchema).space("box").optional(),
|
|
943
|
+
/** Degrees clockwise, a quarter turn, about the middle of `box`; `null` upright. */
|
|
944
|
+
rotation: field.data(PdfRotationSchema).nullable().optional()
|
|
945
|
+
};
|
|
946
|
+
const textMarkupFields = {
|
|
947
|
+
...annotationBaseFields,
|
|
948
|
+
...colorStyleFields,
|
|
949
|
+
/** The box around the quads. */
|
|
950
|
+
...drawnRectFields,
|
|
951
|
+
quadPoints: field.data(z.array(PdfQuadSchema).min(1)).space("quads")
|
|
952
|
+
};
|
|
953
|
+
const shapeFields = {
|
|
954
|
+
...annotationBaseFields,
|
|
955
|
+
...filledStyleFields,
|
|
956
|
+
...boxFields,
|
|
957
|
+
cloudyIntensity: field.data(z.number().positive()).nullable().optional()
|
|
958
|
+
};
|
|
959
|
+
const vertexFields = {
|
|
960
|
+
...annotationBaseFields,
|
|
961
|
+
...filledStyleFields,
|
|
962
|
+
...drawnRectFields,
|
|
963
|
+
vertices: field.data(z.array(PdfPointSchema)).space("points"),
|
|
964
|
+
...pointsTurnFields
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* `/Measure`. A write takes a rectilinear scale, or sends back the marker a read
|
|
968
|
+
* returned for a scale the engine can't model.
|
|
969
|
+
*/
|
|
970
|
+
const measureField = field.data(PdfMeasurementSchema).writes(z.union([PdfMeasureWriteSchema, PdfForeignMeasureSchema])).nullable().optional().space("measure");
|
|
971
|
+
/** Our caption on a polygon or polyline measurement; `null` when the shape has no caption flag. */
|
|
972
|
+
const shapeCaptionFields = {
|
|
973
|
+
captionEnabled: field.data(z.boolean()).nullable().optional(),
|
|
974
|
+
/** `null` places the caption automatically. */
|
|
975
|
+
captionCenter: field.data(PdfPointSchema).nullable().optional().space("point")
|
|
976
|
+
};
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/annotation/kinds/caret/declaration.ts
|
|
979
|
+
const CaretDeclaration = defineKind("caret", {
|
|
980
|
+
...annotationBaseFields,
|
|
981
|
+
...colorStyleFields,
|
|
982
|
+
...boxFields,
|
|
983
|
+
intent: field.data(CaretIntentSchema).nullable().optional()
|
|
984
|
+
});
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/annotation/kinds/caret/index.ts
|
|
987
|
+
const CaretDTOSchema = CaretDeclaration.readSchema;
|
|
988
|
+
const CaretDraftSchema = CaretDeclaration.createSchema;
|
|
989
|
+
const CaretPatchSchema = CaretDeclaration.updateSchema;
|
|
990
|
+
const CaretKind = {
|
|
991
|
+
subtype: "caret",
|
|
992
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.CARET,
|
|
993
|
+
dtoSchema: CaretDTOSchema,
|
|
994
|
+
draftSchema: CaretDraftSchema,
|
|
995
|
+
patchSchema: CaretPatchSchema,
|
|
996
|
+
readBackWrites: CaretDeclaration.readBackWrites
|
|
997
|
+
};
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/annotation/kinds/circle/declaration.ts
|
|
1000
|
+
const CircleDeclaration = defineKind("circle", shapeFields);
|
|
1001
|
+
//#endregion
|
|
1002
|
+
//#region src/annotation/kinds/circle/index.ts
|
|
1003
|
+
const CircleDTOSchema = CircleDeclaration.readSchema;
|
|
1004
|
+
const CircleDraftSchema = CircleDeclaration.createSchema;
|
|
1005
|
+
const CirclePatchSchema = CircleDeclaration.updateSchema;
|
|
1006
|
+
const CircleKind = {
|
|
1007
|
+
subtype: "circle",
|
|
1008
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.CIRCLE,
|
|
1009
|
+
dtoSchema: CircleDTOSchema,
|
|
1010
|
+
draftSchema: CircleDraftSchema,
|
|
1011
|
+
patchSchema: CirclePatchSchema,
|
|
1012
|
+
readBackWrites: CircleDeclaration.readBackWrites
|
|
1013
|
+
};
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/wire/resourceKeys.ts
|
|
1016
|
+
/**
|
|
1017
|
+
* A multipart message carries each file as a part `resource:<key>`, and its
|
|
1018
|
+
* JSON names the file by role: `resources: { <role>: <key> }`, on the
|
|
1019
|
+
* object the files belong to. These are those objects, one per set of roles.
|
|
1020
|
+
*/
|
|
1021
|
+
/** A file's key: the `<key>` of its `resource:<key>` part. */
|
|
1022
|
+
const ResourceKeySchema = z.string().min(1);
|
|
1023
|
+
/** An annotation write's files: its drawing and its attached file. */
|
|
1024
|
+
const AnnotationResourceKeysSchema = z.object({
|
|
1025
|
+
appearance: ResourceKeySchema.optional(),
|
|
1026
|
+
file: ResourceKeySchema.optional()
|
|
1027
|
+
}).strict();
|
|
1028
|
+
/** A drawn appearance: a signature's mark, as a one-page PDF or an image. */
|
|
1029
|
+
const AppearanceResourceKeysSchema = z.object({ appearance: ResourceKeySchema }).strict();
|
|
1030
|
+
/** An attachment's file. */
|
|
1031
|
+
const FileResourceKeysSchema = z.object({ file: ResourceKeySchema }).strict();
|
|
1032
|
+
/** The PDF whose pages an insert copies in. */
|
|
1033
|
+
const SourceResourceKeysSchema = z.object({ source: ResourceKeySchema }).strict();
|
|
1034
|
+
/** An answer's picture. */
|
|
1035
|
+
const ImageResourceKeysSchema = z.object({ image: ResourceKeySchema }).strict();
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region src/dto/Attachment.schema.ts
|
|
1038
|
+
/**
|
|
1039
|
+
* Wire schemas for the attachment vocabulary (see `Attachment.ts`). The
|
|
1040
|
+
* write-side `AttachmentFileSource` carries bytes and never appears on the
|
|
1041
|
+
* wire; `WireAttachmentFile` is its form there.
|
|
1042
|
+
*/
|
|
1043
|
+
const WireAttachmentFileSchema = z.object({
|
|
1044
|
+
resources: FileResourceKeysSchema,
|
|
1045
|
+
name: z.string().min(1),
|
|
1046
|
+
mimeType: z.string().optional(),
|
|
1047
|
+
description: z.string().optional()
|
|
1048
|
+
});
|
|
1049
|
+
/** What a write takes of a file: its name (its key), type and description. */
|
|
1050
|
+
const AttachmentFileBaseSchema = z.object({
|
|
1051
|
+
name: z.string().min(1),
|
|
1052
|
+
mimeType: z.string().optional(),
|
|
1053
|
+
description: z.string().optional()
|
|
1054
|
+
});
|
|
1055
|
+
const AttachmentFileInfoSchema = z.object({
|
|
1056
|
+
name: z.string(),
|
|
1057
|
+
mimeType: z.string().nullable(),
|
|
1058
|
+
description: z.string().nullable(),
|
|
1059
|
+
size: z.number().int().nonnegative().nullable(),
|
|
1060
|
+
checksum: z.string().nullable(),
|
|
1061
|
+
createdAt: IsoDateTimeSchema.nullable(),
|
|
1062
|
+
modifiedAt: IsoDateTimeSchema.nullable()
|
|
1063
|
+
});
|
|
1064
|
+
const AttachmentRefSchema = z.object({
|
|
1065
|
+
kind: z.literal("key"),
|
|
1066
|
+
key: z.string().min(1)
|
|
1067
|
+
});
|
|
1068
|
+
const AttachmentSchema = z.object({
|
|
1069
|
+
ref: z.object({
|
|
1070
|
+
kind: z.literal("key"),
|
|
1071
|
+
key: z.string()
|
|
1072
|
+
}),
|
|
1073
|
+
name: z.string(),
|
|
1074
|
+
mimeType: z.string().nullable(),
|
|
1075
|
+
description: z.string().nullable(),
|
|
1076
|
+
size: z.number().int().nonnegative().nullable(),
|
|
1077
|
+
checksum: z.string().nullable(),
|
|
1078
|
+
createdAt: IsoDateTimeSchema.nullable(),
|
|
1079
|
+
modifiedAt: IsoDateTimeSchema.nullable(),
|
|
1080
|
+
index: z.number().int().nonnegative()
|
|
1081
|
+
});
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/annotation/kinds/file-attachment/values.ts
|
|
1084
|
+
const FileAttachmentIconSchema = z.enum([
|
|
1085
|
+
"push-pin",
|
|
1086
|
+
"paperclip",
|
|
1087
|
+
"graph",
|
|
1088
|
+
"tag"
|
|
1089
|
+
]);
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region src/annotation/kinds/file-attachment/declaration.ts
|
|
1092
|
+
/**
|
|
1093
|
+
* The file's metadata; its bytes travel as the `file` resource. What a read
|
|
1094
|
+
* adds (size, checksum, creation date) comes from the bytes and is ignored.
|
|
1095
|
+
* A create may leave it out when the resource is a `File`, which brings its
|
|
1096
|
+
* name and type.
|
|
1097
|
+
*/
|
|
1098
|
+
const AttachmentFileWriteSchema = z.object({
|
|
1099
|
+
name: z.string().min(1),
|
|
1100
|
+
mimeType: z.string().nullable().optional(),
|
|
1101
|
+
description: z.string().nullable().optional()
|
|
1102
|
+
});
|
|
1103
|
+
/** A file on the page: its icon fills `rect`, 20×20 at the usual size. */
|
|
1104
|
+
const FileAttachmentDeclaration = defineKind("file-attachment", {
|
|
1105
|
+
...annotationBaseFields,
|
|
1106
|
+
...colorStyleFields,
|
|
1107
|
+
icon: field.data(FileAttachmentIconSchema).optional(),
|
|
1108
|
+
/**
|
|
1109
|
+
* `null` when the file specification has no embedded file. A write takes
|
|
1110
|
+
* what a read returns, so a read can be copied: on a create `null` is the
|
|
1111
|
+
* same as leaving it out, and an update that sends back the `null` a read
|
|
1112
|
+
* returned changes nothing (a file can't be removed).
|
|
1113
|
+
*/
|
|
1114
|
+
file: field.data(AttachmentFileInfoSchema).writes(AttachmentFileWriteSchema).nullable().optional()
|
|
1115
|
+
}, { file: "required" });
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region src/annotation/kinds/file-attachment/index.ts
|
|
1118
|
+
const FileAttachmentDTOSchema = FileAttachmentDeclaration.readSchema;
|
|
1119
|
+
const FileAttachmentDraftSchema = FileAttachmentDeclaration.createSchema;
|
|
1120
|
+
const FileAttachmentPatchSchema = FileAttachmentDeclaration.updateSchema;
|
|
1121
|
+
const FileAttachmentKind = {
|
|
1122
|
+
subtype: "file-attachment",
|
|
1123
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.FILEATTACHMENT,
|
|
1124
|
+
dtoSchema: FileAttachmentDTOSchema,
|
|
1125
|
+
draftSchema: FileAttachmentDraftSchema,
|
|
1126
|
+
patchSchema: FileAttachmentPatchSchema,
|
|
1127
|
+
readBackWrites: FileAttachmentDeclaration.readBackWrites
|
|
1128
|
+
};
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/annotation/kinds/free-text/values.ts
|
|
1131
|
+
/** How a paragraph's lines line up: a free text's `textAlign` too. */
|
|
1132
|
+
const RichTextAlignSchema = z.enum([
|
|
1133
|
+
"left",
|
|
1134
|
+
"center",
|
|
1135
|
+
"right",
|
|
1136
|
+
"justify"
|
|
1137
|
+
]);
|
|
1138
|
+
const RichTextRunStyleShape = {
|
|
1139
|
+
family: z.string().min(1),
|
|
1140
|
+
weight: z.number().int().min(100).max(900),
|
|
1141
|
+
italic: z.boolean(),
|
|
1142
|
+
size: z.number().nonnegative(),
|
|
1143
|
+
color: ColorSchema,
|
|
1144
|
+
decoration: z.array(z.enum([
|
|
1145
|
+
"underline",
|
|
1146
|
+
"line-through",
|
|
1147
|
+
"word"
|
|
1148
|
+
])),
|
|
1149
|
+
script: z.enum([
|
|
1150
|
+
"normal",
|
|
1151
|
+
"sub",
|
|
1152
|
+
"super"
|
|
1153
|
+
]),
|
|
1154
|
+
letterSpacing: z.number(),
|
|
1155
|
+
horizontalScale: z.number().positive(),
|
|
1156
|
+
unknown: z.string().optional()
|
|
1157
|
+
};
|
|
1158
|
+
const RichTextParagraphPropsShape = {
|
|
1159
|
+
align: RichTextAlignSchema,
|
|
1160
|
+
dir: z.enum(["ltr", "rtl"]),
|
|
1161
|
+
lineHeight: z.number().positive().optional(),
|
|
1162
|
+
margins: z.object({
|
|
1163
|
+
top: z.number(),
|
|
1164
|
+
bottom: z.number(),
|
|
1165
|
+
left: z.number(),
|
|
1166
|
+
right: z.number()
|
|
1167
|
+
}).optional(),
|
|
1168
|
+
textIndent: z.number().optional(),
|
|
1169
|
+
unknown: z.string().optional()
|
|
1170
|
+
};
|
|
1171
|
+
const RichTextRunStyleDeltaSchema = z.object(RichTextRunStyleShape).partial();
|
|
1172
|
+
const RichTextParagraphSchema = z.object({
|
|
1173
|
+
...RichTextParagraphPropsShape,
|
|
1174
|
+
runs: z.array(z.object({
|
|
1175
|
+
text: z.string(),
|
|
1176
|
+
style: RichTextRunStyleDeltaSchema.optional()
|
|
1177
|
+
}))
|
|
1178
|
+
}).partial({
|
|
1179
|
+
align: true,
|
|
1180
|
+
dir: true
|
|
1181
|
+
});
|
|
1182
|
+
const RichTextDocumentSchema = z.object({
|
|
1183
|
+
body: z.object({
|
|
1184
|
+
...RichTextRunStyleShape,
|
|
1185
|
+
...RichTextParagraphPropsShape
|
|
1186
|
+
}),
|
|
1187
|
+
paragraphs: z.array(RichTextParagraphSchema)
|
|
1188
|
+
});
|
|
1189
|
+
const RichTextDocumentInputSchema = z.object({
|
|
1190
|
+
body: z.object({
|
|
1191
|
+
...RichTextRunStyleShape,
|
|
1192
|
+
...RichTextParagraphPropsShape
|
|
1193
|
+
}).partial().optional(),
|
|
1194
|
+
paragraphs: z.array(RichTextParagraphSchema)
|
|
1195
|
+
});
|
|
1196
|
+
//#endregion
|
|
1197
|
+
//#region src/annotation/kinds/free-text/declaration.ts
|
|
1198
|
+
const FreeTextDeclaration = defineKind("free-text", {
|
|
1199
|
+
...annotationBaseFields,
|
|
1200
|
+
...boxFields,
|
|
1201
|
+
/**
|
|
1202
|
+
* A create without it is a callout when it has a `calloutLine`, else a
|
|
1203
|
+
* plain box. A typewriter another app made is kept as it is.
|
|
1204
|
+
*/
|
|
1205
|
+
intent: field.data(FreeTextIntentSchema).writes(FreeTextIntentWriteSchema).readBack().optional(),
|
|
1206
|
+
/** The text's font: the rich text body's. Helvetica when a create leaves it out. */
|
|
1207
|
+
fontFamily: field.data(FontNameSchema).optional(),
|
|
1208
|
+
/** The body's size in points: 12 when a create leaves it out. */
|
|
1209
|
+
fontSize: field.data(z.number().positive()).optional(),
|
|
1210
|
+
/** The body's alignment: left when a create leaves it out. */
|
|
1211
|
+
textAlign: field.data(RichTextAlignSchema).optional(),
|
|
1212
|
+
/** Where the lines sit in the box: top when a create leaves it out. */
|
|
1213
|
+
verticalAlign: field.data(VerticalAlignmentSchema).optional(),
|
|
1214
|
+
richText: field.data(RichTextDocumentSchema).writes(RichTextDocumentInputSchema).optional().space("length"),
|
|
1215
|
+
/** The border's color, and a callout line's. */
|
|
1216
|
+
color: field.data(ColorSchema).optional(),
|
|
1217
|
+
/** The text's color: the rich text body's. Black when a create leaves it out. */
|
|
1218
|
+
fontColor: field.data(ColorSchema).optional(),
|
|
1219
|
+
interiorColor: field.data(ColorSchema).nullable().optional(),
|
|
1220
|
+
opacity: field.data(z.number().min(0).max(1)).optional(),
|
|
1221
|
+
strokeWidth: field.data(z.number().nonnegative()).optional(),
|
|
1222
|
+
borderStyle: field.data(AnnotationBorderStyleSchema).writes(DrawnBorderStyleSchema).readBack().optional(),
|
|
1223
|
+
dashArray: field.data(z.array(z.number().nonnegative())).nullable().optional(),
|
|
1224
|
+
cloudyIntensity: field.data(z.number().positive()).nullable().optional(),
|
|
1225
|
+
calloutLine: field.data(CalloutLineSchema).nullable().optional().space("calloutLine"),
|
|
1226
|
+
lineEnding: field.data(LineEndingSchema).nullable().optional()
|
|
1227
|
+
});
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/annotation/kinds/free-text/index.ts
|
|
1230
|
+
const FreeTextDTOSchema = FreeTextDeclaration.readSchema;
|
|
1231
|
+
const FreeTextDraftSchema = FreeTextDeclaration.createSchema;
|
|
1232
|
+
const FreeTextPatchSchema = FreeTextDeclaration.updateSchema;
|
|
1233
|
+
const FreeTextKind = {
|
|
1234
|
+
subtype: "free-text",
|
|
1235
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.FREETEXT,
|
|
1236
|
+
dtoSchema: FreeTextDTOSchema,
|
|
1237
|
+
draftSchema: FreeTextDraftSchema,
|
|
1238
|
+
patchSchema: FreeTextPatchSchema,
|
|
1239
|
+
readBackWrites: FreeTextDeclaration.readBackWrites
|
|
1240
|
+
};
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/annotation/kinds/highlight/declaration.ts
|
|
1243
|
+
const HighlightDeclaration = defineKind("highlight", textMarkupFields);
|
|
1244
|
+
//#endregion
|
|
1245
|
+
//#region src/annotation/kinds/highlight/index.ts
|
|
1246
|
+
const HighlightDTOSchema = HighlightDeclaration.readSchema;
|
|
1247
|
+
const HighlightDraftSchema = HighlightDeclaration.createSchema;
|
|
1248
|
+
const HighlightPatchSchema = HighlightDeclaration.updateSchema;
|
|
1249
|
+
const HighlightKind = {
|
|
1250
|
+
subtype: "highlight",
|
|
1251
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.HIGHLIGHT,
|
|
1252
|
+
dtoSchema: HighlightDTOSchema,
|
|
1253
|
+
draftSchema: HighlightDraftSchema,
|
|
1254
|
+
patchSchema: HighlightPatchSchema,
|
|
1255
|
+
readBackWrites: HighlightDeclaration.readBackWrites
|
|
1256
|
+
};
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/annotation/kinds/ink/declaration.ts
|
|
1259
|
+
const InkDeclaration = defineKind("ink", {
|
|
1260
|
+
...annotationBaseFields,
|
|
1261
|
+
...geometryStyleFields,
|
|
1262
|
+
/** More than 0 on a write: ink has no fill, so a line of 0 draws nothing. */
|
|
1263
|
+
strokeWidth: field.data(z.number().nonnegative()).writes(z.number().positive()).readBack().optional(),
|
|
1264
|
+
...drawnRectFields,
|
|
1265
|
+
/** At least one stroke on a write, and no stroke without points. */
|
|
1266
|
+
inkList: field.data(InkListSchema).writes(z.array(z.array(PdfPointSchema).min(1)).min(1)).readBack().space("strokes"),
|
|
1267
|
+
intent: field.data(InkIntentSchema).nullable().optional(),
|
|
1268
|
+
...pointsTurnFields
|
|
1269
|
+
});
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region src/annotation/kinds/ink/index.ts
|
|
1272
|
+
const InkDTOSchema = InkDeclaration.readSchema;
|
|
1273
|
+
const InkDraftSchema = InkDeclaration.createSchema;
|
|
1274
|
+
const InkPatchSchema = InkDeclaration.updateSchema;
|
|
1275
|
+
const InkKind = {
|
|
1276
|
+
subtype: "ink",
|
|
1277
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.INK,
|
|
1278
|
+
dtoSchema: InkDTOSchema,
|
|
1279
|
+
draftSchema: InkDraftSchema,
|
|
1280
|
+
patchSchema: InkPatchSchema,
|
|
1281
|
+
readBackWrites: InkDeclaration.readBackWrites
|
|
1282
|
+
};
|
|
1283
|
+
//#endregion
|
|
1284
|
+
//#region src/annotation/kinds/line/declaration.ts
|
|
1285
|
+
const LineDeclaration = defineKind("line", {
|
|
1286
|
+
...annotationBaseFields,
|
|
1287
|
+
...filledStyleFields,
|
|
1288
|
+
...drawnRectFields,
|
|
1289
|
+
linePoints: field.data(LinePointsSchema).space("linePoints"),
|
|
1290
|
+
lineEndings: field.data(LineEndingsSchema).optional(),
|
|
1291
|
+
...pointsTurnFields,
|
|
1292
|
+
intent: field.data(LineIntentSchema).nullable().optional(),
|
|
1293
|
+
measure: measureField,
|
|
1294
|
+
/** `/Cap`: paint `/Contents` on the line. */
|
|
1295
|
+
captionEnabled: field.data(z.boolean()).nullable().optional(),
|
|
1296
|
+
/** `/CP`. */
|
|
1297
|
+
captionPosition: field.data(z.enum(["inline", "top"])).optional(),
|
|
1298
|
+
/** `/CO`, along the line and its normal; `null` is the normal position. */
|
|
1299
|
+
captionOffset: field.data(z.object({
|
|
1300
|
+
along: z.number(),
|
|
1301
|
+
perpendicular: z.number()
|
|
1302
|
+
})).nullable().optional(),
|
|
1303
|
+
/** `/LL`, `/LLE` and `/LLO`. */
|
|
1304
|
+
leader: field.data(LineLeaderSchema).nullable().optional()
|
|
1305
|
+
});
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region src/annotation/kinds/line/index.ts
|
|
1308
|
+
const LineDTOSchema = LineDeclaration.readSchema;
|
|
1309
|
+
const LineDraftSchema = LineDeclaration.createSchema;
|
|
1310
|
+
const LinePatchSchema = LineDeclaration.updateSchema;
|
|
1311
|
+
const LineKind = {
|
|
1312
|
+
subtype: "line",
|
|
1313
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.LINE,
|
|
1314
|
+
dtoSchema: LineDTOSchema,
|
|
1315
|
+
draftSchema: LineDraftSchema,
|
|
1316
|
+
patchSchema: LinePatchSchema,
|
|
1317
|
+
readBackWrites: LineDeclaration.readBackWrites
|
|
1318
|
+
};
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region src/annotation/kinds/link/declaration.ts
|
|
1321
|
+
const LinkDeclaration = defineKind("link", {
|
|
1322
|
+
...annotationBaseFields,
|
|
1323
|
+
target: field.data(FileLinkTargetSchema).writes(FileLinkTargetWritableSchema).nullable().readBack().space("linkTarget")
|
|
1324
|
+
});
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/annotation/kinds/link/index.ts
|
|
1327
|
+
const LinkDTOSchema = LinkDeclaration.readSchema;
|
|
1328
|
+
const LinkDraftSchema = LinkDeclaration.createSchema;
|
|
1329
|
+
const LinkPatchSchema = LinkDeclaration.updateSchema;
|
|
1330
|
+
const LinkKind = {
|
|
1331
|
+
subtype: "link",
|
|
1332
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.LINK,
|
|
1333
|
+
dtoSchema: LinkDTOSchema,
|
|
1334
|
+
draftSchema: LinkDraftSchema,
|
|
1335
|
+
patchSchema: LinkPatchSchema,
|
|
1336
|
+
readBackWrites: LinkDeclaration.readBackWrites
|
|
1337
|
+
};
|
|
1338
|
+
//#endregion
|
|
1339
|
+
//#region src/annotation/kinds/polygon/declaration.ts
|
|
1340
|
+
const PolygonDeclaration = defineKind("polygon", {
|
|
1341
|
+
...vertexFields,
|
|
1342
|
+
/** At least three points on a write; fewer enclose nothing. */
|
|
1343
|
+
vertices: field.data(z.array(PdfPointSchema)).writes(z.array(PdfPointSchema).min(3)).readBack().space("points"),
|
|
1344
|
+
...shapeCaptionFields,
|
|
1345
|
+
intent: field.data(PolygonIntentSchema).nullable().optional(),
|
|
1346
|
+
measure: measureField,
|
|
1347
|
+
cloudyIntensity: field.data(z.number().positive()).nullable().optional()
|
|
1348
|
+
});
|
|
1349
|
+
//#endregion
|
|
1350
|
+
//#region src/annotation/kinds/polygon/index.ts
|
|
1351
|
+
const PolygonDTOSchema = PolygonDeclaration.readSchema;
|
|
1352
|
+
const PolygonDraftSchema = PolygonDeclaration.createSchema;
|
|
1353
|
+
const PolygonPatchSchema = PolygonDeclaration.updateSchema;
|
|
1354
|
+
const PolygonKind = {
|
|
1355
|
+
subtype: "polygon",
|
|
1356
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.POLYGON,
|
|
1357
|
+
dtoSchema: PolygonDTOSchema,
|
|
1358
|
+
draftSchema: PolygonDraftSchema,
|
|
1359
|
+
patchSchema: PolygonPatchSchema,
|
|
1360
|
+
readBackWrites: PolygonDeclaration.readBackWrites
|
|
1361
|
+
};
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/annotation/kinds/polyline/declaration.ts
|
|
1364
|
+
const PolylineDeclaration = defineKind("polyline", {
|
|
1365
|
+
...vertexFields,
|
|
1366
|
+
/** At least two points on a write; fewer draw nothing. */
|
|
1367
|
+
vertices: field.data(z.array(PdfPointSchema)).writes(z.array(PdfPointSchema).min(2)).readBack().space("points"),
|
|
1368
|
+
...shapeCaptionFields,
|
|
1369
|
+
intent: field.data(PolylineIntentSchema).nullable().optional(),
|
|
1370
|
+
measure: measureField,
|
|
1371
|
+
lineEndings: field.data(LineEndingsSchema).optional()
|
|
1372
|
+
});
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/annotation/kinds/polyline/index.ts
|
|
1375
|
+
const PolylineDTOSchema = PolylineDeclaration.readSchema;
|
|
1376
|
+
const PolylineDraftSchema = PolylineDeclaration.createSchema;
|
|
1377
|
+
const PolylinePatchSchema = PolylineDeclaration.updateSchema;
|
|
1378
|
+
const PolylineKind = {
|
|
1379
|
+
subtype: "polyline",
|
|
1380
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.POLYLINE,
|
|
1381
|
+
dtoSchema: PolylineDTOSchema,
|
|
1382
|
+
draftSchema: PolylineDraftSchema,
|
|
1383
|
+
patchSchema: PolylinePatchSchema,
|
|
1384
|
+
readBackWrites: PolylineDeclaration.readBackWrites
|
|
1385
|
+
};
|
|
1386
|
+
//#endregion
|
|
1387
|
+
//#region src/annotation/kinds/popup/declaration.ts
|
|
1388
|
+
/** The window that shows its parent annotation's text. */
|
|
1389
|
+
const PopupDeclaration = defineKind("popup", {
|
|
1390
|
+
...annotationBaseFields,
|
|
1391
|
+
/**
|
|
1392
|
+
* `/Parent`: the annotation this popup shows. Required on create; `null`
|
|
1393
|
+
* on a read of a popup whose PDF names none, which an update may send
|
|
1394
|
+
* back unchanged.
|
|
1395
|
+
*/
|
|
1396
|
+
parent: field.data(AnnotationRefSchema).nullableOnRead().readBack(),
|
|
1397
|
+
/** `/Open`: whether the window is shown open. `false` when the PDF doesn't say. */
|
|
1398
|
+
open: field.data(z.boolean()).optional()
|
|
1399
|
+
});
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region src/annotation/kinds/popup/index.ts
|
|
1402
|
+
const PopupDTOSchema = PopupDeclaration.readSchema;
|
|
1403
|
+
const PopupDraftSchema = PopupDeclaration.createSchema;
|
|
1404
|
+
const PopupPatchSchema = PopupDeclaration.updateSchema;
|
|
1405
|
+
const PopupKind = {
|
|
1406
|
+
subtype: "popup",
|
|
1407
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.POPUP,
|
|
1408
|
+
dtoSchema: PopupDTOSchema,
|
|
1409
|
+
draftSchema: PopupDraftSchema,
|
|
1410
|
+
patchSchema: PopupPatchSchema,
|
|
1411
|
+
readBackWrites: PopupDeclaration.readBackWrites
|
|
1412
|
+
};
|
|
1413
|
+
//#endregion
|
|
1414
|
+
//#region src/annotation/kinds/redact/declaration.ts
|
|
1415
|
+
const RedactDeclaration = defineKind("redact", {
|
|
1416
|
+
...annotationBaseFields,
|
|
1417
|
+
...colorStyleFields,
|
|
1418
|
+
/** Worked out from the quads when a create gives quads and no `rect`. */
|
|
1419
|
+
rect: field.data(PdfRectSchema).optional().space("box"),
|
|
1420
|
+
quadPoints: field.data(z.array(PdfQuadSchema)).optional().space("quads"),
|
|
1421
|
+
interiorColor: field.data(ColorSchema).nullable().optional(),
|
|
1422
|
+
overlayText: field.data(z.string()).nullable().optional(),
|
|
1423
|
+
repeat: field.data(z.boolean()).optional(),
|
|
1424
|
+
/** A standard font or a registered key, as on free text. */
|
|
1425
|
+
fontFamily: field.data(FontNameSchema).optional(),
|
|
1426
|
+
/** `0` fits the label to the region. */
|
|
1427
|
+
fontSize: field.data(z.number().nonnegative()).optional(),
|
|
1428
|
+
fontColor: field.data(ColorSchema).optional(),
|
|
1429
|
+
textAlign: field.data(TextAlignmentSchema).optional()
|
|
1430
|
+
});
|
|
1431
|
+
//#endregion
|
|
1432
|
+
//#region src/annotation/kinds/redact/index.ts
|
|
1433
|
+
const RedactDTOSchema = RedactDeclaration.readSchema;
|
|
1434
|
+
const RedactDraftSchema = RedactDeclaration.createSchema;
|
|
1435
|
+
const RedactPatchSchema = RedactDeclaration.updateSchema;
|
|
1436
|
+
const RedactKind = {
|
|
1437
|
+
subtype: "redact",
|
|
1438
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.REDACT,
|
|
1439
|
+
dtoSchema: RedactDTOSchema,
|
|
1440
|
+
draftSchema: RedactDraftSchema,
|
|
1441
|
+
patchSchema: RedactPatchSchema,
|
|
1442
|
+
readBackWrites: RedactDeclaration.readBackWrites
|
|
1443
|
+
};
|
|
1444
|
+
//#endregion
|
|
1445
|
+
//#region src/annotation/kinds/square/declaration.ts
|
|
1446
|
+
const SquareDeclaration = defineKind("square", shapeFields);
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/annotation/kinds/square/index.ts
|
|
1449
|
+
const SquareDTOSchema = SquareDeclaration.readSchema;
|
|
1450
|
+
const SquareDraftSchema = SquareDeclaration.createSchema;
|
|
1451
|
+
const SquarePatchSchema = SquareDeclaration.updateSchema;
|
|
1452
|
+
const SquareKind = {
|
|
1453
|
+
subtype: "square",
|
|
1454
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.SQUARE,
|
|
1455
|
+
dtoSchema: SquareDTOSchema,
|
|
1456
|
+
draftSchema: SquareDraftSchema,
|
|
1457
|
+
patchSchema: SquarePatchSchema,
|
|
1458
|
+
readBackWrites: SquareDeclaration.readBackWrites
|
|
1459
|
+
};
|
|
1460
|
+
//#endregion
|
|
1461
|
+
//#region src/annotation/kinds/squiggly/declaration.ts
|
|
1462
|
+
const SquigglyDeclaration = defineKind("squiggly", textMarkupFields);
|
|
1463
|
+
//#endregion
|
|
1464
|
+
//#region src/annotation/kinds/squiggly/index.ts
|
|
1465
|
+
const SquigglyDTOSchema = SquigglyDeclaration.readSchema;
|
|
1466
|
+
const SquigglyDraftSchema = SquigglyDeclaration.createSchema;
|
|
1467
|
+
const SquigglyPatchSchema = SquigglyDeclaration.updateSchema;
|
|
1468
|
+
const SquigglyKind = {
|
|
1469
|
+
subtype: "squiggly",
|
|
1470
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.SQUIGGLY,
|
|
1471
|
+
dtoSchema: SquigglyDTOSchema,
|
|
1472
|
+
draftSchema: SquigglyDraftSchema,
|
|
1473
|
+
patchSchema: SquigglyPatchSchema,
|
|
1474
|
+
readBackWrites: SquigglyDeclaration.readBackWrites
|
|
1475
|
+
};
|
|
1476
|
+
//#endregion
|
|
1477
|
+
//#region src/annotation/kinds/stamp/values.ts
|
|
1478
|
+
const StampFitSchema = z.enum([
|
|
1479
|
+
"contain",
|
|
1480
|
+
"cover",
|
|
1481
|
+
"fill"
|
|
1482
|
+
]);
|
|
1483
|
+
//#endregion
|
|
1484
|
+
//#region src/annotation/kinds/stamp/declaration.ts
|
|
1485
|
+
const StampDeclaration = defineKind("stamp", {
|
|
1486
|
+
...annotationBaseFields,
|
|
1487
|
+
...boxFields,
|
|
1488
|
+
/** `/Name`: the stamp's label, such as `Approved`. */
|
|
1489
|
+
name: field.data(z.string()).nullable().optional(),
|
|
1490
|
+
/**
|
|
1491
|
+
* How the drawing is scaled into the box, and re-fit when the box changes
|
|
1492
|
+
* (`/EMBD_Metadata/AppearanceFit`). `null` when the PDF doesn't record it,
|
|
1493
|
+
* as for a stamp another tool made; the engine then fits with `'fill'`,
|
|
1494
|
+
* the way a PDF places any appearance in its `/Rect`. A create without it
|
|
1495
|
+
* fits with `'contain'` and records that.
|
|
1496
|
+
*/
|
|
1497
|
+
fit: field.data(StampFitSchema).nullable().optional(),
|
|
1498
|
+
/** `/CA`, painted once over the whole drawing. */
|
|
1499
|
+
opacity: field.data(z.number().min(0).max(1)).optional()
|
|
1500
|
+
}, { appearance: "required" });
|
|
1501
|
+
//#endregion
|
|
1502
|
+
//#region src/annotation/kinds/stamp/index.ts
|
|
1503
|
+
const StampDTOSchema = StampDeclaration.readSchema;
|
|
1504
|
+
const StampDraftSchema = StampDeclaration.createSchema;
|
|
1505
|
+
const StampPatchSchema = StampDeclaration.updateSchema;
|
|
1506
|
+
const StampKind = {
|
|
1507
|
+
subtype: "stamp",
|
|
1508
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.STAMP,
|
|
1509
|
+
dtoSchema: StampDTOSchema,
|
|
1510
|
+
draftSchema: StampDraftSchema,
|
|
1511
|
+
patchSchema: StampPatchSchema,
|
|
1512
|
+
readBackWrites: StampDeclaration.readBackWrites
|
|
1513
|
+
};
|
|
1514
|
+
//#endregion
|
|
1515
|
+
//#region src/annotation/kinds/strikeout/declaration.ts
|
|
1516
|
+
const StrikeoutDeclaration = defineKind("strikeout", {
|
|
1517
|
+
...textMarkupFields,
|
|
1518
|
+
intent: field.data(StrikeoutIntentSchema).nullable().optional()
|
|
1519
|
+
});
|
|
1520
|
+
//#endregion
|
|
1521
|
+
//#region src/annotation/kinds/strikeout/index.ts
|
|
1522
|
+
const StrikeoutDTOSchema = StrikeoutDeclaration.readSchema;
|
|
1523
|
+
const StrikeoutDraftSchema = StrikeoutDeclaration.createSchema;
|
|
1524
|
+
const StrikeoutPatchSchema = StrikeoutDeclaration.updateSchema;
|
|
1525
|
+
const StrikeoutKind = {
|
|
1526
|
+
subtype: "strikeout",
|
|
1527
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.STRIKEOUT,
|
|
1528
|
+
dtoSchema: StrikeoutDTOSchema,
|
|
1529
|
+
draftSchema: StrikeoutDraftSchema,
|
|
1530
|
+
patchSchema: StrikeoutPatchSchema,
|
|
1531
|
+
readBackWrites: StrikeoutDeclaration.readBackWrites
|
|
1532
|
+
};
|
|
1533
|
+
//#endregion
|
|
1534
|
+
//#region src/annotation/kinds/text/values.ts
|
|
1535
|
+
const NoteIconSchema = z.enum([
|
|
1536
|
+
"comment",
|
|
1537
|
+
"key",
|
|
1538
|
+
"note",
|
|
1539
|
+
"help",
|
|
1540
|
+
"new-paragraph",
|
|
1541
|
+
"paragraph",
|
|
1542
|
+
"insert"
|
|
1543
|
+
]);
|
|
1544
|
+
//#endregion
|
|
1545
|
+
//#region src/annotation/kinds/text/declaration.ts
|
|
1546
|
+
/** A note: its icon fills `rect`, 20×20 at the usual size. */
|
|
1547
|
+
const TextDeclaration = defineKind("text", {
|
|
1548
|
+
...annotationBaseFields,
|
|
1549
|
+
...colorStyleFields,
|
|
1550
|
+
icon: field.data(NoteIconSchema).optional(),
|
|
1551
|
+
/**
|
|
1552
|
+
* `/Open`: whether the note's window shows open. Kept equal to its
|
|
1553
|
+
* popup's `open`: a write sets both. `false` when the PDF doesn't say.
|
|
1554
|
+
*/
|
|
1555
|
+
open: field.data(z.boolean()).optional(),
|
|
1556
|
+
/** `/State`: standard states in lowercase, custom ones as written. */
|
|
1557
|
+
state: field.data(z.string().min(1)).nullable().optional(),
|
|
1558
|
+
stateModel: field.data(z.string().min(1)).nullable().optional()
|
|
1559
|
+
});
|
|
1560
|
+
//#endregion
|
|
1561
|
+
//#region src/annotation/kinds/text/index.ts
|
|
1562
|
+
const TextDTOSchema = TextDeclaration.readSchema;
|
|
1563
|
+
const TextDraftSchema = TextDeclaration.createSchema;
|
|
1564
|
+
const TextPatchSchema = TextDeclaration.updateSchema;
|
|
1565
|
+
const TextKind = {
|
|
1566
|
+
subtype: "text",
|
|
1567
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.TEXT,
|
|
1568
|
+
dtoSchema: TextDTOSchema,
|
|
1569
|
+
draftSchema: TextDraftSchema,
|
|
1570
|
+
patchSchema: TextPatchSchema,
|
|
1571
|
+
readBackWrites: TextDeclaration.readBackWrites
|
|
1572
|
+
};
|
|
1573
|
+
//#endregion
|
|
1574
|
+
//#region src/annotation/kinds/underline/declaration.ts
|
|
1575
|
+
const UnderlineDeclaration = defineKind("underline", textMarkupFields);
|
|
1576
|
+
//#endregion
|
|
1577
|
+
//#region src/annotation/kinds/underline/index.ts
|
|
1578
|
+
const UnderlineDTOSchema = UnderlineDeclaration.readSchema;
|
|
1579
|
+
const UnderlineDraftSchema = UnderlineDeclaration.createSchema;
|
|
1580
|
+
const UnderlinePatchSchema = UnderlineDeclaration.updateSchema;
|
|
1581
|
+
const UnderlineKind = {
|
|
1582
|
+
subtype: "underline",
|
|
1583
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.UNDERLINE,
|
|
1584
|
+
dtoSchema: UnderlineDTOSchema,
|
|
1585
|
+
draftSchema: UnderlineDraftSchema,
|
|
1586
|
+
patchSchema: UnderlinePatchSchema,
|
|
1587
|
+
readBackWrites: UnderlineDeclaration.readBackWrites
|
|
1588
|
+
};
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region src/annotation/kinds/unsupported/declaration.ts
|
|
1591
|
+
/** An annotation of a type the engine doesn't model: only the shared fields are read. */
|
|
1592
|
+
const UnsupportedDeclaration = defineKind("unsupported", {
|
|
1593
|
+
...annotationBaseFields,
|
|
1594
|
+
rawSubtypeCode: field.engine(z.number().int()),
|
|
1595
|
+
rawSubtypeName: field.engine(z.string()).nullable()
|
|
1596
|
+
});
|
|
1597
|
+
//#endregion
|
|
1598
|
+
//#region src/annotation/kinds/unsupported/index.ts
|
|
1599
|
+
const UnsupportedDTOSchema = UnsupportedDeclaration.readSchema;
|
|
1600
|
+
const UnsupportedDraftSchema = z.never();
|
|
1601
|
+
const UnsupportedPatchSchema = z.never();
|
|
1602
|
+
const UnsupportedKind = {
|
|
1603
|
+
subtype: "unsupported",
|
|
1604
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.UNKNOWN,
|
|
1605
|
+
dtoSchema: UnsupportedDTOSchema,
|
|
1606
|
+
draftSchema: UnsupportedDraftSchema,
|
|
1607
|
+
patchSchema: UnsupportedPatchSchema,
|
|
1608
|
+
readBackWrites: UnsupportedDeclaration.readBackWrites
|
|
1609
|
+
};
|
|
1610
|
+
//#endregion
|
|
1611
|
+
//#region src/identity/FormFieldRef.schema.ts
|
|
1612
|
+
/** Wire form of `FormFieldRef` — see the type. */
|
|
1613
|
+
const FormFieldRefSchema = z.discriminatedUnion("kind", [z.object({
|
|
1614
|
+
kind: z.literal("objectNumber"),
|
|
1615
|
+
objectNumber: z.number().int().positive()
|
|
1616
|
+
}), z.object({
|
|
1617
|
+
kind: z.literal("fqn"),
|
|
1618
|
+
name: z.string().min(1)
|
|
1619
|
+
})]);
|
|
1620
|
+
//#endregion
|
|
1621
|
+
//#region src/annotation/kinds/widget/declaration.ts
|
|
1622
|
+
const WidgetDeclaration = defineKind("widget", {
|
|
1623
|
+
...annotationBaseFields,
|
|
1624
|
+
...widgetBoxFields,
|
|
1625
|
+
color: field.data(ColorSchema).nullable().optional(),
|
|
1626
|
+
interiorColor: field.data(ColorSchema).nullable().optional(),
|
|
1627
|
+
strokeWidth: field.data(z.number().nonnegative()).optional(),
|
|
1628
|
+
borderStyle: field.data(WidgetBorderStyleSchema).optional(),
|
|
1629
|
+
/** The border's dash pattern (`/BS /D`), for a dashed border; `null` for the default (3 on, 3 off). */
|
|
1630
|
+
dashArray: field.data(z.array(z.number().nonnegative())).nullable().optional(),
|
|
1631
|
+
/**
|
|
1632
|
+
* The font `/DA` names, as a free text names its font: a standard font's
|
|
1633
|
+
* name, a registered font's key, or the family of a font the document has.
|
|
1634
|
+
* `null` when `/DA` names none. A write takes a standard name or a key.
|
|
1635
|
+
*/
|
|
1636
|
+
fontFamily: field.data(FontNameSchema).nullable().optional(),
|
|
1637
|
+
fontSize: field.data(z.number().nonnegative()).nullable().optional(),
|
|
1638
|
+
fontColor: field.data(ColorSchema).nullable().optional(),
|
|
1639
|
+
textAlign: field.data(TextAlignmentSchema).optional(),
|
|
1640
|
+
/**
|
|
1641
|
+
* A push button's caption (`/MK /CA`), drawn centred on the button.
|
|
1642
|
+
* `null` for every other widget, whose `/MK /CA` is no caption (a
|
|
1643
|
+
* checkbox's is its symbol); a caption written to one is refused.
|
|
1644
|
+
*/
|
|
1645
|
+
caption: field.data(z.string()).nullable().optional(),
|
|
1646
|
+
/**
|
|
1647
|
+
* The symbol a checkbox's or radio button's widget shows while it's on
|
|
1648
|
+
* (`/MK /CA`); `null` shows its family's own, a checkbox's check and a
|
|
1649
|
+
* radio button's circle. Always `null` for other widgets, and one written
|
|
1650
|
+
* to another widget is refused.
|
|
1651
|
+
*/
|
|
1652
|
+
checkStyle: field.data(WidgetCheckStyleSchema).nullable().optional(),
|
|
1653
|
+
/**
|
|
1654
|
+
* `/A` and `/AA`: what the widget does when clicked, entered, focused and
|
|
1655
|
+
* so on. A write sets an event's action, `null` removes it, an event left
|
|
1656
|
+
* out keeps what it has; `null` for the whole removes them all. The
|
|
1657
|
+
* actions a read returns, sent back unchanged, are kept.
|
|
1658
|
+
*/
|
|
1659
|
+
actions: field.data(FileAnnotationActionsSchema).writes(FileWidgetActionsPatchSchema).readBack().nullable().optional().space("actions"),
|
|
1660
|
+
/** The field the widget belongs to, or `null` when it's in none. */
|
|
1661
|
+
field: field.engine(FormFieldRefSchema).nullable(),
|
|
1662
|
+
/** Its field's family, so a widget reads as what it is without the form. */
|
|
1663
|
+
fieldFamily: field.engine(z.enum([
|
|
1664
|
+
"text",
|
|
1665
|
+
"checkbox",
|
|
1666
|
+
"radio",
|
|
1667
|
+
"combobox",
|
|
1668
|
+
"listbox",
|
|
1669
|
+
"pushbutton",
|
|
1670
|
+
"signature",
|
|
1671
|
+
"unknown"
|
|
1672
|
+
]))
|
|
1673
|
+
});
|
|
1674
|
+
//#endregion
|
|
1675
|
+
//#region src/annotation/kinds/widget/index.ts
|
|
1676
|
+
const WidgetDTOSchema = WidgetDeclaration.readSchema;
|
|
1677
|
+
const WidgetDraftSchema = WidgetDeclaration.createSchema;
|
|
1678
|
+
const WidgetPatchSchema = WidgetDeclaration.updateSchema;
|
|
1679
|
+
const WidgetKind = {
|
|
1680
|
+
subtype: "widget",
|
|
1681
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.WIDGET,
|
|
1682
|
+
dtoSchema: WidgetDTOSchema,
|
|
1683
|
+
draftSchema: WidgetDraftSchema,
|
|
1684
|
+
patchSchema: WidgetPatchSchema,
|
|
1685
|
+
readBackWrites: WidgetDeclaration.readBackWrites
|
|
1686
|
+
};
|
|
1687
|
+
//#endregion
|
|
1688
|
+
//#region src/annotation/kinds/declarations.ts
|
|
1689
|
+
/** Every annotation kind's declaration, in the engine's catalog order. */
|
|
1690
|
+
const ANNOTATION_DECLARATIONS = [
|
|
1691
|
+
HighlightDeclaration,
|
|
1692
|
+
UnderlineDeclaration,
|
|
1693
|
+
SquigglyDeclaration,
|
|
1694
|
+
StrikeoutDeclaration,
|
|
1695
|
+
CircleDeclaration,
|
|
1696
|
+
SquareDeclaration,
|
|
1697
|
+
PolygonDeclaration,
|
|
1698
|
+
PolylineDeclaration,
|
|
1699
|
+
LineDeclaration,
|
|
1700
|
+
LinkDeclaration,
|
|
1701
|
+
InkDeclaration,
|
|
1702
|
+
FreeTextDeclaration,
|
|
1703
|
+
CaretDeclaration,
|
|
1704
|
+
TextDeclaration,
|
|
1705
|
+
StampDeclaration,
|
|
1706
|
+
FileAttachmentDeclaration,
|
|
1707
|
+
WidgetDeclaration,
|
|
1708
|
+
RedactDeclaration,
|
|
1709
|
+
PopupDeclaration,
|
|
1710
|
+
UnsupportedDeclaration
|
|
1711
|
+
];
|
|
1712
|
+
/** Looks up a kind's declaration by its `subtype`. */
|
|
1713
|
+
function declarationOf(subtype) {
|
|
1714
|
+
return ANNOTATION_DECLARATIONS.find((declaration) => declaration.subtype === subtype) ?? null;
|
|
1715
|
+
}
|
|
1716
|
+
/** The style fields' schemas, as a widget annotation's update takes them. */
|
|
1717
|
+
const WIDGET_STYLE_SHAPE = Object.fromEntries([
|
|
1718
|
+
"color",
|
|
1719
|
+
"interiorColor",
|
|
1720
|
+
"strokeWidth",
|
|
1721
|
+
"borderStyle",
|
|
1722
|
+
"dashArray",
|
|
1723
|
+
"fontFamily",
|
|
1724
|
+
"fontSize",
|
|
1725
|
+
"fontColor",
|
|
1726
|
+
"textAlign",
|
|
1727
|
+
"caption",
|
|
1728
|
+
"checkStyle"
|
|
1729
|
+
].map((name) => [name, WidgetDeclaration.shapes.update[name]]));
|
|
1730
|
+
const WidgetAppearanceSchema = z.object(WIDGET_STYLE_SHAPE).strict();
|
|
1731
|
+
//#endregion
|
|
1732
|
+
//#region src/annotation/kinds/index.ts
|
|
1733
|
+
/**
|
|
1734
|
+
* The closed-world catalog of currently-implemented annotation kinds.
|
|
1735
|
+
*
|
|
1736
|
+
* Adding a new subtype is one folder under `kinds/<name>/` with its
|
|
1737
|
+
* `declaration.ts` and `index.ts`, and one entry in this tuple and in
|
|
1738
|
+
* `declarations.ts`. The discriminated unions and zod discriminator below regenerate
|
|
1739
|
+
* automatically; no other file in the package needs to change.
|
|
1740
|
+
*
|
|
1741
|
+
* Every subtype the engine has not yet wired up rides on
|
|
1742
|
+
* `UnsupportedKind`. The wire format is stable: when a per-subtype reader
|
|
1743
|
+
* lands later, the engine starts emitting the dedicated DTO instead of
|
|
1744
|
+
* `unsupported`, and existing clients widen their handling without a
|
|
1745
|
+
* version bump.
|
|
1746
|
+
*/
|
|
1747
|
+
const ANNOTATION_KINDS = [
|
|
1748
|
+
HighlightKind,
|
|
1749
|
+
UnderlineKind,
|
|
1750
|
+
SquigglyKind,
|
|
1751
|
+
StrikeoutKind,
|
|
1752
|
+
CircleKind,
|
|
1753
|
+
SquareKind,
|
|
1754
|
+
PolygonKind,
|
|
1755
|
+
PolylineKind,
|
|
1756
|
+
LineKind,
|
|
1757
|
+
LinkKind,
|
|
1758
|
+
InkKind,
|
|
1759
|
+
FreeTextKind,
|
|
1760
|
+
CaretKind,
|
|
1761
|
+
TextKind,
|
|
1762
|
+
StampKind,
|
|
1763
|
+
FileAttachmentKind,
|
|
1764
|
+
WidgetKind,
|
|
1765
|
+
RedactKind,
|
|
1766
|
+
PopupKind,
|
|
1767
|
+
UnsupportedKind
|
|
1768
|
+
];
|
|
1769
|
+
/**
|
|
1770
|
+
* Lookup helper for the engine's reader catalog and identity resolver.
|
|
1771
|
+
* O(1) by `subtype` literal at runtime.
|
|
1772
|
+
*/
|
|
1773
|
+
const KIND_BY_SUBTYPE = Object.freeze(Object.fromEntries(ANNOTATION_KINDS.map((kind) => [kind.subtype, kind])));
|
|
1774
|
+
/**
|
|
1775
|
+
* Runtime zod schema for the discriminated union. The cast unwinds the
|
|
1776
|
+
* generic schema map into the specific tuple form `discriminatedUnion`
|
|
1777
|
+
* needs. Servers and cloud clients use this to validate every annotation
|
|
1778
|
+
* payload on the wire.
|
|
1779
|
+
*/
|
|
1780
|
+
const AnnotationSchema = z.discriminatedUnion("subtype", [
|
|
1781
|
+
HighlightKind.dtoSchema,
|
|
1782
|
+
UnderlineKind.dtoSchema,
|
|
1783
|
+
SquigglyKind.dtoSchema,
|
|
1784
|
+
StrikeoutKind.dtoSchema,
|
|
1785
|
+
CircleKind.dtoSchema,
|
|
1786
|
+
SquareKind.dtoSchema,
|
|
1787
|
+
PolygonKind.dtoSchema,
|
|
1788
|
+
PolylineKind.dtoSchema,
|
|
1789
|
+
LineKind.dtoSchema,
|
|
1790
|
+
LinkKind.dtoSchema,
|
|
1791
|
+
InkKind.dtoSchema,
|
|
1792
|
+
FreeTextKind.dtoSchema,
|
|
1793
|
+
CaretKind.dtoSchema,
|
|
1794
|
+
TextKind.dtoSchema,
|
|
1795
|
+
StampKind.dtoSchema,
|
|
1796
|
+
FileAttachmentKind.dtoSchema,
|
|
1797
|
+
WidgetKind.dtoSchema,
|
|
1798
|
+
RedactKind.dtoSchema,
|
|
1799
|
+
PopupKind.dtoSchema,
|
|
1800
|
+
UnsupportedKind.dtoSchema
|
|
1801
|
+
]);
|
|
1802
|
+
/** Validates a create's data against its kind. */
|
|
1803
|
+
const AnnotationDraftSchema = z.discriminatedUnion("subtype", [
|
|
1804
|
+
HighlightKind.draftSchema,
|
|
1805
|
+
UnderlineKind.draftSchema,
|
|
1806
|
+
SquigglyKind.draftSchema,
|
|
1807
|
+
StrikeoutKind.draftSchema,
|
|
1808
|
+
CircleKind.draftSchema,
|
|
1809
|
+
SquareKind.draftSchema,
|
|
1810
|
+
PolygonKind.draftSchema,
|
|
1811
|
+
PolylineKind.draftSchema,
|
|
1812
|
+
LineKind.draftSchema,
|
|
1813
|
+
LinkKind.draftSchema,
|
|
1814
|
+
InkKind.draftSchema,
|
|
1815
|
+
FreeTextKind.draftSchema,
|
|
1816
|
+
CaretKind.draftSchema,
|
|
1817
|
+
TextKind.draftSchema,
|
|
1818
|
+
StampKind.draftSchema,
|
|
1819
|
+
FileAttachmentKind.draftSchema,
|
|
1820
|
+
WidgetKind.draftSchema,
|
|
1821
|
+
RedactKind.draftSchema,
|
|
1822
|
+
PopupKind.draftSchema
|
|
1823
|
+
]);
|
|
1824
|
+
/**
|
|
1825
|
+
* Validates a patch against every kind. A
|
|
1826
|
+
* patch may leave out its `subtype`, so this only checks that the patch fits
|
|
1827
|
+
* some kind; {@link annotationPatchSchemaOf} checks it against its target.
|
|
1828
|
+
*/
|
|
1829
|
+
const AnnotationPatchSchema = z.union(ANNOTATION_KINDS.filter((kind) => kind.subtype !== "unsupported").map((kind) => kind.patchSchema));
|
|
1830
|
+
/** The patch schema of one kind: how an update of an annotation of that kind is checked. */
|
|
1831
|
+
function annotationPatchSchemaOf(subtype) {
|
|
1832
|
+
return KIND_BY_SUBTYPE[subtype].patchSchema;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* A create's data in the file's coordinates, checked against its kind: the
|
|
1836
|
+
* engine's own check, after the worker converted the data from page space.
|
|
1837
|
+
*/
|
|
1838
|
+
const FileAnnotationDraftSchema = z.discriminatedUnion("subtype", ANNOTATION_DECLARATIONS.filter((declaration) => declaration.subtype !== "unsupported").map((declaration) => declaration.fileSchemas.create));
|
|
1839
|
+
/** An update's data in the file's coordinates, checked against the kind it changes. */
|
|
1840
|
+
function fileAnnotationPatchSchemaOf(subtype) {
|
|
1841
|
+
return declarationOf(subtype).fileSchemas.update;
|
|
1842
|
+
}
|
|
1843
|
+
//#endregion
|
|
1844
|
+
//#region src/forms/schema.ts
|
|
1845
|
+
const FormWidgetShape = {
|
|
1846
|
+
ref: AnnotationRefSchema.nullable(),
|
|
1847
|
+
objectNumber: z.number().int().nonnegative(),
|
|
1848
|
+
page: PageRefSchema.nullable()
|
|
1849
|
+
};
|
|
1850
|
+
const FormWidgetSchema = z.object(FormWidgetShape);
|
|
1851
|
+
const FormFieldWidgetSchema = FormWidgetSchema;
|
|
1852
|
+
const ToggleFieldWidgetSchema = z.object({
|
|
1853
|
+
...FormWidgetShape,
|
|
1854
|
+
onState: z.string(),
|
|
1855
|
+
exportValue: z.string(),
|
|
1856
|
+
checked: z.boolean()
|
|
1857
|
+
});
|
|
1858
|
+
const FormFieldOptionSchema = z.object({
|
|
1859
|
+
label: z.string(),
|
|
1860
|
+
value: z.string(),
|
|
1861
|
+
selected: z.boolean()
|
|
1862
|
+
});
|
|
1863
|
+
const FormValueEntrySchema = z.discriminatedUnion("kind", [
|
|
1864
|
+
z.object({ kind: z.literal("none") }),
|
|
1865
|
+
z.object({
|
|
1866
|
+
kind: z.literal("scalar"),
|
|
1867
|
+
value: z.string()
|
|
1868
|
+
}),
|
|
1869
|
+
z.object({
|
|
1870
|
+
kind: z.literal("array"),
|
|
1871
|
+
values: z.array(z.string())
|
|
1872
|
+
}),
|
|
1873
|
+
z.object({ kind: z.literal("unsupported") })
|
|
1874
|
+
]);
|
|
1875
|
+
const FormFieldBaseShape = {
|
|
1876
|
+
ref: FormFieldRefSchema,
|
|
1877
|
+
name: z.string(),
|
|
1878
|
+
origin: z.enum(["acroform", "recovered"]),
|
|
1879
|
+
readOnly: z.boolean(),
|
|
1880
|
+
required: z.boolean(),
|
|
1881
|
+
noExport: z.boolean(),
|
|
1882
|
+
alternateName: z.string().nullable(),
|
|
1883
|
+
mappingName: z.string().nullable(),
|
|
1884
|
+
valueEntry: FormValueEntrySchema,
|
|
1885
|
+
defaultValueEntry: FormValueEntrySchema,
|
|
1886
|
+
actions: PdfFieldActionsSchema.optional(),
|
|
1887
|
+
groupId: z.string().nullable(),
|
|
1888
|
+
createdBy: z.string().nullable(),
|
|
1889
|
+
createdAt: IsoDateTimeSchema.nullable(),
|
|
1890
|
+
filledBy: z.string().nullable(),
|
|
1891
|
+
filledByName: z.string().nullable(),
|
|
1892
|
+
filledAt: IsoDateTimeSchema.nullable(),
|
|
1893
|
+
importedBy: z.string().nullable(),
|
|
1894
|
+
widgets: z.array(FormFieldWidgetSchema)
|
|
1895
|
+
};
|
|
1896
|
+
const FormFieldDTOSchema = z.discriminatedUnion("family", [
|
|
1897
|
+
z.object({
|
|
1898
|
+
...FormFieldBaseShape,
|
|
1899
|
+
family: z.literal("text"),
|
|
1900
|
+
value: z.string(),
|
|
1901
|
+
defaultValue: z.string(),
|
|
1902
|
+
maxLength: z.number().int().positive().nullable(),
|
|
1903
|
+
multiline: z.boolean(),
|
|
1904
|
+
password: z.boolean(),
|
|
1905
|
+
comb: z.boolean()
|
|
1906
|
+
}),
|
|
1907
|
+
z.object({
|
|
1908
|
+
...FormFieldBaseShape,
|
|
1909
|
+
family: z.literal("checkbox"),
|
|
1910
|
+
checked: z.boolean(),
|
|
1911
|
+
exportValue: z.string(),
|
|
1912
|
+
widgets: z.array(ToggleFieldWidgetSchema)
|
|
1913
|
+
}),
|
|
1914
|
+
z.object({
|
|
1915
|
+
...FormFieldBaseShape,
|
|
1916
|
+
family: z.literal("radio"),
|
|
1917
|
+
value: z.string(),
|
|
1918
|
+
radiosInUnison: z.boolean(),
|
|
1919
|
+
noToggleToOff: z.boolean(),
|
|
1920
|
+
widgets: z.array(ToggleFieldWidgetSchema)
|
|
1921
|
+
}),
|
|
1922
|
+
z.object({
|
|
1923
|
+
...FormFieldBaseShape,
|
|
1924
|
+
family: z.literal("combobox"),
|
|
1925
|
+
value: z.string(),
|
|
1926
|
+
defaultValue: z.string(),
|
|
1927
|
+
edit: z.boolean(),
|
|
1928
|
+
options: z.array(FormFieldOptionSchema)
|
|
1929
|
+
}),
|
|
1930
|
+
z.object({
|
|
1931
|
+
...FormFieldBaseShape,
|
|
1932
|
+
family: z.literal("listbox"),
|
|
1933
|
+
selectedValues: z.array(z.string()),
|
|
1934
|
+
defaultValue: z.array(z.string()),
|
|
1935
|
+
multiSelect: z.boolean(),
|
|
1936
|
+
options: z.array(FormFieldOptionSchema),
|
|
1937
|
+
topIndex: z.number().int().nonnegative()
|
|
1938
|
+
}),
|
|
1939
|
+
z.object({
|
|
1940
|
+
...FormFieldBaseShape,
|
|
1941
|
+
family: z.literal("pushbutton")
|
|
1942
|
+
}),
|
|
1943
|
+
z.object({
|
|
1944
|
+
...FormFieldBaseShape,
|
|
1945
|
+
family: z.literal("signature")
|
|
1946
|
+
}),
|
|
1947
|
+
z.object({
|
|
1948
|
+
...FormFieldBaseShape,
|
|
1949
|
+
family: z.literal("unknown"),
|
|
1950
|
+
rawValue: z.string()
|
|
1951
|
+
})
|
|
1952
|
+
]);
|
|
1953
|
+
const FormKindSchema = z.enum([
|
|
1954
|
+
"none",
|
|
1955
|
+
"acroform",
|
|
1956
|
+
"xfa"
|
|
1957
|
+
]);
|
|
1958
|
+
const FormSnapshotSchema = z.object({
|
|
1959
|
+
formKind: FormKindSchema,
|
|
1960
|
+
needsAppearances: z.boolean(),
|
|
1961
|
+
fields: z.array(FormFieldDTOSchema),
|
|
1962
|
+
widgets: z.array(WidgetDTOSchema),
|
|
1963
|
+
calculationOrder: z.array(FormFieldRefSchema.nullable())
|
|
1964
|
+
});
|
|
1965
|
+
/**
|
|
1966
|
+
* `{ value }`, `{ checked }` or `{ selectedValues }`: one object with exactly
|
|
1967
|
+
* one of the three, so the wire has no untagged union (the API reference
|
|
1968
|
+
* labels variants by a discriminating literal, and a value has none to add).
|
|
1969
|
+
*/
|
|
1970
|
+
const FormFieldValueSchema = z.object({
|
|
1971
|
+
value: z.string().nullable().optional(),
|
|
1972
|
+
checked: z.boolean().optional(),
|
|
1973
|
+
selectedValues: z.array(z.string()).optional()
|
|
1974
|
+
}).strict().refine((value) => [
|
|
1975
|
+
value.value,
|
|
1976
|
+
value.checked,
|
|
1977
|
+
value.selectedValues
|
|
1978
|
+
].filter((set) => set !== void 0).length === 1, { message: "exactly one of value, checked or selectedValues" });
|
|
1979
|
+
const WidgetPlacementSchema = z.object({
|
|
1980
|
+
page: PageRefSchema,
|
|
1981
|
+
rect: PageBoxSchema.optional(),
|
|
1982
|
+
box: PageBoxSchema.optional(),
|
|
1983
|
+
rotation: PdfRotationSchema.optional(),
|
|
1984
|
+
exportValue: z.string().min(1).optional(),
|
|
1985
|
+
actions: WidgetActionsPatchSchema.optional(),
|
|
1986
|
+
...WIDGET_STYLE_SHAPE
|
|
1987
|
+
}).strict();
|
|
1988
|
+
const FormFieldOptionInputSchema = z.object({
|
|
1989
|
+
label: z.string(),
|
|
1990
|
+
value: z.string()
|
|
1991
|
+
});
|
|
1992
|
+
const FormFieldDraftBaseShape = {
|
|
1993
|
+
name: z.string().min(1),
|
|
1994
|
+
readOnly: z.boolean().optional(),
|
|
1995
|
+
required: z.boolean().optional(),
|
|
1996
|
+
noExport: z.boolean().optional(),
|
|
1997
|
+
alternateName: z.string().optional(),
|
|
1998
|
+
mappingName: z.string().optional(),
|
|
1999
|
+
groupId: z.string().min(1).max(256).optional(),
|
|
2000
|
+
actions: FieldActionsPatchSchema.optional(),
|
|
2001
|
+
widgets: z.array(WidgetPlacementSchema).optional()
|
|
2002
|
+
};
|
|
2003
|
+
/** A draft that names a member its family doesn't have is refused, not trimmed. */
|
|
2004
|
+
const FormFieldDraftSchema = z.discriminatedUnion("family", [
|
|
2005
|
+
z.object({
|
|
2006
|
+
...FormFieldDraftBaseShape,
|
|
2007
|
+
family: z.literal("text"),
|
|
2008
|
+
defaultValue: z.string().optional(),
|
|
2009
|
+
maxLength: z.number().int().positive().optional(),
|
|
2010
|
+
multiline: z.boolean().optional(),
|
|
2011
|
+
password: z.boolean().optional(),
|
|
2012
|
+
comb: z.boolean().optional()
|
|
2013
|
+
}).strict(),
|
|
2014
|
+
z.object({
|
|
2015
|
+
...FormFieldDraftBaseShape,
|
|
2016
|
+
family: z.literal("checkbox")
|
|
2017
|
+
}).strict(),
|
|
2018
|
+
z.object({
|
|
2019
|
+
...FormFieldDraftBaseShape,
|
|
2020
|
+
family: z.literal("radio"),
|
|
2021
|
+
radiosInUnison: z.boolean().optional(),
|
|
2022
|
+
noToggleToOff: z.boolean().optional()
|
|
2023
|
+
}).strict(),
|
|
2024
|
+
z.object({
|
|
2025
|
+
...FormFieldDraftBaseShape,
|
|
2026
|
+
family: z.literal("combobox"),
|
|
2027
|
+
edit: z.boolean().optional(),
|
|
2028
|
+
options: z.array(FormFieldOptionInputSchema).optional(),
|
|
2029
|
+
defaultValue: z.string().optional()
|
|
2030
|
+
}).strict(),
|
|
2031
|
+
z.object({
|
|
2032
|
+
...FormFieldDraftBaseShape,
|
|
2033
|
+
family: z.literal("listbox"),
|
|
2034
|
+
multiSelect: z.boolean().optional(),
|
|
2035
|
+
options: z.array(FormFieldOptionInputSchema).optional(),
|
|
2036
|
+
defaultValue: z.array(z.string()).optional()
|
|
2037
|
+
}).strict(),
|
|
2038
|
+
z.object({
|
|
2039
|
+
...FormFieldDraftBaseShape,
|
|
2040
|
+
family: z.literal("pushbutton")
|
|
2041
|
+
}).strict(),
|
|
2042
|
+
z.object({
|
|
2043
|
+
...FormFieldDraftBaseShape,
|
|
2044
|
+
family: z.literal("signature")
|
|
2045
|
+
}).strict()
|
|
2046
|
+
]);
|
|
2047
|
+
const FormFieldPatchBaseShape = {
|
|
2048
|
+
name: z.string().min(1).optional(),
|
|
2049
|
+
readOnly: z.boolean().optional(),
|
|
2050
|
+
required: z.boolean().optional(),
|
|
2051
|
+
noExport: z.boolean().optional(),
|
|
2052
|
+
alternateName: z.string().nullable().optional(),
|
|
2053
|
+
mappingName: z.string().nullable().optional(),
|
|
2054
|
+
groupId: z.string().min(1).max(256).optional(),
|
|
2055
|
+
actions: FieldActionsPatchSchema.optional()
|
|
2056
|
+
};
|
|
2057
|
+
/**
|
|
2058
|
+
* One object on the wire: the family is optional (the engine knows it from
|
|
2059
|
+
* the ref), so there is no discriminator, and the engine refuses members
|
|
2060
|
+
* the field's family doesn't have.
|
|
2061
|
+
*/
|
|
2062
|
+
const FormFieldPatchSchema = z.object({
|
|
2063
|
+
...FormFieldPatchBaseShape,
|
|
2064
|
+
family: z.enum([
|
|
2065
|
+
"text",
|
|
2066
|
+
"checkbox",
|
|
2067
|
+
"radio",
|
|
2068
|
+
"combobox",
|
|
2069
|
+
"listbox",
|
|
2070
|
+
"pushbutton",
|
|
2071
|
+
"signature"
|
|
2072
|
+
]).optional(),
|
|
2073
|
+
defaultValue: z.union([z.string(), z.array(z.string())]).nullable().optional(),
|
|
2074
|
+
maxLength: z.number().int().positive().nullable().optional(),
|
|
2075
|
+
multiline: z.boolean().optional(),
|
|
2076
|
+
password: z.boolean().optional(),
|
|
2077
|
+
comb: z.boolean().optional(),
|
|
2078
|
+
radiosInUnison: z.boolean().optional(),
|
|
2079
|
+
noToggleToOff: z.boolean().optional(),
|
|
2080
|
+
edit: z.boolean().optional(),
|
|
2081
|
+
multiSelect: z.boolean().optional(),
|
|
2082
|
+
options: z.array(FormFieldOptionInputSchema).optional()
|
|
2083
|
+
}).strict();
|
|
2084
|
+
//#endregion
|
|
2085
|
+
export { PolylineDTOSchema as $, PolygonIntentSchema as $t, UnderlineDTOSchema as A, InkIntentSchema as An, AppearanceResourceKeysSchema as At, StampDTOSchema as B, WidgetCheckStyleSchema as Bn, CaretPatchSchema as Bt, declarationOf as C, AnnotationRefSchema as Cn, FileAttachmentIconSchema as Ct, UnsupportedDTOSchema as D, DrawnBorderStyleSchema as Dn, AttachmentSchema as Dt, FormFieldRefSchema as E, ColorSchema as En, AttachmentRefSchema as Et, TextPatchSchema as F, StandardFontSchema as Fn, CircleDTOSchema as Ft, SquigglyDraftSchema as G, PagePointSchema as Gn, PageMeasurementViewportListSchema as Gt, StampPatchSchema as H, InkListSchema as Hn, LineDimensionCaptionSchema as Ht, NoteIconSchema as I, StrikeoutIntentSchema as In, CircleDraftSchema as It, SquareDraftSchema as J, PdfQuadSchema as Jn, PdfForeignMeasureSchema as Jt, SquigglyPatchSchema as K, PageQuadSchema as Kn, PageMeasurementViewportSchema as Kt, StrikeoutDTOSchema as L, TextAlignmentSchema as Ln, CirclePatchSchema as Lt, UnderlinePatchSchema as M, LineEndingsSchema as Mn, ImageResourceKeysSchema as Mt, TextDTOSchema as N, PointSchema as Nn, ResourceKeySchema as Nt, UnsupportedDraftSchema as O, FreeTextIntentSchema as On, WireAttachmentFileSchema as Ot, TextDraftSchema as P, RectSchema as Pn, SourceResourceKeysSchema as Pt, PopupPatchSchema as Q, PageRefSchema as Qn, PdfNumberFormatSchema as Qt, StrikeoutDraftSchema as R, VerticalAlignmentSchema as Rn, CaretDTOSchema as Rt, WidgetAppearanceSchema as S, AnnotationBorderStyleSchema as Sn, FileAttachmentPatchSchema as St, WidgetPatchSchema as T, CaretIntentSchema as Tn, AttachmentFileInfoSchema as Tt, StampFitSchema as U, LinePointsSchema as Un, LineIntentSchema as Ut, StampDraftSchema as V, CalloutLineSchema as Vn, LineCaptionPatchSchema as Vt, SquigglyDTOSchema as W, PageBoxSchema as Wn, LineLeaderSchema as Wt, PopupDTOSchema as X, PdfRotationSchema as Xn, PdfMeasureWriteSchema as Xt, SquarePatchSchema as Y, PdfRectSchema as Yn, PdfMeasureSchema as Yt, PopupDraftSchema as Z, PdfSizeSchema as Zn, PdfMeasurementSchema as Zt, AnnotationSchema as _, PdfPageActionsSchema as _n, FreeTextDTOSchema as _t, FormFieldPatchSchema as a, DocumentActionsSnapshotSchema as an, LinkDTOSchema as at, annotationPatchSchemaOf as b, PdfLinkTargetWritableSchema as bn, FileAttachmentDTOSchema as bt, FormKindSchema as c, FileWidgetActionsPatchSchema as cn, LineDTOSchema as ct, FormWidgetSchema as d, PdfActionTreeSchema as dn, InkDTOSchema as dt, PolylineIntentSchema as en, PolylineDraftSchema as et, ToggleFieldWidgetSchema as f, PdfActionTypeSchema as fn, InkDraftSchema as ft, AnnotationPatchSchema as g, PdfFieldActionsSchema as gn, HighlightPatchSchema as gt, AnnotationDraftSchema as h, PdfAnnotationActionsSchema as hn, HighlightDraftSchema as ht, FormFieldOptionSchema as i, IsoDateTimeSchema as in, PolygonPatchSchema as it, UnderlineDraftSchema as j, LineEndingSchema as jn, FileResourceKeysSchema as jt, UnsupportedPatchSchema as k, FreeTextIntentWriteSchema as kn, AnnotationResourceKeysSchema as kt, FormSnapshotSchema as l, PdfActionNodeSchema as ln, LineDraftSchema as lt, ANNOTATION_KINDS as m, PdfActionWriteSchema as mn, HighlightDTOSchema as mt, FormFieldDraftSchema as n, ShapeDimensionCaptionSchema as nn, PolygonDTOSchema as nt, FormFieldValueSchema as o, FieldActionsPatchSchema as on, LinkDraftSchema as ot, WidgetPlacementSchema as p, PdfActionWireComponents as pn, InkPatchSchema as pt, SquareDTOSchema as q, PdfPointSchema as qn, PageScaleInputSchema as qt, FormFieldOptionInputSchema as r, DateInputSchema as rn, PolygonDraftSchema as rt, FormFieldWidgetSchema as s, FieldScriptWriteSchema as sn, LinkPatchSchema as st, FormFieldDTOSchema as t, ShapeCaptionPatchSchema as tn, PolylinePatchSchema as tt, FormValueEntrySchema as u, PdfActionTargetRefSchema as un, LinePatchSchema as ut, FileAnnotationDraftSchema as v, WidgetActionsPatchSchema as vn, FreeTextDraftSchema as vt, WidgetDTOSchema as w, BlendModeSchema as wn, AttachmentFileBaseSchema as wt, fileAnnotationPatchSchemaOf as x, PdfDestinationSchema as xn, FileAttachmentDraftSchema as xt, KIND_BY_SUBTYPE as y, PdfLinkTargetSchema as yn, FreeTextPatchSchema as yt, StrikeoutPatchSchema as z, WidgetBorderStyleSchema as zn, CaretDraftSchema as zt };
|
|
2086
|
+
|
|
2087
|
+
//# sourceMappingURL=schema-6S2VmlAj.js.map
|