@cloudpdf/contract 3.0.0-next.14 → 3.0.0-next.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,26 +1,50 @@
1
1
  // src/index.ts
2
2
  import {
3
+ ChangeRequestSchema,
4
+ ChangeResponseSchema,
3
5
  PageScaleInputSchema,
4
6
  PageScaleResultSchema,
5
- PageMeasurementViewportSchema
7
+ PageMeasurementViewportListSchema
6
8
  } from "@embedpdf/engine-core/wire";
7
9
  import {
8
- AnnotationListPageSnapshotSchema,
9
- AnnotationListSnapshotAllPagesSchema,
10
+ AnnotationCreateResultSchema,
11
+ AnnotationDeleteResultSchema,
12
+ AnnotationFlattenResultSchema,
13
+ AnnotationListSchema,
14
+ AnnotationReorderBodySchema,
15
+ AnnotationReorderResultSchema,
16
+ AnnotationUpdateResultSchema,
10
17
  DocumentHeadSchema,
11
18
  DocumentManifestSchema,
19
+ CustomMetadataSchema,
12
20
  DocumentMetadataSchema,
21
+ DocumentOutlineSchema,
13
22
  EngineErrorPayloadSchema,
23
+ FormResetBodySchema,
24
+ FormWidgetDeleteResultSchema,
25
+ FormWidgetUpdateBodySchema,
26
+ FormWidgetUpdateResultSchema,
27
+ FormWidgetsReorderBodySchema,
28
+ FormWidgetsReorderResultSchema,
29
+ FormCalculationsReorderBodySchema,
30
+ FormCalculationsReorderResultSchema,
31
+ FormResetResultSchema,
32
+ FormSetValueResultSchema,
14
33
  FormSnapshotSchema,
15
- MutationMetaSchema,
34
+ IdentitySchema,
35
+ PageFlattenResultSchema,
36
+ PageNameResultSchema,
37
+ RedactionApplyResultSchema,
38
+ RedactionApplyScopeSchema,
16
39
  PageTextSnapshotSchema,
17
40
  ChangeAnalysisSchema,
18
41
  DocumentVersionsSchema,
19
- SignatureAbortResultSchema,
42
+ SignatureCancelResultSchema,
20
43
  SignatureCompleteBodySchema,
21
44
  SignatureCompleteResultSchema,
22
45
  SignaturePreparedWireSchema,
23
46
  SignatureSnapshotSchema,
47
+ AttachmentListSchema,
24
48
  wireTemplates
25
49
  } from "@embedpdf/engine-core/wire";
26
50
  import { z } from "zod";
@@ -157,7 +181,7 @@ var AdminImportSourceSchema = z.discriminatedUnion("kind", [
157
181
  "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
182
  )
159
183
  ]).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."
184
+ "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
185
  );
