@embedpdf/engine-core 3.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -0
- package/README.md +24 -0
- package/dist/AbortError-ByBflvEl.cjs +38 -0
- package/dist/AbortError-ByBflvEl.cjs.map +1 -0
- package/dist/AbortError-CjSasIlL.js +27 -0
- package/dist/AbortError-CjSasIlL.js.map +1 -0
- package/dist/AnnotationListSnapshot-W0RCsyDE.d.cts +5043 -0
- package/dist/AnnotationListSnapshot-W0RCsyDE.d.ts +5043 -0
- package/dist/DocumentSecurityService-B-tULKNY.d.ts +332 -0
- package/dist/DocumentSecurityService-Df79fgpe.d.cts +332 -0
- package/dist/Engine-B7Oe7f5i.d.ts +1013 -0
- package/dist/Engine-D9loFZc1.d.cts +1013 -0
- package/dist/builders-BvikWRuO.cjs +1684 -0
- package/dist/builders-BvikWRuO.cjs.map +1 -0
- package/dist/builders-C548U47M.js +1367 -0
- package/dist/builders-C548U47M.js.map +1 -0
- package/dist/conformance.cjs +5414 -0
- package/dist/conformance.cjs.map +1 -0
- package/dist/conformance.d.cts +530 -0
- package/dist/conformance.d.ts +530 -0
- package/dist/conformance.js +5394 -0
- package/dist/conformance.js.map +1 -0
- package/dist/fold-CB4fAOOy.js +175 -0
- package/dist/fold-CB4fAOOy.js.map +1 -0
- package/dist/fold-IaMph3CO.cjs +216 -0
- package/dist/fold-IaMph3CO.cjs.map +1 -0
- package/dist/index.cjs +82 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/resolver-DAZWVoJL.cjs +434 -0
- package/dist/resolver-DAZWVoJL.cjs.map +1 -0
- package/dist/resolver-DiPMTfcy.js +363 -0
- package/dist/resolver-DiPMTfcy.js.map +1 -0
- package/dist/runtime.cjs +453 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +1002 -0
- package/dist/runtime.d.ts +1002 -0
- package/dist/runtime.js +361 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schemas-9OpSSeM6.js +2493 -0
- package/dist/schemas-9OpSSeM6.js.map +1 -0
- package/dist/schemas-B_1VyFsm.cjs +3608 -0
- package/dist/schemas-B_1VyFsm.cjs.map +1 -0
- package/dist/subtype-BvAzLCGC.js +196 -0
- package/dist/subtype-BvAzLCGC.js.map +1 -0
- package/dist/subtype-qejjVr6h.cjs +231 -0
- package/dist/subtype-qejjVr6h.cjs.map +1 -0
- package/dist/wire.cjs +1516 -0
- package/dist/wire.cjs.map +1 -0
- package/dist/wire.d.cts +1546 -0
- package/dist/wire.d.ts +1546 -0
- package/dist/wire.js +1280 -0
- package/dist/wire.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,2493 @@
|
|
|
1
|
+
import { i as PdfAnnotationSubtypeCode, o as EngineErrorCode } from "./subtype-BvAzLCGC.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/geometry/schemas.ts
|
|
4
|
+
/**
|
|
5
|
+
* Zod schemas for engine PDF-document geometry. Exported from `wire.ts` ONLY
|
|
6
|
+
* (never from `shared.ts`/`runtime`) so the zod-free runtime stays zod-free.
|
|
7
|
+
*/
|
|
8
|
+
const PdfPointSchema = z.object({
|
|
9
|
+
x: z.number(),
|
|
10
|
+
y: z.number()
|
|
11
|
+
});
|
|
12
|
+
const LinePointsSchema = z.object({
|
|
13
|
+
start: PdfPointSchema,
|
|
14
|
+
end: PdfPointSchema
|
|
15
|
+
});
|
|
16
|
+
/** `/CL` callout leader line — two points (straight) or three (knee-jointed). */
|
|
17
|
+
const CalloutLineSchema = z.union([z.tuple([PdfPointSchema, PdfPointSchema]), z.tuple([
|
|
18
|
+
PdfPointSchema,
|
|
19
|
+
PdfPointSchema,
|
|
20
|
+
PdfPointSchema
|
|
21
|
+
])]);
|
|
22
|
+
/** `/InkList` — an array of strokes, each an array of points. */
|
|
23
|
+
const InkListSchema = z.array(z.array(PdfPointSchema));
|
|
24
|
+
const PdfRectSchema = z.object({
|
|
25
|
+
left: z.number(),
|
|
26
|
+
bottom: z.number(),
|
|
27
|
+
right: z.number(),
|
|
28
|
+
top: z.number()
|
|
29
|
+
});
|
|
30
|
+
const PdfSizeSchema = z.object({
|
|
31
|
+
width: z.number().nonnegative(),
|
|
32
|
+
height: z.number().nonnegative()
|
|
33
|
+
});
|
|
34
|
+
const PdfQuadSchema = z.object({
|
|
35
|
+
p1: PdfPointSchema,
|
|
36
|
+
p2: PdfPointSchema,
|
|
37
|
+
p3: PdfPointSchema,
|
|
38
|
+
p4: PdfPointSchema
|
|
39
|
+
});
|
|
40
|
+
const PdfRotationSchema = z.union([
|
|
41
|
+
z.literal(0),
|
|
42
|
+
z.literal(90),
|
|
43
|
+
z.literal(180),
|
|
44
|
+
z.literal(270)
|
|
45
|
+
]);
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/dto/PdfAction.schema.ts
|
|
48
|
+
const PdfActionTypeSchema = z.enum([
|
|
49
|
+
"unknown",
|
|
50
|
+
"goto",
|
|
51
|
+
"goto-remote",
|
|
52
|
+
"goto-embedded",
|
|
53
|
+
"launch",
|
|
54
|
+
"thread",
|
|
55
|
+
"uri",
|
|
56
|
+
"sound",
|
|
57
|
+
"movie",
|
|
58
|
+
"hide",
|
|
59
|
+
"named",
|
|
60
|
+
"submit-form",
|
|
61
|
+
"reset-form",
|
|
62
|
+
"import-data",
|
|
63
|
+
"javascript",
|
|
64
|
+
"set-ocg-state",
|
|
65
|
+
"rendition",
|
|
66
|
+
"transition",
|
|
67
|
+
"goto-3d-view"
|
|
68
|
+
]);
|
|
69
|
+
const PdfActionNodeSchema = z.lazy(() => z.object({
|
|
70
|
+
type: PdfActionTypeSchema,
|
|
71
|
+
subtype: z.string(),
|
|
72
|
+
script: z.string().optional(),
|
|
73
|
+
next: z.array(PdfActionNodeSchema)
|
|
74
|
+
}));
|
|
75
|
+
const PdfActionTreeSchema = z.object({
|
|
76
|
+
root: PdfActionNodeSchema.nullable(),
|
|
77
|
+
incomplete: z.boolean(),
|
|
78
|
+
warningFlags: z.number().int().nonnegative(),
|
|
79
|
+
warnings: z.array(z.enum([
|
|
80
|
+
"cycle-dropped",
|
|
81
|
+
"malformed-next",
|
|
82
|
+
"incomplete"
|
|
83
|
+
]))
|
|
84
|
+
});
|
|
85
|
+
const PdfFieldActionsSchema = z.object({
|
|
86
|
+
keystroke: PdfActionTreeSchema.optional(),
|
|
87
|
+
format: PdfActionTreeSchema.optional(),
|
|
88
|
+
validate: PdfActionTreeSchema.optional(),
|
|
89
|
+
calculate: PdfActionTreeSchema.optional()
|
|
90
|
+
});
|
|
91
|
+
const PdfPageActionsSchema = z.object({
|
|
92
|
+
open: PdfActionTreeSchema.optional(),
|
|
93
|
+
close: PdfActionTreeSchema.optional()
|
|
94
|
+
});
|
|
95
|
+
const PdfAnnotationActionsSchema = z.object({
|
|
96
|
+
activate: PdfActionTreeSchema.optional(),
|
|
97
|
+
cursorEnter: PdfActionTreeSchema.optional(),
|
|
98
|
+
cursorExit: PdfActionTreeSchema.optional(),
|
|
99
|
+
mouseDown: PdfActionTreeSchema.optional(),
|
|
100
|
+
mouseUp: PdfActionTreeSchema.optional(),
|
|
101
|
+
focus: PdfActionTreeSchema.optional(),
|
|
102
|
+
blur: PdfActionTreeSchema.optional(),
|
|
103
|
+
pageOpen: PdfActionTreeSchema.optional(),
|
|
104
|
+
pageClose: PdfActionTreeSchema.optional(),
|
|
105
|
+
pageVisible: PdfActionTreeSchema.optional(),
|
|
106
|
+
pageInvisible: PdfActionTreeSchema.optional()
|
|
107
|
+
});
|
|
108
|
+
const DocumentActionsSnapshotSchema = z.object({
|
|
109
|
+
nameTreeScripts: z.array(z.object({
|
|
110
|
+
name: z.string(),
|
|
111
|
+
action: PdfActionTreeSchema
|
|
112
|
+
})),
|
|
113
|
+
openAction: PdfActionTreeSchema.nullable(),
|
|
114
|
+
willClose: PdfActionTreeSchema.optional(),
|
|
115
|
+
willSave: PdfActionTreeSchema.optional(),
|
|
116
|
+
didSave: PdfActionTreeSchema.optional(),
|
|
117
|
+
willPrint: PdfActionTreeSchema.optional(),
|
|
118
|
+
didPrint: PdfActionTreeSchema.optional()
|
|
119
|
+
});
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/annotation/base.schema.ts
|
|
122
|
+
/** @deprecated Use `PdfPointSchema` from `../geometry/schemas`. */
|
|
123
|
+
const PointSchema = PdfPointSchema;
|
|
124
|
+
/** @deprecated Use `PdfRectSchema` from `../geometry/schemas`. */
|
|
125
|
+
const RectSchema = PdfRectSchema;
|
|
126
|
+
const ColorSchema = z.object({
|
|
127
|
+
r: z.number().int().min(0).max(255),
|
|
128
|
+
g: z.number().int().min(0).max(255),
|
|
129
|
+
b: z.number().int().min(0).max(255)
|
|
130
|
+
});
|
|
131
|
+
const AnnotationBorderStyleSchema = z.enum([
|
|
132
|
+
"solid",
|
|
133
|
+
"dashed",
|
|
134
|
+
"beveled",
|
|
135
|
+
"inset"
|
|
136
|
+
]);
|
|
137
|
+
const PdfRectDifferencesSchema = z.object({
|
|
138
|
+
left: z.number().nonnegative(),
|
|
139
|
+
top: z.number().nonnegative(),
|
|
140
|
+
right: z.number().nonnegative(),
|
|
141
|
+
bottom: z.number().nonnegative()
|
|
142
|
+
});
|
|
143
|
+
const LineEndingSchema = z.enum([
|
|
144
|
+
"none",
|
|
145
|
+
"square",
|
|
146
|
+
"circle",
|
|
147
|
+
"diamond",
|
|
148
|
+
"open-arrow",
|
|
149
|
+
"closed-arrow",
|
|
150
|
+
"butt",
|
|
151
|
+
"r-open-arrow",
|
|
152
|
+
"r-closed-arrow",
|
|
153
|
+
"slash"
|
|
154
|
+
]);
|
|
155
|
+
const LineEndingsSchema = z.object({
|
|
156
|
+
start: LineEndingSchema,
|
|
157
|
+
end: LineEndingSchema
|
|
158
|
+
});
|
|
159
|
+
const StandardFontSchema = z.enum([
|
|
160
|
+
"courier",
|
|
161
|
+
"courier-bold",
|
|
162
|
+
"courier-bold-oblique",
|
|
163
|
+
"courier-oblique",
|
|
164
|
+
"helvetica",
|
|
165
|
+
"helvetica-bold",
|
|
166
|
+
"helvetica-bold-oblique",
|
|
167
|
+
"helvetica-oblique",
|
|
168
|
+
"times-roman",
|
|
169
|
+
"times-bold",
|
|
170
|
+
"times-bold-italic",
|
|
171
|
+
"times-italic",
|
|
172
|
+
"symbol",
|
|
173
|
+
"zapf-dingbats"
|
|
174
|
+
]);
|
|
175
|
+
const TextAlignmentSchema = z.enum([
|
|
176
|
+
"left",
|
|
177
|
+
"center",
|
|
178
|
+
"right"
|
|
179
|
+
]);
|
|
180
|
+
const FreeTextIntentSchema = z.enum(["free-text", "free-text-callout"]);
|
|
181
|
+
const CaretIntentSchema = z.literal("replace");
|
|
182
|
+
const StrikeoutIntentSchema = z.literal("strikeout-text-edit");
|
|
183
|
+
const InkIntentSchema = z.literal("ink-highlight");
|
|
184
|
+
const BlendModeSchema = z.enum([
|
|
185
|
+
"normal",
|
|
186
|
+
"multiply",
|
|
187
|
+
"screen",
|
|
188
|
+
"overlay",
|
|
189
|
+
"darken",
|
|
190
|
+
"lighten",
|
|
191
|
+
"color-dodge",
|
|
192
|
+
"color-burn",
|
|
193
|
+
"hard-light",
|
|
194
|
+
"soft-light",
|
|
195
|
+
"difference",
|
|
196
|
+
"exclusion",
|
|
197
|
+
"hue",
|
|
198
|
+
"saturation",
|
|
199
|
+
"color",
|
|
200
|
+
"luminosity"
|
|
201
|
+
]);
|
|
202
|
+
const AnnotationFlagsSchema = z.object({
|
|
203
|
+
invisible: z.boolean(),
|
|
204
|
+
hidden: z.boolean(),
|
|
205
|
+
print: z.boolean(),
|
|
206
|
+
noZoom: z.boolean(),
|
|
207
|
+
noRotate: z.boolean(),
|
|
208
|
+
noView: z.boolean(),
|
|
209
|
+
readOnly: z.boolean(),
|
|
210
|
+
locked: z.boolean(),
|
|
211
|
+
toggleNoView: z.boolean(),
|
|
212
|
+
lockedContents: z.boolean()
|
|
213
|
+
});
|
|
214
|
+
/**
|
|
215
|
+
* Partial flag set authorable on a Draft or Patch — every key optional so
|
|
216
|
+
* callers set only the bits they care about. The engine merges these onto
|
|
217
|
+
* the annotation's current `/F` bitset.
|
|
218
|
+
*/
|
|
219
|
+
const AnnotationFlagsPartialSchema = z.object({
|
|
220
|
+
invisible: z.boolean(),
|
|
221
|
+
hidden: z.boolean(),
|
|
222
|
+
print: z.boolean(),
|
|
223
|
+
noZoom: z.boolean(),
|
|
224
|
+
noRotate: z.boolean(),
|
|
225
|
+
noView: z.boolean(),
|
|
226
|
+
readOnly: z.boolean(),
|
|
227
|
+
locked: z.boolean(),
|
|
228
|
+
toggleNoView: z.boolean(),
|
|
229
|
+
lockedContents: z.boolean()
|
|
230
|
+
}).partial();
|
|
231
|
+
const AnnotationStableIdSchema = z.discriminatedUnion("kind", [z.object({
|
|
232
|
+
kind: z.literal("objectNumber"),
|
|
233
|
+
value: z.number().int().nonnegative()
|
|
234
|
+
}), z.object({
|
|
235
|
+
kind: z.literal("nm"),
|
|
236
|
+
value: z.string()
|
|
237
|
+
})]);
|
|
238
|
+
const RevisionTokenSchema = z.object({
|
|
239
|
+
docSessionId: z.string(),
|
|
240
|
+
pageObjectNumber: z.number().int().positive(),
|
|
241
|
+
generation: z.number().int().nonnegative()
|
|
242
|
+
});
|
|
243
|
+
const AnnotationRefSchema = z.discriminatedUnion("kind", [
|
|
244
|
+
z.object({
|
|
245
|
+
kind: z.literal("objectNumber"),
|
|
246
|
+
pageObjectNumber: z.number().int().positive(),
|
|
247
|
+
annotObjectNumber: z.number().int().positive()
|
|
248
|
+
}),
|
|
249
|
+
z.object({
|
|
250
|
+
kind: z.literal("nm"),
|
|
251
|
+
pageObjectNumber: z.number().int().positive(),
|
|
252
|
+
nm: z.string()
|
|
253
|
+
}),
|
|
254
|
+
z.object({
|
|
255
|
+
kind: z.literal("index"),
|
|
256
|
+
pageObjectNumber: z.number().int().positive(),
|
|
257
|
+
index: z.number().int().nonnegative(),
|
|
258
|
+
revision: RevisionTokenSchema
|
|
259
|
+
})
|
|
260
|
+
]);
|
|
261
|
+
/**
|
|
262
|
+
* Shared object literal for every per-subtype DTO schema. Each kind's
|
|
263
|
+
* `dto.schema.ts` extends this with its own `subtype` literal and
|
|
264
|
+
* subtype-specific fields. Note that we do NOT include `subtype` here —
|
|
265
|
+
* each kind sets its own literal so `z.discriminatedUnion('subtype', ...)`
|
|
266
|
+
* works at the catalog level.
|
|
267
|
+
*/
|
|
268
|
+
const AnnotationBaseShape = {
|
|
269
|
+
ref: AnnotationRefSchema,
|
|
270
|
+
pageObjectNumber: z.number().int().positive(),
|
|
271
|
+
index: z.number().int().nonnegative(),
|
|
272
|
+
identityQuality: z.enum(["durable", "weak"]),
|
|
273
|
+
nm: z.string().nullable(),
|
|
274
|
+
flags: AnnotationFlagsSchema,
|
|
275
|
+
rect: PdfRectSchema,
|
|
276
|
+
contents: z.string().nullable(),
|
|
277
|
+
author: z.string().nullable(),
|
|
278
|
+
created: z.string().datetime().nullable(),
|
|
279
|
+
modified: z.string().datetime().nullable(),
|
|
280
|
+
blendMode: BlendModeSchema,
|
|
281
|
+
inReplyTo: AnnotationRefSchema.nullable(),
|
|
282
|
+
replyType: z.enum(["reply", "group"]).nullable(),
|
|
283
|
+
userId: z.string().optional(),
|
|
284
|
+
groupId: z.string().optional(),
|
|
285
|
+
createdBy: z.string().optional(),
|
|
286
|
+
updatedBy: z.string().optional(),
|
|
287
|
+
actions: PdfAnnotationActionsSchema.optional()
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Annotation-wide fields shared by every Draft. Per-kind draft schemas
|
|
291
|
+
* spread this alongside their family-specific shape.
|
|
292
|
+
*
|
|
293
|
+
* Authorial identity (/T, /EMBD_Metadata UserID/GroupID) is set by the
|
|
294
|
+
* server from the caller's JWT identity — see the AnnotationDraftBase
|
|
295
|
+
* docstring.
|
|
296
|
+
*/
|
|
297
|
+
const AnnotationDraftBaseShape = {
|
|
298
|
+
contents: z.string().nullable().optional(),
|
|
299
|
+
blendMode: BlendModeSchema.optional(),
|
|
300
|
+
nm: z.string().optional(),
|
|
301
|
+
flags: AnnotationFlagsPartialSchema.optional(),
|
|
302
|
+
inReplyTo: AnnotationRefSchema.optional(),
|
|
303
|
+
replyType: z.enum(["reply", "group"]).optional()
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Annotation-wide fields shared by every Patch. `nm` is monotonic per
|
|
307
|
+
* annotation; clients target an existing annotation via AnnotationRef
|
|
308
|
+
* instead of renaming.
|
|
309
|
+
*
|
|
310
|
+
* `groupId` is the only identity-shaped field on a patch — it
|
|
311
|
+
* represents organizational ownership, and reassignment runs through
|
|
312
|
+
* `checkSetGroup`. See AnnotationPatchBase for the full immutability
|
|
313
|
+
* rules.
|
|
314
|
+
*/
|
|
315
|
+
const AnnotationPatchBaseShape = {
|
|
316
|
+
contents: z.string().nullable().optional(),
|
|
317
|
+
blendMode: BlendModeSchema.optional(),
|
|
318
|
+
groupId: z.string().min(1).optional(),
|
|
319
|
+
flags: AnnotationFlagsPartialSchema.optional(),
|
|
320
|
+
inReplyTo: AnnotationRefSchema.nullable().optional(),
|
|
321
|
+
replyType: z.enum(["reply", "group"]).optional()
|
|
322
|
+
};
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/annotation/kinds/style.shared.ts
|
|
325
|
+
const ColorStyleDTOShape = {
|
|
326
|
+
color: ColorSchema,
|
|
327
|
+
opacity: z.number().min(0).max(1)
|
|
328
|
+
};
|
|
329
|
+
const ColorStyleDraftShape = {
|
|
330
|
+
color: ColorSchema.optional(),
|
|
331
|
+
opacity: z.number().min(0).max(1).optional()
|
|
332
|
+
};
|
|
333
|
+
const ColorStylePatchShape = ColorStyleDraftShape;
|
|
334
|
+
const GeometryStyleDTOShape = {
|
|
335
|
+
...ColorStyleDTOShape,
|
|
336
|
+
strokeWidth: z.number().nonnegative(),
|
|
337
|
+
borderStyle: AnnotationBorderStyleSchema,
|
|
338
|
+
dashArray: z.array(z.number().nonnegative()).optional()
|
|
339
|
+
};
|
|
340
|
+
const GeometryStyleDraftShape = {
|
|
341
|
+
...ColorStyleDraftShape,
|
|
342
|
+
strokeWidth: z.number().nonnegative().optional(),
|
|
343
|
+
borderStyle: AnnotationBorderStyleSchema.optional(),
|
|
344
|
+
dashArray: z.array(z.number().nonnegative()).optional()
|
|
345
|
+
};
|
|
346
|
+
const GeometryStylePatchShape = GeometryStyleDraftShape;
|
|
347
|
+
const FilledStyleDTOShape = {
|
|
348
|
+
...GeometryStyleDTOShape,
|
|
349
|
+
interiorColor: ColorSchema.nullable()
|
|
350
|
+
};
|
|
351
|
+
const FilledStyleDraftShape = {
|
|
352
|
+
...GeometryStyleDraftShape,
|
|
353
|
+
interiorColor: ColorSchema.nullable().optional()
|
|
354
|
+
};
|
|
355
|
+
const FilledStylePatchShape = FilledStyleDraftShape;
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/annotation/kinds/caret/schema.ts
|
|
358
|
+
const CaretDTOSchema = z.object({
|
|
359
|
+
...AnnotationBaseShape,
|
|
360
|
+
...ColorStyleDTOShape,
|
|
361
|
+
intent: CaretIntentSchema.nullable(),
|
|
362
|
+
rectDifferences: PdfRectDifferencesSchema.nullable(),
|
|
363
|
+
subtype: z.literal("caret")
|
|
364
|
+
});
|
|
365
|
+
const CaretDraftSchema = z.object({
|
|
366
|
+
...ColorStyleDraftShape,
|
|
367
|
+
...AnnotationDraftBaseShape,
|
|
368
|
+
intent: CaretIntentSchema.optional(),
|
|
369
|
+
rect: PdfRectSchema,
|
|
370
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
371
|
+
subtype: z.literal("caret")
|
|
372
|
+
});
|
|
373
|
+
const CaretPatchSchema = z.object({
|
|
374
|
+
...ColorStylePatchShape,
|
|
375
|
+
...AnnotationPatchBaseShape,
|
|
376
|
+
intent: CaretIntentSchema.optional(),
|
|
377
|
+
rect: PdfRectSchema.optional(),
|
|
378
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
379
|
+
subtype: z.literal("caret")
|
|
380
|
+
});
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/annotation/kinds/caret/index.ts
|
|
383
|
+
const CaretKind = {
|
|
384
|
+
subtype: "caret",
|
|
385
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.CARET,
|
|
386
|
+
dtoSchema: CaretDTOSchema,
|
|
387
|
+
draftSchema: CaretDraftSchema,
|
|
388
|
+
patchSchema: CaretPatchSchema
|
|
389
|
+
};
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/annotation/kinds/shape.shared.ts
|
|
392
|
+
const ShapeDTOShape = {
|
|
393
|
+
...AnnotationBaseShape,
|
|
394
|
+
...FilledStyleDTOShape,
|
|
395
|
+
cloudyIntensity: z.number().positive().nullable(),
|
|
396
|
+
rectDifferences: PdfRectDifferencesSchema.nullable(),
|
|
397
|
+
rotation: z.number().optional(),
|
|
398
|
+
unrotatedRect: PdfRectSchema.optional()
|
|
399
|
+
};
|
|
400
|
+
const ShapeDraftShape = {
|
|
401
|
+
...FilledStyleDraftShape,
|
|
402
|
+
rect: PdfRectSchema,
|
|
403
|
+
cloudyIntensity: z.number().positive().nullable().optional(),
|
|
404
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
405
|
+
rotation: z.number().nullable().optional(),
|
|
406
|
+
unrotatedRect: PdfRectSchema.nullable().optional()
|
|
407
|
+
};
|
|
408
|
+
const ShapePatchShape = {
|
|
409
|
+
...FilledStylePatchShape,
|
|
410
|
+
rect: PdfRectSchema.optional(),
|
|
411
|
+
cloudyIntensity: z.number().positive().nullable().optional(),
|
|
412
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
413
|
+
rotation: z.number().nullable().optional(),
|
|
414
|
+
unrotatedRect: PdfRectSchema.nullable().optional()
|
|
415
|
+
};
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/annotation/kinds/circle/schema.ts
|
|
418
|
+
const CircleDTOSchema = z.object({
|
|
419
|
+
...ShapeDTOShape,
|
|
420
|
+
subtype: z.literal("circle")
|
|
421
|
+
});
|
|
422
|
+
const CircleDraftSchema = z.object({
|
|
423
|
+
...ShapeDraftShape,
|
|
424
|
+
...AnnotationDraftBaseShape,
|
|
425
|
+
subtype: z.literal("circle")
|
|
426
|
+
});
|
|
427
|
+
const CirclePatchSchema = z.object({
|
|
428
|
+
...ShapePatchShape,
|
|
429
|
+
...AnnotationPatchBaseShape,
|
|
430
|
+
subtype: z.literal("circle")
|
|
431
|
+
});
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/annotation/kinds/circle/index.ts
|
|
434
|
+
const CircleKind = {
|
|
435
|
+
subtype: "circle",
|
|
436
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.CIRCLE,
|
|
437
|
+
dtoSchema: CircleDTOSchema,
|
|
438
|
+
draftSchema: CircleDraftSchema,
|
|
439
|
+
patchSchema: CirclePatchSchema
|
|
440
|
+
};
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/dto/Attachment.schema.ts
|
|
443
|
+
/**
|
|
444
|
+
* Wire schemas for the attachment read vocabulary (see `Attachment.ts`).
|
|
445
|
+
* The write-side `AttachmentFileSource` carries inline bytes and never
|
|
446
|
+
* appears on the wire — its post-normalization form is the kind-owned
|
|
447
|
+
* `WireAttachmentFile` (see `annotation/kinds/file-attachment/schema.ts`).
|
|
448
|
+
*/
|
|
449
|
+
const AttachmentFileInfoSchema = z.object({
|
|
450
|
+
name: z.string(),
|
|
451
|
+
mimeType: z.string().optional(),
|
|
452
|
+
description: z.string().optional(),
|
|
453
|
+
size: z.number().int().nonnegative().optional(),
|
|
454
|
+
checksum: z.string().optional(),
|
|
455
|
+
creationDate: z.string().optional()
|
|
456
|
+
});
|
|
457
|
+
const EmbeddedFileRefSchema = z.object({
|
|
458
|
+
kind: z.literal("key"),
|
|
459
|
+
key: z.string().min(1)
|
|
460
|
+
});
|
|
461
|
+
const EmbeddedFileItemSchema = z.object({
|
|
462
|
+
key: z.string(),
|
|
463
|
+
name: z.string(),
|
|
464
|
+
mimeType: z.string().optional(),
|
|
465
|
+
description: z.string().optional(),
|
|
466
|
+
size: z.number().int().nonnegative().optional(),
|
|
467
|
+
checksum: z.string().optional(),
|
|
468
|
+
creationDate: z.string().optional(),
|
|
469
|
+
index: z.number().int().nonnegative()
|
|
470
|
+
});
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/annotation/kinds/file-attachment/schema.ts
|
|
473
|
+
const FileAttachmentIconSchema = z.enum([
|
|
474
|
+
"push-pin",
|
|
475
|
+
"paperclip",
|
|
476
|
+
"graph",
|
|
477
|
+
"tag"
|
|
478
|
+
]);
|
|
479
|
+
/** Post-normalization form of the attached file: metadata + resource ref. */
|
|
480
|
+
const WireAttachmentFileSchema = z.object({
|
|
481
|
+
resource: z.string().min(1),
|
|
482
|
+
name: z.string().min(1),
|
|
483
|
+
mimeType: z.string().optional(),
|
|
484
|
+
description: z.string().optional()
|
|
485
|
+
});
|
|
486
|
+
const FileAttachmentDTOSchema = z.object({
|
|
487
|
+
...AnnotationBaseShape,
|
|
488
|
+
...ColorStyleDTOShape,
|
|
489
|
+
icon: FileAttachmentIconSchema,
|
|
490
|
+
file: AttachmentFileInfoSchema,
|
|
491
|
+
subtype: z.literal("file-attachment")
|
|
492
|
+
});
|
|
493
|
+
const FileAttachmentWireDraftSchema = z.object({
|
|
494
|
+
...ColorStyleDraftShape,
|
|
495
|
+
...AnnotationDraftBaseShape,
|
|
496
|
+
rect: PdfRectSchema,
|
|
497
|
+
file: WireAttachmentFileSchema,
|
|
498
|
+
icon: FileAttachmentIconSchema.optional(),
|
|
499
|
+
subtype: z.literal("file-attachment")
|
|
500
|
+
});
|
|
501
|
+
const FileAttachmentPatchSchema = z.object({
|
|
502
|
+
...ColorStylePatchShape,
|
|
503
|
+
...AnnotationPatchBaseShape,
|
|
504
|
+
rect: PdfRectSchema.optional(),
|
|
505
|
+
icon: FileAttachmentIconSchema.optional(),
|
|
506
|
+
subtype: z.literal("file-attachment")
|
|
507
|
+
});
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/annotation/kinds/file-attachment/index.ts
|
|
510
|
+
/**
|
|
511
|
+
* WIRE-typed like `StampKind`: the draft schema validates the
|
|
512
|
+
* post-normalization form (`file` as metadata + resource ref). The
|
|
513
|
+
* authoring `FileAttachmentDraft` (inline bytes) is swapped into the
|
|
514
|
+
* public `AnnotationDraft` union in `kinds/index.ts`. The patch carries
|
|
515
|
+
* no binary (`file` is create-only), so its authoring and wire forms are
|
|
516
|
+
* the same type.
|
|
517
|
+
*/
|
|
518
|
+
const FileAttachmentKind = {
|
|
519
|
+
subtype: "file-attachment",
|
|
520
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.FILEATTACHMENT,
|
|
521
|
+
dtoSchema: FileAttachmentDTOSchema,
|
|
522
|
+
draftSchema: FileAttachmentWireDraftSchema,
|
|
523
|
+
patchSchema: FileAttachmentPatchSchema
|
|
524
|
+
};
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/annotation/kinds/free-text/schema.ts
|
|
527
|
+
/** Authoring `fontFamily`: a standard font name OR a registered font `key`.
|
|
528
|
+
* Any non-empty string is accepted; the writer resolves which it is (and a
|
|
529
|
+
* key that was never registered fails loud there). The read-back DTO keeps the
|
|
530
|
+
* narrower {@link StandardFontSchema}. */
|
|
531
|
+
const FreeTextFontSchema = z.string().min(1);
|
|
532
|
+
const FreeTextDTOSchema = z.object({
|
|
533
|
+
...AnnotationBaseShape,
|
|
534
|
+
intent: FreeTextIntentSchema,
|
|
535
|
+
fontFamily: StandardFontSchema,
|
|
536
|
+
fontSize: z.number().positive(),
|
|
537
|
+
textAlign: TextAlignmentSchema,
|
|
538
|
+
color: ColorSchema,
|
|
539
|
+
fontColor: ColorSchema.optional(),
|
|
540
|
+
interiorColor: ColorSchema.nullable(),
|
|
541
|
+
opacity: z.number().min(0).max(1),
|
|
542
|
+
strokeWidth: z.number().nonnegative(),
|
|
543
|
+
borderStyle: AnnotationBorderStyleSchema,
|
|
544
|
+
dashArray: z.array(z.number().nonnegative()).optional(),
|
|
545
|
+
rectDifferences: PdfRectDifferencesSchema.nullable(),
|
|
546
|
+
calloutLine: CalloutLineSchema.optional(),
|
|
547
|
+
lineEnding: LineEndingSchema.optional(),
|
|
548
|
+
rotation: z.number().optional(),
|
|
549
|
+
unrotatedRect: PdfRectSchema.optional(),
|
|
550
|
+
subtype: z.literal("free-text")
|
|
551
|
+
});
|
|
552
|
+
const FreeTextDraftSchema = z.object({
|
|
553
|
+
...AnnotationDraftBaseShape,
|
|
554
|
+
intent: FreeTextIntentSchema,
|
|
555
|
+
fontFamily: FreeTextFontSchema,
|
|
556
|
+
fontSize: z.number().positive(),
|
|
557
|
+
textAlign: TextAlignmentSchema,
|
|
558
|
+
rect: PdfRectSchema,
|
|
559
|
+
color: ColorSchema.optional(),
|
|
560
|
+
fontColor: ColorSchema.optional(),
|
|
561
|
+
interiorColor: ColorSchema.nullable().optional(),
|
|
562
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
563
|
+
strokeWidth: z.number().nonnegative().optional(),
|
|
564
|
+
borderStyle: AnnotationBorderStyleSchema.optional(),
|
|
565
|
+
dashArray: z.array(z.number().nonnegative()).optional(),
|
|
566
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
567
|
+
calloutLine: CalloutLineSchema.optional(),
|
|
568
|
+
lineEnding: LineEndingSchema.optional(),
|
|
569
|
+
rotation: z.number().nullable().optional(),
|
|
570
|
+
unrotatedRect: PdfRectSchema.nullable().optional(),
|
|
571
|
+
subtype: z.literal("free-text")
|
|
572
|
+
});
|
|
573
|
+
const FreeTextPatchSchema = z.object({
|
|
574
|
+
...AnnotationPatchBaseShape,
|
|
575
|
+
intent: FreeTextIntentSchema.optional(),
|
|
576
|
+
fontFamily: FreeTextFontSchema.optional(),
|
|
577
|
+
fontSize: z.number().positive().optional(),
|
|
578
|
+
textAlign: TextAlignmentSchema.optional(),
|
|
579
|
+
rect: PdfRectSchema.optional(),
|
|
580
|
+
color: ColorSchema.optional(),
|
|
581
|
+
fontColor: ColorSchema.optional(),
|
|
582
|
+
interiorColor: ColorSchema.nullable().optional(),
|
|
583
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
584
|
+
strokeWidth: z.number().nonnegative().optional(),
|
|
585
|
+
borderStyle: AnnotationBorderStyleSchema.optional(),
|
|
586
|
+
dashArray: z.array(z.number().nonnegative()).optional(),
|
|
587
|
+
rectDifferences: PdfRectDifferencesSchema.nullable().optional(),
|
|
588
|
+
calloutLine: CalloutLineSchema.optional(),
|
|
589
|
+
lineEnding: LineEndingSchema.optional(),
|
|
590
|
+
rotation: z.number().nullable().optional(),
|
|
591
|
+
unrotatedRect: PdfRectSchema.nullable().optional(),
|
|
592
|
+
subtype: z.literal("free-text")
|
|
593
|
+
});
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/annotation/kinds/free-text/index.ts
|
|
596
|
+
const FreeTextKind = {
|
|
597
|
+
subtype: "free-text",
|
|
598
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.FREETEXT,
|
|
599
|
+
dtoSchema: FreeTextDTOSchema,
|
|
600
|
+
draftSchema: FreeTextDraftSchema,
|
|
601
|
+
patchSchema: FreeTextPatchSchema
|
|
602
|
+
};
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/annotation/kinds/text-markup.shared.ts
|
|
605
|
+
const TextMarkupDTOShape = {
|
|
606
|
+
...AnnotationBaseShape,
|
|
607
|
+
...ColorStyleDTOShape,
|
|
608
|
+
quadPoints: z.array(PdfQuadSchema)
|
|
609
|
+
};
|
|
610
|
+
const TextMarkupDraftShape = {
|
|
611
|
+
...ColorStyleDraftShape,
|
|
612
|
+
quadPoints: z.array(PdfQuadSchema)
|
|
613
|
+
};
|
|
614
|
+
const TextMarkupPatchShape = {
|
|
615
|
+
...ColorStylePatchShape,
|
|
616
|
+
quadPoints: z.array(PdfQuadSchema).optional()
|
|
617
|
+
};
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region src/annotation/kinds/highlight/schema.ts
|
|
620
|
+
const HighlightDTOSchema = z.object({
|
|
621
|
+
...TextMarkupDTOShape,
|
|
622
|
+
subtype: z.literal("highlight")
|
|
623
|
+
});
|
|
624
|
+
const HighlightDraftSchema = z.object({
|
|
625
|
+
...TextMarkupDraftShape,
|
|
626
|
+
...AnnotationDraftBaseShape,
|
|
627
|
+
subtype: z.literal("highlight")
|
|
628
|
+
});
|
|
629
|
+
const HighlightPatchSchema = z.object({
|
|
630
|
+
...TextMarkupPatchShape,
|
|
631
|
+
...AnnotationPatchBaseShape,
|
|
632
|
+
subtype: z.literal("highlight")
|
|
633
|
+
});
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/annotation/kinds/highlight/index.ts
|
|
636
|
+
const HighlightKind = {
|
|
637
|
+
subtype: "highlight",
|
|
638
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.HIGHLIGHT,
|
|
639
|
+
dtoSchema: HighlightDTOSchema,
|
|
640
|
+
draftSchema: HighlightDraftSchema,
|
|
641
|
+
patchSchema: HighlightPatchSchema
|
|
642
|
+
};
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/annotation/kinds/ink/schema.ts
|
|
645
|
+
const InkDTOSchema = z.object({
|
|
646
|
+
...AnnotationBaseShape,
|
|
647
|
+
...GeometryStyleDTOShape,
|
|
648
|
+
intent: InkIntentSchema.nullable(),
|
|
649
|
+
inkList: InkListSchema,
|
|
650
|
+
rotation: z.number().optional(),
|
|
651
|
+
subtype: z.literal("ink")
|
|
652
|
+
});
|
|
653
|
+
const InkDraftSchema = z.object({
|
|
654
|
+
...GeometryStyleDraftShape,
|
|
655
|
+
...AnnotationDraftBaseShape,
|
|
656
|
+
intent: InkIntentSchema.optional(),
|
|
657
|
+
inkList: InkListSchema,
|
|
658
|
+
rect: PdfRectSchema,
|
|
659
|
+
rotation: z.number().nullable().optional(),
|
|
660
|
+
subtype: z.literal("ink")
|
|
661
|
+
});
|
|
662
|
+
const InkPatchSchema = z.object({
|
|
663
|
+
...GeometryStylePatchShape,
|
|
664
|
+
...AnnotationPatchBaseShape,
|
|
665
|
+
intent: InkIntentSchema.optional(),
|
|
666
|
+
inkList: InkListSchema.optional(),
|
|
667
|
+
rect: PdfRectSchema.optional(),
|
|
668
|
+
rotation: z.number().nullable().optional(),
|
|
669
|
+
subtype: z.literal("ink")
|
|
670
|
+
});
|
|
671
|
+
//#endregion
|
|
672
|
+
//#region src/annotation/kinds/ink/index.ts
|
|
673
|
+
const InkKind = {
|
|
674
|
+
subtype: "ink",
|
|
675
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.INK,
|
|
676
|
+
dtoSchema: InkDTOSchema,
|
|
677
|
+
draftSchema: InkDraftSchema,
|
|
678
|
+
patchSchema: InkPatchSchema
|
|
679
|
+
};
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/annotation/kinds/line/schema.ts
|
|
682
|
+
const LineDTOSchema = z.object({
|
|
683
|
+
...AnnotationBaseShape,
|
|
684
|
+
...FilledStyleDTOShape,
|
|
685
|
+
linePoints: LinePointsSchema,
|
|
686
|
+
lineEndings: LineEndingsSchema,
|
|
687
|
+
rotation: z.number().optional(),
|
|
688
|
+
subtype: z.literal("line")
|
|
689
|
+
});
|
|
690
|
+
const LineDraftSchema = z.object({
|
|
691
|
+
...FilledStyleDraftShape,
|
|
692
|
+
...AnnotationDraftBaseShape,
|
|
693
|
+
linePoints: LinePointsSchema,
|
|
694
|
+
rect: PdfRectSchema,
|
|
695
|
+
lineEndings: LineEndingsSchema.optional(),
|
|
696
|
+
rotation: z.number().nullable().optional(),
|
|
697
|
+
subtype: z.literal("line")
|
|
698
|
+
});
|
|
699
|
+
const LinePatchSchema = z.object({
|
|
700
|
+
...FilledStylePatchShape,
|
|
701
|
+
...AnnotationPatchBaseShape,
|
|
702
|
+
linePoints: LinePointsSchema.optional(),
|
|
703
|
+
rect: PdfRectSchema.optional(),
|
|
704
|
+
lineEndings: LineEndingsSchema.optional(),
|
|
705
|
+
rotation: z.number().nullable().optional(),
|
|
706
|
+
subtype: z.literal("line")
|
|
707
|
+
});
|
|
708
|
+
//#endregion
|
|
709
|
+
//#region src/annotation/kinds/line/index.ts
|
|
710
|
+
const LineKind = {
|
|
711
|
+
subtype: "line",
|
|
712
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.LINE,
|
|
713
|
+
dtoSchema: LineDTOSchema,
|
|
714
|
+
draftSchema: LineDraftSchema,
|
|
715
|
+
patchSchema: LinePatchSchema
|
|
716
|
+
};
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region src/annotation/kinds/link/schema.ts
|
|
719
|
+
const pageObjectNumber = z.number().int().positive();
|
|
720
|
+
/** Spec-nullable axis value: absent and `null` both mean "retain current". */
|
|
721
|
+
const axis = z.number().nullable().optional();
|
|
722
|
+
/**
|
|
723
|
+
* Runtime schema for {@link PdfDestination}. Lives with the link kind (its
|
|
724
|
+
* first wire consumer); the outline/bookmark port reuses it from here.
|
|
725
|
+
*/
|
|
726
|
+
const PdfDestinationSchema = z.discriminatedUnion("kind", [
|
|
727
|
+
z.object({
|
|
728
|
+
kind: z.literal("xyz"),
|
|
729
|
+
pageObjectNumber,
|
|
730
|
+
left: axis,
|
|
731
|
+
top: axis,
|
|
732
|
+
zoom: axis
|
|
733
|
+
}),
|
|
734
|
+
z.object({
|
|
735
|
+
kind: z.literal("fit"),
|
|
736
|
+
pageObjectNumber
|
|
737
|
+
}),
|
|
738
|
+
z.object({
|
|
739
|
+
kind: z.literal("fitH"),
|
|
740
|
+
pageObjectNumber,
|
|
741
|
+
top: axis
|
|
742
|
+
}),
|
|
743
|
+
z.object({
|
|
744
|
+
kind: z.literal("fitV"),
|
|
745
|
+
pageObjectNumber,
|
|
746
|
+
left: axis
|
|
747
|
+
}),
|
|
748
|
+
z.object({
|
|
749
|
+
kind: z.literal("fitR"),
|
|
750
|
+
pageObjectNumber,
|
|
751
|
+
left: z.number(),
|
|
752
|
+
bottom: z.number(),
|
|
753
|
+
right: z.number(),
|
|
754
|
+
top: z.number()
|
|
755
|
+
}),
|
|
756
|
+
z.object({
|
|
757
|
+
kind: z.literal("fitB"),
|
|
758
|
+
pageObjectNumber
|
|
759
|
+
}),
|
|
760
|
+
z.object({
|
|
761
|
+
kind: z.literal("fitBH"),
|
|
762
|
+
pageObjectNumber,
|
|
763
|
+
top: axis
|
|
764
|
+
}),
|
|
765
|
+
z.object({
|
|
766
|
+
kind: z.literal("fitBV"),
|
|
767
|
+
pageObjectNumber,
|
|
768
|
+
left: axis
|
|
769
|
+
})
|
|
770
|
+
]);
|
|
771
|
+
const GotoTargetSchema = z.object({
|
|
772
|
+
kind: z.literal("goto"),
|
|
773
|
+
destination: PdfDestinationSchema
|
|
774
|
+
});
|
|
775
|
+
const UriTargetSchema = z.object({
|
|
776
|
+
kind: z.literal("uri"),
|
|
777
|
+
uri: z.string()
|
|
778
|
+
});
|
|
779
|
+
const PdfLinkTargetSchema = z.discriminatedUnion("kind", [
|
|
780
|
+
GotoTargetSchema,
|
|
781
|
+
UriTargetSchema,
|
|
782
|
+
z.object({
|
|
783
|
+
kind: z.literal("goto-remote"),
|
|
784
|
+
file: z.string()
|
|
785
|
+
}),
|
|
786
|
+
z.object({
|
|
787
|
+
kind: z.literal("launch"),
|
|
788
|
+
path: z.string()
|
|
789
|
+
}),
|
|
790
|
+
z.object({ kind: z.literal("javascript") }),
|
|
791
|
+
z.object({
|
|
792
|
+
kind: z.literal("named"),
|
|
793
|
+
name: z.string()
|
|
794
|
+
}),
|
|
795
|
+
z.object({ kind: z.literal("unsupported") })
|
|
796
|
+
]);
|
|
797
|
+
/** Drafts/patches only author `goto`/`uri` — see {@link PdfLinkTargetWritable}. */
|
|
798
|
+
const PdfLinkTargetWritableSchema = z.discriminatedUnion("kind", [GotoTargetSchema, UriTargetSchema]);
|
|
799
|
+
const LinkDTOSchema = z.object({
|
|
800
|
+
...AnnotationBaseShape,
|
|
801
|
+
subtype: z.literal("link"),
|
|
802
|
+
target: PdfLinkTargetSchema.nullable()
|
|
803
|
+
});
|
|
804
|
+
const LinkDraftSchema = z.object({
|
|
805
|
+
...AnnotationDraftBaseShape,
|
|
806
|
+
subtype: z.literal("link"),
|
|
807
|
+
rect: PdfRectSchema,
|
|
808
|
+
target: PdfLinkTargetWritableSchema.nullable()
|
|
809
|
+
});
|
|
810
|
+
const LinkPatchSchema = z.object({
|
|
811
|
+
...AnnotationPatchBaseShape,
|
|
812
|
+
subtype: z.literal("link"),
|
|
813
|
+
rect: PdfRectSchema.optional(),
|
|
814
|
+
target: PdfLinkTargetWritableSchema.nullable().optional()
|
|
815
|
+
});
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/annotation/kinds/link/index.ts
|
|
818
|
+
const LinkKind = {
|
|
819
|
+
subtype: "link",
|
|
820
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.LINK,
|
|
821
|
+
dtoSchema: LinkDTOSchema,
|
|
822
|
+
draftSchema: LinkDraftSchema,
|
|
823
|
+
patchSchema: LinkPatchSchema
|
|
824
|
+
};
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region src/annotation/kinds/vertex.shared.ts
|
|
827
|
+
const VertexDTOShape = {
|
|
828
|
+
...AnnotationBaseShape,
|
|
829
|
+
...FilledStyleDTOShape,
|
|
830
|
+
vertices: z.array(PdfPointSchema),
|
|
831
|
+
rotation: z.number().optional()
|
|
832
|
+
};
|
|
833
|
+
const VertexDraftShape = {
|
|
834
|
+
...FilledStyleDraftShape,
|
|
835
|
+
vertices: z.array(PdfPointSchema),
|
|
836
|
+
rect: PdfRectSchema,
|
|
837
|
+
rotation: z.number().nullable().optional()
|
|
838
|
+
};
|
|
839
|
+
const VertexPatchShape = {
|
|
840
|
+
...FilledStylePatchShape,
|
|
841
|
+
vertices: z.array(PdfPointSchema).optional(),
|
|
842
|
+
rect: PdfRectSchema.optional(),
|
|
843
|
+
rotation: z.number().nullable().optional()
|
|
844
|
+
};
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/annotation/kinds/polygon/schema.ts
|
|
847
|
+
const PolygonDTOSchema = z.object({
|
|
848
|
+
...VertexDTOShape,
|
|
849
|
+
vertices: z.array(PdfPointSchema).min(3),
|
|
850
|
+
cloudyIntensity: z.number().positive().nullable(),
|
|
851
|
+
subtype: z.literal("polygon")
|
|
852
|
+
});
|
|
853
|
+
const PolygonDraftSchema = z.object({
|
|
854
|
+
...VertexDraftShape,
|
|
855
|
+
...AnnotationDraftBaseShape,
|
|
856
|
+
vertices: z.array(PdfPointSchema).min(3),
|
|
857
|
+
cloudyIntensity: z.number().positive().nullable().optional(),
|
|
858
|
+
subtype: z.literal("polygon")
|
|
859
|
+
});
|
|
860
|
+
const PolygonPatchSchema = z.object({
|
|
861
|
+
...VertexPatchShape,
|
|
862
|
+
...AnnotationPatchBaseShape,
|
|
863
|
+
vertices: z.array(PdfPointSchema).min(3).optional(),
|
|
864
|
+
cloudyIntensity: z.number().positive().nullable().optional(),
|
|
865
|
+
subtype: z.literal("polygon")
|
|
866
|
+
});
|
|
867
|
+
//#endregion
|
|
868
|
+
//#region src/annotation/kinds/polygon/index.ts
|
|
869
|
+
const PolygonKind = {
|
|
870
|
+
subtype: "polygon",
|
|
871
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.POLYGON,
|
|
872
|
+
dtoSchema: PolygonDTOSchema,
|
|
873
|
+
draftSchema: PolygonDraftSchema,
|
|
874
|
+
patchSchema: PolygonPatchSchema
|
|
875
|
+
};
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/annotation/kinds/polyline/schema.ts
|
|
878
|
+
const PolylineDTOSchema = z.object({
|
|
879
|
+
...VertexDTOShape,
|
|
880
|
+
vertices: z.array(PdfPointSchema).min(2),
|
|
881
|
+
lineEndings: LineEndingsSchema,
|
|
882
|
+
subtype: z.literal("polyline")
|
|
883
|
+
});
|
|
884
|
+
const PolylineDraftSchema = z.object({
|
|
885
|
+
...VertexDraftShape,
|
|
886
|
+
...AnnotationDraftBaseShape,
|
|
887
|
+
vertices: z.array(PdfPointSchema).min(2),
|
|
888
|
+
lineEndings: LineEndingsSchema.optional(),
|
|
889
|
+
subtype: z.literal("polyline")
|
|
890
|
+
});
|
|
891
|
+
const PolylinePatchSchema = z.object({
|
|
892
|
+
...VertexPatchShape,
|
|
893
|
+
...AnnotationPatchBaseShape,
|
|
894
|
+
vertices: z.array(PdfPointSchema).min(2).optional(),
|
|
895
|
+
lineEndings: LineEndingsSchema.optional(),
|
|
896
|
+
subtype: z.literal("polyline")
|
|
897
|
+
});
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region src/annotation/kinds/polyline/index.ts
|
|
900
|
+
const PolylineKind = {
|
|
901
|
+
subtype: "polyline",
|
|
902
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.POLYLINE,
|
|
903
|
+
dtoSchema: PolylineDTOSchema,
|
|
904
|
+
draftSchema: PolylineDraftSchema,
|
|
905
|
+
patchSchema: PolylinePatchSchema
|
|
906
|
+
};
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/annotation/kinds/redact/schema.ts
|
|
909
|
+
/** Authoring `fontFamily`: a standard font name OR a registered font `key`.
|
|
910
|
+
* Any non-empty string is accepted; the writer resolves which it is (and a
|
|
911
|
+
* key that was never registered fails loud there). The read-back DTO keeps
|
|
912
|
+
* the narrower {@link StandardFontSchema}. */
|
|
913
|
+
const RedactFontSchema = z.string().min(1);
|
|
914
|
+
/** `/DA` size — unlike free text, `0` is meaningful for a redaction label:
|
|
915
|
+
* auto-fit to the region. */
|
|
916
|
+
const RedactFontSizeSchema = z.number().nonnegative();
|
|
917
|
+
const RedactDTOSchema = z.object({
|
|
918
|
+
...AnnotationBaseShape,
|
|
919
|
+
quadPoints: z.array(PdfQuadSchema),
|
|
920
|
+
color: ColorSchema,
|
|
921
|
+
opacity: z.number().min(0).max(1),
|
|
922
|
+
interiorColor: ColorSchema.nullable(),
|
|
923
|
+
overlayText: z.string().nullable(),
|
|
924
|
+
repeat: z.boolean(),
|
|
925
|
+
fontFamily: StandardFontSchema,
|
|
926
|
+
fontSize: RedactFontSizeSchema,
|
|
927
|
+
fontColor: ColorSchema,
|
|
928
|
+
textAlign: TextAlignmentSchema,
|
|
929
|
+
subtype: z.literal("redact")
|
|
930
|
+
});
|
|
931
|
+
const RedactDraftSchema = z.object({
|
|
932
|
+
...AnnotationDraftBaseShape,
|
|
933
|
+
rect: PdfRectSchema,
|
|
934
|
+
quadPoints: z.array(PdfQuadSchema).optional(),
|
|
935
|
+
color: ColorSchema.optional(),
|
|
936
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
937
|
+
interiorColor: ColorSchema.nullable().optional(),
|
|
938
|
+
overlayText: z.string().optional(),
|
|
939
|
+
repeat: z.boolean().optional(),
|
|
940
|
+
fontFamily: RedactFontSchema.optional(),
|
|
941
|
+
fontSize: RedactFontSizeSchema.optional(),
|
|
942
|
+
fontColor: ColorSchema.optional(),
|
|
943
|
+
textAlign: TextAlignmentSchema.optional(),
|
|
944
|
+
subtype: z.literal("redact")
|
|
945
|
+
});
|
|
946
|
+
const RedactPatchSchema = z.object({
|
|
947
|
+
...AnnotationPatchBaseShape,
|
|
948
|
+
rect: PdfRectSchema.optional(),
|
|
949
|
+
quadPoints: z.array(PdfQuadSchema).optional(),
|
|
950
|
+
color: ColorSchema.optional(),
|
|
951
|
+
opacity: z.number().min(0).max(1).optional(),
|
|
952
|
+
interiorColor: ColorSchema.nullable().optional(),
|
|
953
|
+
overlayText: z.string().nullable().optional(),
|
|
954
|
+
repeat: z.boolean().optional(),
|
|
955
|
+
fontFamily: RedactFontSchema.optional(),
|
|
956
|
+
fontSize: RedactFontSizeSchema.optional(),
|
|
957
|
+
fontColor: ColorSchema.optional(),
|
|
958
|
+
textAlign: TextAlignmentSchema.optional(),
|
|
959
|
+
subtype: z.literal("redact")
|
|
960
|
+
});
|
|
961
|
+
//#endregion
|
|
962
|
+
//#region src/annotation/kinds/redact/index.ts
|
|
963
|
+
const RedactKind = {
|
|
964
|
+
subtype: "redact",
|
|
965
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.REDACT,
|
|
966
|
+
dtoSchema: RedactDTOSchema,
|
|
967
|
+
draftSchema: RedactDraftSchema,
|
|
968
|
+
patchSchema: RedactPatchSchema
|
|
969
|
+
};
|
|
970
|
+
//#endregion
|
|
971
|
+
//#region src/annotation/kinds/square/schema.ts
|
|
972
|
+
const SquareDTOSchema = z.object({
|
|
973
|
+
...ShapeDTOShape,
|
|
974
|
+
subtype: z.literal("square")
|
|
975
|
+
});
|
|
976
|
+
const SquareDraftSchema = z.object({
|
|
977
|
+
...ShapeDraftShape,
|
|
978
|
+
...AnnotationDraftBaseShape,
|
|
979
|
+
subtype: z.literal("square")
|
|
980
|
+
});
|
|
981
|
+
const SquarePatchSchema = z.object({
|
|
982
|
+
...ShapePatchShape,
|
|
983
|
+
...AnnotationPatchBaseShape,
|
|
984
|
+
subtype: z.literal("square")
|
|
985
|
+
});
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/annotation/kinds/square/index.ts
|
|
988
|
+
const SquareKind = {
|
|
989
|
+
subtype: "square",
|
|
990
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.SQUARE,
|
|
991
|
+
dtoSchema: SquareDTOSchema,
|
|
992
|
+
draftSchema: SquareDraftSchema,
|
|
993
|
+
patchSchema: SquarePatchSchema
|
|
994
|
+
};
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/annotation/kinds/squiggly/schema.ts
|
|
997
|
+
const SquigglyDTOSchema = z.object({
|
|
998
|
+
...TextMarkupDTOShape,
|
|
999
|
+
subtype: z.literal("squiggly")
|
|
1000
|
+
});
|
|
1001
|
+
const SquigglyDraftSchema = z.object({
|
|
1002
|
+
...TextMarkupDraftShape,
|
|
1003
|
+
...AnnotationDraftBaseShape,
|
|
1004
|
+
subtype: z.literal("squiggly")
|
|
1005
|
+
});
|
|
1006
|
+
const SquigglyPatchSchema = z.object({
|
|
1007
|
+
...TextMarkupPatchShape,
|
|
1008
|
+
...AnnotationPatchBaseShape,
|
|
1009
|
+
subtype: z.literal("squiggly")
|
|
1010
|
+
});
|
|
1011
|
+
//#endregion
|
|
1012
|
+
//#region src/annotation/kinds/squiggly/index.ts
|
|
1013
|
+
const SquigglyKind = {
|
|
1014
|
+
subtype: "squiggly",
|
|
1015
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.SQUIGGLY,
|
|
1016
|
+
dtoSchema: SquigglyDTOSchema,
|
|
1017
|
+
draftSchema: SquigglyDraftSchema,
|
|
1018
|
+
patchSchema: SquigglyPatchSchema
|
|
1019
|
+
};
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/annotation/kinds/stamp/schema.ts
|
|
1022
|
+
/**
|
|
1023
|
+
* Schemas validate the WIRE forms. The authoring types (`StampDraft`,
|
|
1024
|
+
* `StampPatch`) carry inline `BinarySource` bytes and are normalized to
|
|
1025
|
+
* these shapes before validation — see `annotation/normalize.ts`.
|
|
1026
|
+
*/
|
|
1027
|
+
const ResourceRefSchema = z.object({ resource: z.string().min(1) });
|
|
1028
|
+
const StampFitSchema = z.enum([
|
|
1029
|
+
"contain",
|
|
1030
|
+
"cover",
|
|
1031
|
+
"fill"
|
|
1032
|
+
]);
|
|
1033
|
+
const StampDTOSchema = z.object({
|
|
1034
|
+
...AnnotationBaseShape,
|
|
1035
|
+
name: z.string().nullable(),
|
|
1036
|
+
rotation: z.number().optional(),
|
|
1037
|
+
unrotatedRect: PdfRectSchema.optional(),
|
|
1038
|
+
subtype: z.literal("stamp")
|
|
1039
|
+
});
|
|
1040
|
+
const StampWireDraftSchema = z.object({
|
|
1041
|
+
...AnnotationDraftBaseShape,
|
|
1042
|
+
rect: PdfRectSchema,
|
|
1043
|
+
source: ResourceRefSchema,
|
|
1044
|
+
name: z.string().optional(),
|
|
1045
|
+
fit: StampFitSchema.optional(),
|
|
1046
|
+
rotation: z.number().nullable().optional(),
|
|
1047
|
+
unrotatedRect: PdfRectSchema.nullable().optional(),
|
|
1048
|
+
subtype: z.literal("stamp")
|
|
1049
|
+
});
|
|
1050
|
+
const StampWirePatchSchema = z.object({
|
|
1051
|
+
...AnnotationPatchBaseShape,
|
|
1052
|
+
rect: PdfRectSchema.optional(),
|
|
1053
|
+
source: ResourceRefSchema.optional(),
|
|
1054
|
+
name: z.string().optional(),
|
|
1055
|
+
fit: StampFitSchema.optional(),
|
|
1056
|
+
rotation: z.number().nullable().optional(),
|
|
1057
|
+
unrotatedRect: PdfRectSchema.nullable().optional(),
|
|
1058
|
+
subtype: z.literal("stamp")
|
|
1059
|
+
});
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/annotation/kinds/stamp/index.ts
|
|
1062
|
+
/**
|
|
1063
|
+
* The kind module is WIRE-typed (schemas validate the post-normalization
|
|
1064
|
+
* form). The authoring types with inline bytes (`StampDraft`, `StampPatch`)
|
|
1065
|
+
* are swapped into the public `AnnotationDraft`/`AnnotationPatch` unions in
|
|
1066
|
+
* `kinds/index.ts`; `annotation/normalize.ts` bridges the two.
|
|
1067
|
+
*/
|
|
1068
|
+
const StampKind = {
|
|
1069
|
+
subtype: "stamp",
|
|
1070
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.STAMP,
|
|
1071
|
+
dtoSchema: StampDTOSchema,
|
|
1072
|
+
draftSchema: StampWireDraftSchema,
|
|
1073
|
+
patchSchema: StampWirePatchSchema
|
|
1074
|
+
};
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region src/annotation/kinds/strikeout/schema.ts
|
|
1077
|
+
const StrikeoutDTOSchema = z.object({
|
|
1078
|
+
...TextMarkupDTOShape,
|
|
1079
|
+
intent: StrikeoutIntentSchema.nullable(),
|
|
1080
|
+
subtype: z.literal("strikeout")
|
|
1081
|
+
});
|
|
1082
|
+
const StrikeoutDraftSchema = z.object({
|
|
1083
|
+
...TextMarkupDraftShape,
|
|
1084
|
+
...AnnotationDraftBaseShape,
|
|
1085
|
+
intent: StrikeoutIntentSchema.optional(),
|
|
1086
|
+
subtype: z.literal("strikeout")
|
|
1087
|
+
});
|
|
1088
|
+
const StrikeoutPatchSchema = z.object({
|
|
1089
|
+
...TextMarkupPatchShape,
|
|
1090
|
+
...AnnotationPatchBaseShape,
|
|
1091
|
+
intent: StrikeoutIntentSchema.optional(),
|
|
1092
|
+
subtype: z.literal("strikeout")
|
|
1093
|
+
});
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/annotation/kinds/strikeout/index.ts
|
|
1096
|
+
const StrikeoutKind = {
|
|
1097
|
+
subtype: "strikeout",
|
|
1098
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.STRIKEOUT,
|
|
1099
|
+
dtoSchema: StrikeoutDTOSchema,
|
|
1100
|
+
draftSchema: StrikeoutDraftSchema,
|
|
1101
|
+
patchSchema: StrikeoutPatchSchema
|
|
1102
|
+
};
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/annotation/kinds/text/schema.ts
|
|
1105
|
+
const NoteIconSchema = z.enum([
|
|
1106
|
+
"comment",
|
|
1107
|
+
"key",
|
|
1108
|
+
"note",
|
|
1109
|
+
"help",
|
|
1110
|
+
"new-paragraph",
|
|
1111
|
+
"paragraph",
|
|
1112
|
+
"insert"
|
|
1113
|
+
]);
|
|
1114
|
+
const TextDTOSchema = z.object({
|
|
1115
|
+
...AnnotationBaseShape,
|
|
1116
|
+
...ColorStyleDTOShape,
|
|
1117
|
+
icon: NoteIconSchema,
|
|
1118
|
+
subtype: z.literal("text")
|
|
1119
|
+
});
|
|
1120
|
+
const TextDraftSchema = z.object({
|
|
1121
|
+
...ColorStyleDraftShape,
|
|
1122
|
+
...AnnotationDraftBaseShape,
|
|
1123
|
+
rect: PdfRectSchema,
|
|
1124
|
+
icon: NoteIconSchema.optional(),
|
|
1125
|
+
subtype: z.literal("text")
|
|
1126
|
+
});
|
|
1127
|
+
const TextPatchSchema = z.object({
|
|
1128
|
+
...ColorStylePatchShape,
|
|
1129
|
+
...AnnotationPatchBaseShape,
|
|
1130
|
+
rect: PdfRectSchema.optional(),
|
|
1131
|
+
icon: NoteIconSchema.optional(),
|
|
1132
|
+
subtype: z.literal("text")
|
|
1133
|
+
});
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/annotation/kinds/text/index.ts
|
|
1136
|
+
const TextKind = {
|
|
1137
|
+
subtype: "text",
|
|
1138
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.TEXT,
|
|
1139
|
+
dtoSchema: TextDTOSchema,
|
|
1140
|
+
draftSchema: TextDraftSchema,
|
|
1141
|
+
patchSchema: TextPatchSchema
|
|
1142
|
+
};
|
|
1143
|
+
//#endregion
|
|
1144
|
+
//#region src/annotation/kinds/underline/schema.ts
|
|
1145
|
+
const UnderlineDTOSchema = z.object({
|
|
1146
|
+
...TextMarkupDTOShape,
|
|
1147
|
+
subtype: z.literal("underline")
|
|
1148
|
+
});
|
|
1149
|
+
const UnderlineDraftSchema = z.object({
|
|
1150
|
+
...TextMarkupDraftShape,
|
|
1151
|
+
...AnnotationDraftBaseShape,
|
|
1152
|
+
subtype: z.literal("underline")
|
|
1153
|
+
});
|
|
1154
|
+
const UnderlinePatchSchema = z.object({
|
|
1155
|
+
...TextMarkupPatchShape,
|
|
1156
|
+
...AnnotationPatchBaseShape,
|
|
1157
|
+
subtype: z.literal("underline")
|
|
1158
|
+
});
|
|
1159
|
+
//#endregion
|
|
1160
|
+
//#region src/annotation/kinds/underline/index.ts
|
|
1161
|
+
const UnderlineKind = {
|
|
1162
|
+
subtype: "underline",
|
|
1163
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.UNDERLINE,
|
|
1164
|
+
dtoSchema: UnderlineDTOSchema,
|
|
1165
|
+
draftSchema: UnderlineDraftSchema,
|
|
1166
|
+
patchSchema: UnderlinePatchSchema
|
|
1167
|
+
};
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region src/annotation/kinds/unsupported/schema.ts
|
|
1170
|
+
const UnsupportedDTOSchema = z.object({
|
|
1171
|
+
...AnnotationBaseShape,
|
|
1172
|
+
subtype: z.literal("unsupported"),
|
|
1173
|
+
rawSubtypeCode: z.number().int(),
|
|
1174
|
+
rawSubtypeName: z.string().nullable()
|
|
1175
|
+
});
|
|
1176
|
+
const UnsupportedDraftSchema = z.never();
|
|
1177
|
+
const UnsupportedPatchSchema = z.never();
|
|
1178
|
+
//#endregion
|
|
1179
|
+
//#region src/annotation/kinds/unsupported/index.ts
|
|
1180
|
+
const UnsupportedKind = {
|
|
1181
|
+
subtype: "unsupported",
|
|
1182
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.UNKNOWN,
|
|
1183
|
+
dtoSchema: UnsupportedDTOSchema,
|
|
1184
|
+
draftSchema: UnsupportedDraftSchema,
|
|
1185
|
+
patchSchema: UnsupportedPatchSchema
|
|
1186
|
+
};
|
|
1187
|
+
//#endregion
|
|
1188
|
+
//#region src/annotation/kinds/widget.shared.ts
|
|
1189
|
+
const WidgetStyleDTOShape = {
|
|
1190
|
+
color: ColorSchema.nullable(),
|
|
1191
|
+
interiorColor: ColorSchema.nullable(),
|
|
1192
|
+
strokeWidth: z.number().nonnegative(),
|
|
1193
|
+
borderStyle: AnnotationBorderStyleSchema,
|
|
1194
|
+
fontFamily: StandardFontSchema.optional(),
|
|
1195
|
+
fontSize: z.number().nonnegative().optional(),
|
|
1196
|
+
fontColor: ColorSchema.optional(),
|
|
1197
|
+
textAlign: TextAlignmentSchema
|
|
1198
|
+
};
|
|
1199
|
+
const WidgetStyleDraftShape = {
|
|
1200
|
+
color: ColorSchema.nullable().optional(),
|
|
1201
|
+
interiorColor: ColorSchema.nullable().optional(),
|
|
1202
|
+
strokeWidth: z.number().nonnegative().optional(),
|
|
1203
|
+
borderStyle: AnnotationBorderStyleSchema.optional(),
|
|
1204
|
+
fontFamily: StandardFontSchema.optional(),
|
|
1205
|
+
fontSize: z.number().nonnegative().optional(),
|
|
1206
|
+
fontColor: ColorSchema.optional(),
|
|
1207
|
+
textAlign: TextAlignmentSchema.optional()
|
|
1208
|
+
};
|
|
1209
|
+
const WidgetStylePatchShape = WidgetStyleDraftShape;
|
|
1210
|
+
const WidgetAppearanceSchema = z.object(WidgetStyleDraftShape);
|
|
1211
|
+
//#endregion
|
|
1212
|
+
//#region src/annotation/kinds/widget/schema.ts
|
|
1213
|
+
const WidgetDTOSchema = z.object({
|
|
1214
|
+
...AnnotationBaseShape,
|
|
1215
|
+
...WidgetStyleDTOShape,
|
|
1216
|
+
subtype: z.literal("widget"),
|
|
1217
|
+
fieldObjectNumber: z.number().int().nonnegative(),
|
|
1218
|
+
fieldFamily: z.enum([
|
|
1219
|
+
"text",
|
|
1220
|
+
"checkbox",
|
|
1221
|
+
"radio",
|
|
1222
|
+
"combobox",
|
|
1223
|
+
"listbox",
|
|
1224
|
+
"pushbutton",
|
|
1225
|
+
"signature",
|
|
1226
|
+
"unknown"
|
|
1227
|
+
])
|
|
1228
|
+
});
|
|
1229
|
+
const WidgetDraftSchema = z.object({
|
|
1230
|
+
...AnnotationDraftBaseShape,
|
|
1231
|
+
...WidgetStyleDraftShape,
|
|
1232
|
+
subtype: z.literal("widget"),
|
|
1233
|
+
rect: PdfRectSchema
|
|
1234
|
+
});
|
|
1235
|
+
const WidgetPatchSchema = z.object({
|
|
1236
|
+
...AnnotationPatchBaseShape,
|
|
1237
|
+
...WidgetStylePatchShape,
|
|
1238
|
+
subtype: z.literal("widget"),
|
|
1239
|
+
rect: PdfRectSchema.optional()
|
|
1240
|
+
});
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/annotation/kinds/widget/index.ts
|
|
1243
|
+
const WidgetKind = {
|
|
1244
|
+
subtype: "widget",
|
|
1245
|
+
pdfSubtypeCode: PdfAnnotationSubtypeCode.WIDGET,
|
|
1246
|
+
dtoSchema: WidgetDTOSchema,
|
|
1247
|
+
draftSchema: WidgetDraftSchema,
|
|
1248
|
+
patchSchema: WidgetPatchSchema
|
|
1249
|
+
};
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region src/annotation/kinds/index.ts
|
|
1252
|
+
/**
|
|
1253
|
+
* The closed-world catalog of currently-implemented annotation kinds.
|
|
1254
|
+
*
|
|
1255
|
+
* Adding a new subtype is one folder under `kinds/<name>/` exporting the
|
|
1256
|
+
* five files (dto, draft, patch, schema, index) and one entry in this
|
|
1257
|
+
* tuple. The discriminated unions and zod discriminator below regenerate
|
|
1258
|
+
* automatically; no other file in the package needs to change.
|
|
1259
|
+
*
|
|
1260
|
+
* Every subtype the engine has not yet wired up rides on
|
|
1261
|
+
* `UnsupportedKind`. The wire format is stable: when a per-subtype reader
|
|
1262
|
+
* lands later, the engine starts emitting the dedicated DTO instead of
|
|
1263
|
+
* `unsupported`, and existing clients widen their handling without a
|
|
1264
|
+
* version bump.
|
|
1265
|
+
*/
|
|
1266
|
+
const ANNOTATION_KINDS = [
|
|
1267
|
+
HighlightKind,
|
|
1268
|
+
UnderlineKind,
|
|
1269
|
+
SquigglyKind,
|
|
1270
|
+
StrikeoutKind,
|
|
1271
|
+
CircleKind,
|
|
1272
|
+
SquareKind,
|
|
1273
|
+
PolygonKind,
|
|
1274
|
+
PolylineKind,
|
|
1275
|
+
LineKind,
|
|
1276
|
+
LinkKind,
|
|
1277
|
+
InkKind,
|
|
1278
|
+
FreeTextKind,
|
|
1279
|
+
CaretKind,
|
|
1280
|
+
TextKind,
|
|
1281
|
+
StampKind,
|
|
1282
|
+
FileAttachmentKind,
|
|
1283
|
+
WidgetKind,
|
|
1284
|
+
RedactKind,
|
|
1285
|
+
UnsupportedKind
|
|
1286
|
+
];
|
|
1287
|
+
/**
|
|
1288
|
+
* Lookup helper for the engine's reader catalog and identity resolver.
|
|
1289
|
+
* O(1) by `subtype` literal at runtime.
|
|
1290
|
+
*/
|
|
1291
|
+
const KIND_BY_SUBTYPE = Object.freeze(Object.fromEntries(ANNOTATION_KINDS.map((kind) => [kind.subtype, kind])));
|
|
1292
|
+
/**
|
|
1293
|
+
* Runtime zod schema for the discriminated union. The cast unwinds the
|
|
1294
|
+
* generic schema map into the specific tuple form `discriminatedUnion`
|
|
1295
|
+
* needs. Servers and cloud clients use this to validate every annotation
|
|
1296
|
+
* payload on the wire.
|
|
1297
|
+
*/
|
|
1298
|
+
const AnnotationDTOSchema = z.discriminatedUnion("subtype", [
|
|
1299
|
+
HighlightKind.dtoSchema,
|
|
1300
|
+
UnderlineKind.dtoSchema,
|
|
1301
|
+
SquigglyKind.dtoSchema,
|
|
1302
|
+
StrikeoutKind.dtoSchema,
|
|
1303
|
+
CircleKind.dtoSchema,
|
|
1304
|
+
SquareKind.dtoSchema,
|
|
1305
|
+
PolygonKind.dtoSchema,
|
|
1306
|
+
PolylineKind.dtoSchema,
|
|
1307
|
+
LineKind.dtoSchema,
|
|
1308
|
+
LinkKind.dtoSchema,
|
|
1309
|
+
InkKind.dtoSchema,
|
|
1310
|
+
FreeTextKind.dtoSchema,
|
|
1311
|
+
CaretKind.dtoSchema,
|
|
1312
|
+
TextKind.dtoSchema,
|
|
1313
|
+
StampKind.dtoSchema,
|
|
1314
|
+
FileAttachmentKind.dtoSchema,
|
|
1315
|
+
WidgetKind.dtoSchema,
|
|
1316
|
+
RedactKind.dtoSchema,
|
|
1317
|
+
UnsupportedKind.dtoSchema
|
|
1318
|
+
]);
|
|
1319
|
+
/**
|
|
1320
|
+
* Validates the WIRE draft form (post-normalization) — binary-carrying
|
|
1321
|
+
* kinds appear here with `{ resource }` refs, never inline bytes.
|
|
1322
|
+
*/
|
|
1323
|
+
const AnnotationDraftSchema = z.discriminatedUnion("subtype", [
|
|
1324
|
+
HighlightKind.draftSchema,
|
|
1325
|
+
UnderlineKind.draftSchema,
|
|
1326
|
+
SquigglyKind.draftSchema,
|
|
1327
|
+
StrikeoutKind.draftSchema,
|
|
1328
|
+
CircleKind.draftSchema,
|
|
1329
|
+
SquareKind.draftSchema,
|
|
1330
|
+
PolygonKind.draftSchema,
|
|
1331
|
+
PolylineKind.draftSchema,
|
|
1332
|
+
LineKind.draftSchema,
|
|
1333
|
+
LinkKind.draftSchema,
|
|
1334
|
+
InkKind.draftSchema,
|
|
1335
|
+
FreeTextKind.draftSchema,
|
|
1336
|
+
CaretKind.draftSchema,
|
|
1337
|
+
TextKind.draftSchema,
|
|
1338
|
+
StampKind.draftSchema,
|
|
1339
|
+
FileAttachmentKind.draftSchema,
|
|
1340
|
+
WidgetKind.draftSchema,
|
|
1341
|
+
RedactKind.draftSchema
|
|
1342
|
+
]);
|
|
1343
|
+
/** Validates the WIRE patch form (post-normalization). */
|
|
1344
|
+
const AnnotationPatchSchema = z.discriminatedUnion("subtype", [
|
|
1345
|
+
HighlightKind.patchSchema,
|
|
1346
|
+
UnderlineKind.patchSchema,
|
|
1347
|
+
SquigglyKind.patchSchema,
|
|
1348
|
+
StrikeoutKind.patchSchema,
|
|
1349
|
+
CircleKind.patchSchema,
|
|
1350
|
+
SquareKind.patchSchema,
|
|
1351
|
+
PolygonKind.patchSchema,
|
|
1352
|
+
PolylineKind.patchSchema,
|
|
1353
|
+
LineKind.patchSchema,
|
|
1354
|
+
LinkKind.patchSchema,
|
|
1355
|
+
InkKind.patchSchema,
|
|
1356
|
+
FreeTextKind.patchSchema,
|
|
1357
|
+
CaretKind.patchSchema,
|
|
1358
|
+
TextKind.patchSchema,
|
|
1359
|
+
StampKind.patchSchema,
|
|
1360
|
+
FileAttachmentKind.patchSchema,
|
|
1361
|
+
WidgetKind.patchSchema,
|
|
1362
|
+
RedactKind.patchSchema
|
|
1363
|
+
]);
|
|
1364
|
+
//#endregion
|
|
1365
|
+
//#region src/forms/schema.ts
|
|
1366
|
+
const FormFieldRefSchema = z.discriminatedUnion("kind", [z.object({
|
|
1367
|
+
kind: z.literal("objectNumber"),
|
|
1368
|
+
fieldObjectNumber: z.number().int().positive()
|
|
1369
|
+
}), z.object({
|
|
1370
|
+
kind: z.literal("fqn"),
|
|
1371
|
+
name: z.string().min(1)
|
|
1372
|
+
})]);
|
|
1373
|
+
const FormWidgetRefShape = {
|
|
1374
|
+
annotObjectNumber: z.number().int().nonnegative(),
|
|
1375
|
+
pageObjectNumber: z.number().int().nonnegative()
|
|
1376
|
+
};
|
|
1377
|
+
const FormWidgetRefSchema = z.object(FormWidgetRefShape);
|
|
1378
|
+
const FormFieldFlagsSchema = z.object({
|
|
1379
|
+
readOnly: z.boolean(),
|
|
1380
|
+
required: z.boolean(),
|
|
1381
|
+
noExport: z.boolean(),
|
|
1382
|
+
raw: z.number().int().nonnegative()
|
|
1383
|
+
});
|
|
1384
|
+
const ToggleFieldWidgetSchema = z.object({
|
|
1385
|
+
...FormWidgetRefShape,
|
|
1386
|
+
onState: z.string(),
|
|
1387
|
+
exportValue: z.string(),
|
|
1388
|
+
checked: z.boolean()
|
|
1389
|
+
});
|
|
1390
|
+
const FormFieldOptionSchema = z.object({
|
|
1391
|
+
label: z.string(),
|
|
1392
|
+
value: z.string(),
|
|
1393
|
+
selected: z.boolean()
|
|
1394
|
+
});
|
|
1395
|
+
const FormValueEntrySchema = z.discriminatedUnion("kind", [
|
|
1396
|
+
z.object({ kind: z.literal("none") }),
|
|
1397
|
+
z.object({
|
|
1398
|
+
kind: z.literal("scalar"),
|
|
1399
|
+
value: z.string()
|
|
1400
|
+
}),
|
|
1401
|
+
z.object({
|
|
1402
|
+
kind: z.literal("array"),
|
|
1403
|
+
values: z.array(z.string())
|
|
1404
|
+
}),
|
|
1405
|
+
z.object({ kind: z.literal("unsupported") })
|
|
1406
|
+
]);
|
|
1407
|
+
const FormFieldBaseShape = {
|
|
1408
|
+
ref: FormFieldRefSchema,
|
|
1409
|
+
fieldObjectNumber: z.number().int().nonnegative(),
|
|
1410
|
+
name: z.string(),
|
|
1411
|
+
origin: z.enum(["acroform", "recovered"]),
|
|
1412
|
+
flags: FormFieldFlagsSchema,
|
|
1413
|
+
alternateName: z.string().nullable(),
|
|
1414
|
+
mappingName: z.string().nullable(),
|
|
1415
|
+
valueEntry: FormValueEntrySchema,
|
|
1416
|
+
defaultValueEntry: FormValueEntrySchema,
|
|
1417
|
+
actions: PdfFieldActionsSchema.optional(),
|
|
1418
|
+
widgets: z.array(FormWidgetRefSchema)
|
|
1419
|
+
};
|
|
1420
|
+
const FormFieldDTOSchema = z.discriminatedUnion("family", [
|
|
1421
|
+
z.object({
|
|
1422
|
+
...FormFieldBaseShape,
|
|
1423
|
+
family: z.literal("text"),
|
|
1424
|
+
value: z.string(),
|
|
1425
|
+
defaultValue: z.string(),
|
|
1426
|
+
maxLength: z.number().int().positive().nullable(),
|
|
1427
|
+
multiline: z.boolean(),
|
|
1428
|
+
password: z.boolean(),
|
|
1429
|
+
comb: z.boolean()
|
|
1430
|
+
}),
|
|
1431
|
+
z.object({
|
|
1432
|
+
...FormFieldBaseShape,
|
|
1433
|
+
family: z.literal("checkbox"),
|
|
1434
|
+
checked: z.boolean(),
|
|
1435
|
+
exportValue: z.string(),
|
|
1436
|
+
widgets: z.array(ToggleFieldWidgetSchema)
|
|
1437
|
+
}),
|
|
1438
|
+
z.object({
|
|
1439
|
+
...FormFieldBaseShape,
|
|
1440
|
+
family: z.literal("radio"),
|
|
1441
|
+
value: z.string(),
|
|
1442
|
+
radiosInUnison: z.boolean(),
|
|
1443
|
+
noToggleToOff: z.boolean(),
|
|
1444
|
+
widgets: z.array(ToggleFieldWidgetSchema)
|
|
1445
|
+
}),
|
|
1446
|
+
z.object({
|
|
1447
|
+
...FormFieldBaseShape,
|
|
1448
|
+
family: z.literal("combobox"),
|
|
1449
|
+
value: z.string(),
|
|
1450
|
+
defaultValue: z.string(),
|
|
1451
|
+
edit: z.boolean(),
|
|
1452
|
+
options: z.array(FormFieldOptionSchema)
|
|
1453
|
+
}),
|
|
1454
|
+
z.object({
|
|
1455
|
+
...FormFieldBaseShape,
|
|
1456
|
+
family: z.literal("listbox"),
|
|
1457
|
+
selectedValues: z.array(z.string()),
|
|
1458
|
+
multiSelect: z.boolean(),
|
|
1459
|
+
options: z.array(FormFieldOptionSchema)
|
|
1460
|
+
}),
|
|
1461
|
+
z.object({
|
|
1462
|
+
...FormFieldBaseShape,
|
|
1463
|
+
family: z.literal("pushbutton")
|
|
1464
|
+
}),
|
|
1465
|
+
z.object({
|
|
1466
|
+
...FormFieldBaseShape,
|
|
1467
|
+
family: z.literal("signature")
|
|
1468
|
+
}),
|
|
1469
|
+
z.object({
|
|
1470
|
+
...FormFieldBaseShape,
|
|
1471
|
+
family: z.literal("unknown"),
|
|
1472
|
+
rawValue: z.string()
|
|
1473
|
+
})
|
|
1474
|
+
]);
|
|
1475
|
+
const FormKindSchema = z.enum([
|
|
1476
|
+
"none",
|
|
1477
|
+
"acroform",
|
|
1478
|
+
"xfa"
|
|
1479
|
+
]);
|
|
1480
|
+
const FormSnapshotSchema = z.object({
|
|
1481
|
+
formKind: FormKindSchema,
|
|
1482
|
+
needsAppearances: z.boolean(),
|
|
1483
|
+
fields: z.array(FormFieldDTOSchema),
|
|
1484
|
+
calculationOrder: z.array(FormFieldRefSchema.nullable())
|
|
1485
|
+
});
|
|
1486
|
+
const FormFieldValueSchema = z.discriminatedUnion("type", [
|
|
1487
|
+
z.object({
|
|
1488
|
+
type: z.literal("text"),
|
|
1489
|
+
value: z.string()
|
|
1490
|
+
}),
|
|
1491
|
+
z.object({
|
|
1492
|
+
type: z.literal("toggle"),
|
|
1493
|
+
state: z.string().nullable()
|
|
1494
|
+
}),
|
|
1495
|
+
z.object({
|
|
1496
|
+
type: z.literal("choice"),
|
|
1497
|
+
values: z.array(z.string())
|
|
1498
|
+
})
|
|
1499
|
+
]);
|
|
1500
|
+
const FormDataFormatSchema = z.enum(["fdf", "xfdf"]);
|
|
1501
|
+
const WidgetPlacementSchema = z.object({
|
|
1502
|
+
pageObjectNumber: z.number().int().positive(),
|
|
1503
|
+
rect: PdfRectSchema,
|
|
1504
|
+
onState: z.string().min(1).optional(),
|
|
1505
|
+
appearance: WidgetAppearanceSchema.optional()
|
|
1506
|
+
});
|
|
1507
|
+
const FormFieldOptionInputSchema = z.object({
|
|
1508
|
+
label: z.string(),
|
|
1509
|
+
value: z.string()
|
|
1510
|
+
});
|
|
1511
|
+
const FormFieldDraftBaseShape = {
|
|
1512
|
+
name: z.string().min(1),
|
|
1513
|
+
readOnly: z.boolean().optional(),
|
|
1514
|
+
required: z.boolean().optional(),
|
|
1515
|
+
noExport: z.boolean().optional(),
|
|
1516
|
+
alternateName: z.string().optional(),
|
|
1517
|
+
mappingName: z.string().optional()
|
|
1518
|
+
};
|
|
1519
|
+
const FormFieldDraftSchema = z.discriminatedUnion("family", [
|
|
1520
|
+
z.object({
|
|
1521
|
+
...FormFieldDraftBaseShape,
|
|
1522
|
+
family: z.literal("text"),
|
|
1523
|
+
defaultValue: z.string().optional(),
|
|
1524
|
+
maxLength: z.number().int().positive().optional(),
|
|
1525
|
+
multiline: z.boolean().optional(),
|
|
1526
|
+
password: z.boolean().optional(),
|
|
1527
|
+
comb: z.boolean().optional(),
|
|
1528
|
+
widget: WidgetPlacementSchema.optional()
|
|
1529
|
+
}),
|
|
1530
|
+
z.object({
|
|
1531
|
+
...FormFieldDraftBaseShape,
|
|
1532
|
+
family: z.literal("checkbox"),
|
|
1533
|
+
widget: WidgetPlacementSchema.optional()
|
|
1534
|
+
}),
|
|
1535
|
+
z.object({
|
|
1536
|
+
...FormFieldDraftBaseShape,
|
|
1537
|
+
family: z.literal("radio"),
|
|
1538
|
+
radiosInUnison: z.boolean().optional(),
|
|
1539
|
+
noToggleToOff: z.boolean().optional(),
|
|
1540
|
+
widgets: z.array(WidgetPlacementSchema).optional()
|
|
1541
|
+
}),
|
|
1542
|
+
z.object({
|
|
1543
|
+
...FormFieldDraftBaseShape,
|
|
1544
|
+
family: z.literal("combobox"),
|
|
1545
|
+
edit: z.boolean().optional(),
|
|
1546
|
+
options: z.array(FormFieldOptionInputSchema).optional(),
|
|
1547
|
+
defaultValue: z.string().optional(),
|
|
1548
|
+
widget: WidgetPlacementSchema.optional()
|
|
1549
|
+
}),
|
|
1550
|
+
z.object({
|
|
1551
|
+
...FormFieldDraftBaseShape,
|
|
1552
|
+
family: z.literal("listbox"),
|
|
1553
|
+
multiSelect: z.boolean().optional(),
|
|
1554
|
+
options: z.array(FormFieldOptionInputSchema).optional(),
|
|
1555
|
+
widget: WidgetPlacementSchema.optional()
|
|
1556
|
+
})
|
|
1557
|
+
]);
|
|
1558
|
+
const FormFieldPatchBaseShape = {
|
|
1559
|
+
name: z.string().min(1).optional(),
|
|
1560
|
+
readOnly: z.boolean().optional(),
|
|
1561
|
+
required: z.boolean().optional(),
|
|
1562
|
+
noExport: z.boolean().optional(),
|
|
1563
|
+
alternateName: z.string().nullable().optional(),
|
|
1564
|
+
mappingName: z.string().nullable().optional()
|
|
1565
|
+
};
|
|
1566
|
+
const FormFieldPatchSchema = z.discriminatedUnion("family", [
|
|
1567
|
+
z.object({
|
|
1568
|
+
...FormFieldPatchBaseShape,
|
|
1569
|
+
family: z.literal("text"),
|
|
1570
|
+
defaultValue: z.string().nullable().optional(),
|
|
1571
|
+
maxLength: z.number().int().positive().nullable().optional(),
|
|
1572
|
+
multiline: z.boolean().optional(),
|
|
1573
|
+
password: z.boolean().optional(),
|
|
1574
|
+
comb: z.boolean().optional()
|
|
1575
|
+
}),
|
|
1576
|
+
z.object({
|
|
1577
|
+
...FormFieldPatchBaseShape,
|
|
1578
|
+
family: z.literal("checkbox")
|
|
1579
|
+
}),
|
|
1580
|
+
z.object({
|
|
1581
|
+
...FormFieldPatchBaseShape,
|
|
1582
|
+
family: z.literal("radio"),
|
|
1583
|
+
radiosInUnison: z.boolean().optional(),
|
|
1584
|
+
noToggleToOff: z.boolean().optional()
|
|
1585
|
+
}),
|
|
1586
|
+
z.object({
|
|
1587
|
+
...FormFieldPatchBaseShape,
|
|
1588
|
+
family: z.literal("combobox"),
|
|
1589
|
+
edit: z.boolean().optional(),
|
|
1590
|
+
defaultValue: z.string().nullable().optional(),
|
|
1591
|
+
options: z.array(FormFieldOptionInputSchema).optional()
|
|
1592
|
+
}),
|
|
1593
|
+
z.object({
|
|
1594
|
+
...FormFieldPatchBaseShape,
|
|
1595
|
+
family: z.literal("listbox"),
|
|
1596
|
+
multiSelect: z.boolean().optional(),
|
|
1597
|
+
options: z.array(FormFieldOptionInputSchema).optional()
|
|
1598
|
+
})
|
|
1599
|
+
]);
|
|
1600
|
+
//#endregion
|
|
1601
|
+
//#region src/wire/schemas.ts
|
|
1602
|
+
const DocumentMetadataSchema = z.object({
|
|
1603
|
+
title: z.string().nullable(),
|
|
1604
|
+
author: z.string().nullable(),
|
|
1605
|
+
subject: z.string().nullable(),
|
|
1606
|
+
keywords: z.string().nullable(),
|
|
1607
|
+
producer: z.string().nullable(),
|
|
1608
|
+
creator: z.string().nullable(),
|
|
1609
|
+
created: z.string().datetime().nullable(),
|
|
1610
|
+
modified: z.string().datetime().nullable(),
|
|
1611
|
+
trapped: z.enum([
|
|
1612
|
+
"true",
|
|
1613
|
+
"false",
|
|
1614
|
+
"unknown"
|
|
1615
|
+
]),
|
|
1616
|
+
custom: z.record(z.string(), z.string())
|
|
1617
|
+
});
|
|
1618
|
+
/**
|
|
1619
|
+
* Three-state metadata patch. Mirrors annotation patch semantics:
|
|
1620
|
+
* `undefined` leaves a field, `null` clears it, a value sets it. `custom`
|
|
1621
|
+
* is a per-key three-state map (string set / null clear / absent leave).
|
|
1622
|
+
*/
|
|
1623
|
+
const MetadataPatchSchema = z.object({
|
|
1624
|
+
title: z.string().nullable().optional(),
|
|
1625
|
+
author: z.string().nullable().optional(),
|
|
1626
|
+
subject: z.string().nullable().optional(),
|
|
1627
|
+
keywords: z.string().nullable().optional(),
|
|
1628
|
+
producer: z.string().nullable().optional(),
|
|
1629
|
+
creator: z.string().nullable().optional(),
|
|
1630
|
+
created: z.string().datetime().nullable().optional(),
|
|
1631
|
+
modified: z.string().datetime().nullable().optional(),
|
|
1632
|
+
trapped: z.enum([
|
|
1633
|
+
"true",
|
|
1634
|
+
"false",
|
|
1635
|
+
"unknown"
|
|
1636
|
+
]).optional(),
|
|
1637
|
+
custom: z.record(z.string(), z.string().nullable()).optional()
|
|
1638
|
+
}).strict();
|
|
1639
|
+
const OpenDocumentResponseSchema = z.object({ id: z.string() });
|
|
1640
|
+
/**
|
|
1641
|
+
* Wire shape of `GET /v1/docs/:docId/head`. Mirrors the server-side
|
|
1642
|
+
* `DocumentHead` interface; the schema is the source of truth so
|
|
1643
|
+
* older SDKs talking to newer servers degrade gracefully (extra
|
|
1644
|
+
* fields are accepted and ignored).
|
|
1645
|
+
*
|
|
1646
|
+
* `docVersion` is the single monotonic integer per doc; it bumps on
|
|
1647
|
+
* ANY mutation that could change the manifest's content (page list,
|
|
1648
|
+
* per-page content, per-page annotations, per-page weak-flag), which
|
|
1649
|
+
* makes `/manifest@docVersion=N` fully content-addressed and cache-friendly.
|
|
1650
|
+
* Phase 4 hard-codes it to `1`; Phase 5's mutation handler is what
|
|
1651
|
+
* actually bumps it.
|
|
1652
|
+
*/
|
|
1653
|
+
const DocumentHeadSchema = z.object({
|
|
1654
|
+
id: z.string(),
|
|
1655
|
+
baseSha: z.string(),
|
|
1656
|
+
storageSizeBytes: z.number().int().nonnegative(),
|
|
1657
|
+
docVersion: z.number().int().positive(),
|
|
1658
|
+
state: z.enum([
|
|
1659
|
+
"pending",
|
|
1660
|
+
"ready",
|
|
1661
|
+
"failed",
|
|
1662
|
+
"deleting"
|
|
1663
|
+
]),
|
|
1664
|
+
encryption: z.object({
|
|
1665
|
+
state: z.enum([
|
|
1666
|
+
"unknown",
|
|
1667
|
+
"none",
|
|
1668
|
+
"encrypted",
|
|
1669
|
+
"unsupported"
|
|
1670
|
+
]),
|
|
1671
|
+
requiresPassword: z.boolean().nullable()
|
|
1672
|
+
}),
|
|
1673
|
+
permissions: z.object({
|
|
1674
|
+
known: z.boolean(),
|
|
1675
|
+
bits: z.number().int().nonnegative().nullable(),
|
|
1676
|
+
allAllowed: z.boolean().nullable(),
|
|
1677
|
+
openedAs: z.enum([
|
|
1678
|
+
"none",
|
|
1679
|
+
"user",
|
|
1680
|
+
"owner"
|
|
1681
|
+
]).nullable(),
|
|
1682
|
+
securityHandlerRevision: z.number().int().nullable(),
|
|
1683
|
+
canUpgradeToOwner: z.boolean()
|
|
1684
|
+
}),
|
|
1685
|
+
access: z.object({
|
|
1686
|
+
required: z.boolean(),
|
|
1687
|
+
reasons: z.array(z.enum([
|
|
1688
|
+
"password",
|
|
1689
|
+
"cdn",
|
|
1690
|
+
"permissions-unknown"
|
|
1691
|
+
])),
|
|
1692
|
+
endpoint: z.string().optional()
|
|
1693
|
+
})
|
|
1694
|
+
});
|
|
1695
|
+
const AccessRequestSchema = z.object({
|
|
1696
|
+
docId: z.string().min(1),
|
|
1697
|
+
layerName: z.string().min(1).optional(),
|
|
1698
|
+
password: z.string().optional(),
|
|
1699
|
+
passwordGrant: z.string().optional(),
|
|
1700
|
+
mode: z.enum(["any", "owner"]).optional()
|
|
1701
|
+
});
|
|
1702
|
+
/**
|
|
1703
|
+
* Typed boolean view of the PDF user-access permission word. Names
|
|
1704
|
+
* mirror the `PdfBits` shape in @embedpdf/engine-core/auth/scope; ISO
|
|
1705
|
+
* bit numbers (3, 4, 5, 6, 9, 10, 11, 12).
|
|
1706
|
+
*/
|
|
1707
|
+
const PdfBitsObjectSchema = z.object({
|
|
1708
|
+
bit3: z.boolean(),
|
|
1709
|
+
bit4: z.boolean(),
|
|
1710
|
+
bit5: z.boolean(),
|
|
1711
|
+
bit6: z.boolean(),
|
|
1712
|
+
bit9: z.boolean(),
|
|
1713
|
+
bit10: z.boolean(),
|
|
1714
|
+
bit11: z.boolean(),
|
|
1715
|
+
bit12: z.boolean()
|
|
1716
|
+
});
|
|
1717
|
+
/**
|
|
1718
|
+
* Capability-shaped advisory for the client UI. Mirrors
|
|
1719
|
+
* `PdfPermissionAdvisory` in @embedpdf/engine-core/runtime; one
|
|
1720
|
+
* boolean per UI badge.
|
|
1721
|
+
*/
|
|
1722
|
+
const PdfPermissionAdvisoryObjectSchema = z.object({
|
|
1723
|
+
canPrint: z.boolean(),
|
|
1724
|
+
canPrintHigh: z.boolean(),
|
|
1725
|
+
canCopy: z.boolean(),
|
|
1726
|
+
canAnnotate: z.boolean(),
|
|
1727
|
+
canFillForms: z.boolean(),
|
|
1728
|
+
canModifyForms: z.boolean(),
|
|
1729
|
+
canModifyPages: z.boolean(),
|
|
1730
|
+
canAssemble: z.boolean()
|
|
1731
|
+
});
|
|
1732
|
+
const PdfPermissionInfoSchema = z.object({
|
|
1733
|
+
known: z.boolean(),
|
|
1734
|
+
allAllowed: z.boolean().nullable(),
|
|
1735
|
+
bits: z.number().int().nonnegative().nullable(),
|
|
1736
|
+
openedAs: z.enum([
|
|
1737
|
+
"none",
|
|
1738
|
+
"user",
|
|
1739
|
+
"owner"
|
|
1740
|
+
]).nullable(),
|
|
1741
|
+
securityHandlerRevision: z.number().int().nullable(),
|
|
1742
|
+
flags: PdfBitsObjectSchema.optional(),
|
|
1743
|
+
advisory: PdfPermissionAdvisoryObjectSchema.optional()
|
|
1744
|
+
}).nullable();
|
|
1745
|
+
const DocumentSecurityStateSchema = z.object({
|
|
1746
|
+
encryption: z.object({
|
|
1747
|
+
state: z.enum([
|
|
1748
|
+
"unknown",
|
|
1749
|
+
"none",
|
|
1750
|
+
"encrypted",
|
|
1751
|
+
"unsupported"
|
|
1752
|
+
]),
|
|
1753
|
+
requiresPassword: z.boolean().nullable()
|
|
1754
|
+
}),
|
|
1755
|
+
permissions: z.object({
|
|
1756
|
+
known: z.boolean(),
|
|
1757
|
+
bits: z.number().int().nonnegative().nullable(),
|
|
1758
|
+
allAllowed: z.boolean().nullable(),
|
|
1759
|
+
openedAs: z.enum([
|
|
1760
|
+
"none",
|
|
1761
|
+
"user",
|
|
1762
|
+
"owner"
|
|
1763
|
+
]).nullable(),
|
|
1764
|
+
securityHandlerRevision: z.number().int().nullable(),
|
|
1765
|
+
canUpgradeToOwner: z.boolean()
|
|
1766
|
+
}),
|
|
1767
|
+
access: z.object({
|
|
1768
|
+
required: z.boolean(),
|
|
1769
|
+
reasons: z.array(z.enum([
|
|
1770
|
+
"password",
|
|
1771
|
+
"cdn",
|
|
1772
|
+
"permissions-unknown"
|
|
1773
|
+
])),
|
|
1774
|
+
endpoint: z.string().optional()
|
|
1775
|
+
})
|
|
1776
|
+
});
|
|
1777
|
+
const AccessResponseSchema = z.object({
|
|
1778
|
+
security: DocumentSecurityStateSchema,
|
|
1779
|
+
cdn: z.object({
|
|
1780
|
+
adapter: z.enum([
|
|
1781
|
+
"none",
|
|
1782
|
+
"cloudfront",
|
|
1783
|
+
"cloud-cdn",
|
|
1784
|
+
"bunny",
|
|
1785
|
+
"azure-fd",
|
|
1786
|
+
"custom-hmac"
|
|
1787
|
+
]),
|
|
1788
|
+
expiresAt: z.number().int().positive(),
|
|
1789
|
+
cache: z.object({
|
|
1790
|
+
scope: z.enum(["browser-private", "edge-shared"]),
|
|
1791
|
+
immutableVersionedReads: z.boolean()
|
|
1792
|
+
}),
|
|
1793
|
+
baseUrlOverrides: z.record(z.string(), z.string()).nullable(),
|
|
1794
|
+
authHeader: z.object({
|
|
1795
|
+
name: z.string(),
|
|
1796
|
+
value: z.string()
|
|
1797
|
+
}).nullable(),
|
|
1798
|
+
signedQueryParams: z.record(z.string(), z.string()).nullable(),
|
|
1799
|
+
signedCookies: z.array(z.object({
|
|
1800
|
+
name: z.string(),
|
|
1801
|
+
value: z.string(),
|
|
1802
|
+
domain: z.string().optional(),
|
|
1803
|
+
path: z.string().optional(),
|
|
1804
|
+
expires: z.number().int().optional()
|
|
1805
|
+
})).nullable(),
|
|
1806
|
+
signedPathPolicies: z.array(z.object({
|
|
1807
|
+
pathPrefix: z.string(),
|
|
1808
|
+
queryParams: z.record(z.string(), z.string())
|
|
1809
|
+
})).nullable()
|
|
1810
|
+
}),
|
|
1811
|
+
passwordGrant: z.string().nullable(),
|
|
1812
|
+
pdfPermissions: PdfPermissionInfoSchema,
|
|
1813
|
+
scope: z.array(z.string()),
|
|
1814
|
+
/**
|
|
1815
|
+
* Concrete capability set granted to this caller after expanding
|
|
1816
|
+
* `pdf.permissions` and applying resolver implication rules. Client
|
|
1817
|
+
* UI should drive feature visibility off this, not off raw `scope`.
|
|
1818
|
+
* Always present in /access responses (server populates from
|
|
1819
|
+
* `expandRawScope`). Sorted alphabetically for stable change
|
|
1820
|
+
* detection.
|
|
1821
|
+
*/
|
|
1822
|
+
effectiveScope: z.array(z.string()),
|
|
1823
|
+
identity: z.object({
|
|
1824
|
+
user_id: z.string().optional(),
|
|
1825
|
+
group_id: z.string().optional(),
|
|
1826
|
+
groups: z.array(z.string()).optional(),
|
|
1827
|
+
display_name: z.string().optional()
|
|
1828
|
+
}),
|
|
1829
|
+
originPasswordPolicy: z.object({ mode: z.enum([
|
|
1830
|
+
"not-needed",
|
|
1831
|
+
"client-retry",
|
|
1832
|
+
"server-session"
|
|
1833
|
+
]) }),
|
|
1834
|
+
expiresAt: z.number().int().positive(),
|
|
1835
|
+
/**
|
|
1836
|
+
* The deployment's render lattice — the canonical parameter points the
|
|
1837
|
+
* server treats as durable, CDN-shared artifacts. Lives HERE and never in
|
|
1838
|
+
* the manifest: manifests are version-pinned immutable objects; the
|
|
1839
|
+
* lattice is mutable deployment policy. The SDK exposes it (and a pure
|
|
1840
|
+
* `snap` helper) but NEVER conforms requests implicitly — the same render
|
|
1841
|
+
* call must not return different pixels on local vs cloud. When
|
|
1842
|
+
* `enforced` is true the server rejects off-lattice render tokens with
|
|
1843
|
+
* 400; when false, off-lattice renders are computed but not persisted.
|
|
1844
|
+
* Absent on older servers → treat as unenforced/unknown.
|
|
1845
|
+
*/
|
|
1846
|
+
renderPolicy: z.object({
|
|
1847
|
+
/**
|
|
1848
|
+
* Full-page renders quantize on `viewport.width` — the bounded
|
|
1849
|
+
* quantity is OUTPUT PIXELS, never zoom (PDF page space is
|
|
1850
|
+
* effectively unbounded, so a scale lattice bounds artifact count
|
|
1851
|
+
* but not size).
|
|
1852
|
+
*/
|
|
1853
|
+
fullPage: z.object({ widths: z.array(z.number().int().positive()) }),
|
|
1854
|
+
/**
|
|
1855
|
+
* RESERVED for deep-zoom tile support: scale-based pyramid ×
|
|
1856
|
+
* fixed tile size, constant per-job cost. Absent until the tiling
|
|
1857
|
+
* plugin ships.
|
|
1858
|
+
*/
|
|
1859
|
+
tiles: z.object({
|
|
1860
|
+
tileSizes: z.array(z.number().int().positive()),
|
|
1861
|
+
scales: z.array(z.number().positive())
|
|
1862
|
+
}).optional(),
|
|
1863
|
+
/**
|
|
1864
|
+
* Annotation-appearance lattice — SCALE-based (appearances are sized
|
|
1865
|
+
* by `rect × scale` and must track the page's effective render scale
|
|
1866
|
+
* for crisp composites).
|
|
1867
|
+
*/
|
|
1868
|
+
appearances: z.object({ scales: z.array(z.number().positive()) }).optional(),
|
|
1869
|
+
/** Worker-side output budget for degenerate page geometry. */
|
|
1870
|
+
maxRenderPixels: z.number().int().positive().optional(),
|
|
1871
|
+
formats: z.array(z.enum(["webp", "png"])),
|
|
1872
|
+
background: z.enum(["white"]),
|
|
1873
|
+
enforced: z.boolean()
|
|
1874
|
+
}).optional()
|
|
1875
|
+
});
|
|
1876
|
+
const PdfSaveModeSchema = z.enum(["incremental", "rewrite"]);
|
|
1877
|
+
const engineErrorCodeValues = Object.values(EngineErrorCode);
|
|
1878
|
+
const EngineErrorPayloadSchema = z.object({
|
|
1879
|
+
name: z.literal("EngineError"),
|
|
1880
|
+
code: z.enum(engineErrorCodeValues),
|
|
1881
|
+
message: z.string(),
|
|
1882
|
+
details: z.record(z.string(), z.unknown()).optional()
|
|
1883
|
+
});
|
|
1884
|
+
const WeakAnnotationStateSchema = z.discriminatedUnion("kind", [z.object({ kind: z.literal("unknown") }), z.object({
|
|
1885
|
+
kind: z.literal("known"),
|
|
1886
|
+
hasAnyWeakAnnotations: z.boolean()
|
|
1887
|
+
})]);
|
|
1888
|
+
const PageStateSchema = z.object({
|
|
1889
|
+
pageObjectNumber: z.number().int().positive(),
|
|
1890
|
+
revision: RevisionTokenSchema,
|
|
1891
|
+
weakAnnotationState: WeakAnnotationStateSchema
|
|
1892
|
+
});
|
|
1893
|
+
const CachePinsSchema = z.object({
|
|
1894
|
+
contentVersion: z.number().int().positive(),
|
|
1895
|
+
annotationVersion: z.number().int().positive()
|
|
1896
|
+
});
|
|
1897
|
+
/**
|
|
1898
|
+
* Plane scopes are DERIVED from the version counters at every emission
|
|
1899
|
+
* point (layer manifests, mutation cache envelopes, SSE rows), never stored.
|
|
1900
|
+
* Additive/optional both ways: old clients ignore it, old servers omit it
|
|
1901
|
+
* (consumers treat absence as all-'layer' — never wrong, only unshared).
|
|
1902
|
+
*/
|
|
1903
|
+
const LayerScopeValueSchema = z.enum(["base", "layer"]);
|
|
1904
|
+
const LayerScopesSchema = z.object({
|
|
1905
|
+
content: LayerScopeValueSchema,
|
|
1906
|
+
annotations: LayerScopeValueSchema,
|
|
1907
|
+
layout: LayerScopeValueSchema,
|
|
1908
|
+
attachments: LayerScopeValueSchema,
|
|
1909
|
+
metadata: LayerScopeValueSchema,
|
|
1910
|
+
actions: LayerScopeValueSchema
|
|
1911
|
+
});
|
|
1912
|
+
/**
|
|
1913
|
+
* Per-page envelope inside `DocumentManifest`. Carries the full
|
|
1914
|
+
* `PageState` plus the cache-busting integers the SDK embeds in
|
|
1915
|
+
* leaf URLs (`/pages/:pon/text@contentVersion=N`, `/pages/:pon/annotations@annotationVersion=N`).
|
|
1916
|
+
*
|
|
1917
|
+
* `contentVersion` bumps when the page's content stream changes
|
|
1918
|
+
* (text, page reorder doesn't, the pon is durable). `annotationVersion`
|
|
1919
|
+
* bumps when /Annots gains/loses entries or when a tracked annotation
|
|
1920
|
+
* mutates. `hasWeakAnnotations` is hoisted from `PageState` so the
|
|
1921
|
+
* SDK can decide whether to display a "stale-on-reorder" badge
|
|
1922
|
+
* without re-fetching the page.
|
|
1923
|
+
*
|
|
1924
|
+
* Phase 4 hard-codes all three to (1, 1, false); Phase 5's
|
|
1925
|
+
* `layer_pages` table drives the real values.
|
|
1926
|
+
*/
|
|
1927
|
+
const ManifestPageSchema = z.object({
|
|
1928
|
+
state: PageStateSchema,
|
|
1929
|
+
cache: CachePinsSchema
|
|
1930
|
+
}).superRefine((page, ctx) => {
|
|
1931
|
+
if (page.state.weakAnnotationState.kind !== "known") ctx.addIssue({
|
|
1932
|
+
code: z.ZodIssueCode.custom,
|
|
1933
|
+
path: ["state", "weakAnnotationState"],
|
|
1934
|
+
message: "manifest pages must have a known weak annotation state"
|
|
1935
|
+
});
|
|
1936
|
+
});
|
|
1937
|
+
/**
|
|
1938
|
+
* Wire shape of `GET /v1/docs/:docId/manifest@docVersion=N`. Content-addressed
|
|
1939
|
+
* by `docVersion`; safe to cache with `Cache-Control: public,
|
|
1940
|
+
* max-age=31536000, immutable`.
|
|
1941
|
+
*/
|
|
1942
|
+
const DocumentManifestSchema = z.object({
|
|
1943
|
+
docVersion: z.number().int().positive(),
|
|
1944
|
+
layoutVersion: z.number().int().positive(),
|
|
1945
|
+
metadataVersion: z.number().int().positive(),
|
|
1946
|
+
actionsVersion: z.number().int().positive().default(1),
|
|
1947
|
+
attachmentsVersion: z.number().int().positive().default(1),
|
|
1948
|
+
auditHead: z.number().int().nonnegative(),
|
|
1949
|
+
baseSha: z.string(),
|
|
1950
|
+
scopes: LayerScopesSchema.optional(),
|
|
1951
|
+
pages: z.array(ManifestPageSchema)
|
|
1952
|
+
});
|
|
1953
|
+
const AnnotationListPageSnapshotSchema = z.object({
|
|
1954
|
+
pageState: PageStateSchema,
|
|
1955
|
+
annotations: z.array(AnnotationDTOSchema)
|
|
1956
|
+
});
|
|
1957
|
+
const AnnotationListSnapshotAllPagesSchema = z.object({ pages: z.array(AnnotationListPageSnapshotSchema) });
|
|
1958
|
+
/**
|
|
1959
|
+
* Wire shape of `GET /v1/docs/:docId/pages/:pon/text@contentVersion=N` and the
|
|
1960
|
+
* `pages.text` worker result. Carries the same `pageState` envelope
|
|
1961
|
+
* every page-scoped read returns, plus the full plain-text extraction
|
|
1962
|
+
* in display order and PDFium's char-count (which may exceed
|
|
1963
|
+
* `text.length / 1` when astral-plane characters are present).
|
|
1964
|
+
*/
|
|
1965
|
+
const PageTextSnapshotSchema = z.object({
|
|
1966
|
+
text: z.string(),
|
|
1967
|
+
charCount: z.number().int().nonnegative()
|
|
1968
|
+
});
|
|
1969
|
+
const PageGeometryGlyphSchema = z.object({
|
|
1970
|
+
looseBox: PdfRectSchema,
|
|
1971
|
+
flags: z.number().int().nonnegative(),
|
|
1972
|
+
tightBox: PdfRectSchema.optional()
|
|
1973
|
+
});
|
|
1974
|
+
const PageGeometryRunSchema = z.object({
|
|
1975
|
+
rect: PdfRectSchema,
|
|
1976
|
+
charStart: z.number().int().nonnegative(),
|
|
1977
|
+
glyphs: z.array(PageGeometryGlyphSchema),
|
|
1978
|
+
fontSize: z.number().optional()
|
|
1979
|
+
});
|
|
1980
|
+
const PageGeometrySnapshotSchema = z.object({ runs: z.array(PageGeometryRunSchema) });
|
|
1981
|
+
/**
|
|
1982
|
+
* Search wire shapes: the request body of the layer search route and the
|
|
1983
|
+
* `search.query` worker/route result. The server re-validates the query
|
|
1984
|
+
* semantics (`validateSearchQuery`: regex dialect + flag combos) after
|
|
1985
|
+
* parse — the schema only checks structure.
|
|
1986
|
+
*/
|
|
1987
|
+
const SearchQuerySchema = z.object({
|
|
1988
|
+
text: z.string(),
|
|
1989
|
+
regex: z.boolean().optional(),
|
|
1990
|
+
matchCase: z.boolean().optional(),
|
|
1991
|
+
wholeWord: z.boolean().optional(),
|
|
1992
|
+
matchDiacritics: z.boolean().optional()
|
|
1993
|
+
});
|
|
1994
|
+
const SearchModeSchema = z.enum(["rects", "full"]);
|
|
1995
|
+
const SearchRequestSchema = z.object({
|
|
1996
|
+
query: SearchQuerySchema,
|
|
1997
|
+
mode: SearchModeSchema.optional(),
|
|
1998
|
+
cursor: z.string().optional(),
|
|
1999
|
+
startPage: z.number().int().positive().optional(),
|
|
2000
|
+
skip: z.number().int().nonnegative().optional(),
|
|
2001
|
+
budget: z.object({
|
|
2002
|
+
maxMatches: z.number().int().positive().optional(),
|
|
2003
|
+
maxPages: z.number().int().positive().optional()
|
|
2004
|
+
}).optional()
|
|
2005
|
+
});
|
|
2006
|
+
const SearchSnippetSchema = z.object({
|
|
2007
|
+
text: z.string(),
|
|
2008
|
+
matchStart: z.number().int().nonnegative(),
|
|
2009
|
+
matchLength: z.number().int().positive()
|
|
2010
|
+
});
|
|
2011
|
+
const SearchMatchSchema = z.object({
|
|
2012
|
+
pageObjectNumber: z.number().int().positive(),
|
|
2013
|
+
charStart: z.number().int().nonnegative(),
|
|
2014
|
+
charCount: z.number().int().positive(),
|
|
2015
|
+
rects: z.array(PdfRectSchema),
|
|
2016
|
+
snippet: SearchSnippetSchema.optional()
|
|
2017
|
+
});
|
|
2018
|
+
const SearchSliceSchema = z.object({
|
|
2019
|
+
matches: z.array(SearchMatchSchema),
|
|
2020
|
+
nextCursor: z.string().nullable(),
|
|
2021
|
+
scannedPages: z.number().int().nonnegative(),
|
|
2022
|
+
totalPages: z.number().int().nonnegative()
|
|
2023
|
+
});
|
|
2024
|
+
const PageNetworkRenderFormatSchema = z.enum(["png", "webp"]);
|
|
2025
|
+
/**
|
|
2026
|
+
* Wire schema for the cloud render endpoints, applied to the **nested**
|
|
2027
|
+
* shape produced by `unflatten(...)` of the parsed token or query string.
|
|
2028
|
+
*
|
|
2029
|
+
* Adding a new render option is one change here (a new field plus any
|
|
2030
|
+
* cross-field rule in `superRefine`) plus one entry in
|
|
2031
|
+
* `RenderTokenSchema.fields`. The token codec, flatten/unflatten helpers,
|
|
2032
|
+
* route handlers, and SDK URL builder are all generic and pick the new
|
|
2033
|
+
* field up automatically.
|
|
2034
|
+
*
|
|
2035
|
+
* Coercion: token fields and query strings both arrive as strings, so every
|
|
2036
|
+
* scalar uses `z.coerce.*`. Discriminated unions on `viewport.kind` and
|
|
2037
|
+
* `target.kind` enforce viewport / rect coherence by construction — no
|
|
2038
|
+
* superRefine for "fields must appear together" rules.
|
|
2039
|
+
*/
|
|
2040
|
+
const RenderViewportSchema = z.discriminatedUnion("kind", [z.object({
|
|
2041
|
+
kind: z.literal("width"),
|
|
2042
|
+
width: z.coerce.number().positive().finite()
|
|
2043
|
+
}).strict(), z.object({
|
|
2044
|
+
kind: z.literal("scale"),
|
|
2045
|
+
scale: z.coerce.number().positive().finite().optional()
|
|
2046
|
+
}).strict()]);
|
|
2047
|
+
const RenderTargetSchema = z.discriminatedUnion("kind", [z.object({ kind: z.literal("page") }).strict(), z.object({
|
|
2048
|
+
kind: z.literal("rect"),
|
|
2049
|
+
rect: z.object({
|
|
2050
|
+
left: z.coerce.number().finite(),
|
|
2051
|
+
bottom: z.coerce.number().finite(),
|
|
2052
|
+
right: z.coerce.number().finite(),
|
|
2053
|
+
top: z.coerce.number().finite()
|
|
2054
|
+
}).strict()
|
|
2055
|
+
}).strict()]);
|
|
2056
|
+
const RenderRotationSchema = z.preprocess((raw) => raw === void 0 ? void 0 : Number(raw), z.number().refine((n) => n === 0 || n === 90 || n === 180 || n === 270, { message: "render rotation must be 0, 90, 180, or 270" }));
|
|
2057
|
+
const RenderBackgroundSchema = z.enum(["white", "transparent"]);
|
|
2058
|
+
const RenderQualitySchema = z.coerce.number().int().min(1).max(100);
|
|
2059
|
+
/**
|
|
2060
|
+
* Token/path rule: annotatedness is PATH-expressed —
|
|
2061
|
+
* the render FAMILY the route belongs to — never token/query-expressed.
|
|
2062
|
+
* Each family therefore gets its own query schema, built from one shared
|
|
2063
|
+
* base:
|
|
2064
|
+
*
|
|
2065
|
+
* - the annotation-free family (`…/render/pages/`) has NO
|
|
2066
|
+
* `annotationVersion` field at all — `.strict()` rejects it as an
|
|
2067
|
+
* unrecognized key, so the illegal combination is unrepresentable;
|
|
2068
|
+
* - the annotated family (`…/render/annotated/pages/`) REQUIRES
|
|
2069
|
+
* `annotationVersion` on versioned requests — its artifact depends on
|
|
2070
|
+
* the `annotations` plane, so the pin must be in the cache key.
|
|
2071
|
+
*
|
|
2072
|
+
* Both transforms stamp `includeAnnotations` onto the parsed SDK options
|
|
2073
|
+
* from the family, so downstream consumers (worker options, classify) are
|
|
2074
|
+
* family-blind.
|
|
2075
|
+
*/
|
|
2076
|
+
function buildPageRenderQuerySchema(annotated) {
|
|
2077
|
+
return z.object({
|
|
2078
|
+
contentVersion: z.coerce.number().int().positive().optional(),
|
|
2079
|
+
...annotated ? { annotationVersion: z.coerce.number().int().positive().optional() } : {},
|
|
2080
|
+
format: PageNetworkRenderFormatSchema.optional(),
|
|
2081
|
+
viewport: RenderViewportSchema.optional(),
|
|
2082
|
+
target: RenderTargetSchema.optional(),
|
|
2083
|
+
rotation: RenderRotationSchema.optional(),
|
|
2084
|
+
background: RenderBackgroundSchema.optional(),
|
|
2085
|
+
quality: RenderQualitySchema.optional()
|
|
2086
|
+
}).strict().superRefine((v, ctx) => {
|
|
2087
|
+
const pins = v;
|
|
2088
|
+
if (pins.contentVersion !== void 0 && v.format === void 0) ctx.addIssue({
|
|
2089
|
+
code: z.ZodIssueCode.custom,
|
|
2090
|
+
path: ["format"],
|
|
2091
|
+
message: "versioned render requires format"
|
|
2092
|
+
});
|
|
2093
|
+
if (annotated && pins.annotationVersion !== void 0 && pins.contentVersion === void 0) ctx.addIssue({
|
|
2094
|
+
code: z.ZodIssueCode.custom,
|
|
2095
|
+
path: ["annotationVersion"],
|
|
2096
|
+
message: "annotationVersion requires contentVersion"
|
|
2097
|
+
});
|
|
2098
|
+
if (annotated && pins.contentVersion !== void 0 && pins.annotationVersion === void 0) ctx.addIssue({
|
|
2099
|
+
code: z.ZodIssueCode.custom,
|
|
2100
|
+
path: ["annotationVersion"],
|
|
2101
|
+
message: "versioned annotated render requires annotationVersion"
|
|
2102
|
+
});
|
|
2103
|
+
}).transform((v) => {
|
|
2104
|
+
const pins = v;
|
|
2105
|
+
return {
|
|
2106
|
+
options: {
|
|
2107
|
+
...v.target ? { target: v.target } : {},
|
|
2108
|
+
...v.viewport ? { viewport: v.viewport } : {},
|
|
2109
|
+
...v.rotation !== void 0 ? { rotation: v.rotation } : {},
|
|
2110
|
+
...v.background !== void 0 ? { background: v.background } : {},
|
|
2111
|
+
...v.quality !== void 0 ? { quality: v.quality } : {},
|
|
2112
|
+
...v.format !== void 0 ? { format: v.format } : {},
|
|
2113
|
+
includeAnnotations: annotated
|
|
2114
|
+
},
|
|
2115
|
+
...pins.contentVersion !== void 0 ? { contentVersion: pins.contentVersion } : {},
|
|
2116
|
+
...pins.annotationVersion !== void 0 ? { annotationVersion: pins.annotationVersion } : {}
|
|
2117
|
+
};
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
/** Query/token schema for the annotation-free render family (`page-render`). */
|
|
2121
|
+
const PageRenderQuerySchema = buildPageRenderQuerySchema(false);
|
|
2122
|
+
/** Query/token schema for the annotated render family (`page-render-annotated`). */
|
|
2123
|
+
const PageRenderAnnotatedQuerySchema = buildPageRenderQuerySchema(true);
|
|
2124
|
+
/**
|
|
2125
|
+
* Query/token schema for the batch annotation-appearance render endpoint.
|
|
2126
|
+
* Mirrors `PageRenderQuerySchema` but without page target/viewport/background
|
|
2127
|
+
* or `includeAnnotations` (appearances are always annotation-derived), and
|
|
2128
|
+
* keyed by `annotationVersion` only — appearance bitmaps do not depend on
|
|
2129
|
+
* page base content, so `contentVersion` is not part of the cache key. The
|
|
2130
|
+
* endpoint renders the Normal appearance only.
|
|
2131
|
+
*/
|
|
2132
|
+
const AnnotationAppearancesQuerySchema = z.object({
|
|
2133
|
+
annotationVersion: z.coerce.number().int().positive().optional(),
|
|
2134
|
+
format: PageNetworkRenderFormatSchema.optional(),
|
|
2135
|
+
rotation: RenderRotationSchema.optional(),
|
|
2136
|
+
scale: z.coerce.number().positive().finite().optional(),
|
|
2137
|
+
quality: RenderQualitySchema.optional()
|
|
2138
|
+
}).strict().superRefine((v, ctx) => {
|
|
2139
|
+
if (v.annotationVersion !== void 0 && v.format === void 0) ctx.addIssue({
|
|
2140
|
+
code: z.ZodIssueCode.custom,
|
|
2141
|
+
path: ["format"],
|
|
2142
|
+
message: "versioned appearance render requires format"
|
|
2143
|
+
});
|
|
2144
|
+
}).transform((v) => {
|
|
2145
|
+
return {
|
|
2146
|
+
options: {
|
|
2147
|
+
...v.rotation !== void 0 ? { rotation: v.rotation } : {},
|
|
2148
|
+
...v.scale !== void 0 ? { scale: v.scale } : {},
|
|
2149
|
+
...v.quality !== void 0 ? { quality: v.quality } : {},
|
|
2150
|
+
...v.format !== void 0 ? { format: v.format } : {}
|
|
2151
|
+
},
|
|
2152
|
+
...v.annotationVersion !== void 0 ? { annotationVersion: v.annotationVersion } : {}
|
|
2153
|
+
};
|
|
2154
|
+
});
|
|
2155
|
+
/**
|
|
2156
|
+
* The JSON manifest part of the appearance `multipart/form-data` response.
|
|
2157
|
+
* Wire-stable; the cloud client validates the parsed `manifest` part against
|
|
2158
|
+
* this before reconstructing image handles from the binary parts.
|
|
2159
|
+
*/
|
|
2160
|
+
const AnnotationAppearanceManifestSchema = z.object({
|
|
2161
|
+
pageState: PageStateSchema,
|
|
2162
|
+
appearances: z.array(z.object({
|
|
2163
|
+
part: z.string().min(1),
|
|
2164
|
+
ref: AnnotationRefSchema,
|
|
2165
|
+
mode: z.enum([
|
|
2166
|
+
"normal",
|
|
2167
|
+
"rollover",
|
|
2168
|
+
"down"
|
|
2169
|
+
]),
|
|
2170
|
+
rect: PdfRectSchema,
|
|
2171
|
+
width: z.number().int().positive(),
|
|
2172
|
+
height: z.number().int().positive(),
|
|
2173
|
+
format: PageNetworkRenderFormatSchema,
|
|
2174
|
+
contentType: z.string().min(1)
|
|
2175
|
+
}))
|
|
2176
|
+
});
|
|
2177
|
+
/**
|
|
2178
|
+
* Reasons a mutation tells the client its old snapshot is stale. Wire-stable;
|
|
2179
|
+
* extend with care (forward-compat clients accept only known values).
|
|
2180
|
+
*/
|
|
2181
|
+
const RefetchReasonSchema = z.enum([
|
|
2182
|
+
"weakRefsInvalidated",
|
|
2183
|
+
"externalChange",
|
|
2184
|
+
"pageRebuilt"
|
|
2185
|
+
]);
|
|
2186
|
+
const CacheDeltaSchema = z.object({
|
|
2187
|
+
previousDocVersion: z.number().int().positive(),
|
|
2188
|
+
docVersion: z.number().int().positive(),
|
|
2189
|
+
pages: z.array(z.object({
|
|
2190
|
+
pageObjectNumber: z.number().int().positive(),
|
|
2191
|
+
cache: CachePinsSchema
|
|
2192
|
+
}))
|
|
2193
|
+
});
|
|
2194
|
+
const MutationMetaSchema = z.object({
|
|
2195
|
+
affectedPages: z.array(PageStateSchema),
|
|
2196
|
+
cacheDelta: CacheDeltaSchema.nullable()
|
|
2197
|
+
});
|
|
2198
|
+
/**
|
|
2199
|
+
* Per-page side-effect envelope every annotation mutation returns. Mirrors
|
|
2200
|
+
* `AnnotationListMutationMeta`. The `shouldRefetch` field is `null` when the
|
|
2201
|
+
* client's existing index-based references remain valid; non-null only when
|
|
2202
|
+
* the engine knows for sure the snapshot is stale.
|
|
2203
|
+
*/
|
|
2204
|
+
const AnnotationListMutationMetaSchema = z.object({
|
|
2205
|
+
affectedPages: z.array(PageStateSchema),
|
|
2206
|
+
cacheDelta: CacheDeltaSchema.nullable(),
|
|
2207
|
+
changed: z.array(AnnotationStableIdSchema),
|
|
2208
|
+
weakRefsInvalidated: z.boolean(),
|
|
2209
|
+
shouldRefetch: z.object({ reason: RefetchReasonSchema }).nullable()
|
|
2210
|
+
});
|
|
2211
|
+
const AnnotationCreateResultSchema = z.object({
|
|
2212
|
+
created: AnnotationDTOSchema,
|
|
2213
|
+
meta: AnnotationListMutationMetaSchema
|
|
2214
|
+
});
|
|
2215
|
+
/** The engine's `/AP` verdict riding every update result (see engine-core
|
|
2216
|
+
* `annotation/appearance.ts`). `changed` drives client raster invalidation. */
|
|
2217
|
+
const AppearanceOutcomeSchema = z.object({
|
|
2218
|
+
action: z.enum([
|
|
2219
|
+
"preserved",
|
|
2220
|
+
"regenerated",
|
|
2221
|
+
"generation-unavailable"
|
|
2222
|
+
]),
|
|
2223
|
+
changed: z.boolean()
|
|
2224
|
+
});
|
|
2225
|
+
const AnnotationUpdateResultSchema = z.object({
|
|
2226
|
+
updated: AnnotationDTOSchema,
|
|
2227
|
+
appearance: AppearanceOutcomeSchema,
|
|
2228
|
+
meta: AnnotationListMutationMetaSchema
|
|
2229
|
+
});
|
|
2230
|
+
/**
|
|
2231
|
+
* `deleted` is nullable: a weak annotation (no /NM, no indirect object
|
|
2232
|
+
* number) has no durable id to report after removal. Cloud server and local
|
|
2233
|
+
* worker both emit `null` in that case so callers don't have to special-case
|
|
2234
|
+
* a sentinel.
|
|
2235
|
+
*/
|
|
2236
|
+
const AnnotationDeleteResultSchema = z.object({
|
|
2237
|
+
deleted: AnnotationStableIdSchema.nullable(),
|
|
2238
|
+
meta: AnnotationListMutationMetaSchema
|
|
2239
|
+
});
|
|
2240
|
+
/**
|
|
2241
|
+
* Batch annotation move (contiguous-block, symmetric with `pages.move`).
|
|
2242
|
+
* `moved` is in caller order; each `moved[i]` lives at index `toIndex + i`
|
|
2243
|
+
* after the move. ONE structural envelope per batch.
|
|
2244
|
+
*/
|
|
2245
|
+
const AnnotationMoveResultSchema = z.object({
|
|
2246
|
+
moved: z.array(AnnotationDTOSchema),
|
|
2247
|
+
meta: AnnotationListMutationMetaSchema
|
|
2248
|
+
});
|
|
2249
|
+
const FormSetValueResultSchema = z.object({
|
|
2250
|
+
field: FormFieldDTOSchema,
|
|
2251
|
+
changedWidgets: z.array(FormWidgetRefSchema),
|
|
2252
|
+
meta: MutationMetaSchema
|
|
2253
|
+
});
|
|
2254
|
+
const FormEffectSchema = z.discriminatedUnion("kind", [
|
|
2255
|
+
z.object({
|
|
2256
|
+
kind: z.literal("setValue"),
|
|
2257
|
+
ref: FormFieldRefSchema,
|
|
2258
|
+
value: FormFieldValueSchema
|
|
2259
|
+
}),
|
|
2260
|
+
z.object({
|
|
2261
|
+
kind: z.literal("setDisplay"),
|
|
2262
|
+
ref: FormFieldRefSchema,
|
|
2263
|
+
display: z.enum([
|
|
2264
|
+
"visible",
|
|
2265
|
+
"hidden",
|
|
2266
|
+
"noPrint",
|
|
2267
|
+
"noView"
|
|
2268
|
+
])
|
|
2269
|
+
}),
|
|
2270
|
+
z.object({
|
|
2271
|
+
kind: z.literal("setAppearanceText"),
|
|
2272
|
+
ref: FormFieldRefSchema,
|
|
2273
|
+
text: z.string()
|
|
2274
|
+
}),
|
|
2275
|
+
z.object({
|
|
2276
|
+
kind: z.literal("reset"),
|
|
2277
|
+
refs: z.array(FormFieldRefSchema)
|
|
2278
|
+
})
|
|
2279
|
+
]);
|
|
2280
|
+
const FormEffectsResultSchema = z.object({
|
|
2281
|
+
results: z.array(z.object({
|
|
2282
|
+
index: z.number().int().nonnegative(),
|
|
2283
|
+
status: z.enum([
|
|
2284
|
+
"applied",
|
|
2285
|
+
"unchanged",
|
|
2286
|
+
"rejected",
|
|
2287
|
+
"failed",
|
|
2288
|
+
"skipped"
|
|
2289
|
+
]),
|
|
2290
|
+
fields: z.array(FormFieldDTOSchema),
|
|
2291
|
+
changedWidgets: z.array(FormWidgetRefSchema),
|
|
2292
|
+
error: EngineErrorPayloadSchema.optional()
|
|
2293
|
+
})),
|
|
2294
|
+
changedWidgets: z.array(FormWidgetRefSchema),
|
|
2295
|
+
meta: MutationMetaSchema.nullable()
|
|
2296
|
+
});
|
|
2297
|
+
const FormImportResultSchema = z.object({
|
|
2298
|
+
fieldsTotal: z.number().int().nonnegative(),
|
|
2299
|
+
fieldsApplied: z.number().int().nonnegative(),
|
|
2300
|
+
fieldsSkipped: z.number().int().nonnegative(),
|
|
2301
|
+
widgetsChanged: z.number().int().nonnegative(),
|
|
2302
|
+
snapshot: FormSnapshotSchema,
|
|
2303
|
+
meta: MutationMetaSchema
|
|
2304
|
+
});
|
|
2305
|
+
const FormFieldCreateResultSchema = z.object({
|
|
2306
|
+
field: FormFieldDTOSchema,
|
|
2307
|
+
meta: MutationMetaSchema
|
|
2308
|
+
});
|
|
2309
|
+
const FormFieldUpdateResultSchema = z.object({
|
|
2310
|
+
field: FormFieldDTOSchema,
|
|
2311
|
+
meta: MutationMetaSchema
|
|
2312
|
+
});
|
|
2313
|
+
const FormFieldDeleteResultSchema = z.object({
|
|
2314
|
+
deletedFieldObjectNumber: z.number().int().positive(),
|
|
2315
|
+
removedWidgets: z.array(FormWidgetRefSchema),
|
|
2316
|
+
meta: MutationMetaSchema
|
|
2317
|
+
});
|
|
2318
|
+
const FormWidgetLinkResultSchema = z.object({
|
|
2319
|
+
field: FormFieldDTOSchema,
|
|
2320
|
+
meta: MutationMetaSchema
|
|
2321
|
+
});
|
|
2322
|
+
const FormRepairResultSchema = z.object({
|
|
2323
|
+
acroformCreated: z.boolean(),
|
|
2324
|
+
fieldsLinked: z.number().int().nonnegative(),
|
|
2325
|
+
widgetsLinked: z.number().int().nonnegative(),
|
|
2326
|
+
fieldsUnrepairable: z.number().int().nonnegative(),
|
|
2327
|
+
appearancesBaked: z.number().int().nonnegative(),
|
|
2328
|
+
needAppearancesCleared: z.boolean(),
|
|
2329
|
+
meta: MutationMetaSchema
|
|
2330
|
+
});
|
|
2331
|
+
const PageBoxesSchema = z.object({
|
|
2332
|
+
media: PdfRectSchema,
|
|
2333
|
+
crop: PdfRectSchema,
|
|
2334
|
+
bleed: PdfRectSchema.optional(),
|
|
2335
|
+
trim: PdfRectSchema.optional(),
|
|
2336
|
+
art: PdfRectSchema.optional()
|
|
2337
|
+
});
|
|
2338
|
+
/**
|
|
2339
|
+
* Pure geometry for one page (`pages.list()` element). No annotation
|
|
2340
|
+
* liveness — that lives on annotation reads and the manifest.
|
|
2341
|
+
*/
|
|
2342
|
+
const PageLayoutSchema = z.object({
|
|
2343
|
+
index: z.number().int().nonnegative(),
|
|
2344
|
+
pageObjectNumber: z.number().int().positive(),
|
|
2345
|
+
label: z.string().nullable(),
|
|
2346
|
+
size: PdfSizeSchema,
|
|
2347
|
+
rotation: PdfRotationSchema,
|
|
2348
|
+
userUnit: z.number().positive(),
|
|
2349
|
+
boxes: PageBoxesSchema,
|
|
2350
|
+
actions: PdfPageActionsSchema.optional()
|
|
2351
|
+
});
|
|
2352
|
+
const PageFlattenResultSchema = z.object({
|
|
2353
|
+
pageObjectNumbers: z.array(z.number().int().positive()),
|
|
2354
|
+
usage: z.enum(["display", "print"]),
|
|
2355
|
+
results: z.array(z.object({
|
|
2356
|
+
pageObjectNumber: z.number().int().positive(),
|
|
2357
|
+
status: z.enum([
|
|
2358
|
+
"applied",
|
|
2359
|
+
"unchanged",
|
|
2360
|
+
"failed",
|
|
2361
|
+
"skipped"
|
|
2362
|
+
]),
|
|
2363
|
+
error: EngineErrorPayloadSchema.optional()
|
|
2364
|
+
})),
|
|
2365
|
+
meta: MutationMetaSchema.nullable()
|
|
2366
|
+
});
|
|
2367
|
+
const PageFlattenInputSchema = z.object({
|
|
2368
|
+
pageObjectNumbers: z.array(z.number().int().positive()),
|
|
2369
|
+
usage: z.enum(["display", "print"])
|
|
2370
|
+
});
|
|
2371
|
+
const RedactionApplyScopeSchema = z.discriminatedUnion("kind", [z.object({
|
|
2372
|
+
kind: z.literal("pages"),
|
|
2373
|
+
pageObjectNumbers: z.array(z.number().int().positive())
|
|
2374
|
+
}), z.object({
|
|
2375
|
+
kind: z.literal("annotations"),
|
|
2376
|
+
refs: z.array(AnnotationRefSchema)
|
|
2377
|
+
})]);
|
|
2378
|
+
const RedactionApplyResultSchema = z.object({
|
|
2379
|
+
scope: RedactionApplyScopeSchema,
|
|
2380
|
+
results: z.array(z.object({
|
|
2381
|
+
pageObjectNumber: z.number().int().positive(),
|
|
2382
|
+
status: z.enum([
|
|
2383
|
+
"applied",
|
|
2384
|
+
"unchanged",
|
|
2385
|
+
"failed",
|
|
2386
|
+
"skipped"
|
|
2387
|
+
]),
|
|
2388
|
+
removedAnnotationCount: z.number().int().nonnegative(),
|
|
2389
|
+
error: EngineErrorPayloadSchema.optional()
|
|
2390
|
+
})),
|
|
2391
|
+
removedAnnotationCount: z.number().int().nonnegative(),
|
|
2392
|
+
meta: MutationMetaSchema.nullable()
|
|
2393
|
+
});
|
|
2394
|
+
/**
|
|
2395
|
+
* Snapshot of every page in display order. Pages are addressed by
|
|
2396
|
+
* `pageObjectNumber` everywhere except the per-element `index`, which is
|
|
2397
|
+
* display order and intentionally not an identity. Carries geometry only.
|
|
2398
|
+
*/
|
|
2399
|
+
const PageListSnapshotSchema = z.object({
|
|
2400
|
+
pageCount: z.number().int().nonnegative(),
|
|
2401
|
+
pages: z.array(PageLayoutSchema)
|
|
2402
|
+
});
|
|
2403
|
+
/**
|
|
2404
|
+
* Page reorder input. Pages are always addressed by `pageObjectNumber`;
|
|
2405
|
+
* `destIndex` is the insertion point in the post-removal index space.
|
|
2406
|
+
*/
|
|
2407
|
+
const PageMoveInputSchema = z.object({
|
|
2408
|
+
pageObjectNumbers: z.array(z.number().int().positive()),
|
|
2409
|
+
destIndex: z.number().int().nonnegative()
|
|
2410
|
+
});
|
|
2411
|
+
/**
|
|
2412
|
+
* Coherence pins shared by every page-STRUCTURE result (move/rotate/delete) —
|
|
2413
|
+
* see `PageStructureCache`. Nullable at each use site (local engines).
|
|
2414
|
+
*/
|
|
2415
|
+
const PageStructureCacheSchema = z.object({
|
|
2416
|
+
previousDocVersion: z.number().int().nonnegative(),
|
|
2417
|
+
docVersion: z.number().int().positive(),
|
|
2418
|
+
layoutVersion: z.number().int().positive()
|
|
2419
|
+
});
|
|
2420
|
+
/**
|
|
2421
|
+
* Page reorder result. No revision is bumped (no doc-level revision exists,
|
|
2422
|
+
* and per-page revisions intentionally survive a page reorder). The full
|
|
2423
|
+
* post-move order is returned so callers can swap their snapshot directly.
|
|
2424
|
+
*/
|
|
2425
|
+
const PageMoveResultSchema = z.object({
|
|
2426
|
+
layout: PageListSnapshotSchema,
|
|
2427
|
+
cache: PageStructureCacheSchema.nullable()
|
|
2428
|
+
});
|
|
2429
|
+
/**
|
|
2430
|
+
* Page rotate input. ABSOLUTE rotation (idempotent — see `PageRotateInput`),
|
|
2431
|
+
* one value applied to every listed page.
|
|
2432
|
+
*/
|
|
2433
|
+
const PageRotateInputSchema = z.object({
|
|
2434
|
+
pageObjectNumbers: z.array(z.number().int().positive()),
|
|
2435
|
+
rotation: PdfRotationSchema
|
|
2436
|
+
});
|
|
2437
|
+
/**
|
|
2438
|
+
* Page rotate result. Rotation is presentation metadata over normalized
|
|
2439
|
+
* content: nothing per-page invalidates; the new `layout` carries the
|
|
2440
|
+
* rotation values (see `PageRotateResult`).
|
|
2441
|
+
*/
|
|
2442
|
+
const PageRotateResultSchema = z.object({
|
|
2443
|
+
layout: PageListSnapshotSchema,
|
|
2444
|
+
cache: PageStructureCacheSchema.nullable()
|
|
2445
|
+
});
|
|
2446
|
+
/** Page delete input. Deleting every page is rejected server/worker-side. */
|
|
2447
|
+
const PageDeleteInputSchema = z.object({ pageObjectNumbers: z.array(z.number().int().positive()) });
|
|
2448
|
+
/**
|
|
2449
|
+
* Page delete result. Deleted PONs are retired (never recycled); surviving
|
|
2450
|
+
* pages keep identity + revisions (see `PageDeleteResult`).
|
|
2451
|
+
*/
|
|
2452
|
+
const PageDeleteResultSchema = z.object({
|
|
2453
|
+
layout: PageListSnapshotSchema,
|
|
2454
|
+
cache: PageStructureCacheSchema.nullable()
|
|
2455
|
+
});
|
|
2456
|
+
/**
|
|
2457
|
+
* Metadata write result. The Info dict is rewritten in place, so the
|
|
2458
|
+
* result returns the re-read `metadata` plus cloud coherence pins. No
|
|
2459
|
+
* `layoutVersion` is touched — a metadata edit bumps only `docVersion`
|
|
2460
|
+
* and `metadataVersion`. `cache` is `null` for local engines.
|
|
2461
|
+
*/
|
|
2462
|
+
const AttachmentsCacheSchema = z.object({
|
|
2463
|
+
previousDocVersion: z.number().int().nonnegative(),
|
|
2464
|
+
docVersion: z.number().int().positive(),
|
|
2465
|
+
attachmentsVersion: z.number().int().positive()
|
|
2466
|
+
});
|
|
2467
|
+
const AttachmentCreateResultSchema = z.object({
|
|
2468
|
+
created: EmbeddedFileItemSchema,
|
|
2469
|
+
cache: AttachmentsCacheSchema.nullable()
|
|
2470
|
+
});
|
|
2471
|
+
const AttachmentDeleteResultSchema = z.object({
|
|
2472
|
+
deleted: EmbeddedFileRefSchema,
|
|
2473
|
+
cache: AttachmentsCacheSchema.nullable()
|
|
2474
|
+
});
|
|
2475
|
+
const MetadataUpdateResultSchema = z.object({
|
|
2476
|
+
metadata: DocumentMetadataSchema,
|
|
2477
|
+
cache: z.object({
|
|
2478
|
+
previousDocVersion: z.number().int().nonnegative(),
|
|
2479
|
+
docVersion: z.number().int().positive(),
|
|
2480
|
+
metadataVersion: z.number().int().positive()
|
|
2481
|
+
}).nullable()
|
|
2482
|
+
});
|
|
2483
|
+
const WeakAnnotationSessionResponseSchema = z.object({
|
|
2484
|
+
sessionId: z.string().min(1),
|
|
2485
|
+
expiresAt: z.number().int().positive(),
|
|
2486
|
+
heartbeatIntervalMs: z.number().int().positive(),
|
|
2487
|
+
pageObjectNumbers: z.array(z.number().int().positive())
|
|
2488
|
+
});
|
|
2489
|
+
const WeakAnnotationSessionPagesRequestSchema = z.object({ pageObjectNumbers: z.array(z.number().int().positive()).transform((pages) => [...new Set(pages)]) });
|
|
2490
|
+
//#endregion
|
|
2491
|
+
export { PageStateSchema as $, FreeTextIntentSchema as $n, SquigglyDraftSchema as $t, FormSetValueResultSchema as A, FileAttachmentPatchSchema as An, AnnotationDTOSchema as At, PageDeleteResultSchema as B, CaretDraftSchema as Bn, UnderlinePatchSchema as Bt, FormEffectSchema as C, HighlightDraftSchema as Cn, PdfRotationSchema as Cr, FormKindSchema as Ct, FormFieldUpdateResultSchema as D, FreeTextPatchSchema as Dn, ToggleFieldWidgetSchema as Dt, FormFieldDeleteResultSchema as E, FreeTextDraftSchema as En, FormWidgetRefSchema as Et, MetadataUpdateResultSchema as F, EmbeddedFileRefSchema as Fn, UnsupportedDTOSchema as Ft, PageListSnapshotSchema as G, AnnotationFlagsPartialSchema as Gn, StrikeoutDTOSchema as Gt, PageFlattenResultSchema as H, AnnotationBaseShape as Hn, TextDTOSchema as Ht, MutationMetaSchema as I, CircleDTOSchema as In, UnsupportedDraftSchema as It, PageNetworkRenderFormatSchema as J, AnnotationRefSchema as Jn, ResourceRefSchema as Jt, PageMoveInputSchema as K, AnnotationFlagsSchema as Kn, StrikeoutDraftSchema as Kt, OpenDocumentResponseSchema as L, CircleDraftSchema as Ln, UnsupportedPatchSchema as Lt, LayerScopesSchema as M, WireAttachmentFileSchema as Mn, AnnotationPatchSchema as Mt, ManifestPageSchema as N, AttachmentFileInfoSchema as Nn, KIND_BY_SUBTYPE as Nt, FormImportResultSchema as O, FileAttachmentDTOSchema as On, WidgetPlacementSchema as Ot, MetadataPatchSchema as P, EmbeddedFileItemSchema as Pn, WidgetAppearanceSchema as Pt, PageRotateResultSchema as Q, ColorSchema as Qn, SquigglyDTOSchema as Qt, PageBoxesSchema as R, CirclePatchSchema as Rn, UnderlineDTOSchema as Rt, EngineErrorPayloadSchema as S, HighlightDTOSchema as Sn, PdfRectSchema as Sr, FormFieldValueSchema as St, FormFieldCreateResultSchema as T, FreeTextDTOSchema as Tn, FormValueEntrySchema as Tt, PageGeometrySnapshotSchema as U, AnnotationBorderStyleSchema as Un, TextDraftSchema as Ut, PageFlattenInputSchema as V, CaretPatchSchema as Vn, NoteIconSchema as Vt, PageLayoutSchema as W, AnnotationDraftBaseShape as Wn, TextPatchSchema as Wt, PageRenderQuerySchema as X, BlendModeSchema as Xn, StampWireDraftSchema as Xt, PageRenderAnnotatedQuerySchema as Y, AnnotationStableIdSchema as Yn, StampDTOSchema as Yt, PageRotateInputSchema as Z, CaretIntentSchema as Zn, StampWirePatchSchema as Zt, CachePinsSchema as _, LineDraftSchema as _n, CalloutLineSchema as _r, FormFieldFlagsSchema as _t, AnnotationCreateResultSchema as a, PolylineDraftSchema as an, RectSchema as ar, RefetchReasonSchema as at, DocumentMetadataSchema as b, InkDraftSchema as bn, PdfPointSchema as br, FormFieldPatchSchema as bt, AnnotationListPageSnapshotSchema as c, PolygonDraftSchema as cn, StrikeoutIntentSchema as cr, SearchQuerySchema as ct, AnnotationUpdateResultSchema as d, LinkDraftSchema as dn, PdfActionNodeSchema as dr, SearchSnippetSchema as dt, SquigglyPatchSchema as en, InkIntentSchema as er, PageStructureCacheSchema as et, AppearanceOutcomeSchema as f, LinkPatchSchema as fn, PdfActionTreeSchema as fr, WeakAnnotationSessionPagesRequestSchema as ft, CacheDeltaSchema as g, LineDTOSchema as gn, PdfPageActionsSchema as gr, FormFieldDraftSchema as gt, AttachmentsCacheSchema as h, PdfLinkTargetWritableSchema as hn, PdfFieldActionsSchema as hr, FormFieldDTOSchema as ht, AnnotationAppearancesQuerySchema as i, PolylineDTOSchema as in, PointSchema as ir, RedactionApplyScopeSchema as it, FormWidgetLinkResultSchema as j, FileAttachmentWireDraftSchema as jn, AnnotationDraftSchema as jt, FormRepairResultSchema as k, FileAttachmentIconSchema as kn, ANNOTATION_KINDS as kt, AnnotationListSnapshotAllPagesSchema as l, PolygonPatchSchema as ln, TextAlignmentSchema as lr, SearchRequestSchema as lt, AttachmentDeleteResultSchema as m, PdfLinkTargetSchema as mn, PdfAnnotationActionsSchema as mr, FormDataFormatSchema as mt, AccessResponseSchema as n, SquareDraftSchema as nn, LineEndingsSchema as nr, PdfSaveModeSchema as nt, AnnotationDeleteResultSchema as o, PolylinePatchSchema as on, RevisionTokenSchema as or, SearchMatchSchema as ot, AttachmentCreateResultSchema as p, PdfDestinationSchema as pn, PdfActionTypeSchema as pr, WeakAnnotationSessionResponseSchema as pt, PageMoveResultSchema as q, AnnotationPatchBaseShape as qn, StrikeoutPatchSchema as qt, AnnotationAppearanceManifestSchema as r, SquarePatchSchema as rn, PdfRectDifferencesSchema as rr, RedactionApplyResultSchema as rt, AnnotationListMutationMetaSchema as s, PolygonDTOSchema as sn, StandardFontSchema as sr, SearchModeSchema as st, AccessRequestSchema as t, SquareDTOSchema as tn, LineEndingSchema as tr, PageTextSnapshotSchema as tt, AnnotationMoveResultSchema as u, LinkDTOSchema as un, DocumentActionsSnapshotSchema as ur, SearchSliceSchema as ut, DocumentHeadSchema as v, LinePatchSchema as vn, InkListSchema as vr, FormFieldOptionInputSchema as vt, FormEffectsResultSchema as w, HighlightPatchSchema as wn, PdfSizeSchema as wr, FormSnapshotSchema as wt, DocumentSecurityStateSchema as x, InkPatchSchema as xn, PdfQuadSchema as xr, FormFieldRefSchema as xt, DocumentManifestSchema as y, InkDTOSchema as yn, LinePointsSchema as yr, FormFieldOptionSchema as yt, PageDeleteInputSchema as z, CaretDTOSchema as zn, UnderlineDraftSchema as zt };
|
|
2492
|
+
|
|
2493
|
+
//# sourceMappingURL=schemas-9OpSSeM6.js.map
|