@embedpdf/engine-core 3.0.0-next.0 → 3.0.0-next.10

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.
Files changed (56) hide show
  1. package/dist/{AbortError-CjSasIlL.js → AbortError-8-9JAX1Y.js} +2 -2
  2. package/dist/{AbortError-CjSasIlL.js.map → AbortError-8-9JAX1Y.js.map} +1 -1
  3. package/dist/{AbortError-ByBflvEl.cjs → AbortError-CRSooKsk.cjs} +2 -2
  4. package/dist/{AbortError-ByBflvEl.cjs.map → AbortError-CRSooKsk.cjs.map} +1 -1
  5. package/dist/{AnnotationListSnapshot-W0RCsyDE.d.cts → AnnotationListSnapshot-DDxHpJQU.d.cts} +538 -41
  6. package/dist/{AnnotationListSnapshot-W0RCsyDE.d.ts → AnnotationListSnapshot-DDxHpJQU.d.ts} +538 -41
  7. package/dist/{DocumentSecurityService-Df79fgpe.d.cts → DocumentSecurityService-BV4_YXkU.d.cts} +33 -2
  8. package/dist/{DocumentSecurityService-B-tULKNY.d.ts → DocumentSecurityService-o9aeTHwT.d.ts} +33 -2
  9. package/dist/{Engine-D9loFZc1.d.cts → Engine-D9je6GdU.d.cts} +50 -19
  10. package/dist/{Engine-B7Oe7f5i.d.ts → Engine-DOoVem7_.d.ts} +50 -19
  11. package/dist/{subtype-qejjVr6h.cjs → PageInsertBlankInput-CzShuSJI.cjs} +184 -1
  12. package/dist/PageInsertBlankInput-CzShuSJI.cjs.map +1 -0
  13. package/dist/{subtype-BvAzLCGC.js → PageInsertBlankInput-WKY0tr6S.js} +149 -2
  14. package/dist/PageInsertBlankInput-WKY0tr6S.js.map +1 -0
  15. package/dist/{builders-C548U47M.js → builders-B_KufGJ9.js} +547 -169
  16. package/dist/builders-B_KufGJ9.js.map +1 -0
  17. package/dist/{builders-BvikWRuO.cjs → builders-Cp_rlGob.cjs} +603 -225
  18. package/dist/builders-Cp_rlGob.cjs.map +1 -0
  19. package/dist/conformance.cjs +822 -198
  20. package/dist/conformance.cjs.map +1 -1
  21. package/dist/conformance.d.cts +124 -6
  22. package/dist/conformance.d.ts +124 -6
  23. package/dist/conformance.js +777 -157
  24. package/dist/conformance.js.map +1 -1
  25. package/dist/{fold-CB4fAOOy.js → fold-BfyxxwS6.js} +162 -3
  26. package/dist/fold-BfyxxwS6.js.map +1 -0
  27. package/dist/{fold-IaMph3CO.cjs → fold-C7I5GpBz.cjs} +235 -4
  28. package/dist/fold-C7I5GpBz.cjs.map +1 -0
  29. package/dist/index.cjs +36 -18
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +4 -4
  33. package/dist/runtime.cjs +41 -23
  34. package/dist/runtime.cjs.map +1 -1
  35. package/dist/runtime.d.cts +103 -5
  36. package/dist/runtime.d.ts +103 -5
  37. package/dist/runtime.js +5 -5
  38. package/dist/{schemas-B_1VyFsm.cjs → schemas-D1pxEv3t.cjs} +138 -32
  39. package/dist/schemas-D1pxEv3t.cjs.map +1 -0
  40. package/dist/{schemas-9OpSSeM6.js → schemas-DAnu8tuW.js} +95 -13
  41. package/dist/schemas-DAnu8tuW.js.map +1 -0
  42. package/dist/wire.cjs +118 -3
  43. package/dist/wire.cjs.map +1 -1
  44. package/dist/wire.d.cts +139 -27
  45. package/dist/wire.d.ts +139 -27
  46. package/dist/wire.js +111 -4
  47. package/dist/wire.js.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/builders-BvikWRuO.cjs.map +0 -1
  50. package/dist/builders-C548U47M.js.map +0 -1
  51. package/dist/fold-CB4fAOOy.js.map +0 -1
  52. package/dist/fold-IaMph3CO.cjs.map +0 -1
  53. package/dist/schemas-9OpSSeM6.js.map +0 -1
  54. package/dist/schemas-B_1VyFsm.cjs.map +0 -1
  55. package/dist/subtype-BvAzLCGC.js.map +0 -1
  56. package/dist/subtype-qejjVr6h.cjs.map +0 -1
