document-operations 1.1.74 → 1.1.76

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.cjs CHANGED
@@ -11,7 +11,7 @@ let document_outline_js = require("document-outline.js");
11
11
  /**
12
12
  * Builds a DocumentOperation whose input and output types are both inferred from real Zod schemas, so a call site never has to repeat `z.infer<typeof Schema>` itself. Use `defineOperationWithoutOutputSchema` instead for the rare operation whose original MCP tool registration declared no outputSchema at all.
13
13
  *
14
- * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (ZodType<Output, Input, Internals>), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
14
+ * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (`ZodType<Output, Input, Internals>`), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
15
15
  */
16
16
  function defineOperation(operation) {
17
17
  return operation;
@@ -218,7 +218,7 @@ const listDocumentConversionsOperation = defineOperation({
218
218
  description: "Lists every (source, target) format pair convert_document actually supports, straight from documents.js's own DocumentConverter port — the definitive source of truth for what convert_document will and will not accept as a (source, targetFormat) combination.",
219
219
  inputSchema: ListDocumentConversionsInputSchema,
220
220
  outputSchema: ListDocumentConversionsOutputSchema,
221
- run() {
221
+ async run() {
222
222
  return Promise.resolve({ conversions: converter.conversions.map((conversion) => ({
223
223
  source: conversion.source,
224
224
  target: conversion.target
@@ -406,6 +406,9 @@ function appendMarkdownParagraphs(body, paragraphs) {
406
406
  }
407
407
  }
408
408
  }
409
+ function assertNever(format) {
410
+ throw new Error(`createDocumentBytes: unhandled format ${String(format)}`);
411
+ }
409
412
  function createDocumentBytes(format) {
410
413
  switch (format) {
411
414
  case "docx": return (0, documents_js.createDocx)().toBytes();
@@ -417,6 +420,7 @@ function createDocumentBytes(format) {
417
420
  case "pdf": return (0, documents_js.createPdf)().toBytes();
418
421
  case "markdown": return (0, documents_js.encodeMarkdownText)((0, documents_js.createMarkdownEditor)().toMarkdownText());
419
422
  }
423
+ return assertNever(format);
420
424
  }
421
425
  const ResolvedDocumentOutputSchema$2 = zod.z.union([zod.z.object({
422
426
  path: zod.z.string(),
package/dist/index.d.cts CHANGED
@@ -22,7 +22,7 @@ interface DocumentOperation<In = unknown, Out = unknown> {
22
22
  /**
23
23
  * Builds a DocumentOperation whose input and output types are both inferred from real Zod schemas, so a call site never has to repeat `z.infer<typeof Schema>` itself. Use `defineOperationWithoutOutputSchema` instead for the rare operation whose original MCP tool registration declared no outputSchema at all.
24
24
  *
25
- * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (ZodType<Output, Input, Internals>), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
25
+ * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (`ZodType<Output, Input, Internals>`), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
26
26
  */
27
27
  declare function defineOperation<InputSchema extends z.ZodType, OutputSchema extends z.ZodType>(operation: {
28
28
  readonly name: string;
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ interface DocumentOperation<In = unknown, Out = unknown> {
22
22
  /**
23
23
  * Builds a DocumentOperation whose input and output types are both inferred from real Zod schemas, so a call site never has to repeat `z.infer<typeof Schema>` itself. Use `defineOperationWithoutOutputSchema` instead for the rare operation whose original MCP tool registration declared no outputSchema at all.
24
24
  *
25
- * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (ZodType<Output, Input, Internals>), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
25
+ * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (`ZodType<Output, Input, Internals>`), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
26
26
  */
27
27
  declare function defineOperation<InputSchema extends z.ZodType, OutputSchema extends z.ZodType>(operation: {
28
28
  readonly name: string;
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { buildOutline, isOutlineNode, outlineLeafText } from "document-outline.j
10
10
  /**
11
11
  * Builds a DocumentOperation whose input and output types are both inferred from real Zod schemas, so a call site never has to repeat `z.infer<typeof Schema>` itself. Use `defineOperationWithoutOutputSchema` instead for the rare operation whose original MCP tool registration declared no outputSchema at all.
12
12
  *
13
- * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (ZodType<Output, Input, Internals>), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
13
+ * Deliberately returns the parameter object's own inferred literal type rather than an explicit `DocumentOperation<...>` return annotation. Zod 4's ZodType carries its own output type as one of three generic parameters (`ZodType<Output, Input, Internals>`), and TypeScript cannot prove, from inside this function body, that a generic `InputSchema extends z.ZodType` also extends `z.ZodType<z.infer<InputSchema>>` — the two-step indirection through an abstract type parameter defeats it even though it is true for every concrete schema. Letting the literal's own type flow out instead sidesteps that: a caller's own concrete schema (e.g. `ConvertDocumentInputSchema`) is trivially assignable to `DocumentOperation<In, Out>`'s `z.ZodType<In>` field wherever that supertype is actually needed (the registry array below, or a future MCP/REST/CLI adapter parameter), because widening a CONCRETE schema's output type to line up is a normal covariant check, not the same self-referential generic one.
14
14
  */
15
15
  function defineOperation(operation) {
16
16
  return operation;
@@ -217,7 +217,7 @@ const listDocumentConversionsOperation = defineOperation({
217
217
  description: "Lists every (source, target) format pair convert_document actually supports, straight from documents.js's own DocumentConverter port — the definitive source of truth for what convert_document will and will not accept as a (source, targetFormat) combination.",
218
218
  inputSchema: ListDocumentConversionsInputSchema,
219
219
  outputSchema: ListDocumentConversionsOutputSchema,
220
- run() {
220
+ async run() {
221
221
  return Promise.resolve({ conversions: converter.conversions.map((conversion) => ({
222
222
  source: conversion.source,
223
223
  target: conversion.target
@@ -405,6 +405,9 @@ function appendMarkdownParagraphs(body, paragraphs) {
405
405
  }
406
406
  }
407
407
  }
408
+ function assertNever(format) {
409
+ throw new Error(`createDocumentBytes: unhandled format ${String(format)}`);
410
+ }
408
411
  function createDocumentBytes(format) {
409
412
  switch (format) {
410
413
  case "docx": return createDocx().toBytes();
@@ -416,6 +419,7 @@ function createDocumentBytes(format) {
416
419
  case "pdf": return createPdf().toBytes();
417
420
  case "markdown": return encodeMarkdownText(createMarkdownEditor().toMarkdownText());
418
421
  }
422
+ return assertNever(format);
419
423
  }
420
424
  const ResolvedDocumentOutputSchema$2 = z.union([z.object({
421
425
  path: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-operations",
3
- "version": "1.1.74",
3
+ "version": "1.1.76",
4
4
  "description": "The canonical set of document-conversion, editing, inspection, and .odb operations documents.js exposes — one Zod input/output schema and one transport-agnostic run() function per operation, shared by document-mcp, document-cli, and a REST API server rather than each defining its own copy.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -82,10 +82,10 @@
82
82
  "license": "MIT",
83
83
  "packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
84
84
  "dependencies": {
85
- "document-compute.js": "1.6.22",
86
- "document-outline.js": "3.10.14",
85
+ "document-compute.js": "1.6.24",
86
+ "document-outline.js": "3.10.15",
87
87
  "document-schema.js": "7.15.0",
88
- "documents.js": "14.4.13",
88
+ "documents.js": "14.4.15",
89
89
  "zod": "4.4.3"
90
90
  },
91
91
  "devDependencies": {
@@ -98,7 +98,7 @@
98
98
  "@vitest/coverage-v8": "4.1.11",
99
99
  "eslint": "10.8.1",
100
100
  "husky": "9.1.7",
101
- "odf.js": "11.1.3",
101
+ "odf.js": "11.1.4",
102
102
  "publint": "0.3.22",
103
103
  "semantic-release": "25.0.9",
104
104
  "tsdown": "0.22.14",