@cloudpdf/contract 3.0.0-next.14 → 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,27 +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 {
15
+ ChangeRequestSchema,
16
+ ChangeResponseSchema,
8
17
  PageScaleInputSchema,
9
18
  PageScaleResultSchema,
10
- PageMeasurementViewportSchema
19
+ PageMeasurementViewportListSchema
11
20
  } from "@embedpdf/engine-core/wire";
12
21
  import {
13
- AnnotationListPageSnapshotSchema,
14
- AnnotationListSnapshotAllPagesSchema,
22
+ AnnotationCreateResultSchema,
23
+ AnnotationDeleteResultSchema,
24
+ AnnotationFlattenResultSchema,
25
+ AnnotationListSchema,
26
+ AnnotationReorderBodySchema,
27
+ AnnotationReorderResultSchema,
28
+ AnnotationUpdateResultSchema,
15
29
  DocumentHeadSchema,
16
30
  DocumentManifestSchema,
31
+ CustomMetadataSchema,
17
32
  DocumentMetadataSchema,
18
33
  EngineErrorPayloadSchema,
34
+ FormResetBodySchema,
35
+ FormWidgetDeleteResultSchema,
36
+ FormWidgetUpdateBodySchema,
37
+ FormWidgetUpdateResultSchema,
38
+ FormWidgetsReorderBodySchema,
39
+ FormWidgetsReorderResultSchema,
40
+ FormCalculationsReorderBodySchema,
41
+ FormCalculationsReorderResultSchema,
42
+ FormResetResultSchema,
43
+ FormSetValueResultSchema,
19
44
  FormSnapshotSchema,
20
- MutationMetaSchema,
45
+ IdentitySchema,
46
+ PageDeleteResultSchema,
47
+ PageFlattenResultSchema,
48
+ PageInsertResultSchema,
49
+ PageReorderInputSchema,
50
+ PageReorderResultSchema,
51
+ PageNameResultSchema,
52
+ PageRotateResultSchema,
53
+ RedactionApplyResultSchema,
54
+ RedactionApplyScopeSchema,
21
55
  PageTextSnapshotSchema,
22
56
  ChangeAnalysisSchema,
23
57
  DocumentVersionsSchema,
24
- SignatureAbortResultSchema,
58
+ SignatureCancelResultSchema,
25
59
  SignatureCompleteBodySchema,
26
60
  SignatureCompleteResultSchema,
27
61
  SignaturePreparedWireSchema,
@@ -162,7 +196,7 @@ var AdminImportSourceSchema = z.discriminatedUnion("kind", [
162
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."
163
197
  )
164
198
  ]).describe(
165
- "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."
166
200
  );
