@json-to-office/jto 0.2.1 → 0.3.0
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 +54 -17
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{HomePage-DX_EbLqY.js → HomePage-muPAe_M2.js} +3 -3
- package/dist/client/assets/{HomePage-DX_EbLqY.js.map → HomePage-muPAe_M2.js.map} +1 -1
- package/dist/client/assets/{JsonEditorPage-C8a43kG2.js → JsonEditorPage-DKor0I6f.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-C8a43kG2.js.map → JsonEditorPage-DKor0I6f.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-C_k1zpkx.js → MonacoPluginProvider-BGYshg9R.js} +3 -3
- package/dist/client/assets/MonacoPluginProvider-BGYshg9R.js.map +1 -0
- package/dist/client/assets/{button-DLt0WPRa.js → button-BzUKH2aN.js} +2 -2
- package/dist/client/assets/{button-DLt0WPRa.js.map → button-BzUKH2aN.js.map} +1 -1
- package/dist/client/assets/{editor-LsSIrw3S.js → editor-BS2qlF-X.js} +8 -8
- package/dist/client/assets/editor-BS2qlF-X.js.map +1 -0
- package/dist/client/assets/editor-monaco-json-DKrX3IiN.js +6 -0
- package/dist/client/assets/{editor-monaco-json-CTzuM8w2.js.map → editor-monaco-json-DKrX3IiN.js.map} +1 -1
- package/dist/client/assets/index-D_aKAAFg.js +3 -0
- package/dist/client/assets/index-D_aKAAFg.js.map +1 -0
- package/dist/client/assets/preview-AJZwEEO9.js +3 -0
- package/dist/client/assets/preview-AJZwEEO9.js.map +1 -0
- package/dist/client/index.html +1 -1
- package/package.json +5 -5
- package/dist/client/assets/MonacoPluginProvider-C_k1zpkx.js.map +0 -1
- package/dist/client/assets/editor-LsSIrw3S.js.map +0 -1
- package/dist/client/assets/editor-monaco-json-CTzuM8w2.js +0 -6
- package/dist/client/assets/index-CslfgN2g.js +0 -3
- package/dist/client/assets/index-CslfgN2g.js.map +0 -1
- package/dist/client/assets/preview-CeZ8u4Ec.js +0 -3
- package/dist/client/assets/preview-CeZ8u4Ec.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1777,7 +1777,9 @@ function createFormatRouter(adapter) {
|
|
|
1777
1777
|
const contentTypeMw = async (c, next) => {
|
|
1778
1778
|
const contentType = c.req.header("content-type");
|
|
1779
1779
|
if (!contentType || !contentType.includes("application/json")) {
|
|
1780
|
-
throw new HTTPException3(400, {
|
|
1780
|
+
throw new HTTPException3(400, {
|
|
1781
|
+
message: "Content-Type must be application/json"
|
|
1782
|
+
});
|
|
1781
1783
|
}
|
|
1782
1784
|
await next();
|
|
1783
1785
|
};
|
|
@@ -1820,10 +1822,13 @@ function createFormatRouter(adapter) {
|
|
|
1820
1822
|
meta: { timestamp: (/* @__PURE__ */ new Date()).toISOString(), requestId }
|
|
1821
1823
|
});
|
|
1822
1824
|
} catch (error) {
|
|
1823
|
-
logger.error(`${adapter.label} generation failed`, {
|
|
1825
|
+
logger.error(`${adapter.label} generation failed`, {
|
|
1826
|
+
error,
|
|
1827
|
+
requestId
|
|
1828
|
+
});
|
|
1824
1829
|
if (error instanceof Error) {
|
|
1825
1830
|
const msg = error.message.toLowerCase();
|
|
1826
|
-
if (msg.includes("invalid") || msg.includes("validation") || msg.includes("missing required")) {
|
|
1831
|
+
if (msg.includes("invalid") || msg.includes("validation") || msg.includes("missing required") || msg.includes("unknown component")) {
|
|
1827
1832
|
throw new HTTPException3(400, { message: error.message });
|
|
1828
1833
|
}
|
|
1829
1834
|
}
|
|
@@ -1840,7 +1845,10 @@ function createFormatRouter(adapter) {
|
|
|
1840
1845
|
tbValidator(LooseDocumentValidationRequestSchema),
|
|
1841
1846
|
async (c) => {
|
|
1842
1847
|
const generatorService = getContainer().get("generatorService");
|
|
1843
|
-
const { jsonDefinition } = getValidated(
|
|
1848
|
+
const { jsonDefinition } = getValidated(
|
|
1849
|
+
c,
|
|
1850
|
+
"json"
|
|
1851
|
+
);
|
|
1844
1852
|
const requestId = c.get("requestId");
|
|
1845
1853
|
try {
|
|
1846
1854
|
const result = await generatorService.validate(jsonDefinition);
|
|
@@ -1864,26 +1872,38 @@ function createFormatRouter(adapter) {
|
|
|
1864
1872
|
}),
|
|
1865
1873
|
async (c) => {
|
|
1866
1874
|
const requestId = c.get("requestId");
|
|
1867
|
-
const libreOfficeService = getContainer().get(
|
|
1875
|
+
const libreOfficeService = getContainer().get(
|
|
1876
|
+
"libreOfficeConverterService"
|
|
1877
|
+
);
|
|
1868
1878
|
try {
|
|
1869
1879
|
const body = await c.req.parseBody();
|
|
1870
1880
|
const file = body.file;
|
|
1871
1881
|
if (!file || typeof file === "string") {
|
|
1872
|
-
throw new HTTPException3(400, {
|
|
1882
|
+
throw new HTTPException3(400, {
|
|
1883
|
+
message: `No ${adapter.name.toUpperCase()} file provided`
|
|
1884
|
+
});
|
|
1873
1885
|
}
|
|
1874
1886
|
if (file.size === 0) {
|
|
1875
|
-
throw new HTTPException3(400, {
|
|
1887
|
+
throw new HTTPException3(400, {
|
|
1888
|
+
message: `${adapter.name.toUpperCase()} file is empty`
|
|
1889
|
+
});
|
|
1876
1890
|
}
|
|
1877
1891
|
const arrayBuffer = await file.arrayBuffer();
|
|
1878
1892
|
const inputBuffer = Buffer.from(arrayBuffer);
|
|
1879
|
-
const pdfBuffer = await libreOfficeService.convertToPdf(
|
|
1893
|
+
const pdfBuffer = await libreOfficeService.convertToPdf(
|
|
1894
|
+
inputBuffer,
|
|
1895
|
+
file.name
|
|
1896
|
+
);
|
|
1880
1897
|
const pdfName = (file.name || "preview").replace(/\.[^.]+$/i, "") + ".pdf";
|
|
1881
1898
|
c.header("Content-Type", "application/pdf");
|
|
1882
1899
|
c.header("Content-Disposition", `inline; filename="${pdfName}"`);
|
|
1883
1900
|
c.header("Content-Length", String(pdfBuffer.length));
|
|
1884
1901
|
return c.body(pdfBuffer);
|
|
1885
1902
|
} catch (error) {
|
|
1886
|
-
logger.error("LibreOffice preview conversion failed", {
|
|
1903
|
+
logger.error("LibreOffice preview conversion failed", {
|
|
1904
|
+
error,
|
|
1905
|
+
requestId
|
|
1906
|
+
});
|
|
1887
1907
|
if (error instanceof HTTPException3) throw error;
|
|
1888
1908
|
if (error instanceof LibreOfficeBinaryNotFoundError) {
|
|
1889
1909
|
throw new HTTPException3(503, {
|
|
@@ -1891,9 +1911,13 @@ function createFormatRouter(adapter) {
|
|
|
1891
1911
|
});
|
|
1892
1912
|
}
|
|
1893
1913
|
if (error instanceof LibreOfficeTimeoutError || error instanceof LibreOfficeConversionError || error instanceof LibreOfficeOutputNotFoundError) {
|
|
1894
|
-
throw new HTTPException3(500, {
|
|
1914
|
+
throw new HTTPException3(500, {
|
|
1915
|
+
message: "LibreOffice preview conversion failed."
|
|
1916
|
+
});
|
|
1895
1917
|
}
|
|
1896
|
-
throw new HTTPException3(500, {
|
|
1918
|
+
throw new HTTPException3(500, {
|
|
1919
|
+
message: "Internal server error during preview conversion"
|
|
1920
|
+
});
|
|
1897
1921
|
}
|
|
1898
1922
|
}
|
|
1899
1923
|
);
|
|
@@ -1927,9 +1951,14 @@ function createFormatRouter(adapter) {
|
|
|
1927
1951
|
meta: { timestamp: (/* @__PURE__ */ new Date()).toISOString(), requestId }
|
|
1928
1952
|
});
|
|
1929
1953
|
} catch (error) {
|
|
1930
|
-
logger.error("Failed to get standard components definition", {
|
|
1954
|
+
logger.error("Failed to get standard components definition", {
|
|
1955
|
+
error,
|
|
1956
|
+
requestId
|
|
1957
|
+
});
|
|
1931
1958
|
if (error instanceof HTTPException3) throw error;
|
|
1932
|
-
throw new HTTPException3(500, {
|
|
1959
|
+
throw new HTTPException3(500, {
|
|
1960
|
+
message: "Failed to get standard components definition"
|
|
1961
|
+
});
|
|
1933
1962
|
}
|
|
1934
1963
|
}
|
|
1935
1964
|
);
|
|
@@ -1955,14 +1984,20 @@ function createFormatRouter(adapter) {
|
|
|
1955
1984
|
});
|
|
1956
1985
|
} catch (error) {
|
|
1957
1986
|
logger.error("Failed to get cache statistics", { error });
|
|
1958
|
-
throw new HTTPException3(500, {
|
|
1987
|
+
throw new HTTPException3(500, {
|
|
1988
|
+
message: "Failed to get cache statistics"
|
|
1989
|
+
});
|
|
1959
1990
|
}
|
|
1960
1991
|
});
|
|
1961
1992
|
router.get("/cache-analytics", async (c) => {
|
|
1962
1993
|
try {
|
|
1963
1994
|
const analytics = await adapter.getComponentCacheAnalytics?.();
|
|
1964
1995
|
if (!analytics) {
|
|
1965
|
-
return c.json({
|
|
1996
|
+
return c.json({
|
|
1997
|
+
success: true,
|
|
1998
|
+
data: null,
|
|
1999
|
+
meta: { timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
2000
|
+
});
|
|
1966
2001
|
}
|
|
1967
2002
|
return c.json({
|
|
1968
2003
|
success: true,
|
|
@@ -1971,7 +2006,9 @@ function createFormatRouter(adapter) {
|
|
|
1971
2006
|
});
|
|
1972
2007
|
} catch (error) {
|
|
1973
2008
|
logger.error("Failed to get cache analytics", { error });
|
|
1974
|
-
throw new HTTPException3(500, {
|
|
2009
|
+
throw new HTTPException3(500, {
|
|
2010
|
+
message: "Failed to get cache analytics"
|
|
2011
|
+
});
|
|
1975
2012
|
}
|
|
1976
2013
|
});
|
|
1977
2014
|
router.delete("/cache", async (c) => {
|
|
@@ -5777,7 +5814,7 @@ ${chalk8.cyan("Health:")} ${url}/health
|
|
|
5777
5814
|
}
|
|
5778
5815
|
|
|
5779
5816
|
// src/cli.ts
|
|
5780
|
-
var PACKAGE_VERSION = true ? "0.
|
|
5817
|
+
var PACKAGE_VERSION = true ? "0.3.0" : "dev-mode";
|
|
5781
5818
|
function registerFormatCommands(parent, adapter) {
|
|
5782
5819
|
parent.addCommand(createGenerateCommand(adapter));
|
|
5783
5820
|
parent.addCommand(createValidateCommand(adapter));
|