intlayer-editor 8.4.3 → 8.4.5
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-BK4mShNB.js +121 -0
- package/client/dist/assets/{bundle-web-C53U69TC.js → bundle-web-MVlAwHWN.js} +1 -1
- package/client/dist/assets/{index-CutqtHet.js → index-C0bpNoe3.js} +15899 -8917
- package/client/dist/index.html +1 -1
- package/package.json +11 -11
- package/server/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/server/dist/controllers/configuration.controller.cjs +32 -1
- package/server/dist/controllers/configuration.controller.cjs.map +1 -1
- package/server/dist/controllers/configuration.controller.d.ts +1 -1
- package/server/dist/controllers/configuration.controller.mjs +30 -1
- package/server/dist/controllers/configuration.controller.mjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.cjs +108 -1
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.d.ts +1 -1
- package/server/dist/controllers/dictionary.controller.mjs +105 -1
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
- package/server/dist/export.cjs +7 -1
- package/server/dist/export.mjs +4 -1
- package/server/dist/index.cjs +100 -7
- package/server/dist/index.cjs.map +1 -1
- package/server/dist/index.mjs +90 -7
- package/server/dist/index.mjs.map +1 -1
- package/server/dist/routes/config.routes.cjs +20 -1
- package/server/dist/routes/config.routes.cjs.map +1 -1
- package/server/dist/routes/config.routes.mjs +17 -1
- package/server/dist/routes/config.routes.mjs.map +1 -1
- package/server/dist/routes/dictionary.routes.cjs +28 -1
- package/server/dist/routes/dictionary.routes.cjs.map +1 -1
- package/server/dist/routes/dictionary.routes.mjs +25 -1
- package/server/dist/routes/dictionary.routes.mjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.cjs +24 -1
- package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.mjs +20 -1
- package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.cjs +401 -1
- package/server/dist/utils/httpStatusCodes.cjs.map +1 -1
- package/server/dist/utils/httpStatusCodes.d.ts +407 -2
- package/server/dist/utils/httpStatusCodes.mjs +399 -1
- package/server/dist/utils/httpStatusCodes.mjs.map +1 -1
- package/server/dist/utils/responseData.cjs +33 -1
- package/server/dist/utils/responseData.cjs.map +1 -1
- package/server/dist/utils/responseData.d.ts +87 -2
- package/server/dist/utils/responseData.mjs +31 -1
- package/server/dist/utils/responseData.mjs.map +1 -1
- package/client/dist/assets/CodeBlockShiki-B3siK5AS.js +0 -105
package/client/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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-C0bpNoe3.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-C0u3WHrm.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/react-BI_C_976.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-D6NEtBOG.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intlayer-editor",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.5",
|
|
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,17 +93,17 @@
|
|
|
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.5",
|
|
97
|
+
"@intlayer/config": "8.4.5",
|
|
98
|
+
"@intlayer/unmerged-dictionaries-entry": "8.4.5",
|
|
99
99
|
"fastify": "5.8.2",
|
|
100
|
-
"fastify-intlayer": "8.4.
|
|
100
|
+
"fastify-intlayer": "8.4.5",
|
|
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.5",
|
|
105
|
+
"@intlayer/editor-react": "8.4.5",
|
|
106
|
+
"@intlayer/types": "8.4.5",
|
|
107
107
|
"@tailwindcss/vite": "4.2.1",
|
|
108
108
|
"@tanstack/react-query": "5.91.0",
|
|
109
109
|
"@types/node": "25.5.0",
|
|
@@ -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.5",
|
|
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.5",
|
|
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.0",
|
|
131
|
-
"vite-intlayer": "8.4.
|
|
131
|
+
"vite-intlayer": "8.4.5",
|
|
132
132
|
"vitest": "4.1.0"
|
|
133
133
|
},
|
|
134
134
|
"engines": {
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1,2 +1,33 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
4
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
5
|
+
|
|
6
|
+
//#region src/controllers/configuration.controller.ts
|
|
7
|
+
/**
|
|
8
|
+
* Get the Intlayer configuration
|
|
9
|
+
*/
|
|
10
|
+
const getConfiguration = async (_req, res) => {
|
|
11
|
+
try {
|
|
12
|
+
const formattedResponse = require_utils_responseData.formatResponse({ data: (0, _intlayer_config_node.getConfiguration)() });
|
|
13
|
+
return res.send(formattedResponse);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
const errorMessage = err ?? {
|
|
16
|
+
message: "Internal Server Error",
|
|
17
|
+
status: 500
|
|
18
|
+
};
|
|
19
|
+
const formattedErrorResponse = require_utils_responseData.formatResponse({
|
|
20
|
+
error: {
|
|
21
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
22
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
23
|
+
title: "Internal Server Error"
|
|
24
|
+
},
|
|
25
|
+
status: errorMessage.status ?? 500
|
|
26
|
+
});
|
|
27
|
+
return res.send(formattedErrorResponse);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.getConfiguration = getConfiguration;
|
|
2
33
|
//# sourceMappingURL=configuration.controller.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.controller.cjs","names":["formatResponse"],"sources":["../../src/controllers/configuration.controller.ts"],"sourcesContent":["import { getConfiguration as getApplicationConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n\nexport type GetConfigurationResult = ResponseData<IntlayerConfig>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getConfiguration = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const config = getApplicationConfiguration();\n\n const formattedResponse = formatResponse<IntlayerConfig>({\n data: config,\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<IntlayerConfig>({\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":"configuration.controller.cjs","names":["formatResponse"],"sources":["../../src/controllers/configuration.controller.ts"],"sourcesContent":["import { getConfiguration as getApplicationConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n\nexport type GetConfigurationResult = ResponseData<IntlayerConfig>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getConfiguration = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const config = getApplicationConfiguration();\n\n const formattedResponse = formatResponse<IntlayerConfig>({\n data: config,\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<IntlayerConfig>({\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":";;;;;;;;;AAUA,MAAa,mBAAmB,OAC9B,MACA,QACkB;AAClB,KAAI;EAGF,MAAM,oBAAoBA,0CAA+B,EACvD,mDAH0C,EAI3C,CAAC;AAEF,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;EAED,MAAM,yBAAyBA,0CAA+B;GAC5D,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEF,SAAO,IAAI,KAAK,uBAAuB"}
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
import{formatResponse
|
|
1
|
+
import { formatResponse } from "../utils/responseData.mjs";
|
|
2
|
+
import { getConfiguration as getConfiguration$1 } from "@intlayer/config/node";
|
|
3
|
+
|
|
4
|
+
//#region src/controllers/configuration.controller.ts
|
|
5
|
+
/**
|
|
6
|
+
* Get the Intlayer configuration
|
|
7
|
+
*/
|
|
8
|
+
const getConfiguration = async (_req, res) => {
|
|
9
|
+
try {
|
|
10
|
+
const formattedResponse = formatResponse({ data: getConfiguration$1() });
|
|
11
|
+
return res.send(formattedResponse);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
const errorMessage = err ?? {
|
|
14
|
+
message: "Internal Server Error",
|
|
15
|
+
status: 500
|
|
16
|
+
};
|
|
17
|
+
const formattedErrorResponse = formatResponse({
|
|
18
|
+
error: {
|
|
19
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
20
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
21
|
+
title: "Internal Server Error"
|
|
22
|
+
},
|
|
23
|
+
status: errorMessage.status ?? 500
|
|
24
|
+
});
|
|
25
|
+
return res.send(formattedErrorResponse);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getConfiguration };
|
|
2
31
|
//# sourceMappingURL=configuration.controller.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.controller.mjs","names":["getApplicationConfiguration"],"sources":["../../src/controllers/configuration.controller.ts"],"sourcesContent":["import { getConfiguration as getApplicationConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n\nexport type GetConfigurationResult = ResponseData<IntlayerConfig>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getConfiguration = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const config = getApplicationConfiguration();\n\n const formattedResponse = formatResponse<IntlayerConfig>({\n data: config,\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<IntlayerConfig>({\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":"configuration.controller.mjs","names":["getApplicationConfiguration"],"sources":["../../src/controllers/configuration.controller.ts"],"sourcesContent":["import { getConfiguration as getApplicationConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { formatResponse, type ResponseData } from '@utils/responseData';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\n\nexport type GetConfigurationResult = ResponseData<IntlayerConfig>;\n\n/**\n * Get the Intlayer configuration\n */\nexport const getConfiguration = async (\n _req: FastifyRequest,\n res: FastifyReply\n): Promise<void> => {\n try {\n const config = getApplicationConfiguration();\n\n const formattedResponse = formatResponse<IntlayerConfig>({\n data: config,\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<IntlayerConfig>({\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":";;;;;;;AAUA,MAAa,mBAAmB,OAC9B,MACA,QACkB;AAClB,KAAI;EAGF,MAAM,oBAAoB,eAA+B,EACvD,MAHaA,oBAA6B,EAI3C,CAAC;AAEF,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;EAED,MAAM,yBAAyB,eAA+B;GAC5D,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEF,SAAO,IAAI,KAAK,uBAAuB"}
|
|
@@ -1,2 +1,109 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_utils_responseData = require('../utils/responseData.cjs');
|
|
4
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
5
|
+
let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
|
|
6
|
+
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
7
|
+
let fastify_intlayer = require("fastify-intlayer");
|
|
8
|
+
|
|
9
|
+
//#region src/controllers/dictionary.controller.ts
|
|
10
|
+
/**
|
|
11
|
+
* Get the Intlayer configuration
|
|
12
|
+
*/
|
|
13
|
+
const getDictionaries = async (_req, res) => {
|
|
14
|
+
try {
|
|
15
|
+
const formattedResponse = require_utils_responseData.formatResponse({ data: (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)() });
|
|
16
|
+
return res.send(formattedResponse);
|
|
17
|
+
} catch (err) {
|
|
18
|
+
const errorMessage = err ?? {
|
|
19
|
+
message: "Internal Server Error",
|
|
20
|
+
status: 500
|
|
21
|
+
};
|
|
22
|
+
const formattedErrorResponse = require_utils_responseData.formatResponse({
|
|
23
|
+
error: {
|
|
24
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
25
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
26
|
+
title: "Internal Server Error"
|
|
27
|
+
},
|
|
28
|
+
status: errorMessage.status ?? 500
|
|
29
|
+
});
|
|
30
|
+
return res.send(formattedErrorResponse);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Adds a new dictionary to the database.
|
|
35
|
+
*/
|
|
36
|
+
const writeContentDeclaration = async (req, res) => {
|
|
37
|
+
try {
|
|
38
|
+
const dictionaryData = req.body.dictionary;
|
|
39
|
+
const result = await (0, _intlayer_chokidar_build.writeContentDeclaration)(dictionaryData, (0, _intlayer_config_node.getConfiguration)());
|
|
40
|
+
let description = "";
|
|
41
|
+
switch (result.status) {
|
|
42
|
+
case "created":
|
|
43
|
+
description = (0, fastify_intlayer.t)({
|
|
44
|
+
en: "Content declaration created successfully",
|
|
45
|
+
fr: "Déclaration de contenu créée avec succès",
|
|
46
|
+
es: "Declaración de contenido creada con éxito"
|
|
47
|
+
});
|
|
48
|
+
break;
|
|
49
|
+
case "updated":
|
|
50
|
+
description = (0, fastify_intlayer.t)({
|
|
51
|
+
en: "Content declaration updated successfully",
|
|
52
|
+
fr: "Déclaration de contenu mise à jour avec succès",
|
|
53
|
+
es: "Declaración de contenido actualizada con éxito"
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
case "reimported in JSON":
|
|
57
|
+
description = (0, fastify_intlayer.t)({
|
|
58
|
+
en: "Content declaration reimported in JSON successfully",
|
|
59
|
+
fr: "Déclaration de contenu réimportée en JSON avec succès",
|
|
60
|
+
es: "Declaración de contenido reimportada en JSON con éxito"
|
|
61
|
+
});
|
|
62
|
+
break;
|
|
63
|
+
case "new content file":
|
|
64
|
+
description = (0, fastify_intlayer.t)({
|
|
65
|
+
en: "Content declaration new content file successfully",
|
|
66
|
+
fr: "Déclaration de contenu réimportée dans un nouveau emplacement avec succès",
|
|
67
|
+
es: "Declaración de contenido reimportada en un nuevo lugar con éxito"
|
|
68
|
+
});
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
description = (0, fastify_intlayer.t)({
|
|
72
|
+
en: "Content declaration written successfully",
|
|
73
|
+
fr: "Déclaration de contenu écrite avec succès",
|
|
74
|
+
es: "Declaración de contenido escrita con éxito"
|
|
75
|
+
});
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
const formattedResponse = require_utils_responseData.formatResponse({
|
|
79
|
+
data: result,
|
|
80
|
+
message: (0, fastify_intlayer.t)({
|
|
81
|
+
en: "Content declaration written",
|
|
82
|
+
fr: "Déclaration de contenu écrite",
|
|
83
|
+
es: "Declaración de contenido escrita"
|
|
84
|
+
}),
|
|
85
|
+
description
|
|
86
|
+
});
|
|
87
|
+
return res.send(formattedResponse);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const errorMessage = err ?? {
|
|
90
|
+
message: "Internal Server Error",
|
|
91
|
+
status: 500
|
|
92
|
+
};
|
|
93
|
+
console.error(errorMessage);
|
|
94
|
+
const formattedErrorResponse = require_utils_responseData.formatResponse({
|
|
95
|
+
error: {
|
|
96
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
97
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
98
|
+
title: "Internal Server Error"
|
|
99
|
+
},
|
|
100
|
+
status: errorMessage.status ?? 500
|
|
101
|
+
});
|
|
102
|
+
return res.send(formattedErrorResponse);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.getDictionaries = getDictionaries;
|
|
108
|
+
exports.writeContentDeclaration = writeContentDeclaration;
|
|
2
109
|
//# sourceMappingURL=dictionary.controller.cjs.map
|
|
@@ -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 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":";;;;;;;;;;;;AAmBA,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;GACT;EAED,MAAM,yBAAyBA,0CAAqC;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;EAIhC,MAAM,SAAS,4DAAoC,6DAFlB,CAEyC;EAE1E,IAAI,cAAc;AAElB,UAAQ,OAAO,QAAf;GACE,KAAK;AACH,0CAAgB;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAGF,KAAK;AACH,0CAAgB;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF,KAAK;AACH,0CAAgB;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF,KAAK;AACH,0CAAgB;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF;AACE,0CAAgB;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;;EAIJ,MAAM,oBAAoBA,0CACxB;GACE,MAAM;GACN,iCAAW;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;IACL,CAAC;GACF;GACD,CACF;AAED,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;AAED,UAAQ,MAAM,aAAa;EAE3B,MAAM,yBACJA,0CAAkD;GAChD,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEJ,SAAO,IAAI,KAAK,uBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResponseData } from "../utils/responseData.js";
|
|
2
2
|
import { FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
import { DictionaryStatus } from "@intlayer/chokidar/build";
|
|
4
4
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
@@ -1,2 +1,106 @@
|
|
|
1
|
-
import{formatResponse
|
|
1
|
+
import { formatResponse } from "../utils/responseData.mjs";
|
|
2
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
+
import { writeContentDeclaration as writeContentDeclaration$1 } from "@intlayer/chokidar/build";
|
|
4
|
+
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";
|
|
5
|
+
import { t } from "fastify-intlayer";
|
|
6
|
+
|
|
7
|
+
//#region src/controllers/dictionary.controller.ts
|
|
8
|
+
/**
|
|
9
|
+
* Get the Intlayer configuration
|
|
10
|
+
*/
|
|
11
|
+
const getDictionaries = async (_req, res) => {
|
|
12
|
+
try {
|
|
13
|
+
const formattedResponse = formatResponse({ data: getUnmergedDictionaries() });
|
|
14
|
+
return res.send(formattedResponse);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
const errorMessage = err ?? {
|
|
17
|
+
message: "Internal Server Error",
|
|
18
|
+
status: 500
|
|
19
|
+
};
|
|
20
|
+
const formattedErrorResponse = formatResponse({
|
|
21
|
+
error: {
|
|
22
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
23
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
24
|
+
title: "Internal Server Error"
|
|
25
|
+
},
|
|
26
|
+
status: errorMessage.status ?? 500
|
|
27
|
+
});
|
|
28
|
+
return res.send(formattedErrorResponse);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Adds a new dictionary to the database.
|
|
33
|
+
*/
|
|
34
|
+
const writeContentDeclaration = async (req, res) => {
|
|
35
|
+
try {
|
|
36
|
+
const dictionaryData = req.body.dictionary;
|
|
37
|
+
const result = await writeContentDeclaration$1(dictionaryData, getConfiguration());
|
|
38
|
+
let description = "";
|
|
39
|
+
switch (result.status) {
|
|
40
|
+
case "created":
|
|
41
|
+
description = t({
|
|
42
|
+
en: "Content declaration created successfully",
|
|
43
|
+
fr: "Déclaration de contenu créée avec succès",
|
|
44
|
+
es: "Declaración de contenido creada con éxito"
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
case "updated":
|
|
48
|
+
description = t({
|
|
49
|
+
en: "Content declaration updated successfully",
|
|
50
|
+
fr: "Déclaration de contenu mise à jour avec succès",
|
|
51
|
+
es: "Declaración de contenido actualizada con éxito"
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
case "reimported in JSON":
|
|
55
|
+
description = t({
|
|
56
|
+
en: "Content declaration reimported in JSON successfully",
|
|
57
|
+
fr: "Déclaration de contenu réimportée en JSON avec succès",
|
|
58
|
+
es: "Declaración de contenido reimportada en JSON con éxito"
|
|
59
|
+
});
|
|
60
|
+
break;
|
|
61
|
+
case "new content file":
|
|
62
|
+
description = t({
|
|
63
|
+
en: "Content declaration new content file successfully",
|
|
64
|
+
fr: "Déclaration de contenu réimportée dans un nouveau emplacement avec succès",
|
|
65
|
+
es: "Declaración de contenido reimportada en un nuevo lugar con éxito"
|
|
66
|
+
});
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
description = t({
|
|
70
|
+
en: "Content declaration written successfully",
|
|
71
|
+
fr: "Déclaration de contenu écrite avec succès",
|
|
72
|
+
es: "Declaración de contenido escrita con éxito"
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const formattedResponse = formatResponse({
|
|
77
|
+
data: result,
|
|
78
|
+
message: t({
|
|
79
|
+
en: "Content declaration written",
|
|
80
|
+
fr: "Déclaration de contenu écrite",
|
|
81
|
+
es: "Declaración de contenido escrita"
|
|
82
|
+
}),
|
|
83
|
+
description
|
|
84
|
+
});
|
|
85
|
+
return res.send(formattedResponse);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
const errorMessage = err ?? {
|
|
88
|
+
message: "Internal Server Error",
|
|
89
|
+
status: 500
|
|
90
|
+
};
|
|
91
|
+
console.error(errorMessage);
|
|
92
|
+
const formattedErrorResponse = formatResponse({
|
|
93
|
+
error: {
|
|
94
|
+
message: errorMessage.message ?? "Internal Server Error",
|
|
95
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
96
|
+
title: "Internal Server Error"
|
|
97
|
+
},
|
|
98
|
+
status: errorMessage.status ?? 500
|
|
99
|
+
});
|
|
100
|
+
return res.send(formattedErrorResponse);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
export { getDictionaries, writeContentDeclaration };
|
|
2
106
|
//# sourceMappingURL=dictionary.controller.mjs.map
|
|
@@ -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 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":";;;;;;;;;;AAmBA,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;EAIhC,MAAM,SAAS,MAAMA,0BAA8B,gBAFpC,kBAAkB,CAEyC;EAE1E,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;KACL,CAAC;AACF;GAEF,KAAK;AACH,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;GAEF;AACE,kBAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;KACL,CAAC;AACF;;EAIJ,MAAM,oBAAoB,eACxB;GACE,MAAM;GACN,SAAS,EAAE;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;IACL,CAAC;GACF;GACD,CACF;AAED,SAAO,IAAI,KAAK,kBAAkB;UAC3B,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;GACT;AAED,UAAQ,MAAM,aAAa;EAE3B,MAAM,yBACJ,eAAkD;GAChD,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;IACR;GACD,QAAQ,aAAa,UAAU;GAChC,CAAC;AAEJ,SAAO,IAAI,KAAK,uBAAuB"}
|
package/server/dist/export.cjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_controllers_configuration_controller = require('./controllers/configuration.controller.cjs');
|
|
3
|
+
const require_controllers_dictionary_controller = require('./controllers/dictionary.controller.cjs');
|
|
4
|
+
|
|
5
|
+
exports.getConfiguration = require_controllers_configuration_controller.getConfiguration;
|
|
6
|
+
exports.getDictionaries = require_controllers_dictionary_controller.getDictionaries;
|
|
7
|
+
exports.writeContentDeclaration = require_controllers_dictionary_controller.writeContentDeclaration;
|
package/server/dist/export.mjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{getConfiguration
|
|
1
|
+
import { getConfiguration } from "./controllers/configuration.controller.mjs";
|
|
2
|
+
import { getDictionaries, writeContentDeclaration } from "./controllers/dictionary.controller.mjs";
|
|
3
|
+
|
|
4
|
+
export { getConfiguration, getDictionaries, writeContentDeclaration };
|