167
201
  var AdminDocumentImportRequestSchema = z.object({
168
202
  source: AdminImportSourceSchema,
@@ -171,7 +205,7 @@ var AdminDocumentImportRequestSchema = z.object({
171
205
  * against the source's declared Content-Length before the transfer,
172
206
  * `sha256` against the server-observed digest after it. When absent
173
207
  * the server-observed values become authoritative.
174
- * `dedupMode=reuse-existing` REQUIRES `sha256` — without a declared
208
+ * `dedupMode=reuse-existing` requires `sha256` — without a declared
175
209
  * hash the server cannot know what content to reuse.
176
210
  */
177
211
  expected: z.object({
@@ -262,7 +296,7 @@ var AdminTokenRevokeRequestSchema = z.object({
262
296
  /** Optional human reason, written to the audit row. */
263
297
  reason: z.string().max(1024).optional(),
264
298
  /**
265
- * 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
266
300
  * once the token would have expired anyway. Defaults server-side to
267
301
  * now + 30 days.
268
302
  */
@@ -329,10 +363,12 @@ var AdminTokenIssueDocRequestSchema = z.object({
329
363
  * vocabulary — an unknown string rejects the whole request.
330
364
  */
331
365
  scope: z.array(z.string().min(1).max(128)).min(1).max(64),
332
- userId: z.string().max(256).optional(),
333
- displayName: z.string().max(256).optional(),
334
- groupId: z.string().max(256).optional(),
335
- 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(),
336
372
  /**
337
373
  * Origin lock: web origins (scheme + host, optional port; one leading
338
374
  * `*.` wildcard label allowed) the minted token may be presented
@@ -779,7 +815,7 @@ var adminOperations = {
779
815
  403: { contentType: "application/json", schema: AdminErrorPayloadSchema },
780
816
  404: { contentType: "application/json", schema: AdminErrorPayloadSchema }
781
817
  },
782
- 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."
783
819
  },
784
820
  "shares.list": {
785
821
  operationId: "shares.list",
@@ -867,10 +903,14 @@ var DocLayerParamsSchema = DocIdParamsSchema.extend({
867
903
  layerName: z.string().min(1)
868
904
  });
869
905
  var DocPageParamsSchema = DocLayerParamsSchema.extend({
870
- 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
+ )
871
909
  });
872
910
  var DocAnnotationParamsSchema = DocPageParamsSchema.extend({
873
- 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
+ )
874
914
  });
875
915
  var DocFieldParamsSchema = DocLayerParamsSchema.extend({
876
916
  fieldKey: z.string().min(1)
@@ -880,9 +920,13 @@ var documentPasswordHeader = {
880
920
  required: false,
881
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."
882
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
+ };
883
928
  var looseJson = z.record(z.string(), z.unknown());
884
929
  var docCredentials = ["api-token", "doc-jwt"];
885
- var MutationResponseSchema = z.object({ meta: MutationMetaSchema }).passthrough();
886
930
  var DocSigningParamsSchema = DocLayerParamsSchema.extend({
887
931
  signingId: z.string().min(1)
888
932
  });
@@ -958,6 +1002,22 @@ var docOperations = {
958
1002
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
959
1003
  }
960
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
+ },
961
1021
  "doc.signatures.list": {
962
1022
  operationId: "doc.signatures.list",
963
1023
  title: "List signatures",
@@ -1012,7 +1072,7 @@ var docOperations = {
1012
1072
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1013
1073
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1014
1074
  },
1015
- 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)."
1016
1076
  },
1017
1077
  "doc.signatures.complete": {
1018
1078
  operationId: "doc.signatures.complete",
@@ -1034,19 +1094,19 @@ var docOperations = {
1034
1094
  },
1035
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."
1036
1096
  },
1037
- "doc.signatures.abort": {
1038
- operationId: "doc.signatures.abort",
1039
- title: "Abort a signature",
1097
+ "doc.signatures.cancel": {
1098
+ operationId: "doc.signatures.cancel",
1099
+ title: "Cancel a signature",
1040
1100
  summary: "Discard a pending signing candidate.",
1041
1101
  method: "DELETE",
1042
- path: wireTemplates.layerSignatureAbort,
1102
+ path: wireTemplates.layerSignatureCancel,
1043
1103
  credentials: docCredentials,
1044
1104
  scope: [],
1045
1105
  docCapabilities: ["doc.sign"],
1046
1106
  requestHeaders: [documentPasswordHeader],
1047
1107
  params: DocSigningParamsSchema,
1048
1108
  responses: {
1049
- 200: { contentType: "application/json", schema: SignatureAbortResultSchema },
1109
+ 200: { contentType: "application/json", schema: SignatureCancelResultSchema },
1050
1110
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1051
1111
  }
1052
1112
  },
@@ -1213,7 +1273,7 @@ var docOperations = {
1213
1273
  requestHeaders: [documentPasswordHeader],
1214
1274
  params: DocPageParamsSchema,
1215
1275
  responses: {
1216
- 200: { contentType: "application/json", schema: AnnotationListPageSnapshotSchema },
1276
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1217
1277
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1218
1278
  }
1219
1279
  },
@@ -1228,13 +1288,42 @@ var docOperations = {
1228
1288
  docCapabilities: ["doc.annotate.read"],
1229
1289
  requestHeaders: [documentPasswordHeader],
1230
1290
  params: DocLayerParamsSchema,
1231
- 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.",
1232
1292
  responses: {
1233
- 200: { contentType: "application/json", schema: AnnotationListSnapshotAllPagesSchema },
1293
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1234
1294
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1235
1295
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1236
1296
  }
1237
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
+ },
1238
1327
  "doc.annotations.create": {
1239
1328
  operationId: "doc.annotations.create",
1240
1329
  title: "Create annotation",
@@ -1244,12 +1333,12 @@ var docOperations = {
1244
1333
  credentials: docCredentials,
1245
1334
  scope: [],
1246
1335
  docCapabilities: ["doc.annotate.modify"],
1247
- requestHeaders: [documentPasswordHeader],
1336
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1248
1337
  params: DocPageParamsSchema,
1249
1338
  body: { contentType: "application/json", schema: looseJson },
1250
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.",
1251
1340
  responses: {
1252
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1341
+ 200: { contentType: "application/json", schema: AnnotationCreateResultSchema },
1253
1342
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1254
1343
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1255
1344
  }
@@ -1263,11 +1352,11 @@ var docOperations = {
1263
1352
  credentials: docCredentials,
1264
1353
  scope: [],
1265
1354
  docCapabilities: ["doc.annotate.modify"],
1266
- requestHeaders: [documentPasswordHeader],
1355
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1267
1356
  params: DocAnnotationParamsSchema,
1268
1357
  body: { contentType: "application/json", schema: looseJson },
1269
1358
  responses: {
1270
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1359
+ 200: { contentType: "application/json", schema: AnnotationUpdateResultSchema },
1271
1360
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1272
1361
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1273
1362
  }
@@ -1281,27 +1370,45 @@ var docOperations = {
1281
1370
  credentials: docCredentials,
1282
1371
  scope: [],
1283
1372
  docCapabilities: ["doc.annotate.modify"],
1284
- requestHeaders: [documentPasswordHeader],
1373
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1285
1374
  params: DocAnnotationParamsSchema,
1286
1375
  responses: {
1287
- 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 },
1288
1395
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1289
1396
  }
1290
1397
  },
1291
1398
  "doc.annotations.flatten": {
1292
1399
  operationId: "doc.annotations.flatten",
1293
1400
  title: "Flatten annotations",
1294
- 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.",
1295
1402
  method: "POST",
1296
1403
  path: wireTemplates.layerAnnotationItemsFlatten,
1297
1404
  credentials: docCredentials,
1298
1405
  scope: [],
1299
1406
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1300
- requestHeaders: [documentPasswordHeader],
1407
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1301
1408
  params: DocPageParamsSchema,
1302
1409
  body: { contentType: "application/json", schema: looseJson },
1303
1410
  responses: {
1304
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1411
+ 200: { contentType: "application/json", schema: AnnotationFlattenResultSchema },
1305
1412
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1306
1413
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1307
1414
  }
@@ -1324,10 +1431,27 @@ var docOperations = {
1324
1431
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1325
1432
  }
1326
1433
  },
1327
- "doc.forms.get": {
1328
- operationId: "doc.forms.get",
1329
- title: "Get form snapshot",
1330
- 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.",
1331
1455
  method: "GET",
1332
1456
  path: wireTemplates.layerForm,
1333
1457
  credentials: docCredentials,
@@ -1349,62 +1473,100 @@ var docOperations = {
1349
1473
  credentials: docCredentials,
1350
1474
  scope: [],
1351
1475
  docCapabilities: ["doc.forms.fill"],
1352
- requestHeaders: [documentPasswordHeader],
1476
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1353
1477
  params: DocFieldParamsSchema,
1354
1478
  body: { contentType: "application/json", schema: looseJson },
1355
1479
  responses: {
1356
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1480
+ 200: { contentType: "application/json", schema: FormSetValueResultSchema },
1357
1481
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1358
1482
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1359
1483
  }
1360
1484
  },
1361
- "doc.forms.reset": {
1362
- operationId: "doc.forms.reset",
1363
- title: "Reset form field",
1364
- summary: "Reset one form field to its default value.",
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.",
1365
1524
  method: "POST",
1366
- path: wireTemplates.layerFormFieldReset,
1525
+ path: wireTemplates.layerFormWidgetsReorder,
1367
1526
  credentials: docCredentials,
1368
1527
  scope: [],
1369
- docCapabilities: ["doc.forms.fill"],
1370
- requestHeaders: [documentPasswordHeader],
1371
- params: DocFieldParamsSchema,
1528
+ docCapabilities: ["doc.forms.modify"],
1529
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1530
+ params: DocPageParamsSchema,
1531
+ body: { contentType: "application/json", schema: FormWidgetsReorderBodySchema },
1372
1532
  responses: {
1373
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1533
+ 200: { contentType: "application/json", schema: FormWidgetsReorderResultSchema },
1534
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1374
1535
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1375
1536
  }
1376
1537
  },
1377
- "doc.forms.exportData": {
1378
- operationId: "doc.forms.exportData",
1379
- title: "Export form data",
1380
- summary: "Export form data as FDF or XFDF.",
1381
- method: "GET",
1382
- path: wireTemplates.layerFormData,
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,
1383
1544
  credentials: docCredentials,
1384
1545
  scope: [],
1385
- docCapabilities: ["doc.forms.read"],
1386
- requestHeaders: [documentPasswordHeader],
1546
+ docCapabilities: ["doc.forms.modify"],
1547
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1387
1548
  params: DocLayerParamsSchema,
1388
- query: z.object({ format: z.enum(["fdf", "xfdf"]).optional() }),
1549
+ body: { contentType: "application/json", schema: FormCalculationsReorderBodySchema },
1389
1550
  responses: {
1390
- 200: { contentType: ["application/vnd.adobe.xfdf", "application/vnd.fdf"] },
1551
+ 200: { contentType: "application/json", schema: FormCalculationsReorderResultSchema },
1552
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1391
1553
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1392
1554
  }
1393
1555
  },
1394
- "doc.forms.importData": {
1395
- operationId: "doc.forms.importData",
1396
- title: "Import form data",
1397
- summary: "Import form data (FDF/XFDF), filling matching fields.",
1556
+ "doc.forms.reset": {
1557
+ operationId: "doc.forms.reset",
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.",
1398
1560
  method: "POST",
1399
- path: wireTemplates.layerFormData,
1561
+ path: wireTemplates.layerFormReset,
1400
1562
  credentials: docCredentials,
1401
1563
  scope: [],
1402
1564
  docCapabilities: ["doc.forms.fill"],
1403
- requestHeaders: [documentPasswordHeader],
1565
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1404
1566
  params: DocLayerParamsSchema,
1405
- body: { contentType: "application/json", schema: looseJson },
1567
+ body: { contentType: "application/json", schema: FormResetBodySchema },
1406
1568
  responses: {
1407
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1569
+ 200: { contentType: "application/json", schema: FormResetResultSchema },
1408
1570
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1409
1571
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1410
1572
  }
@@ -1421,7 +1583,7 @@ var docOperations = {
1421
1583
  requestHeaders: [documentPasswordHeader],
1422
1584
  params: DocPageParamsSchema,
1423
1585
  responses: {
1424
- 200: { contentType: "application/json", schema: z.array(PageMeasurementViewportSchema) },
1586
+ 200: { contentType: "application/json", schema: PageMeasurementViewportListSchema },
1425
1587
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1426
1588
  }
1427
1589
  },
@@ -1434,7 +1596,7 @@ var docOperations = {
1434
1596
  credentials: docCredentials,
1435
1597
  scope: [],
1436
1598
  docCapabilities: ["doc.annotate.modify"],
1437
- requestHeaders: [documentPasswordHeader],
1599
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1438
1600
  params: DocPageParamsSchema,
1439
1601
  body: { contentType: "application/json", schema: PageScaleInputSchema },
1440
1602
  responses: {
@@ -1443,20 +1605,20 @@ var docOperations = {
1443
1605
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1444
1606
  }
1445
1607
  },
1446
- "doc.pages.move": {
1447
- operationId: "doc.pages.move",
1448
- title: "Move pages",
1449
- 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.",
1450
1612
  method: "POST",
1451
- path: wireTemplates.layerPagesMove,
1613
+ path: wireTemplates.layerPagesReorder,
1452
1614
  credentials: docCredentials,
1453
1615
  scope: [],
1454
1616
  docCapabilities: ["doc.pages.assemble"],
1455
- requestHeaders: [documentPasswordHeader],
1617
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1456
1618
  params: DocLayerParamsSchema,
1457
- body: { contentType: "application/json", schema: looseJson },
1619
+ body: { contentType: "application/json", schema: PageReorderInputSchema },
1458
1620
  responses: {
1459
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1621
+ 200: { contentType: "application/json", schema: PageReorderResultSchema },
1460
1622
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1461
1623
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1462
1624
  }
@@ -1470,11 +1632,11 @@ var docOperations = {
1470
1632
  credentials: docCredentials,
1471
1633
  scope: [],
1472
1634
  docCapabilities: ["doc.pages.assemble"],
1473
- requestHeaders: [documentPasswordHeader],
1635
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1474
1636
  params: DocLayerParamsSchema,
1475
1637
  body: { contentType: "application/json", schema: looseJson },
1476
1638
  responses: {
1477
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1639
+ 200: { contentType: "application/json", schema: PageRotateResultSchema },
1478
1640
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1479
1641
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1480
1642
  }
@@ -1488,11 +1650,11 @@ var docOperations = {
1488
1650
  credentials: docCredentials,
1489
1651
  scope: [],
1490
1652
  docCapabilities: ["doc.pages.assemble"],
1491
- requestHeaders: [documentPasswordHeader],
1653
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1492
1654
  params: DocLayerParamsSchema,
1493
1655
  body: { contentType: "application/json", schema: looseJson },
1494
1656
  responses: {
1495
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1657
+ 200: { contentType: "application/json", schema: PageDeleteResultSchema },
1496
1658
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1497
1659
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1498
1660
  }
@@ -1506,11 +1668,11 @@ var docOperations = {
1506
1668
  credentials: docCredentials,
1507
1669
  scope: [],
1508
1670
  docCapabilities: ["doc.pages.assemble"],
1509
- requestHeaders: [documentPasswordHeader],
1671
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1510
1672
  params: DocLayerParamsSchema,
1511
1673
  body: { contentType: "application/json", schema: looseJson },
1512
1674
  responses: {
1513
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1675
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1514
1676
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1515
1677
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1516
1678
  }
@@ -1524,11 +1686,11 @@ var docOperations = {
1524
1686
  credentials: docCredentials,
1525
1687
  scope: [],
1526
1688
  docCapabilities: ["doc.pages.assemble"],
1527
- requestHeaders: [documentPasswordHeader],
1689
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1528
1690
  params: DocLayerParamsSchema,
1529
1691
  body: { contentType: "application/json", schema: looseJson },
1530
1692
  responses: {
1531
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1693
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1532
1694
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1533
1695
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1534
1696
  }
@@ -1542,11 +1704,11 @@ var docOperations = {
1542
1704
  credentials: docCredentials,
1543
1705
  scope: [],
1544
1706
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1545
- requestHeaders: [documentPasswordHeader],
1707
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1546
1708
  params: DocLayerParamsSchema,
1547
1709
  body: { contentType: "application/json", schema: looseJson, required: false },
1548
1710
  responses: {
1549
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1711
+ 200: { contentType: "application/json", schema: PageFlattenResultSchema },
1550
1712
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1551
1713
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1552
1714
  }
@@ -1560,36 +1722,36 @@ var docOperations = {
1560
1722
  credentials: docCredentials,
1561
1723
  scope: [],
1562
1724
  docCapabilities: ["doc.pages.assemble"],
1563
- requestHeaders: [documentPasswordHeader],
1725
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1564
1726
  params: DocLayerParamsSchema,
1565
1727
  body: {
1566
1728
  contentType: "multipart/form-data"
1567
1729
  },
1568
1730
  responses: {
1569
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1731
+ 200: { contentType: "application/json", schema: PageInsertResultSchema },
1570
1732
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1571
1733
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1572
1734
  },
1573
- 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.'
1574
1736
  },
1575
1737
  "doc.pages.insertBlank": {
1576
1738
  operationId: "doc.pages.insertBlank",
1577
1739
  title: "Insert blank pages",
1578
- summary: "Create blank pages of an explicit size at an index.",
1740
+ summary: "Create blank pages of an explicit size at a position.",
1579
1741
  method: "POST",
1580
1742
  path: wireTemplates.layerPagesInsertBlank,
1581
1743
  credentials: docCredentials,
1582
1744
  scope: [],
1583
1745
  docCapabilities: ["doc.pages.assemble"],
1584
- requestHeaders: [documentPasswordHeader],
1746
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1585
1747
  params: DocLayerParamsSchema,
1586
1748
  body: { contentType: "application/json", schema: looseJson },
1587
1749
  responses: {
1588
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1750
+ 200: { contentType: "application/json", schema: PageInsertResultSchema },
1589
1751
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1590
1752
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1591
1753
  },
1592
- 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).'
1593
1755
  },
1594
1756
  "doc.pages.extract": {
1595
1757
  operationId: "doc.pages.extract",
@@ -1608,7 +1770,7 @@ var docOperations = {
1608
1770
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1609
1771
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1610
1772
  },
1611
- 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.'
1612
1774
  },
1613
1775
  "doc.redactions.apply": {
1614
1776
  operationId: "doc.redactions.apply",
@@ -1619,11 +1781,11 @@ var docOperations = {
1619
1781
  credentials: docCredentials,
1620
1782
  scope: [],
1621
1783
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify", "doc.redact"],
1622
- requestHeaders: [documentPasswordHeader],
1784
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1623
1785
  params: DocLayerParamsSchema,
1624
- body: { contentType: "application/json", schema: looseJson, required: false },
1786
+ body: { contentType: "application/json", schema: RedactionApplyScopeSchema },
1625
1787
  responses: {
1626
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1788
+ 200: { contentType: "application/json", schema: RedactionApplyResultSchema },
1627
1789
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1628
1790
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1629
1791
  }
@@ -1656,6 +1818,7 @@ var docsGroups = {
1656
1818
  "doc.annotations": { title: "Annotations" },
1657
1819
  "doc.forms": { title: "Forms" },
1658
1820
  "doc.metadata": { title: "Metadata" },
1821
+ "doc.metadata.custom": { title: "Custom keys" },
1659
1822
  "doc.pages": { title: "Pages" },
1660
1823
  "doc.redactions": { title: "Redactions" },
1661
1824
  "doc.signatures": { title: "Digital signatures" },
@@ -1681,18 +1844,33 @@ var SECURITY_SCHEME = {
1681
1844
  };
1682
1845
  var ADMIN_ERROR_REF = "#/components/schemas/AdminErrorPayload";
1683
1846
  var ENGINE_ERROR_REF = "#/components/schemas/EngineErrorPayload";
1684
- 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
+ ]);
1685
1855
  var SHARED_COMPONENT_BY_DEFINITION = new Map(
1686
1856
  Object.entries(SHARED_COMPONENT_SCHEMAS).map(([name, schema]) => [schema._def, name])
1687
1857
  );
1688
1858
  var SHARED_COMPONENT_REFS = new Set(
1689
1859
  Object.keys(SHARED_COMPONENT_SCHEMAS).map((name) => `#/components/schemas/${name}`)
1690
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
+ }
1691
1871
  function buildAdminOpenApiDocument(opts) {
1692
1872
  const paths = {};
1693
1873
  const schemas = {};
1694
- registerSchema(schemas, "AdminErrorPayload", AdminErrorPayloadSchema);
1695
- registerSchema(schemas, "EngineErrorPayload", EngineErrorPayloadSchema2);
1696
1874
  for (const [name, schema] of Object.entries(SHARED_COMPONENT_SCHEMAS)) {
1697
1875
  registerSchema(schemas, name, schema);
1698
1876
  }