@cloudpdf/contract 3.0.0-next.13 → 3.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/openapi.js CHANGED
@@ -1,22 +1,61 @@
1
1
  // src/openapi.ts
2
- import { EngineErrorPayloadSchema as EngineErrorPayloadSchema2, PdfActionWireComponents } from "@embedpdf/engine-core/wire";
2
+ import {
3
+ AnnotationWireComponents,
4
+ ChangeWireComponents,
5
+ DocumentWireComponents,
6
+ EngineErrorPayloadSchema as EngineErrorPayloadSchema2,
7
+ FormWireComponents,
8
+ PdfActionWireComponents
9
+ } from "@embedpdf/engine-core/wire";
3
10
  import { z as z2 } from "zod";
4
11
  import { ignoreOverride, zodToJsonSchema } from "zod-to-json-schema";
5
12
 
6
13
  // src/index.ts
7
14
  import {
8
- AnnotationListPageSnapshotSchema,
9
- AnnotationListSnapshotAllPagesSchema,
15
+ ChangeRequestSchema,
16
+ ChangeResponseSchema,
17
+ PageScaleInputSchema,
18
+ PageScaleResultSchema,
19
+ PageMeasurementViewportListSchema
20
+ } from "@embedpdf/engine-core/wire";
21
+ import {
22
+ AnnotationCreateResultSchema,
23
+ AnnotationDeleteResultSchema,
24
+ AnnotationFlattenResultSchema,
25
+ AnnotationListSchema,
26
+ AnnotationReorderBodySchema,
27
+ AnnotationReorderResultSchema,
28
+ AnnotationUpdateResultSchema,
10
29
  DocumentHeadSchema,
11
30
  DocumentManifestSchema,
31
+ CustomMetadataSchema,
12
32
  DocumentMetadataSchema,
13
33
  EngineErrorPayloadSchema,
34
+ FormResetBodySchema,
35
+ FormWidgetDeleteResultSchema,
36
+ FormWidgetUpdateBodySchema,
37
+ FormWidgetUpdateResultSchema,
38
+ FormWidgetsReorderBodySchema,
39
+ FormWidgetsReorderResultSchema,
40
+ FormCalculationsReorderBodySchema,
41
+ FormCalculationsReorderResultSchema,
42
+ FormResetResultSchema,
43
+ FormSetValueResultSchema,
14
44
  FormSnapshotSchema,
15
- MutationMetaSchema,
45
+ IdentitySchema,
46
+ PageDeleteResultSchema,
47
+ PageFlattenResultSchema,
48
+ PageInsertResultSchema,
49
+ PageReorderInputSchema,
50
+ PageReorderResultSchema,
51
+ PageNameResultSchema,
52
+ PageRotateResultSchema,
53
+ RedactionApplyResultSchema,
54
+ RedactionApplyScopeSchema,
16
55
  PageTextSnapshotSchema,
17
56
  ChangeAnalysisSchema,
18
57
  DocumentVersionsSchema,
19
- SignatureAbortResultSchema,
58
+ SignatureCancelResultSchema,
20
59
  SignatureCompleteBodySchema,
21
60
  SignatureCompleteResultSchema,
22
61
  SignaturePreparedWireSchema,
@@ -157,7 +196,7 @@ var AdminImportSourceSchema = z.discriminatedUnion("kind", [
157
196
  "The operator pre-registered the authority: the request names a connection and a key inside it. Which provider backs the connection (S3, GCS, Azure Blob, filesystem, ...) is deployment configuration, never wire surface."
158
197
  )
159
198
  ]).describe(
160
- "Where CloudPDF pulls the bytes from. The two shapes differ in WHO supplies the authority to read, not in which storage vendor holds the file."
199
+ "Where CloudPDF pulls the bytes from. The two shapes differ in who supplies the authority to read, not in which storage vendor holds the file."
161
200
  );
