@json-to-office/jto 0.8.0 → 0.8.2

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/cli.js CHANGED
@@ -1705,6 +1705,12 @@ var init_loose = __esm({
1705
1705
  // src/server/lib/typebox-validator.ts
1706
1706
  import { Value as Value2 } from "@sinclair/typebox/value";
1707
1707
  import { HTTPException } from "hono/http-exception";
1708
+ function autoWrapDocumentBody(value) {
1709
+ if (typeof value === "object" && value !== null && "name" in value && "children" in value && !("jsonDefinition" in value)) {
1710
+ return { jsonDefinition: value };
1711
+ }
1712
+ return value;
1713
+ }
1708
1714
  function tbValidator(schema) {
1709
1715
  return (async (c, next) => {
1710
1716
  let value;
@@ -1715,6 +1721,7 @@ function tbValidator(schema) {
1715
1721
  message: "Invalid JSON in request body"
1716
1722
  });
1717
1723
  }
1724
+ value = autoWrapDocumentBody(value);
1718
1725
  const isValid = Value2.Check(schema, value);
1719
1726
  if (isValid) {
1720
1727
  c.req.validatedData = {
@@ -1727,7 +1734,7 @@ function tbValidator(schema) {
1727
1734
  message: error.message,
1728
1735
  value: error.value
1729
1736
  }));
1730
- const errorMessages = errors.map((e) => e.message);
1737
+ const errorMessages = errors.map((e) => `${e.path || "/"}: ${e.message}`);
1731
1738
  throw new HTTPException(400, {
1732
1739
  message: errorMessages.length === 1 ? errorMessages[0] : `Validation failed:
1733
1740
  ${errorMessages.join("\n")}`,
@@ -5878,7 +5885,7 @@ ${chalk8.cyan("Health:")} ${url}/health
5878
5885
  }
5879
5886
 
5880
5887
  // src/cli.ts
5881
- var PACKAGE_VERSION = true ? "0.8.0" : "dev-mode";
5888
+ var PACKAGE_VERSION = true ? "0.8.2" : "dev-mode";
5882
5889
  function registerFormatCommands(parent, adapter) {
5883
5890
  parent.addCommand(createGenerateCommand(adapter));
5884
5891
  parent.addCommand(createValidateCommand(adapter));