162
186
  var AdminDocumentImportRequestSchema = z.object({
163
187
  source: AdminImportSourceSchema,
@@ -166,7 +190,7 @@ var AdminDocumentImportRequestSchema = z.object({
166
190
  * against the source's declared Content-Length before the transfer,
167
191
  * `sha256` against the server-observed digest after it. When absent
168
192
  * the server-observed values become authoritative.
169
- * `dedupMode=reuse-existing` REQUIRES `sha256` — without a declared
193
+ * `dedupMode=reuse-existing` requires `sha256` — without a declared
170
194
  * hash the server cannot know what content to reuse.
171
195
  */
172
196
  expected: z.object({
@@ -257,7 +281,7 @@ var AdminTokenRevokeRequestSchema = z.object({
257
281
  /** Optional human reason, written to the audit row. */
258
282
  reason: z.string().max(1024).optional(),
259
283
  /**
260
- * The token's `exp` (unix seconds), used to GC the revocation row
284
+ * The token's `exp` (unix seconds); the revocation row is garbage-collected
261
285
  * once the token would have expired anyway. Defaults server-side to
262
286
  * now + 30 days.
263
287
  */
@@ -324,10 +348,12 @@ var AdminTokenIssueDocRequestSchema = z.object({
324
348
  * vocabulary — an unknown string rejects the whole request.
325
349
  */
326
350
  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(),
351
+ /**
352
+ * Who the token acts for: the same `Identity` the local engine takes at
353
+ * open time. `displayName` becomes the author of the annotations the token
354
+ * creates, `userId` and `groupId` their owner and group.
355
+ */
356
+ identity: IdentitySchema.optional(),
331
357
  /**
332
358
  * Origin lock: web origins (scheme + host, optional port; one leading
333
359
  * `*.` wildcard label allowed) the minted token may be presented
@@ -775,7 +801,7 @@ var adminOperations = {
775
801
  403: { contentType: "application/json", schema: AdminErrorPayloadSchema },
776
802
  404: { contentType: "application/json", schema: AdminErrorPayloadSchema }
777
803
  },
778
- 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."
804
+ 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."
779
805
  },
780
806
  "shares.list": {
781
807
  operationId: "shares.list",
@@ -863,22 +889,35 @@ var DocLayerParamsSchema = DocIdParamsSchema.extend({
863
889
  layerName: z.string().min(1)
864
890
  });
865
891
  var DocPageParamsSchema = DocLayerParamsSchema.extend({
866
- pon: z.coerce.number().int().min(0)
892
+ pageKey: z.string().min(1).regex(/^obj:[1-9][0-9]*$/).describe(
893
+ "The page's address, `obj:N`: the page's indirect object number, the durable identity every `PageLayout.ref` carries. Mirrors `annotKey` and `fieldKey`."
894
+ )
867
895
  });
868
896
  var DocAnnotationParamsSchema = DocPageParamsSchema.extend({
869
- annotKey: z.string().min(1)
897
+ annotKey: z.string().min(1).regex(/^(obj:[1-9][0-9]*|base:(0|[1-9][0-9]*))$/).describe(
898
+ "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."
899
+ )
870
900
  });
871
901
  var DocFieldParamsSchema = DocLayerParamsSchema.extend({
872
902
  fieldKey: z.string().min(1)
873
903
  });
904
+ var DocAttachmentParamsSchema = DocLayerParamsSchema.extend({
905
+ fileKey: z.string().min(1).describe(
906
+ "The embedded file's name-tree key (its `ref.key`), token-text encoded, as `fieldKey` is."
907
+ )
908
+ });
874
909
  var documentPasswordHeader = {
875
910
  name: "X-Document-Password",
876
911
  required: false,
877
912
  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."
878
913
  };
914
+ var idempotencyKeyHeader = {
915
+ name: "Idempotency-Key",
916
+ required: false,
917
+ 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."
918
+ };
879
919
  var looseJson = z.record(z.string(), z.unknown());
880
920
  var docCredentials = ["api-token", "doc-jwt"];
881
- var MutationResponseSchema = z.object({ meta: MutationMetaSchema }).passthrough();
882
921
  var DocSigningParamsSchema = DocLayerParamsSchema.extend({
883
922
  signingId: z.string().min(1)
884
923
  });
@@ -954,6 +993,74 @@ var docOperations = {
954
993
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
955
994
  }
956
995
  },
996
+ "doc.metadata.custom.get": {
997
+ operationId: "doc.metadata.custom.get",
998
+ title: "Get custom keys",
999
+ summary: "The Info dictionary's own keys for a layer: every key but the standard fields, as { key: value }.",
1000
+ method: "GET",
1001
+ path: wireTemplates.layerCustomMetadata,
1002
+ credentials: docCredentials,
1003
+ scope: [],
1004
+ docCapabilities: ["doc.open"],
1005
+ requestHeaders: [documentPasswordHeader],
1006
+ params: DocLayerParamsSchema,
1007
+ responses: {
1008
+ 200: { contentType: "application/json", schema: CustomMetadataSchema },
1009
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1010
+ }
1011
+ },
1012
+ "doc.outline.get": {
1013
+ operationId: "doc.outline.get",
1014
+ title: "Get outline",
1015
+ summary: "The document's outline (its bookmarks) for a layer: every item, depth first, with its parent, its target in page space, its look and whether it opens. Edit it with the outline ops of a change.",
1016
+ method: "GET",
1017
+ path: wireTemplates.layerOutline,
1018
+ credentials: docCredentials,
1019
+ scope: [],
1020
+ docCapabilities: ["doc.open"],
1021
+ requestHeaders: [documentPasswordHeader],
1022
+ params: DocLayerParamsSchema,
1023
+ responses: {
1024
+ 200: { contentType: "application/json", schema: DocumentOutlineSchema },
1025
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1026
+ }
1027
+ },
1028
+ "doc.attachments.list": {
1029
+ operationId: "doc.attachments.list",
1030
+ title: "List attachments",
1031
+ summary: "The files embedded in the document (its /EmbeddedFiles) for a layer, in key order: each with its name, type, description, size, checksum and dates, never its bytes. Add and remove them with the attachment ops of a change.",
1032
+ method: "GET",
1033
+ path: wireTemplates.layerAttachments,
1034
+ credentials: docCredentials,
1035
+ scope: [],
1036
+ docCapabilities: ["doc.open"],
1037
+ requestHeaders: [documentPasswordHeader],
1038
+ params: DocLayerParamsSchema,
1039
+ responses: {
1040
+ 200: { contentType: "application/json", schema: AttachmentListSchema },
1041
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1042
+ },
1043
+ notes: "A file-attachment annotation's file is listed with the annotation; read its bytes with `doc.annotations.readFile`."
1044
+ },
1045
+ "doc.attachments.download": {
1046
+ operationId: "doc.attachments.download",
1047
+ title: "Download an attachment",
1048
+ summary: "One embedded file's bytes, decoded. Its name and type are what the listing says; `Content-Type` is its type, or `application/octet-stream` when it has none.",
1049
+ method: "GET",
1050
+ path: wireTemplates.layerAttachmentFile,
1051
+ credentials: docCredentials,
1052
+ scope: [],
1053
+ docCapabilities: ["doc.download"],
1054
+ requestHeaders: [documentPasswordHeader],
1055
+ params: DocAttachmentParamsSchema,
1056
+ responses: {
1057
+ 200: { contentType: "application/octet-stream" },
1058
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1059
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1060
+ 413: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1061
+ },
1062
+ notes: "A file that decodes past the server's limit is refused (PayloadTooLarge)."
1063
+ },
957
1064
  "doc.signatures.list": {
958
1065
  operationId: "doc.signatures.list",
959
1066
  title: "List signatures",
@@ -1008,7 +1115,7 @@ var docOperations = {
1008
1115
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1009
1116
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1010
1117
  },
1011
- 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)."
1118
+ 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)."
1012
1119
  },
1013
1120
  "doc.signatures.complete": {
1014
1121
  operationId: "doc.signatures.complete",
@@ -1030,19 +1137,19 @@ var docOperations = {
1030
1137
  },
1031
1138
  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."
1032
1139
  },
1033
- "doc.signatures.abort": {
1034
- operationId: "doc.signatures.abort",
1035
- title: "Abort a signature",
1140
+ "doc.signatures.cancel": {
1141
+ operationId: "doc.signatures.cancel",
1142
+ title: "Cancel a signature",
1036
1143
  summary: "Discard a pending signing candidate.",
1037
1144
  method: "DELETE",
1038
- path: wireTemplates.layerSignatureAbort,
1145
+ path: wireTemplates.layerSignatureCancel,
1039
1146
  credentials: docCredentials,
1040
1147
  scope: [],
1041
1148
  docCapabilities: ["doc.sign"],
1042
1149
  requestHeaders: [documentPasswordHeader],
1043
1150
  params: DocSigningParamsSchema,
1044
1151
  responses: {
1045
- 200: { contentType: "application/json", schema: SignatureAbortResultSchema },
1152
+ 200: { contentType: "application/json", schema: SignatureCancelResultSchema },
1046
1153
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1047
1154
  }
1048
1155
  },
@@ -1209,7 +1316,7 @@ var docOperations = {
1209
1316
  requestHeaders: [documentPasswordHeader],
1210
1317
  params: DocPageParamsSchema,
1211
1318
  responses: {
1212
- 200: { contentType: "application/json", schema: AnnotationListPageSnapshotSchema },
1319
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1213
1320
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1214
1321
  }
1215
1322
  },
@@ -1224,13 +1331,45 @@ var docOperations = {
1224
1331
  docCapabilities: ["doc.annotate.read"],
1225
1332
  requestHeaders: [documentPasswordHeader],
1226
1333
  params: DocLayerParamsSchema,
1227
- 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.",
1334
+ 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.",
1228
1335
  responses: {
1229
- 200: { contentType: "application/json", schema: AnnotationListSnapshotAllPagesSchema },
1336
+ 200: { contentType: "application/json", schema: AnnotationListSchema },
1230
1337
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1231
1338
  409: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1232
1339
  }
1233
1340
  },
1341
+ "doc.changes": {
1342
+ operationId: "doc.changes",
1343
+ title: "Apply changes",
1344
+ 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.",
1345
+ method: "POST",
1346
+ path: wireTemplates.layerChanges,
1347
+ credentials: docCredentials,
1348
+ scope: [],
1349
+ docCapabilities: [
1350
+ "doc.annotate.modify",
1351
+ "doc.attachments.modify",
1352
+ "doc.forms.fill",
1353
+ "doc.forms.modify",
1354
+ "doc.metadata.modify",
1355
+ "doc.outline.modify",
1356
+ "doc.pages.assemble"
1357
+ ],
1358
+ requestHeaders: [documentPasswordHeader],
1359
+ params: DocLayerParamsSchema,
1360
+ body: {
1361
+ contentType: ["application/json", "multipart/form-data"],
1362
+ schema: ChangeRequestSchema
1363
+ },
1364
+ 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`, outline `doc.outline.modify`, pages `doc.pages.assemble`, embedded files `doc.attachments.modify`. Bytes (a stamp's drawing, an attached file, a signature's artwork, a PDF whose pages come in) 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.",
1365
+ responses: {
1366
+ 200: { contentType: "application/json", schema: ChangeResponseSchema },
1367
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1368
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1369
+ 409: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1370
+ 413: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1371
+ }
1372
+ },
1234
1373
  "doc.annotations.create": {
1235
1374
  operationId: "doc.annotations.create",
1236
1375
  title: "Create annotation",
@@ -1240,12 +1379,12 @@ var docOperations = {
1240
1379
  credentials: docCredentials,
1241
1380
  scope: [],
1242
1381
  docCapabilities: ["doc.annotate.modify"],
1243
- requestHeaders: [documentPasswordHeader],
1382
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1244
1383
  params: DocPageParamsSchema,
1245
1384
  body: { contentType: "application/json", schema: looseJson },
1246
1385
  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.",
1247
1386
  responses: {
1248
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1387
+ 200: { contentType: "application/json", schema: AnnotationCreateResultSchema },
1249
1388
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1250
1389
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1251
1390
  }
@@ -1259,11 +1398,11 @@ var docOperations = {
1259
1398
  credentials: docCredentials,
1260
1399
  scope: [],
1261
1400
  docCapabilities: ["doc.annotate.modify"],
1262
- requestHeaders: [documentPasswordHeader],
1401
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1263
1402
  params: DocAnnotationParamsSchema,
1264
1403
  body: { contentType: "application/json", schema: looseJson },
1265
1404
  responses: {
1266
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1405
+ 200: { contentType: "application/json", schema: AnnotationUpdateResultSchema },
1267
1406
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1268
1407
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1269
1408
  }
@@ -1277,27 +1416,45 @@ var docOperations = {
1277
1416
  credentials: docCredentials,
1278
1417
  scope: [],
1279
1418
  docCapabilities: ["doc.annotate.modify"],
1280
- requestHeaders: [documentPasswordHeader],
1419
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1281
1420
  params: DocAnnotationParamsSchema,
1282
1421
  responses: {
1283
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1422
+ 200: { contentType: "application/json", schema: AnnotationDeleteResultSchema },
1423
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1424
+ }
1425
+ },
1426
+ "doc.annotations.reorder": {
1427
+ operationId: "doc.annotations.reorder",
1428
+ title: "Reorder annotations",
1429
+ 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.",
1430
+ method: "POST",
1431
+ path: wireTemplates.layerAnnotationItemsReorder,
1432
+ credentials: docCredentials,
1433
+ scope: [],
1434
+ docCapabilities: ["doc.annotate.modify"],
1435
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1436
+ params: DocPageParamsSchema,
1437
+ body: { contentType: "application/json", schema: AnnotationReorderBodySchema },
1438
+ responses: {
1439
+ 200: { contentType: "application/json", schema: AnnotationReorderResultSchema },
1440
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1284
1441
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1285
1442
  }
1286
1443
  },
1287
1444
  "doc.annotations.flatten": {
1288
1445
  operationId: "doc.annotations.flatten",
1289
1446
  title: "Flatten annotations",
1290
- 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.",
1447
+ 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.",
1291
1448
  method: "POST",
1292
1449
  path: wireTemplates.layerAnnotationItemsFlatten,
1293
1450
  credentials: docCredentials,
1294
1451
  scope: [],
1295
1452
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1296
- requestHeaders: [documentPasswordHeader],
1453
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1297
1454
  params: DocPageParamsSchema,
1298
1455
  body: { contentType: "application/json", schema: looseJson },
1299
1456
  responses: {
1300
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1457
+ 200: { contentType: "application/json", schema: AnnotationFlattenResultSchema },
1301
1458
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1302
1459
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1303
1460
  }
@@ -1320,10 +1477,46 @@ var docOperations = {
1320
1477
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1321
1478
  }
1322
1479
  },
1323
- "doc.forms.get": {
1324
- operationId: "doc.forms.get",
1325
- title: "Get form snapshot",
1326
- summary: "Reconciled form snapshot: fields, widgets, values.",
1480
+ "doc.annotations.readAppearance": {
1481
+ operationId: "doc.annotations.readAppearance",
1482
+ title: "Read an annotation appearance",
1483
+ 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.",
1484
+ method: "GET",
1485
+ path: wireTemplates.layerAnnotationItemAppearanceResource,
1486
+ credentials: docCredentials,
1487
+ scope: [],
1488
+ docCapabilities: ["doc.download"],
1489
+ requestHeaders: [documentPasswordHeader],
1490
+ params: DocAnnotationParamsSchema,
1491
+ responses: {
1492
+ 200: { contentType: "application/pdf" },
1493
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1494
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1495
+ }
1496
+ },
1497
+ "doc.annotations.readFile": {
1498
+ operationId: "doc.annotations.readFile",
1499
+ title: "Read an attached file",
1500
+ summary: "A file-attachment annotation's file, decoded: its `file` resource. Its name and type are what the annotation's `file` says. A read; the source is untouched.",
1501
+ method: "GET",
1502
+ path: wireTemplates.layerAnnotationItemFileResource,
1503
+ credentials: docCredentials,
1504
+ scope: [],
1505
+ docCapabilities: ["doc.download"],
1506
+ requestHeaders: [documentPasswordHeader],
1507
+ params: DocAnnotationParamsSchema,
1508
+ responses: {
1509
+ 200: { contentType: "application/octet-stream" },
1510
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1511
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1512
+ 413: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1513
+ },
1514
+ notes: "A file that decodes past the server's limit is refused (PayloadTooLarge)."
1515
+ },
1516
+ "doc.forms.list": {
1517
+ operationId: "doc.forms.list",
1518
+ title: "List form fields",
1519
+ 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.",
1327
1520
  method: "GET",
1328
1521
  path: wireTemplates.layerForm,
1329
1522
  credentials: docCredentials,
@@ -1345,62 +1538,100 @@ var docOperations = {
1345
1538
  credentials: docCredentials,
1346
1539
  scope: [],
1347
1540
  docCapabilities: ["doc.forms.fill"],
1348
- requestHeaders: [documentPasswordHeader],
1541
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1349
1542
  params: DocFieldParamsSchema,
1350
1543
  body: { contentType: "application/json", schema: looseJson },
1351
1544
  responses: {
1352
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1545
+ 200: { contentType: "application/json", schema: FormSetValueResultSchema },
1353
1546
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1354
1547
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1355
1548
  }
1356
1549
  },
1357
- "doc.forms.reset": {
1358
- operationId: "doc.forms.reset",
1359
- title: "Reset form field",
1360
- summary: "Reset one form field to its default value.",
1550
+ "doc.forms.updateWidget": {
1551
+ operationId: "doc.forms.updateWidget",
1552
+ title: "Update form widget",
1553
+ 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.",
1554
+ method: "PATCH",
1555
+ path: wireTemplates.layerFormWidget,
1556
+ credentials: docCredentials,
1557
+ scope: [],
1558
+ docCapabilities: ["doc.forms.modify"],
1559
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1560
+ params: DocAnnotationParamsSchema,
1561
+ body: { contentType: "application/json", schema: FormWidgetUpdateBodySchema },
1562
+ responses: {
1563
+ 200: { contentType: "application/json", schema: FormWidgetUpdateResultSchema },
1564
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1565
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1566
+ }
1567
+ },
1568
+ "doc.forms.deleteWidget": {
1569
+ operationId: "doc.forms.deleteWidget",
1570
+ title: "Delete form widget",
1571
+ 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.",
1572
+ method: "DELETE",
1573
+ path: wireTemplates.layerFormWidget,
1574
+ credentials: docCredentials,
1575
+ scope: [],
1576
+ docCapabilities: ["doc.forms.modify"],
1577
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1578
+ params: DocAnnotationParamsSchema,
1579
+ responses: {
1580
+ 200: { contentType: "application/json", schema: FormWidgetDeleteResultSchema },
1581
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1582
+ 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1583
+ }
1584
+ },
1585
+ "doc.forms.reorderWidgets": {
1586
+ operationId: "doc.forms.reorderWidgets",
1587
+ title: "Reorder form widgets",
1588
+ 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.",
1361
1589
  method: "POST",
1362
- path: wireTemplates.layerFormFieldReset,
1590
+ path: wireTemplates.layerFormWidgetsReorder,
1363
1591
  credentials: docCredentials,
1364
1592
  scope: [],
1365
- docCapabilities: ["doc.forms.fill"],
1366
- requestHeaders: [documentPasswordHeader],
1367
- params: DocFieldParamsSchema,
1593
+ docCapabilities: ["doc.forms.modify"],
1594
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1595
+ params: DocPageParamsSchema,
1596
+ body: { contentType: "application/json", schema: FormWidgetsReorderBodySchema },
1368
1597
  responses: {
1369
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1598
+ 200: { contentType: "application/json", schema: FormWidgetsReorderResultSchema },
1599
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1370
1600
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1371
1601
  }
1372
1602
  },
1373
- "doc.forms.exportData": {
1374
- operationId: "doc.forms.exportData",
1375
- title: "Export form data",
1376
- summary: "Export form data as FDF or XFDF.",
1377
- method: "GET",
1378
- path: wireTemplates.layerFormData,
1603
+ "doc.forms.reorderCalculations": {
1604
+ operationId: "doc.forms.reorderCalculations",
1605
+ title: "Reorder form calculations",
1606
+ 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.",
1607
+ method: "POST",
1608
+ path: wireTemplates.layerFormCalculationsReorder,
1379
1609
  credentials: docCredentials,
1380
1610
  scope: [],
1381
- docCapabilities: ["doc.forms.read"],
1382
- requestHeaders: [documentPasswordHeader],
1611
+ docCapabilities: ["doc.forms.modify"],
1612
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1383
1613
  params: DocLayerParamsSchema,
1384
- query: z.object({ format: z.enum(["fdf", "xfdf"]).optional() }),
1614
+ body: { contentType: "application/json", schema: FormCalculationsReorderBodySchema },
1385
1615
  responses: {
1386
- 200: { contentType: ["application/vnd.adobe.xfdf", "application/vnd.fdf"] },
1616
+ 200: { contentType: "application/json", schema: FormCalculationsReorderResultSchema },
1617
+ 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1387
1618
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1388
1619
  }
1389
1620
  },
1390
- "doc.forms.importData": {
1391
- operationId: "doc.forms.importData",
1392
- title: "Import form data",
1393
- summary: "Import form data (FDF/XFDF), filling matching fields.",
1621
+ "doc.forms.reset": {
1622
+ operationId: "doc.forms.reset",
1623
+ title: "Reset form",
1624
+ summary: "Reset the fields named in `refs` to their default values, or the whole form without it. Returns the fields that changed.",
1394
1625
  method: "POST",
1395
- path: wireTemplates.layerFormData,
1626
+ path: wireTemplates.layerFormReset,
1396
1627
  credentials: docCredentials,
1397
1628
  scope: [],
1398
1629
  docCapabilities: ["doc.forms.fill"],
1399
- requestHeaders: [documentPasswordHeader],
1630
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1400
1631
  params: DocLayerParamsSchema,
1401
- body: { contentType: "application/json", schema: looseJson },
1632
+ body: { contentType: "application/json", schema: FormResetBodySchema },
1402
1633
  responses: {
1403
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1634
+ 200: { contentType: "application/json", schema: FormResetResultSchema },
1404
1635
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1405
1636
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1406
1637
  }
@@ -1417,7 +1648,7 @@ var docOperations = {
1417
1648
  requestHeaders: [documentPasswordHeader],
1418
1649
  params: DocPageParamsSchema,
1419
1650
  responses: {
1420
- 200: { contentType: "application/json", schema: z.array(PageMeasurementViewportSchema) },
1651
+ 200: { contentType: "application/json", schema: PageMeasurementViewportListSchema },
1421
1652
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1422
1653
  }
1423
1654
  },
@@ -1430,7 +1661,7 @@ var docOperations = {
1430
1661
  credentials: docCredentials,
1431
1662
  scope: [],
1432
1663
  docCapabilities: ["doc.annotate.modify"],
1433
- requestHeaders: [documentPasswordHeader],
1664
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1434
1665
  params: DocPageParamsSchema,
1435
1666
  body: { contentType: "application/json", schema: PageScaleInputSchema },
1436
1667
  responses: {
@@ -1439,60 +1670,6 @@ var docOperations = {
1439
1670
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1440
1671
  }
1441
1672
  },
1442
- "doc.pages.move": {
1443
- operationId: "doc.pages.move",
1444
- title: "Move pages",
1445
- summary: "Reorder pages.",
1446
- method: "POST",
1447
- path: wireTemplates.layerPagesMove,
1448
- credentials: docCredentials,
1449
- scope: [],
1450
- docCapabilities: ["doc.pages.assemble"],
1451
- requestHeaders: [documentPasswordHeader],
1452
- params: DocLayerParamsSchema,
1453
- body: { contentType: "application/json", schema: looseJson },
1454
- responses: {
1455
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1456
- 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1457
- 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1458
- }
1459
- },
1460
- "doc.pages.rotate": {
1461
- operationId: "doc.pages.rotate",
1462
- title: "Rotate pages",
1463
- summary: "Set absolute rotation on pages.",
1464
- method: "POST",
1465
- path: wireTemplates.layerPagesRotate,
1466
- credentials: docCredentials,
1467
- scope: [],
1468
- docCapabilities: ["doc.pages.assemble"],
1469
- requestHeaders: [documentPasswordHeader],
1470
- params: DocLayerParamsSchema,
1471
- body: { contentType: "application/json", schema: looseJson },
1472
- responses: {
1473
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1474
- 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1475
- 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1476
- }
1477
- },
1478
- "doc.pages.delete": {
1479
- operationId: "doc.pages.delete",
1480
- title: "Delete pages",
1481
- summary: "Delete pages.",
1482
- method: "POST",
1483
- path: wireTemplates.layerPagesDelete,
1484
- credentials: docCredentials,
1485
- scope: [],
1486
- docCapabilities: ["doc.pages.assemble"],
1487
- requestHeaders: [documentPasswordHeader],
1488
- params: DocLayerParamsSchema,
1489
- body: { contentType: "application/json", schema: looseJson },
1490
- responses: {
1491
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1492
- 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1493
- 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1494
- }
1495
- },
1496
1673
  "doc.pages.setName": {
1497
1674
  operationId: "doc.pages.setName",
1498
1675
  title: "Set page name",
@@ -1502,11 +1679,11 @@ var docOperations = {
1502
1679
  credentials: docCredentials,
1503
1680
  scope: [],
1504
1681
  docCapabilities: ["doc.pages.assemble"],
1505
- requestHeaders: [documentPasswordHeader],
1682
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1506
1683
  params: DocLayerParamsSchema,
1507
1684
  body: { contentType: "application/json", schema: looseJson },
1508
1685
  responses: {
1509
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1686
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1510
1687
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1511
1688
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1512
1689
  }
@@ -1520,11 +1697,11 @@ var docOperations = {
1520
1697
  credentials: docCredentials,
1521
1698
  scope: [],
1522
1699
  docCapabilities: ["doc.pages.assemble"],
1523
- requestHeaders: [documentPasswordHeader],
1700
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1524
1701
  params: DocLayerParamsSchema,
1525
1702
  body: { contentType: "application/json", schema: looseJson },
1526
1703
  responses: {
1527
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1704
+ 200: { contentType: "application/json", schema: PageNameResultSchema },
1528
1705
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1529
1706
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1530
1707
  }
@@ -1538,55 +1715,15 @@ var docOperations = {
1538
1715
  credentials: docCredentials,
1539
1716
  scope: [],
1540
1717
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify"],
1541
- requestHeaders: [documentPasswordHeader],
1718
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1542
1719
  params: DocLayerParamsSchema,
1543
1720
  body: { contentType: "application/json", schema: looseJson, required: false },
1544
1721
  responses: {
1545
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1722
+ 200: { contentType: "application/json", schema: PageFlattenResultSchema },
1546
1723
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1547
1724
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1548
1725
  }
1549
1726
  },
1550
- "doc.pages.insert": {
1551
- operationId: "doc.pages.insert",
1552
- title: "Insert pages from a PDF",
1553
- summary: "Copy every page of an uploaded PDF into the document at an index.",
1554
- method: "POST",
1555
- path: wireTemplates.layerPagesInsert,
1556
- credentials: docCredentials,
1557
- scope: [],
1558
- docCapabilities: ["doc.pages.assemble"],
1559
- requestHeaders: [documentPasswordHeader],
1560
- params: DocLayerParamsSchema,
1561
- body: {
1562
- contentType: "multipart/form-data"
1563
- },
1564
- responses: {
1565
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1566
- 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1567
- 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1568
- },
1569
- 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.'
1570
- },
1571
- "doc.pages.insertBlank": {
1572
- operationId: "doc.pages.insertBlank",
1573
- title: "Insert blank pages",
1574
- summary: "Create blank pages of an explicit size at an index.",
1575
- method: "POST",
1576
- path: wireTemplates.layerPagesInsertBlank,
1577
- credentials: docCredentials,
1578
- scope: [],
1579
- docCapabilities: ["doc.pages.assemble"],
1580
- requestHeaders: [documentPasswordHeader],
1581
- params: DocLayerParamsSchema,
1582
- body: { contentType: "application/json", schema: looseJson },
1583
- responses: {
1584
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1585
- 400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1586
- 404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1587
- },
1588
- notes: 'Body is `{"size": {"width", "height"}, "count"?, "destIndex"?}` \u2014 size in PDF points, count in [1, 100], destIndex omitted \u2192 append.'
1589
- },
1590
1727
  "doc.pages.extract": {
1591
1728
  operationId: "doc.pages.extract",
1592
1729
  title: "Extract pages",
@@ -1604,7 +1741,7 @@ var docOperations = {
1604
1741
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1605
1742
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1606
1743
  },
1607
- 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.'
1744
+ notes: 'A read, not a mutation: the source document is untouched and no event is published. Body is `{"pages": PageRef[], "flatten"?: {"usage"?: "display" | "print"}, "includeAnnotations"?: boolean, "includeFormFields"?: boolean}`; the response body is the new PDF. With `flatten` the copy is the pages as they draw for `usage` (`"print"`: a print copy): the annotations and form fields painted in, nothing interactive left, layers in their state for the usage. A flattened copy takes `doc.download` or `doc.download.flattened`, and paints only what the caller may read; `includeAnnotations` and `includeFormFields` choose what it paints, and are refused without `flatten`.'
1608
1745
  },
1609
1746
  "doc.redactions.apply": {
1610
1747
  operationId: "doc.redactions.apply",
@@ -1615,11 +1752,11 @@ var docOperations = {
1615
1752
  credentials: docCredentials,
1616
1753
  scope: [],
1617
1754
  docCapabilities: ["doc.pages.modify", "doc.annotate.modify", "doc.redact"],
1618
- requestHeaders: [documentPasswordHeader],
1755
+ requestHeaders: [documentPasswordHeader, idempotencyKeyHeader],
1619
1756
  params: DocLayerParamsSchema,
1620
- body: { contentType: "application/json", schema: looseJson, required: false },
1757
+ body: { contentType: "application/json", schema: RedactionApplyScopeSchema },
1621
1758
  responses: {
1622
- 200: { contentType: "application/json", schema: MutationResponseSchema },
1759
+ 200: { contentType: "application/json", schema: RedactionApplyResultSchema },
1623
1760
  400: { contentType: "application/json", schema: EngineErrorPayloadSchema },
1624
1761
  404: { contentType: "application/json", schema: EngineErrorPayloadSchema }
1625
1762
  }
@@ -1650,8 +1787,11 @@ var docsGroups = {
1650
1787
  shares: { title: "Shares" },
1651
1788
  doc: { title: "Document operations", slug: "document-operations" },
1652
1789
  "doc.annotations": { title: "Annotations" },
1790
+ "doc.attachments": { title: "Attachments" },
1653
1791
  "doc.forms": { title: "Forms" },
1654
1792
  "doc.metadata": { title: "Metadata" },
1793
+ "doc.metadata.custom": { title: "Custom keys" },
1794
+ "doc.outline": { title: "Outline" },
1655
1795
  "doc.pages": { title: "Pages" },
1656
1796
  "doc.redactions": { title: "Redactions" },
1657
1797
  "doc.signatures": { title: "Digital signatures" },
@@ -1694,6 +1834,7 @@ export {
1694
1834
  AdminUploadProxyResponseSchema,
1695
1835
  DedupModeSchema,
1696
1836
  DocAnnotationParamsSchema,
1837
+ DocAttachmentParamsSchema,
1697
1838
  DocFieldParamsSchema,
1698
1839
  DocIdParamsSchema,
1699
1840
  DocLayerParamsSchema,
@@ -1726,6 +1867,7 @@ export {
1726
1867
  docOperations,
1727
1868
  docsGroups,
1728
1869
  documentPasswordHeader,
1870
+ idempotencyKeyHeader,
1729
1871
  tenantIdPattern
1730
1872
  };
1731
1873
  //# sourceMappingURL=index.js.map