162
201
  var AdminDocumentImportRequestSchema = z.object({
163
202
  source: AdminImportSourceSchema,
@@ -166,7 +205,7 @@ var AdminDocumentImportRequestSchema = z.object({
166
205
  * against the source's declared Content-Length before the transfer,
167
206
  * `sha256` against the server-observed digest after it. When absent
168
207
  * the server-observed values become authoritative.
169
- * `dedupMode=reuse-existing` REQUIRES `sha256` — without a declared
208
+ * `dedupMode=reuse-existing` requires `sha256` — without a declared
170
209
  * hash the server cannot know what content to reuse.
171
210
  */
172
211
  expected: z.object({
@@ -257,7 +296,7 @@ var AdminTokenRevokeRequestSchema = z.object({
257
296
  /** Optional human reason, written to the audit row. */
258
297
  reason: z.string().max(1024).optional(),
259
298
  /**
260
- * The token's `exp` (unix seconds), used to GC the revocation row
299
+ * The token's `exp` (unix seconds); the revocation row is garbage-collected
261
300
  * once the token would have expired anyway. Defaults server-side to
262
301
  * now + 30 days.
263
302
  */
@@ -324,10 +363,12 @@ var AdminTokenIssueDocRequestSchema = z.object({
324
363
  * vocabulary — an unknown string rejects the whole request.
325
364
  */
326
365
  scope: z.array(z.string().min(1).max(128)).min(1).max(64),
327
- userId: z.string().max(256).optional(),
328
- displayName: z.string().max(256).optional(),
329
- groupId: z.string().max(256).optional(),
330
- groups: z.array(z.string().max(256)).max(64).optional(),
366
+ /**
367
+ * Who the token acts for: the same `Identity` the local engine takes at
368
+ * open time. `displayName` becomes the author of the annotations the token
369
+ * creates, `userId` and `groupId` their owner and group.
370
+ */
371
+ identity: IdentitySchema.optional(),
331
372
  /**
332
373
  * Origin lock: web origins (scheme + host, optional port; one leading
333
374
  * `*.` wildcard label allowed) the minted token may be presented
@@ -774,7 +815,7 @@ var adminOperations = {
774
815
  403: { contentType: "application/json", schema: AdminErrorPayloadSchema },
775
816
  404: { contentType: "application/json", schema: AdminErrorPayloadSchema }
776
817
  },
777
- notes: "The returned share id IS the public share token. Mounted only when the deployment can sign (HS256 mode) \u2014 exchange mints session JWTs, so grants exist only where minting does."
818
+ notes: "The returned share id is the public share token. Mounted only when the deployment can sign (HS256 mode) \u2014 exchange mints session JWTs, so grants exist only where minting does."
778
819
  },
779
820
  "shares.list": {
780
821
  operationId: "shares.list",
@@ -862,10 +903,14 @@ var DocLayerParamsSchema = DocIdParamsSchema.extend({
862
903
  layerName: z.string().min(1)
863
904
  });
864
905
  var DocPageParamsSchema = DocLayerParamsSchema.extend({
865
- pon: z.coerce.number().int().min(0)
906
+ pageKey: z.string().min(1).regex(/^obj:[1-9][0-9]*$/).describe(
907
+ "The page's address, `obj:N`: the page's indirect object number, the durable identity every `PageLayout.ref` carries. Mirrors `annotKey` and `fieldKey`."
908
+ )
866
909
  });
867
910
  var DocAnnotationParamsSchema = DocPageParamsSchema.extend({
868
- annotKey: z.string().min(1)
911
+ annotKey: z.string().min(1).regex(/^(obj:[1-9][0-9]*|base:(0|[1-9][0-9]*))$/).describe(
912
+ "The annotation's address on the page: `obj:N`, its indirect object number, or `base:N` for an annotation the uploaded file stored inline (without an object number of its own), the position it was born at in the page's /Annots. The name the annotation's `ref` carries for life."
913
+ )
869
914
  });
870
915
  var DocFieldParamsSchema = DocLayerParamsSchema.extend({
871
916
  fieldKey: z.string().min(1)
@@ -875,9 +920,13 @@ var documentPasswordHeader = {
875
920
  required: false,
876
921
  description: "Base64-encoded password for an encrypted document. Valid only with the API token (403 anywhere else). An encrypted document answers 422 DocPasswordRequired when the header is absent. Viewer doc JWTs use the SDK password-session flow instead."
877
922
  };
923
+ var idempotencyKeyHeader = {
924
+ name: "Idempotency-Key",
925
+ required: false,
926
+ description: "Names the change: 1 to 255 printable ASCII characters. A retry under the same key on the same layer answers with what the first request committed, and changes nothing."
927
+ };
878
928
  var looseJson = z.record(z.string(), z.unknown());
879
929
  var docCredentials = ["api-token", "doc-jwt"];
880
- var MutationResponseSchema = z.object({ meta: MutationMetaSchema }).passthrough();
881
930
  var DocSigningParamsSchema = DocLayerParamsSchema.extend({
882
931
  signingId: z.string().min(1)
883
932
  });
@@ -953,6 +1002,22 @@ var docOperations = {
953
1002
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
954
1003
  }
955
1004
  },
1005
+ "doc.metadata.custom.get": {
1006
+ operationId: "doc.metadata.custom.get",
1007
+ title: "Get custom keys",
1008
+ summary: "The Info dictionary's own keys for a layer: every key but the standard fields, as { key: value }.",
1009
+ method: "GET",
1010
+ path: wireTemplates.layerCustomMetadata,
1011
+ credentials: docCredentials,
1012
+ scope: [],
1013
+ docCapabilities: ["doc.open"],
1014
+ requestHeaders: [documentPasswordHeader],
1015
+ params: DocLayerParamsSchema,
1016
+ responses: {
1017
+ 200: { contentType: "application/json", schema: CustomMetadataSchema },
1018
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1019
+ }
1020
+ },
956
1021
  "doc.signatures.list": {
957
1022
  operationId: "doc.signatures.list",
958
1023
  title: "List signatures",
@@ -1007,7 +1072,7 @@ var docOperations = {
1007
1072
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1008
1073
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1009
1074
  },
1010
- notes: "The multipart envelope: a JSON `body` part (field, subFilter, digest, contentsSize, signer, certify, lock, appearance) and an optional `resource:<key>` PDF part the body's `appearance.resource` names. A certification (`certify.permission`) additionally requires `doc.sign.certify`. The layer is read-only until the signing completes, is aborted, or expires (15 minutes). A layer behind the document head cannot sign (StaleBase)."
1075
+ notes: "Multipart: a JSON `body` part (field, subFilter, digest, contentsSize, signer, certify, lock), naming the appearance PDF it may carry as `resources: { appearance: '<key>' }`, and that PDF as the part `resource:<key>`. A certification (`certify.permission`) additionally requires `doc.sign.certify`. The layer is read-only until the signing completes, is cancelled, or expires (15 minutes). A layer behind the document head cannot sign (StaleBase)."
1011
1076
  },
1012
1077
  "doc.signatures.complete": {
1013
1078
  operationId: "doc.signatures.complete",
@@ -1029,19 +1094,19 @@ var docOperations = {
1029
1094
  },
1030
1095
  notes: "`cms` is the detached CMS over the prepared digest, base64. `expectedVersion` must be what prepare returned. Idempotent by signing id: the same CMS again answers `already-completed`. Every layer of the document then sits over the new version; refetch the manifest after a completion."
1031
1096
  },
1032
- "doc.signatures.abort": {
1033
- operationId: "doc.signatures.abort",
1034
- title: "Abort a signature",
1097
+ "doc.signatures.cancel": {
1098
+ operationId: "doc.signatures.cancel",
1099
+ title: "Cancel a signature",
1035
1100
  summary: "Discard a pending signing candidate.",
1036
1101
  method: "DELETE",
1037
- path: wireTemplates.layerSignatureAbort,
1102
+ path: wireTemplates.layerSignatureCancel,
1038
1103
  credentials: docCredentials,
1039
1104
  scope: [],
1040
1105
  docCapabilities: ["doc.sign"],
1041
1106
  requestHeaders: [documentPasswordHeader],
1042
1107
  params: DocSigningParamsSchema,
1043
1108
  responses: {
1044
- 200: { contentType: "application/json", schema: SignatureAbortResultSchema },
1109
+ 200: { contentType: "application/json", schema: SignatureCancelResultSchema },
1045
1110
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1046
1111
  }
1047
1112
  },
@@ -1208,7 +1273,7 @@ var docOperations = {
1208
1273
  requestHeaders: [documentPasswordHeader],
1209
1274
  params: DocPageParamsSchema,
1210
1275
  responses: {
1211
- 200: { contentType: "application/json", schema: AnnotationListPageSnapshotSchema },
1276
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1212
1277
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1213
1278
  }
1214
1279
  },
@@ -1223,13 +1288,42 @@ var docOperations = {
1223
1288
  docCapabilities: ["doc.annotate.read"],
1224
1289
  requestHeaders: [documentPasswordHeader],
1225
1290
  params: DocLayerParamsSchema,
1226
- notes: "Returns one entry per page plus the audit-log cursor for reconciling subsequent document events. Page order is unspecified; join by `pageState.pageObjectNumber` when display order matters.",
1291
+ notes: "Returns one entry per page plus the audit-log cursor for reconciling subsequent document events. Page order is unspecified; join by `page` (a `PageRef`) when display order matters.",
1227
1292
  responses: {
1228
- 200: { contentType: "application/json", schema: AnnotationListSnapshotAllPagesSchema },
1293
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1229
1294
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1230
1295
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1231
1296
  }
1232
1297
  },
1298
+ "doc.changes": {
1299
+ operationId: "doc.changes",
1300
+ title: "Apply changes",
1301
+ summary: "Apply user actions to a layer, each a change whose ops apply in order, all or none, or the undo of an earlier change.",
1302
+ method: "POST",
1303
+ path: wireTemplates.layerChanges,
1304
+ credentials: docCredentials,
1305
+ scope: [],
1306
+ docCapabilities: [
1307
+ "doc.annotate.modify",
1308
+ "doc.forms.fill",
1309
+ "doc.forms.modify",
1310
+ "doc.metadata.modify"
1311
+ ],
1312
+ requestHeaders: [documentPasswordHeader],
1313
+ params: DocLayerParamsSchema,
1314
+ body: {
1315
+ contentType: ["application/json", "multipart/form-data"],
1316
+ schema: ChangeRequestSchema
1317
+ },
1318
+ notes: "Each change stands on its own and names itself by `opId`: a refused change rolls back alone, and the answer lists every change in order, applied with its result or refused with its error. Asked again under its `opId`, a change gets the same answer, refusals included; a different change under an answered `opId` is refused (IdempotencyKeyReused). `{ opId, undoOf }` undoes an earlier change of the caller, here or in an earlier request; an undo leaves alone what was changed since, and the undo of an undo redoes. A redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (UndoUnavailable). Each op is checked against its own capability: annotation ops need `doc.annotate.modify`, form values `doc.forms.fill`, form structure `doc.forms.modify`, metadata `doc.metadata.modify`. Bytes (a stamp's drawing, an attached file, a signature's artwork) travel as multipart: a JSON `body` part, each op naming its files by role as `resources: { <role>: '<key>' }`, and each file as the part `resource:<key>`. At most 64 changes per request and 512 ops per change.",
1319
+ responses: {
1320
+ 200: { contentType: "application/json", schema: ChangeResponseSchema },
1321
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1322
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1323
+ 409: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1324
+ 413: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1325
+ }
1326
+ },
1233
1327
  "doc.annotations.create": {
1234
1328
  operationId: "doc.annotations.create",
1235
1329
  title: "Create annotation",
@@ -1239,12 +1333,12 @@ var docOperations = {
1239
1333
  credentials: docCredentials,
1240
1334
  scope: [],
1241
1335
  docCapabilities: ["doc.annotate.modify"],
1242
- requestHeaders: [documentPasswordHeader],
1336
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1243
1337
  params: DocPageParamsSchema,
1244
1338
  body: { contentType: "application/json", schema: looseJson },
1245
1339
  notes: "Doc JWTs may instead carry collab scopes (annotations:create:self, \u2026) that refine per-annotation authorship rules; the API token is exempt from both.",
1246
1340
  responses: {
1247
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1341
+ 200: { contentType: "application/json", schema: AnnotationCreateResultSchema },
1248
1342
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1249
1343
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1250
1344
  }
@@ -1258,11 +1352,11 @@ var docOperations = {
1258
1352
  credentials: docCredentials,
1259
1353
  scope: [],
1260
1354
  docCapabilities: ["doc.annotate.modify"],
1261
- requestHeaders: [documentPasswordHeader],
1355
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1262
1356
  params: DocAnnotationParamsSchema,
1263
1357
  body: { contentType: "application/json", schema: looseJson },
1264
1358
  responses: {
1265
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1359
+ 200: { contentType: "application/json", schema: AnnotationUpdateResultSchema },
1266
1360
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1267
1361
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1268
1362
  }
@@ -1276,27 +1370,45 @@ var docOperations = {
1276
1370
  credentials: docCredentials,
1277
1371
  scope: [],
1278
1372
  docCapabilities: ["doc.annotate.modify"],
1279
- requestHeaders: [documentPasswordHeader],
1373
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1280
1374
  params: DocAnnotationParamsSchema,
1281
1375
  responses: {
1282
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1376
+ 200: { contentType: "application/json", schema: AnnotationDeleteResultSchema },
1377
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1378
+ }
1379
+ },
1380
+ "doc.annotations.reorder": {
1381
+ operationId: "doc.annotations.reorder",
1382
+ title: "Reorder annotations",
1383
+ summary: "Change the stacking order of one page's annotations: they go together, in the order given, next to a neighbour annotation (`{ before }`, `{ after }`) or to the bottom (`'start'`) or top (`'end'`). Widgets paint above every annotation and have their own order (`doc.forms.reorderWidgets`): a widget is refused. Returns the page's new order.",
1384
+ method: "POST",
1385
+ path: wireTemplates.layerAnnotationItemsReorder,
1386
+ credentials: docCredentials,
1387
+ scope: [],
1388
+ docCapabilities: ["doc.annotate.modify"],
1389
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1390
+ params: DocPageParamsSchema,
1391
+ body: { contentType: "application/json", schema: AnnotationReorderBodySchema },
1392
+ responses: {
1393
+ 200: { contentType: "application/json", schema: AnnotationReorderResultSchema },
1394
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1283
1395
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1284
1396
  }
1285
1397
  },
1286
1398
  "doc.annotations.flatten": {
1287
1399
  operationId: "doc.annotations.flatten",
1288
1400
  title: "Flatten annotations",
1289
- summary: "Flatten a chosen set of one page's annotations into its content \u2014 pages.flatten for a selection. Painted annotations are removed; ineligible ones report skipped.",
1401
+ summary: "Flatten a chosen set of one page's annotations into its content \u2014 pages.flatten for a selection. Painted annotations are removed; ineligible ones report unchanged.",
1290
1402
  method: "POST",
1291
1403
  path: wireTemplates.layerAnnotationItemsFlatten,
1292
1404
  credentials: docCredentials,
1293
1405
  scope: [],
1294
1406
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1295
- requestHeaders: [documentPasswordHeader],
1407
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1296
1408
  params: DocPageParamsSchema,
1297
1409
  body: { contentType: "application/json", schema: looseJson },
1298
1410
  responses: {
1299
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1411
+ 200: { contentType: "application/json", schema: AnnotationFlattenResultSchema },
1300
1412
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1301
1413
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1302
1414
  }
@@ -1319,10 +1431,27 @@ var docOperations = {
1319
1431
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1320
1432
  }
1321
1433
  },
1322
- "doc.forms.get": {
1323
- operationId: "doc.forms.get",
1324
- title: "Get form snapshot",
1325
- summary: "Reconciled form snapshot: fields, widgets, values.",
1434
+ "doc.annotations.readAppearance": {
1435
+ operationId: "doc.annotations.readAppearance",
1436
+ title: "Read an annotation appearance",
1437
+ summary: "A stamp's drawing as a one-page PDF, before the fit, rotation and opacity its data describes: with the data, the bytes to create the same stamp again. A read; the source is untouched.",
1438
+ method: "GET",
1439
+ path: wireTemplates.layerAnnotationItemAppearanceResource,
1440
+ credentials: docCredentials,
1441
+ scope: [],
1442
+ docCapabilities: ["doc.download"],
1443
+ requestHeaders: [documentPasswordHeader],
1444
+ params: DocAnnotationParamsSchema,
1445
+ responses: {
1446
+ 200: { contentType: "application/pdf" },
1447
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1448
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1449
+ }
1450
+ },
1451
+ "doc.forms.list": {
1452
+ operationId: "doc.forms.list",
1453
+ title: "List form fields",
1454
+ summary: "The form: every field with its value, every widget's row (its place, look and state), and the calculation order. A form field's widgets come with the form, never with the annotations.",
1326
1455
  method: "GET",
1327
1456
  path: wireTemplates.layerForm,
1328
1457
  credentials: docCredentials,
@@ -1344,80 +1473,152 @@ var docOperations = {
1344
1473
  credentials: docCredentials,
1345
1474
  scope: [],
1346
1475
  docCapabilities: ["doc.forms.fill"],
1347
- requestHeaders: [documentPasswordHeader],
1476
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1348
1477
  params: DocFieldParamsSchema,
1349
1478
  body: { contentType: "application/json", schema: looseJson },
1350
1479
  responses: {
1351
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1480
+ 200: { contentType: "application/json", schema: FormSetValueResultSchema },
1481
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1482
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1483
+ }
1484
+ },
1485
+ "doc.forms.updateWidget": {
1486
+ operationId: "doc.forms.updateWidget",
1487
+ title: "Update form widget",
1488
+ summary: "Change a widget's place and look: what an annotation update takes, for a form field's widget. A widget is the form's, so the annotation routes refuse one.",
1489
+ method: "PATCH",
1490
+ path: wireTemplates.layerFormWidget,
1491
+ credentials: docCredentials,
1492
+ scope: [],
1493
+ docCapabilities: ["doc.forms.modify"],
1494
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1495
+ params: DocAnnotationParamsSchema,
1496
+ body: { contentType: "application/json", schema: FormWidgetUpdateBodySchema },
1497
+ responses: {
1498
+ 200: { contentType: "application/json", schema: FormWidgetUpdateResultSchema },
1499
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1500
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1501
+ }
1502
+ },
1503
+ "doc.forms.deleteWidget": {
1504
+ operationId: "doc.forms.deleteWidget",
1505
+ title: "Delete form widget",
1506
+ summary: "Delete a widget: it leaves its page, and its field when it has one. The field survives, unplaced when this was its last widget. A widget that is its field's own dictionary is refused: delete the field. A widget is the form's, so the annotation routes refuse one.",
1507
+ method: "DELETE",
1508
+ path: wireTemplates.layerFormWidget,
1509
+ credentials: docCredentials,
1510
+ scope: [],
1511
+ docCapabilities: ["doc.forms.modify"],
1512
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1513
+ params: DocAnnotationParamsSchema,
1514
+ responses: {
1515
+ 200: { contentType: "application/json", schema: FormWidgetDeleteResultSchema },
1516
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1517
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1518
+ }
1519
+ },
1520
+ "doc.forms.reorderWidgets": {
1521
+ operationId: "doc.forms.reorderWidgets",
1522
+ title: "Reorder form widgets",
1523
+ summary: "Change the stacking order of one page's widgets: they go together, in the order given, next to a neighbour widget or to the bottom (`'start'`) or top (`'end'`) of the page's widgets, which paint above every annotation. Where the page's `/Tabs` follows it, this is also the tab order. Returns the page's new widget order.",
1524
+ method: "POST",
1525
+ path: wireTemplates.layerFormWidgetsReorder,
1526
+ credentials: docCredentials,
1527
+ scope: [],
1528
+ docCapabilities: ["doc.forms.modify"],
1529
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1530
+ params: DocPageParamsSchema,
1531
+ body: { contentType: "application/json", schema: FormWidgetsReorderBodySchema },
1532
+ responses: {
1533
+ 200: { contentType: "application/json", schema: FormWidgetsReorderResultSchema },
1534
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1535
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1536
+ }
1537
+ },
1538
+ "doc.forms.reorderCalculations": {
1539
+ operationId: "doc.forms.reorderCalculations",
1540
+ title: "Reorder form calculations",
1541
+ summary: "Change the form's calculation order, the order its fields' calculate scripts run in: the fields go together, in the order given, next to a neighbour field or to the start (`'start'`) or end (`'end'`). Every field named must have a calculate script, which puts it in the order. Returns the whole new order.",
1542
+ method: "POST",
1543
+ path: wireTemplates.layerFormCalculationsReorder,
1544
+ credentials: docCredentials,
1545
+ scope: [],
1546
+ docCapabilities: ["doc.forms.modify"],
1547
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1548
+ params: DocLayerParamsSchema,
1549
+ body: { contentType: "application/json", schema: FormCalculationsReorderBodySchema },
1550
+ responses: {
1551
+ 200: { contentType: "application/json", schema: FormCalculationsReorderResultSchema },
1352
1552
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1353
1553
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1354
1554
  }
1355
1555
  },
1356
1556
  "doc.forms.reset": {
1357
1557
  operationId: "doc.forms.reset",
1358
- title: "Reset form field",
1359
- summary: "Reset one form field to its default value.",
1558
+ title: "Reset form",
1559
+ summary: "Reset the fields named in `refs` to their default values, or the whole form without it. Returns the fields that changed.",
1360
1560
  method: "POST",
1361
- path: wireTemplates.layerFormFieldReset,
1561
+ path: wireTemplates.layerFormReset,
1362
1562
  credentials: docCredentials,
1363
1563
  scope: [],
1364
1564
  docCapabilities: ["doc.forms.fill"],
1365
- requestHeaders: [documentPasswordHeader],
1366
- params: DocFieldParamsSchema,
1565
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1566
+ params: DocLayerParamsSchema,
1567
+ body: { contentType: "application/json", schema: FormResetBodySchema },
1367
1568
  responses: {
1368
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1569
+ 200: { contentType: "application/json", schema: FormResetResultSchema },
1570
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1369
1571
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1370
1572
  }
1371
1573
  },
1372
- "doc.forms.exportData": {
1373
- operationId: "doc.forms.exportData",
1374
- title: "Export form data",
1375
- summary: "Export form data as FDF or XFDF.",
1574
+ "doc.pages.viewports": {
1575
+ operationId: "doc.pages.viewports",
1576
+ title: "Read measurement viewports",
1577
+ summary: "Read page measurement viewports in drawing order from the current layer.",
1376
1578
  method: "GET",
1377
- path: wireTemplates.layerFormData,
1579
+ path: wireTemplates.layerPageViewports,
1378
1580
  credentials: docCredentials,
1379
1581
  scope: [],
1380
- docCapabilities: ["doc.forms.read"],
1582
+ docCapabilities: ["doc.open"],
1381
1583
  requestHeaders: [documentPasswordHeader],
1382
- params: DocLayerParamsSchema,
1383
- query: z.object({ format: z.enum(["fdf", "xfdf"]).optional() }),
1584
+ params: DocPageParamsSchema,
1384
1585
  responses: {
1385
- 200: { contentType: ["application/vnd.adobe.xfdf", "application/vnd.fdf"] },
1586
+ 200: { contentType: "application/json", schema: PageMeasurementViewportListSchema },
1386
1587
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1387
1588
  }
1388
1589
  },
1389
- "doc.forms.importData": {
1390
- operationId: "doc.forms.importData",
1391
- title: "Import form data",
1392
- summary: "Import form data (FDF/XFDF), filling matching fields.",
1393
- method: "POST",
1394
- path: wireTemplates.layerFormData,
1590
+ "doc.pages.setScale": {
1591
+ operationId: "doc.pages.setScale",
1592
+ title: "Set page measurement scale",
1593
+ summary: "Upsert or remove EmbedPDF calibration while preserving foreign viewports. Existing annotation scales are unchanged.",
1594
+ method: "PUT",
1595
+ path: wireTemplates.layerPageScale,
1395
1596
  credentials: docCredentials,
1396
1597
  scope: [],
1397
- docCapabilities: ["doc.forms.fill"],
1398
- requestHeaders: [documentPasswordHeader],
1399
- params: DocLayerParamsSchema,
1400
- body: { contentType: "application/json", schema: looseJson },
1598
+ docCapabilities: ["doc.annotate.modify"],
1599
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1600
+ params: DocPageParamsSchema,
1601
+ body: { contentType: "application/json", schema: PageScaleInputSchema },
1401
1602
  responses: {
1402
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1603
+ 200: { contentType: "application/json", schema: PageScaleResultSchema },
1403
1604
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1404
1605
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1405
1606
  }
1406
1607
  },
1407
- "doc.pages.move": {
1408
- operationId: "doc.pages.move",
1409
- title: "Move pages",
1410
- summary: "Reorder pages.",
1608
+ "doc.pages.reorder": {
1609
+ operationId: "doc.pages.reorder",
1610
+ title: "Reorder pages",
1611
+ summary: "Move pages together, in the order given, next to a neighbour page (`{ before }`, `{ after }`) or to the start or end. Returns the new layout.",
1411
1612
  method: "POST",
1412
- path: wireTemplates.layerPagesMove,
1613
+ path: wireTemplates.layerPagesReorder,
1413
1614
  credentials: docCredentials,
1414
1615
  scope: [],
1415
1616
  docCapabilities: ["doc.pages.assemble"],
1416
- requestHeaders: [documentPasswordHeader],
1617
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1417
1618
  params: DocLayerParamsSchema,
1418
- body: { contentType: "application/json", schema: looseJson },
1619
+ body: { contentType: "application/json", schema: PageReorderInputSchema },
1419
1620
  responses: {
1420
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1621
+ 200: { contentType: "application/json", schema: PageReorderResultSchema },
1421
1622
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1422
1623
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1423
1624
  }
@@ -1431,11 +1632,11 @@ var docOperations = {
1431
1632
  credentials: docCredentials,
1432
1633
  scope: [],
1433
1634
  docCapabilities: ["doc.pages.assemble"],
1434
- requestHeaders: [documentPasswordHeader],
1635
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1435
1636
  params: DocLayerParamsSchema,
1436
1637
  body: { contentType: "application/json", schema: looseJson },
1437
1638
  responses: {
1438
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1639
+ 200: { contentType: "application/json", schema: PageRotateResultSchema },
1439
1640
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1440
1641
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1441
1642
  }
@@ -1449,11 +1650,11 @@ var docOperations = {
1449
1650
  credentials: docCredentials,
1450
1651
  scope: [],
1451
1652
  docCapabilities: ["doc.pages.assemble"],
1452
- requestHeaders: [documentPasswordHeader],
1653
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1453
1654
  params: DocLayerParamsSchema,
1454
1655
  body: { contentType: "application/json", schema: looseJson },
1455
1656
  responses: {
1456
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1657
+ 200: { contentType: "application/json", schema: PageDeleteResultSchema },
1457
1658
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1458
1659
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1459
1660
  }
@@ -1467,11 +1668,11 @@ var docOperations = {
1467
1668
  credentials: docCredentials,
1468
1669
  scope: [],
1469
1670
  docCapabilities: ["doc.pages.assemble"],
1470
- requestHeaders: [documentPasswordHeader],
1671
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1471
1672
  params: DocLayerParamsSchema,
1472
1673
  body: { contentType: "application/json", schema: looseJson },
1473
1674
  responses: {
1474
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1675
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1475
1676
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1476
1677
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1477
1678
  }
@@ -1485,11 +1686,11 @@ var docOperations = {
1485
1686
  credentials: docCredentials,
1486
1687
  scope: [],
1487
1688
  docCapabilities: ["doc.pages.assemble"],
1488
- requestHeaders: [documentPasswordHeader],
1689
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1489
1690
  params: DocLayerParamsSchema,
1490
1691
  body: { contentType: "application/json", schema: looseJson },
1491
1692
  responses: {
1492
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1693
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1493
1694
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1494
1695
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1495
1696
  }
@@ -1503,11 +1704,11 @@ var docOperations = {
1503
1704
  credentials: docCredentials,
1504
1705
  scope: [],
1505
1706
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1506
- requestHeaders: [documentPasswordHeader],
1707
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1507
1708
  params: DocLayerParamsSchema,
1508
1709
  body: { contentType: "application/json", schema: looseJson, required: false },
1509
1710
  responses: {
1510
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1711
+ 200: { contentType: "application/json", schema: PageFlattenResultSchema },
1511
1712
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1512
1713
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1513
1714
  }
@@ -1521,36 +1722,36 @@ var docOperations = {
1521
1722
  credentials: docCredentials,
1522
1723
  scope: [],
1523
1724
  docCapabilities: ["doc.pages.assemble"],
1524
- requestHeaders: [documentPasswordHeader],
1725
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1525
1726
  params: DocLayerParamsSchema,
1526
1727
  body: {
1527
1728
  contentType: "multipart/form-data"
1528
1729
  },
1529
1730
  responses: {
1530
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1731
+ 200: { contentType: "application/json", schema: PageInsertResultSchema },
1531
1732
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1532
1733
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1533
1734
  },
1534
- notes: 'Multipart mutation envelope: a `body` field holding `{"destIndex"?: number}` (omitted \u2192 append) plus a `resource:source` file part carrying the standalone PDF whose pages are copied in. The inserted copies get fresh page object numbers, returned in insertion order.'
1735
+ notes: 'Multipart: a JSON `body` part `{"position"?: PagePosition, "resources": {"source": "<key>"}}` (position omitted \u2192 the end), and the standalone PDF whose pages are copied in as the part `resource:<key>`. The inserted copies get fresh page object numbers, returned in insertion order.'
1535
1736
  },
1536
1737
  "doc.pages.insertBlank": {
1537
1738
  operationId: "doc.pages.insertBlank",
1538
1739
  title: "Insert blank pages",
1539
- summary: "Create blank pages of an explicit size at an index.",
1740
+ summary: "Create blank pages of an explicit size at a position.",
1540
1741
  method: "POST",
1541
1742
  path: wireTemplates.layerPagesInsertBlank,
1542
1743
  credentials: docCredentials,
1543
1744
  scope: [],
1544
1745
  docCapabilities: ["doc.pages.assemble"],
1545
- requestHeaders: [documentPasswordHeader],
1746
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1546
1747
  params: DocLayerParamsSchema,
1547
1748
  body: { contentType: "application/json", schema: looseJson },
1548
1749
  responses: {
1549
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1750
+ 200: { contentType: "application/json", schema: PageInsertResultSchema },
1550
1751
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1551
1752
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1552
1753
  },
1553
- notes: 'Body is `{"size": {"width", "height"}, "count"?, "destIndex"?}` \u2014 size in PDF points, count in [1, 100], destIndex omitted \u2192 append.'
1754
+ notes: 'Body is `{"size": {"width", "height"}, "count"?, "position"?}` \u2014 size in PDF points, count in [1, 100], `position` a `PagePosition` (omitted \u2192 the end).'
1554
1755
  },
1555
1756
  "doc.pages.extract": {
1556
1757
  operationId: "doc.pages.extract",
@@ -1569,7 +1770,7 @@ var docOperations = {
1569
1770
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1570
1771
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1571
1772
  },
1572
- notes: 'A read, not a mutation: the source document is untouched and no event is published. Body is `{"pageObjectNumbers": number[]}`; the response body is the new PDF.'
1773
+ notes: 'A read, not a mutation: the source document is untouched and no event is published. Body is `{"pages": PageRef[]}`; the response body is the new PDF.'
1573
1774
  },
1574
1775
  "doc.redactions.apply": {
1575
1776
  operationId: "doc.redactions.apply",
@@ -1580,11 +1781,11 @@ var docOperations = {
1580
1781
  credentials: docCredentials,
1581
1782
  scope: [],
1582
1783
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify", "doc.redact"],
1583
- requestHeaders: [documentPasswordHeader],
1784
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1584
1785
  params: DocLayerParamsSchema,
1585
- body: { contentType: "application/json", schema: looseJson, required: false },
1786
+ body: { contentType: "application/json", schema: RedactionApplyScopeSchema },
1586
1787
  responses: {
1587
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1788
+ 200: { contentType: "application/json", schema: RedactionApplyResultSchema },
1588
1789
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1589
1790
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1590
1791
  }
@@ -1617,6 +1818,7 @@ var docsGroups = {
1617
1818
  "doc.annotations": { title: "Annotations" },
1618
1819
  "doc.forms": { title: "Forms" },
1619
1820
  "doc.metadata": { title: "Metadata" },
1821
+ "doc.metadata.custom": { title: "Custom keys" },
1620
1822
  "doc.pages": { title: "Pages" },
1621
1823
  "doc.redactions": { title: "Redactions" },
1622
1824
  "doc.signatures": { title: "Digital signatures" },
@@ -1642,18 +1844,33 @@ var SECURITY_SCHEME = {
1642
1844
  };
1643
1845
  var ADMIN_ERROR_REF = "#/components/schemas/AdminErrorPayload";
1644
1846
  var ENGINE_ERROR_REF = "#/components/schemas/EngineErrorPayload";
1645
- var SHARED_COMPONENT_SCHEMAS = PdfActionWireComponents;
1847
+ var SHARED_COMPONENT_SCHEMAS = sharedComponents([
1848
+ { AdminErrorPayload: AdminErrorPayloadSchema, EngineErrorPayload: EngineErrorPayloadSchema2 },
1849
+ DocumentWireComponents,
1850
+ PdfActionWireComponents,
1851
+ AnnotationWireComponents,
1852
+ FormWireComponents,
1853
+ ChangeWireComponents
1854
+ ]);
1646
1855
  var SHARED_COMPONENT_BY_DEFINITION = new Map(
1647
1856
  Object.entries(SHARED_COMPONENT_SCHEMAS).map(([name, schema]) => [schema._def, name])
1648
1857
  );
1649
1858
  var SHARED_COMPONENT_REFS = new Set(
1650
1859
  Object.keys(SHARED_COMPONENT_SCHEMAS).map((name) => `#/components/schemas/${name}`)
1651
1860
  );
1861
+ function sharedComponents(registries) {
1862
+ const components = {};
1863
+ for (const registry of registries) {
1864
+ for (const [name, schema] of Object.entries(registry)) {
1865
+ if (components[name]) throw new Error(`Duplicate shared component name: ${name}`);
1866
+ components[name] = schema;
1867
+ }
1868
+ }
1869
+ return components;
1870
+ }
1652
1871
  function buildAdminOpenApiDocument(opts) {
1653
1872
  const paths = {};
1654
1873
  const schemas = {};
1655
- registerSchema(schemas, "AdminErrorPayload", AdminErrorPayloadSchema);
1656
- registerSchema(schemas, "EngineErrorPayload", EngineErrorPayloadSchema2);
1657
1874
  for (const [name, schema] of Object.entries(SHARED_COMPONENT_SCHEMAS)) {
1658
1875
  registerSchema(schemas, name, schema);
1659
1876
  }