intlayer-editor 8.4.7 → 8.4.9
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/client/dist/assets/{CodeBlockShiki-DOuQPuaj.js → CodeBlockShiki-67WBbfIc.js} +1 -1
- package/client/dist/assets/{index-BzPJ15Ed.js → index-Bp3XDFNZ.js} +2033 -3236
- package/client/dist/assets/{markdown-BRt2VivO.js → markdown-B_VAQu_B.js} +6 -2
- package/client/dist/assets/{markdown-CCfJaneY.js → markdown-CTJeKACB.js} +2 -2
- package/client/dist/index.html +2 -2
- package/package.json +12 -12
- package/server/dist/controllers/dictionary.controller.cjs +5 -1
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.mjs +5 -1
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
|
@@ -1636,7 +1636,7 @@ var createRules = (createElement, ctx, options, footnotes, refs, attrStringToMap
|
|
|
1636
1636
|
},
|
|
1637
1637
|
_render(node, output, state = {}) {
|
|
1638
1638
|
const table = node;
|
|
1639
|
-
const getStyle = (i) => table.align[i] ? { textAlign: table.align[i] } : {};
|
|
1639
|
+
const getStyle = (i) => table.align[i] && table.align[i] !== "left" ? { textAlign: table.align[i] } : {};
|
|
1640
1640
|
return createElement("table", { key: state.key }, createElement("thead", null, createElement("tr", null, ...table.header.map((c, i) => createElement("th", {
|
|
1641
1641
|
key: i,
|
|
1642
1642
|
style: getStyle(i)
|
|
@@ -1665,7 +1665,11 @@ var createRules = (createElement, ctx, options, footnotes, refs, attrStringToMap
|
|
|
1665
1665
|
_order: Priority.MIN,
|
|
1666
1666
|
_parse(capture) {
|
|
1667
1667
|
const text = capture[0];
|
|
1668
|
-
return { text: text.indexOf("&") === -1 ? text : text.replace(HTML_CHAR_CODE_R, (f, i) =>
|
|
1668
|
+
return { text: text.indexOf("&") === -1 ? text : text.replace(HTML_CHAR_CODE_R, (f, i) => {
|
|
1669
|
+
if (i.startsWith("#x")) return String.fromCharCode(parseInt(i.slice(2), 16));
|
|
1670
|
+
if (i.startsWith("#")) return String.fromCharCode(parseInt(i.slice(1), 10));
|
|
1671
|
+
return namedCodesToUnicode[i] || f;
|
|
1672
|
+
}) };
|
|
1669
1673
|
},
|
|
1670
1674
|
_render(node) {
|
|
1671
1675
|
return node.text;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-C0u3WHrm.js";
|
|
2
|
-
import "./markdown-
|
|
3
|
-
import { r as useMarkdownContext } from "./index-
|
|
2
|
+
import "./markdown-B_VAQu_B.js";
|
|
3
|
+
import { r as useMarkdownContext } from "./index-Bp3XDFNZ.js";
|
|
4
4
|
//#region ../react-intlayer/dist/esm/markdown/MarkdownRendererPlugin.mjs
|
|
5
5
|
var MarkdownRendererPlugin = (props) => {
|
|
6
6
|
const { children, options, components } = props;
|
package/client/dist/index.html
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Intlayer Editor</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-Bp3XDFNZ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-C0u3WHrm.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-B4JcPOPd.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BkWmzJHO.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/react-BI_C_976.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/markdown-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/markdown-B_VAQu_B.js">
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-SO-phafd.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intlayer-editor",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Integrate the Intlayer visual editor into your Intlayer projects, enabling CMS-like content management with multilingual support.",
|
|
6
6
|
"keywords": [
|
|
@@ -93,19 +93,19 @@
|
|
|
93
93
|
"@fastify/formbody": "8.0.2",
|
|
94
94
|
"@fastify/helmet": "13.0.2",
|
|
95
95
|
"@fastify/static": "9.0.0",
|
|
96
|
-
"@intlayer/chokidar": "8.4.
|
|
97
|
-
"@intlayer/config": "8.4.
|
|
98
|
-
"@intlayer/unmerged-dictionaries-entry": "8.4.
|
|
96
|
+
"@intlayer/chokidar": "8.4.9",
|
|
97
|
+
"@intlayer/config": "8.4.9",
|
|
98
|
+
"@intlayer/unmerged-dictionaries-entry": "8.4.9",
|
|
99
99
|
"fastify": "5.8.2",
|
|
100
|
-
"fastify-intlayer": "8.4.
|
|
100
|
+
"fastify-intlayer": "8.4.9",
|
|
101
101
|
"mime": "4.1.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
|
-
"@intlayer/design-system": "8.4.
|
|
105
|
-
"@intlayer/editor-react": "8.4.
|
|
106
|
-
"@intlayer/types": "8.4.
|
|
104
|
+
"@intlayer/design-system": "8.4.9",
|
|
105
|
+
"@intlayer/editor-react": "8.4.9",
|
|
106
|
+
"@intlayer/types": "8.4.9",
|
|
107
107
|
"@tailwindcss/vite": "4.2.2",
|
|
108
|
-
"@tanstack/react-query": "5.
|
|
108
|
+
"@tanstack/react-query": "5.94.5",
|
|
109
109
|
"@types/node": "25.5.0",
|
|
110
110
|
"@types/react": "19.2.14",
|
|
111
111
|
"@types/react-dom": "19.2.3",
|
|
@@ -117,18 +117,18 @@
|
|
|
117
117
|
"framer-motion": "12.38.0",
|
|
118
118
|
"fuse.js": "7.1.0",
|
|
119
119
|
"globals": "17.4.0",
|
|
120
|
-
"intlayer": "8.4.
|
|
120
|
+
"intlayer": "8.4.9",
|
|
121
121
|
"lucide-react": "0.577.0",
|
|
122
122
|
"react": "19.2.4",
|
|
123
123
|
"react-dom": "19.2.4",
|
|
124
|
-
"react-intlayer": "8.4.
|
|
124
|
+
"react-intlayer": "8.4.9",
|
|
125
125
|
"react-router-dom": "7.13.1",
|
|
126
126
|
"tailwind-merge": "3.5.0",
|
|
127
127
|
"tailwindcss": "4.2.2",
|
|
128
128
|
"tsdown": "0.21.4",
|
|
129
129
|
"typescript": "5.9.3",
|
|
130
130
|
"vite": "8.0.1",
|
|
131
|
-
"vite-intlayer": "8.4.
|
|
131
|
+
"vite-intlayer": "8.4.9",
|
|
132
132
|
"vitest": "4.1.0"
|
|
133
133
|
},
|
|
134
134
|
"engines": {
|
|
@@ -3,8 +3,10 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
4
4
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
5
5
|
let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
|
|
6
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
6
7
|
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
7
8
|
let fastify_intlayer = require("fastify-intlayer");
|
|
9
|
+
let path = require("path");
|
|
8
10
|
|
|
9
11
|
//#region src/controllers/dictionary.controller.ts
|
|
10
12
|
/**
|
|
@@ -36,7 +38,9 @@ const getDictionaries = async (_req, res) => {
|
|
|
36
38
|
const writeContentDeclaration = async (req, res) => {
|
|
37
39
|
try {
|
|
38
40
|
const dictionaryData = req.body.dictionary;
|
|
39
|
-
const
|
|
41
|
+
const config = (0, _intlayer_config_node.getConfiguration)();
|
|
42
|
+
const result = await (0, _intlayer_chokidar_build.writeContentDeclaration)(dictionaryData, config);
|
|
43
|
+
(0, _intlayer_config_utils.clearModuleCache)((0, path.join)(config.system.mainDir, `unmerged_dictionaries.cjs`));
|
|
40
44
|
let description = "";
|
|
41
45
|
switch (result.status) {
|
|
42
46
|
case "created":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.cjs","names":["formatResponse"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { t } from 'fastify-intlayer';\n\nexport type GetEditorDictionariesResult = ResponseData<UnmergedDictionaries>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getDictionaries = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const formattedResponse = formatResponse<UnmergedDictionaries>({\n data: getUnmergedDictionaries(),\n });\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n const formattedErrorResponse = formatResponse<UnmergedDictionaries>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n\nexport type WriteContentDeclarationBody = { dictionary: Dictionary };\ntype WriteContentDeclarationResultData = {\n status: DictionaryStatus;\n path: string;\n};\nexport type WriteContentDeclarationResult =\n ResponseData<WriteContentDeclarationResultData>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const writeContentDeclaration = async (\n req: FastifyRequest<{ Body: WriteContentDeclarationBody }>,\n res: FastifyReply\n): Promise<void> => {\n try {\n const dictionaryData = req.body.dictionary;\n\n const config = getConfiguration();\n\n const result = await writeContentDeclarationEditor(dictionaryData, config);\n\n let description = '';\n\n switch (result.status) {\n case 'created': {\n description = t({\n en: 'Content declaration created successfully',\n fr: 'Déclaration de contenu créée avec succès',\n es: 'Declaración de contenido creada con éxito',\n });\n break;\n }\n\n case 'updated': {\n description = t({\n en: 'Content declaration updated successfully',\n fr: 'Déclaration de contenu mise à jour avec succès',\n es: 'Declaración de contenido actualizada con éxito',\n });\n break;\n }\n case 'reimported in JSON': {\n description = t({\n en: 'Content declaration reimported in JSON successfully',\n fr: 'Déclaration de contenu réimportée en JSON avec succès',\n es: 'Declaración de contenido reimportada en JSON con éxito',\n });\n break;\n }\n case 'new content file': {\n description = t({\n en: 'Content declaration new content file successfully',\n fr: 'Déclaration de contenu réimportée dans un nouveau emplacement avec succès',\n es: 'Declaración de contenido reimportada en un nuevo lugar con éxito',\n });\n break;\n }\n default: {\n description = t({\n en: 'Content declaration written successfully',\n fr: 'Déclaration de contenu écrite avec succès',\n es: 'Declaración de contenido escrita con éxito',\n });\n break;\n }\n }\n\n const formattedResponse = formatResponse<WriteContentDeclarationResultData>(\n {\n data: result,\n message: t({\n en: 'Content declaration written',\n fr: 'Déclaration de contenu écrite',\n es: 'Declaración de contenido escrita',\n }),\n description,\n }\n );\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n console.error(errorMessage);\n\n const formattedErrorResponse =\n formatResponse<WriteContentDeclarationResultData>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dictionary.controller.cjs","names":["formatResponse"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { t } from 'fastify-intlayer';\nimport { join } from 'path';\n\nexport type GetEditorDictionariesResult = ResponseData<UnmergedDictionaries>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getDictionaries = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const formattedResponse = formatResponse<UnmergedDictionaries>({\n data: getUnmergedDictionaries(),\n });\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n const formattedErrorResponse = formatResponse<UnmergedDictionaries>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n\nexport type WriteContentDeclarationBody = { dictionary: Dictionary };\ntype WriteContentDeclarationResultData = {\n status: DictionaryStatus;\n path: string;\n};\nexport type WriteContentDeclarationResult =\n ResponseData<WriteContentDeclarationResultData>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const writeContentDeclaration = async (\n req: FastifyRequest<{ Body: WriteContentDeclarationBody }>,\n res: FastifyReply\n): Promise<void> => {\n try {\n const dictionaryData = req.body.dictionary;\n\n const config = getConfiguration();\n\n const result = await writeContentDeclarationEditor(dictionaryData, config);\n\n // Clear cache to hot reload the dictionaries\n const dictionariesPath = join(\n config.system.mainDir,\n `unmerged_dictionaries.cjs`\n );\n clearModuleCache(dictionariesPath);\n\n let description = '';\n\n switch (result.status) {\n case 'created': {\n description = t({\n en: 'Content declaration created successfully',\n fr: 'Déclaration de contenu créée avec succès',\n es: 'Declaración de contenido creada con éxito',\n });\n break;\n }\n\n case 'updated': {\n description = t({\n en: 'Content declaration updated successfully',\n fr: 'Déclaration de contenu mise à jour avec succès',\n es: 'Declaración de contenido actualizada con éxito',\n });\n break;\n }\n case 'reimported in JSON': {\n description = t({\n en: 'Content declaration reimported in JSON successfully',\n fr: 'Déclaration de contenu réimportée en JSON avec succès',\n es: 'Declaración de contenido reimportada en JSON con éxito',\n });\n break;\n }\n case 'new content file': {\n description = t({\n en: 'Content declaration new content file successfully',\n fr: 'Déclaration de contenu réimportée dans un nouveau emplacement avec succès',\n es: 'Declaración de contenido reimportada en un nuevo lugar con éxito',\n });\n break;\n }\n default: {\n description = t({\n en: 'Content declaration written successfully',\n fr: 'Déclaration de contenu écrite avec succès',\n es: 'Declaración de contenido escrita con éxito',\n });\n break;\n }\n }\n\n const formattedResponse = formatResponse<WriteContentDeclarationResultData>(\n {\n data: result,\n message: t({\n en: 'Content declaration written',\n fr: 'Déclaration de contenu écrite',\n es: 'Declaración de contenido escrita',\n }),\n description,\n }\n );\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n console.error(errorMessage);\n\n const formattedErrorResponse =\n formatResponse<WriteContentDeclarationResultData>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,MACA,QACkB;AAClB,KAAI;EACF,MAAM,oBAAoBA,0CAAqC,EAC7D,0EAA+B,EAChC,CAAC;AAEF,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;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responseData.mjs";
|
|
2
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
3
|
import { writeContentDeclaration as writeContentDeclaration$1 } from "@intlayer/chokidar/build";
|
|
4
|
+
import { clearModuleCache } from "@intlayer/config/utils";
|
|
4
5
|
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
5
6
|
import { t } from "fastify-intlayer";
|
|
7
|
+
import { join } from "path";
|
|
6
8
|
|
|
7
9
|
//#region src/controllers/dictionary.controller.ts
|
|
8
10
|
/**
|
|
@@ -34,7 +36,9 @@ const getDictionaries = async (_req, res) => {
|
|
|
34
36
|
const writeContentDeclaration = async (req, res) => {
|
|
35
37
|
try {
|
|
36
38
|
const dictionaryData = req.body.dictionary;
|
|
37
|
-
const
|
|
39
|
+
const config = getConfiguration();
|
|
40
|
+
const result = await writeContentDeclaration$1(dictionaryData, config);
|
|
41
|
+
clearModuleCache(join(config.system.mainDir, `unmerged_dictionaries.cjs`));
|
|
38
42
|
let description = "";
|
|
39
43
|
switch (result.status) {
|
|
40
44
|
case "created":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { t } from 'fastify-intlayer';\n\nexport type GetEditorDictionariesResult = ResponseData<UnmergedDictionaries>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getDictionaries = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const formattedResponse = formatResponse<UnmergedDictionaries>({\n data: getUnmergedDictionaries(),\n });\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n const formattedErrorResponse = formatResponse<UnmergedDictionaries>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n\nexport type WriteContentDeclarationBody = { dictionary: Dictionary };\ntype WriteContentDeclarationResultData = {\n status: DictionaryStatus;\n path: string;\n};\nexport type WriteContentDeclarationResult =\n ResponseData<WriteContentDeclarationResultData>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const writeContentDeclaration = async (\n req: FastifyRequest<{ Body: WriteContentDeclarationBody }>,\n res: FastifyReply\n): Promise<void> => {\n try {\n const dictionaryData = req.body.dictionary;\n\n const config = getConfiguration();\n\n const result = await writeContentDeclarationEditor(dictionaryData, config);\n\n let description = '';\n\n switch (result.status) {\n case 'created': {\n description = t({\n en: 'Content declaration created successfully',\n fr: 'Déclaration de contenu créée avec succès',\n es: 'Declaración de contenido creada con éxito',\n });\n break;\n }\n\n case 'updated': {\n description = t({\n en: 'Content declaration updated successfully',\n fr: 'Déclaration de contenu mise à jour avec succès',\n es: 'Declaración de contenido actualizada con éxito',\n });\n break;\n }\n case 'reimported in JSON': {\n description = t({\n en: 'Content declaration reimported in JSON successfully',\n fr: 'Déclaration de contenu réimportée en JSON avec succès',\n es: 'Declaración de contenido reimportada en JSON con éxito',\n });\n break;\n }\n case 'new content file': {\n description = t({\n en: 'Content declaration new content file successfully',\n fr: 'Déclaration de contenu réimportée dans un nouveau emplacement avec succès',\n es: 'Declaración de contenido reimportada en un nuevo lugar con éxito',\n });\n break;\n }\n default: {\n description = t({\n en: 'Content declaration written successfully',\n fr: 'Déclaration de contenu écrite avec succès',\n es: 'Declaración de contenido escrita con éxito',\n });\n break;\n }\n }\n\n const formattedResponse = formatResponse<WriteContentDeclarationResultData>(\n {\n data: result,\n message: t({\n en: 'Content declaration written',\n fr: 'Déclaration de contenu écrite',\n es: 'Declaración de contenido escrita',\n }),\n description,\n }\n );\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n console.error(errorMessage);\n\n const formattedErrorResponse =\n formatResponse<WriteContentDeclarationResultData>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/unmerged-dictionaries-entry';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { t } from 'fastify-intlayer';\nimport { join } from 'path';\n\nexport type GetEditorDictionariesResult = ResponseData<UnmergedDictionaries>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getDictionaries = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const formattedResponse = formatResponse<UnmergedDictionaries>({\n data: getUnmergedDictionaries(),\n });\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n const formattedErrorResponse = formatResponse<UnmergedDictionaries>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n\nexport type WriteContentDeclarationBody = { dictionary: Dictionary };\ntype WriteContentDeclarationResultData = {\n status: DictionaryStatus;\n path: string;\n};\nexport type WriteContentDeclarationResult =\n ResponseData<WriteContentDeclarationResultData>;\n\n/**\n * Adds a new dictionary to the database.\n */\nexport const writeContentDeclaration = async (\n req: FastifyRequest<{ Body: WriteContentDeclarationBody }>,\n res: FastifyReply\n): Promise<void> => {\n try {\n const dictionaryData = req.body.dictionary;\n\n const config = getConfiguration();\n\n const result = await writeContentDeclarationEditor(dictionaryData, config);\n\n // Clear cache to hot reload the dictionaries\n const dictionariesPath = join(\n config.system.mainDir,\n `unmerged_dictionaries.cjs`\n );\n clearModuleCache(dictionariesPath);\n\n let description = '';\n\n switch (result.status) {\n case 'created': {\n description = t({\n en: 'Content declaration created successfully',\n fr: 'Déclaration de contenu créée avec succès',\n es: 'Declaración de contenido creada con éxito',\n });\n break;\n }\n\n case 'updated': {\n description = t({\n en: 'Content declaration updated successfully',\n fr: 'Déclaration de contenu mise à jour avec succès',\n es: 'Declaración de contenido actualizada con éxito',\n });\n break;\n }\n case 'reimported in JSON': {\n description = t({\n en: 'Content declaration reimported in JSON successfully',\n fr: 'Déclaration de contenu réimportée en JSON avec succès',\n es: 'Declaración de contenido reimportada en JSON con éxito',\n });\n break;\n }\n case 'new content file': {\n description = t({\n en: 'Content declaration new content file successfully',\n fr: 'Déclaration de contenu réimportée dans un nouveau emplacement avec succès',\n es: 'Declaración de contenido reimportada en un nuevo lugar con éxito',\n });\n break;\n }\n default: {\n description = t({\n en: 'Content declaration written successfully',\n fr: 'Déclaration de contenu écrite avec succès',\n es: 'Declaración de contenido escrita con éxito',\n });\n break;\n }\n }\n\n const formattedResponse = formatResponse<WriteContentDeclarationResultData>(\n {\n data: result,\n message: t({\n en: 'Content declaration written',\n fr: 'Déclaration de contenu écrite',\n es: 'Declaración de contenido escrita',\n }),\n description,\n }\n );\n\n return res.send(formattedResponse);\n } catch (err) {\n const errorMessage = (err as { message?: string; status?: number }) ?? {\n message: 'Internal Server Error',\n status: 500,\n };\n\n console.error(errorMessage);\n\n const formattedErrorResponse =\n formatResponse<WriteContentDeclarationResultData>({\n error: {\n message: errorMessage.message ?? 'Internal Server Error',\n code: 'INTERNAL_SERVER_ERROR',\n title: 'Internal Server Error',\n },\n status: errorMessage.status ?? 500,\n });\n\n return res.send(formattedErrorResponse);\n }\n};\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,kBAAkB,OAC7B,MACA,QACkB;AAClB,KAAI;EACF,MAAM,oBAAoB,eAAqC,EAC7D,MAAM,yBAAyB,EAChC,CAAC;AAEF,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;EAED,MAAM,yBAAyB,eAAqC;GAClE,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEF,SAAO,IAAI,KAAK,uBAAuB;;;;;;AAe3C,MAAa,0BAA0B,OACrC,KACA,QACkB;AAClB,KAAI;EACF,MAAM,iBAAiB,IAAI,KAAK;EAEhC,MAAM,SAAS,kBAAkB;EAEjC,MAAM,SAAS,MAAMA,0BAA8B,gBAAgB,OAAO;AAO1E,mBAJyB,KACvB,OAAO,OAAO,SACd,4BACD,CACiC;EAElC,IAAI,cAAc;AAElB,UAAQ,OAAO,QAAf;GACE,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAGF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;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