package/dist/wire.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_resolver = require("./resolver-DAZWVoJL.cjs");
3
- const require_schemas = require("./schemas-B_1VyFsm.cjs");
3
+ const require_schemas = require("./schemas-D1pxEv3t.cjs");
4
4
  //#region src/wire/token.ts
5
5
  const DEFAULT_MAX_TOKEN_LENGTH = 256;
6
6
  const FIELD_NAME_RE = /^[A-Za-z][A-Za-z0-9]*(?:\.[A-Za-z][A-Za-z0-9]*)*$/;
@@ -76,6 +76,9 @@ const ContentTokenSchema = { fields: ["contentVersion"] };
76
76
  const LayoutTokenSchema = { fields: ["layoutVersion"] };
77
77
  const MetadataTokenSchema = { fields: ["metadataVersion"] };
78
78
  const AnnotationTokenSchema = { fields: ["annotationVersion"] };
79
+ /** Doc-level bulk annotations listing pin (plural, vs the per-page
80
+ * `annotationVersion` token above). */
81
+ const AnnotationsAllTokenSchema = { fields: ["annotationsVersion"] };
79
82
  const ActionsTokenSchema = { fields: ["actionsVersion"] };
80
83
  const AttachmentsTokenSchema = { fields: ["attachmentsVersion"] };
81
84
  const DownloadTokenSchema = {
@@ -128,6 +131,7 @@ const RenderTokenSchema = {
128
131
  const SearchTokenSchema = {
129
132
  fields: [
130
133
  "epoch",
134
+ "format",
131
135
  "matchCase",
132
136
  "matchDiacritics",
133
137
  "maxMatches",
@@ -170,6 +174,8 @@ const encodeMetadataToken = (metadataVersion) => encodeToken(MetadataTokenSchema
170
174
  const decodeMetadataToken = (raw) => decodePositiveInteger(decodeToken(MetadataTokenSchema, raw).metadataVersion, "metadataVersion");
171
175
  const encodeAnnotationToken = (annotationVersion) => encodeToken(AnnotationTokenSchema, { annotationVersion });
172
176
  const decodeAnnotationToken = (raw) => decodePositiveInteger(decodeToken(AnnotationTokenSchema, raw).annotationVersion, "annotationVersion");
177
+ const encodeAnnotationsAllToken = (annotationsVersion) => encodeToken(AnnotationsAllTokenSchema, { annotationsVersion });
178
+ const decodeAnnotationsAllToken = (raw) => decodePositiveInteger(decodeToken(AnnotationsAllTokenSchema, raw).annotationsVersion, "annotationsVersion");
173
179
  const encodeActionsToken = (actionsVersion) => encodeToken(ActionsTokenSchema, { actionsVersion });
174
180
  const decodeActionsToken = (raw) => decodePositiveInteger(decodeToken(ActionsTokenSchema, raw).actionsVersion, "actionsVersion");
175
181
  const encodeAttachmentsToken = (attachmentsVersion) => encodeToken(AttachmentsTokenSchema, { attachmentsVersion });
@@ -209,10 +215,20 @@ const decodeRenderToken = (raw) => decodeToken(RenderTokenSchema, raw);
209
215
  const encodeAnnotationAppearancesRenderToken = (input) => encodeToken(AnnotationAppearancesRenderTokenSchema, input);
210
216
  /** Decode an annotation-appearance render token to a flat field map. */
211
217
  const decodeAnnotationAppearancesRenderToken = (raw) => decodeToken(AnnotationAppearancesRenderTokenSchema, raw);
218
+ /**
219
+ * The search RESULT representation this client speaks — part of the token
220
+ * (and therefore the versioned URL), so a response-shape change can never
221
+ * serve a stale CDN body to a newer client: new tokens are new cache keys,
222
+ * and old tokens fail decode on new servers. Deliberately ALWAYS encoded —
223
+ * an exception to the omit-defaults rule, because its entire job is to
224
+ * change the token bytes when the format changes.
225
+ */
226
+ const SEARCH_RESULT_FORMAT = "segments1";
212
227
  const encodeSearchToken = (input) => {
213
228
  const q = input.query;
214
229
  return encodeToken(SearchTokenSchema, {
215
230
  epoch: input.epoch,
231
+ format: SEARCH_RESULT_FORMAT,
216
232
  q: encodeTokenText(q.text),
217
233
  regex: q.regex ? true : void 0,
218
234
  matchCase: q.matchCase ? true : void 0,
@@ -228,6 +244,7 @@ const decodeSearchToken = (raw) => {
228
244
  const t = decodeToken(SearchTokenSchema, raw);
229
245
  if (t.epoch === void 0) throw new Error("search token is missing \"epoch\"");
230
246
  if (t.q === void 0) throw new Error("search token is missing \"q\"");
247
+ if (t.format !== "segments1") throw new Error(`search token has unsupported result format "${t.format ?? "legacy"}" (expected "${SEARCH_RESULT_FORMAT}")`);
231
248
  const query = {
232
249
  text: decodeTokenText(t.q),
233
250
  ...t.regex === "true" ? { regex: true } : {},
@@ -342,8 +359,21 @@ function decodePdfSaveMode(raw) {
342
359
  */
343
360
  const DEFAULT_LAYER_NAME = "default";
344
361
  const wirePaths = {
345
- /** POST: grant document access/caching credentials for the current bearer. */
346
- access: "/v1/access",
362
+ /**
363
+ * POST: grant access/caching credentials for the current bearer on
364
+ * the document + layer namespace the path names (cross-checked
365
+ * against the token like every layer route — the grant is
366
+ * layer-scoped in substance: CDN coverage, scopes, and the client's
367
+ * binding all carry the layer). Path-addressed so the affinity tier —
368
+ * the `X-CloudPDF-Doc` header derivation AND the chart's uri-mode
369
+ * regex — pins the session bootstrap to the document's pod from the
370
+ * very first request. Default-layer callers spell `layers/default/`,
371
+ * same as every other layer route.
372
+ */
373
+ access: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/access`,
374
+ /** Deprecated alias (docId in the BODY) — served for one prerelease
375
+ * cycle so pre-rename clients keep working; remove after. */
376
+ accessLegacy: "/v1/access",
347
377
  /**
348
378
  * GET: open the document referenced by the doc-scoped JWT and
349
379
  * return its `DocumentHead`. The server materialises the base
@@ -480,6 +510,8 @@ const wirePaths = {
480
510
  * object served from the base worker session.
481
511
  */
482
512
  docPageAnnotations: (docId, pageObjectNumber, annotationVersion) => `/v1/docs/${encodeURIComponent(docId)}/annotations/pages/${pageObjectNumber}/items@${encodeAnnotationToken(annotationVersion)}`,
513
+ /** Immutable BASE whole-document annotation listing (bulk hydration). */
514
+ docAnnotationsAll: (docId, annotationsVersion) => `/v1/docs/${encodeURIComponent(docId)}/annotations/items@${encodeAnnotationsAllToken(annotationsVersion)}`,
483
515
  /** Immutable BASE appearance batch (twin of
484
516
  * `layerPageAnnotationAppearances` — same `annotations` plane gate). */
485
517
  docPageAnnotationAppearances: (docId, pageObjectNumber, token) => `/v1/docs/${encodeURIComponent(docId)}/annotations/pages/${pageObjectNumber}/appearances@${encodeAnnotationAppearancesRenderToken(token)}`,
@@ -490,6 +522,8 @@ const wirePaths = {
490
522
  * collection name — see file-level docstring.
491
523
  */
492
524
  layerPageAnnotations: (docId, layerName, pageObjectNumber, annotationVersion) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/annotations/pages/${pageObjectNumber}/items@${encodeAnnotationToken(annotationVersion)}`,
525
+ /** Immutable LAYER whole-document annotation listing (bulk hydration). */
526
+ layerAnnotationsAll: (docId, layerName, annotationsVersion) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/annotations/items@${encodeAnnotationsAllToken(annotationsVersion)}`,
493
527
  layerPageAnnotationsCurrent: (docId, layerName, pageObjectNumber) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/annotations/pages/${pageObjectNumber}/items`,
494
528
  /**
495
529
  * GET: batch-rendered annotation appearance bitmaps for a single page as a
@@ -568,6 +602,20 @@ const wirePaths = {
568
602
  layerPagesRotate: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/rotate`,
569
603
  layerPagesDelete: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/delete`,
570
604
  layerPagesFlatten: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/flatten`,
605
+ /**
606
+ * POST (multipart mutation envelope): copy every page of the `source`
607
+ * resource part (a standalone PDF) in at the body's `destIndex`.
608
+ */
609
+ layerPagesInsert: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/insert`,
610
+ /** POST (plain JSON): create blank pages — pages.insert minus the bytes. */
611
+ layerPagesInsertBlank: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/insert-blank`,
612
+ /**
613
+ * POST (plain JSON → `application/pdf` bytes): export the listed pages,
614
+ * in caller order, as a standalone PDF. A READ over the current layer
615
+ * state (gated like /download), so it is a POST only for its body —
616
+ * nothing mutates and no event is published.
617
+ */
618
+ layerPagesExtract: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/pages/extract`,
571
619
  layerRedactionsApply: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/redactions/apply`,
572
620
  layerEvents: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/events`,
573
621
  layerDownload: (docId, layerName) => `/v1/docs/${encodeURIComponent(docId)}/layers/${encodeURIComponent(layerName)}/download`,
@@ -587,6 +635,38 @@ const wirePaths = {
587
635
  */
588
636
  docWarm: "/v1/warm"
589
637
  };
638
+ /**
639
+ * Fastify-style templates for the PLAIN (unversioned) doc-plane routes —
640
+ * the backend-callable subset that the `@cloudpdf/contract` contract
641
+ * documents. The immutable `@{version}` variants above remain viewer
642
+ * protocol and are deliberately absent. These templates are the single
643
+ * statement of those paths: the contract package imports them, and the
644
+ * server's route table is pinned to them by the doc-plane registry
645
+ * conformance test.
646
+ */
647
+ const wireTemplates = {
648
+ docHead: "/v1/docs/:docId/head",
649
+ layerManifest: "/v1/docs/:docId/layers/:layerName/manifest",
650
+ layerMetadata: "/v1/docs/:docId/layers/:layerName/metadata",
651
+ layerRenderPage: "/v1/docs/:docId/layers/:layerName/render/pages/:pon/data",
652
+ layerTextPage: "/v1/docs/:docId/layers/:layerName/text/pages/:pon/data",
653
+ layerAnnotationItemsAll: "/v1/docs/:docId/layers/:layerName/annotations/items",
654
+ layerAnnotationItems: "/v1/docs/:docId/layers/:layerName/annotations/pages/:pon/items",
655
+ layerAnnotationItem: "/v1/docs/:docId/layers/:layerName/annotations/pages/:pon/items/:annotKey",
656
+ layerForm: "/v1/docs/:docId/layers/:layerName/form",
657
+ layerFormFieldValue: "/v1/docs/:docId/layers/:layerName/form/fields/:fieldKey/value",
658
+ layerFormFieldReset: "/v1/docs/:docId/layers/:layerName/form/fields/:fieldKey/reset",
659
+ layerFormData: "/v1/docs/:docId/layers/:layerName/form/data",
660
+ layerPagesMove: "/v1/docs/:docId/layers/:layerName/pages/move",
661
+ layerPagesRotate: "/v1/docs/:docId/layers/:layerName/pages/rotate",
662
+ layerPagesDelete: "/v1/docs/:docId/layers/:layerName/pages/delete",
663
+ layerPagesFlatten: "/v1/docs/:docId/layers/:layerName/pages/flatten",
664
+ layerPagesInsert: "/v1/docs/:docId/layers/:layerName/pages/insert",
665
+ layerPagesInsertBlank: "/v1/docs/:docId/layers/:layerName/pages/insert-blank",
666
+ layerPagesExtract: "/v1/docs/:docId/layers/:layerName/pages/extract",
667
+ layerRedactionsApply: "/v1/docs/:docId/layers/:layerName/redactions/apply",
668
+ layerDownload: "/v1/docs/:docId/layers/:layerName/download"
669
+ };
590
670
  //#endregion
591
671
  //#region src/wire/resources.ts
592
672
  /**
@@ -674,6 +754,19 @@ const DOC_RESOURCES = {
674
754
  routeKind: "versioned-read",
675
755
  cdnCacheable: true
676
756
  },
757
+ "annotations-all": {
758
+ id: "annotations-all",
759
+ pathPattern: "/v1/docs/{docId}/annotations/items@*",
760
+ resolvePathPattern: (docId) => `/v1/docs/${docId}/annotations/items@*`,
761
+ pathPrefix: "/v1/docs/{docId}/annotations/items@",
762
+ resolvePathPrefix: (docId) => `/v1/docs/${docId}/annotations/items@`,
763
+ requirement: {
764
+ kind: "single",
765
+ capability: "doc.annotate.read"
766
+ },
767
+ routeKind: "versioned-read",
768
+ cdnCacheable: true
769
+ },
677
770
  layout: {
678
771
  id: "layout",
679
772
  pathPattern: "/v1/docs/{docId}/layout@*",
@@ -921,6 +1014,19 @@ const DOC_RESOURCES = {
921
1014
  routeKind: "versioned-read",
922
1015
  cdnCacheable: true
923
1016
  },
1017
+ "layer-annotations-all": {
1018
+ id: "layer-annotations-all",
1019
+ pathPattern: "/v1/docs/{docId}/layers/{layerName}/annotations/items@*",
1020
+ resolvePathPattern: (docId, layerName = "default") => `/v1/docs/${docId}/layers/${layerName}/annotations/items@*`,
1021
+ pathPrefix: "/v1/docs/{docId}/layers/{layerName}/annotations/items@",
1022
+ resolvePathPrefix: (docId, layerName = "default") => `/v1/docs/${docId}/layers/${layerName}/annotations/items@`,
1023
+ requirement: {
1024
+ kind: "single",
1025
+ capability: "doc.annotate.read"
1026
+ },
1027
+ routeKind: "versioned-read",
1028
+ cdnCacheable: true
1029
+ },
924
1030
  "download-current": {
925
1031
  id: "download-current",
926
1032
  pathPattern: "/v1/docs/{docId}/layers/{layerName}/download",
@@ -1004,6 +1110,7 @@ const RESOURCE_PLANES = {
1004
1110
  "page-geometry": ["content"],
1005
1111
  "page-render-annotated": ["content", "annotations"],
1006
1112
  "page-annotations": ["annotations"],
1113
+ "annotations-all": ["annotations"],
1007
1114
  layout: ["layout"],
1008
1115
  metadata: ["metadata"],
1009
1116
  actions: ["actions"],
@@ -1391,9 +1498,13 @@ exports.OpenDocumentResponseSchema = require_schemas.OpenDocumentResponseSchema;
1391
1498
  exports.PageBoxesSchema = require_schemas.PageBoxesSchema;
1392
1499
  exports.PageDeleteInputSchema = require_schemas.PageDeleteInputSchema;
1393
1500
  exports.PageDeleteResultSchema = require_schemas.PageDeleteResultSchema;
1501
+ exports.PageExtractInputSchema = require_schemas.PageExtractInputSchema;
1394
1502
  exports.PageFlattenInputSchema = require_schemas.PageFlattenInputSchema;
1395
1503
  exports.PageFlattenResultSchema = require_schemas.PageFlattenResultSchema;
1396
1504
  exports.PageGeometrySnapshotSchema = require_schemas.PageGeometrySnapshotSchema;
1505
+ exports.PageInsertBlankInputSchema = require_schemas.PageInsertBlankInputSchema;
1506
+ exports.PageInsertInputSchema = require_schemas.PageInsertInputSchema;
1507
+ exports.PageInsertResultSchema = require_schemas.PageInsertResultSchema;
1397
1508
  exports.PageLayoutSchema = require_schemas.PageLayoutSchema;
1398
1509
  exports.PageListSnapshotSchema = require_schemas.PageListSnapshotSchema;
1399
1510
  exports.PageMoveInputSchema = require_schemas.PageMoveInputSchema;
@@ -1436,6 +1547,7 @@ exports.RefetchReasonSchema = require_schemas.RefetchReasonSchema;
1436
1547
  exports.RenderTokenSchema = RenderTokenSchema;
1437
1548
  exports.ResourceRefSchema = require_schemas.ResourceRefSchema;
1438
1549
  exports.RevisionTokenSchema = require_schemas.RevisionTokenSchema;
1550
+ exports.SEARCH_RESULT_FORMAT = SEARCH_RESULT_FORMAT;
1439
1551
  exports.SearchMatchSchema = require_schemas.SearchMatchSchema;
1440
1552
  exports.SearchModeSchema = require_schemas.SearchModeSchema;
1441
1553
  exports.SearchQuerySchema = require_schemas.SearchQuerySchema;
@@ -1482,6 +1594,7 @@ exports.checkResourceAccess = checkResourceAccess;
1482
1594
  exports.decodeActionsToken = decodeActionsToken;
1483
1595
  exports.decodeAnnotationAppearancesRenderToken = decodeAnnotationAppearancesRenderToken;
1484
1596
  exports.decodeAnnotationToken = decodeAnnotationToken;
1597
+ exports.decodeAnnotationsAllToken = decodeAnnotationsAllToken;
1485
1598
  exports.decodeAttachmentsToken = decodeAttachmentsToken;
1486
1599
  exports.decodeContentToken = decodeContentToken;
1487
1600
  exports.decodeDocToken = decodeDocToken;
@@ -1495,6 +1608,7 @@ exports.decodeTokenText = decodeTokenText;
1495
1608
  exports.encodeActionsToken = encodeActionsToken;
1496
1609
  exports.encodeAnnotationAppearancesRenderToken = encodeAnnotationAppearancesRenderToken;
1497
1610
  exports.encodeAnnotationToken = encodeAnnotationToken;
1611
+ exports.encodeAnnotationsAllToken = encodeAnnotationsAllToken;
1498
1612
  exports.encodeAttachmentsToken = encodeAttachmentsToken;
1499
1613
  exports.encodeContentToken = encodeContentToken;
1500
1614
  exports.encodeDocToken = encodeDocToken;
@@ -1512,5 +1626,6 @@ exports.renderImageOptionsToWire = renderImageOptionsToWire;
1512
1626
  exports.resolveResourceIdForPath = resolveResourceIdForPath;
1513
1627
  exports.unflatten = unflatten;
1514
1628
  exports.wirePaths = wirePaths;
1629
+ exports.wireTemplates = wireTemplates;
1515
1630
 
1516
1631
  //# sourceMappingURL=wire.cjs.map