intlayer-editor 9.5.12 → 9.7.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/bin/intlayer-editor.mjs +26 -6
- package/client/dist/assets/CodeBlockShiki-B-OcGOY1.js +2 -0
- package/client/dist/assets/MarkDownRender-BzY_8i9Z.js +1 -0
- package/client/dist/assets/MarkDownRender-CIkPpFUW.js +25 -0
- package/client/dist/assets/MarkdownEditor-BpbsoP4E.js +161 -0
- package/client/dist/assets/{astro-JHDYjn39.js → astro-BZ97kZFP.js} +1 -1
- package/client/dist/assets/codeTransformer-aP9a_qk2.js +9 -0
- package/client/dist/assets/compat-r4Owm_RW.js +1 -0
- package/client/dist/assets/css-BGIxQoYs.js +1 -0
- package/client/dist/assets/css-DUjzNfgv.js +1 -0
- package/client/dist/assets/dist-DRjLHkdX.js +11 -0
- package/client/dist/assets/extractUrlFromSitemap-Chj1JVpo.js +1 -0
- package/client/dist/assets/{html-B2cKP6UN.js → html-DSw1lh5G.js} +1 -1
- package/client/dist/assets/html-WQKKblVZ.js +1 -0
- package/client/dist/assets/index-C5SpC4ap.css +2 -0
- package/client/dist/assets/index-CmQV7Z_A.js +105 -0
- package/client/dist/assets/shikiBundle-BIG1bVgc.js +12 -0
- package/client/dist/assets/{svelte-tEuLYt3E.js → svelte-CdeT-Ich.js} +1 -1
- package/client/dist/assets/{vue-Bg0byEaI.js → vue-BqdMUtqy.js} +1 -1
- package/client/dist/index.html +3 -6
- package/package.json +28 -28
- package/server/dist/controllers/auth.controller.cjs +80 -0
- package/server/dist/controllers/auth.controller.cjs.map +1 -0
- package/server/dist/controllers/auth.controller.d.ts +36 -0
- package/server/dist/controllers/auth.controller.mjs +76 -0
- package/server/dist/controllers/auth.controller.mjs.map +1 -0
- package/server/dist/controllers/configuration.controller.cjs +5 -1
- package/server/dist/controllers/configuration.controller.cjs.map +1 -1
- package/server/dist/controllers/configuration.controller.mjs +5 -1
- package/server/dist/controllers/configuration.controller.mjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.cjs +2 -1
- package/server/dist/controllers/dictionary.controller.cjs.map +1 -1
- package/server/dist/controllers/dictionary.controller.mjs +2 -1
- package/server/dist/controllers/dictionary.controller.mjs.map +1 -1
- package/server/dist/index.cjs +41 -13
- package/server/dist/index.cjs.map +1 -1
- package/server/dist/index.mjs +45 -17
- package/server/dist/index.mjs.map +1 -1
- package/server/dist/routes/auth.routes.cjs +35 -0
- package/server/dist/routes/auth.routes.cjs.map +1 -0
- package/server/dist/routes/auth.routes.d.ts +22 -0
- package/server/dist/routes/auth.routes.mjs +33 -0
- package/server/dist/routes/auth.routes.mjs.map +1 -0
- package/server/dist/services/editorAuth.service.cjs +143 -0
- package/server/dist/services/editorAuth.service.cjs.map +1 -0
- package/server/dist/services/editorAuth.service.d.ts +43 -0
- package/server/dist/services/editorAuth.service.mjs +137 -0
- package/server/dist/services/editorAuth.service.mjs.map +1 -0
- package/server/dist/utils/checkPortAvailability.cjs +38 -12
- package/server/dist/utils/checkPortAvailability.cjs.map +1 -1
- package/server/dist/utils/checkPortAvailability.d.ts +14 -1
- package/server/dist/utils/checkPortAvailability.mjs +38 -13
- package/server/dist/utils/checkPortAvailability.mjs.map +1 -1
- package/client/dist/assets/CodeBlockShiki-df1uxmSd.js +0 -2
- package/client/dist/assets/MarkDownRender-DYcnaCQP.js +0 -1
- package/client/dist/assets/MarkDownRender-MV3lk0jo.js +0 -25
- package/client/dist/assets/MarkdownEditor-CWVj-dFt.js +0 -160
- package/client/dist/assets/codeTransformer-DVPQQcdP.js +0 -9
- package/client/dist/assets/css-CdtkT07m.js +0 -1
- package/client/dist/assets/css-LbU1hoFO.js +0 -1
- package/client/dist/assets/dist-BHukwvnD.js +0 -11
- package/client/dist/assets/dist-CcmWBeAo.js +0 -1
- package/client/dist/assets/dynamic-OZWF58s3.js +0 -41
- package/client/dist/assets/html-DYtkB_T1.js +0 -1
- package/client/dist/assets/index-D82ZIHVs.css +0 -2
- package/client/dist/assets/index-DPHRjaWO.js +0 -59
- package/client/dist/assets/react-Cvdyeg_0.js +0 -1
- package/client/dist/assets/rolldown-runtime-hePW80VL.js +0 -1
- package/client/dist/assets/shikiBundle-C3MOPHUk.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.cjs","names":["formatResponse","getUnmergedDictionaries","getConfiguration","writeContentDeclarationEditor","join","t"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/dictionaries-entry/unmerged';\nimport {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/engine/build';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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 // 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":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dictionary.controller.cjs","names":["formatResponse","getUnmergedDictionaries","getConfiguration","writeContentDeclarationEditor","rebuildUnmergedDictionaries","join","t"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/dictionaries-entry/unmerged';\nimport {\n type DictionaryStatus,\n rebuildUnmergedDictionaries,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/engine/build';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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 // Rebuild the unmerged dictionaries before answering, so a read right\n // after the write returns the new content instead of waiting for the app\n // watcher. The write itself succeeded: a failed rebuild only delays it.\n if (result.status !== 'up-to-date') {\n await rebuildUnmergedDictionaries(result.path, config).catch((error) =>\n console.error(error)\n );\n }\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":";;;;;;;;;;;;;AAsBA,MAAa,kBAAkB,OAC7B,MACA,QACkB;CAClB,IAAI;EACF,MAAM,oBAAoBA,0CAAqC,EAC7D,UAAMC,+DAAwB,EAChC,CAAC;EAED,OAAO,IAAI,KAAK,iBAAiB;CACnC,SAAS,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;EACV;EAEA,MAAM,yBAAyBD,0CAAqC;GAClE,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;GACT;GACA,QAAQ,aAAa,UAAU;EACjC,CAAC;EAED,OAAO,IAAI,KAAK,sBAAsB;CACxC;AACF;;;;AAaA,MAAa,0BAA0B,OACrC,KACA,QACkB;CAClB,IAAI;EACF,MAAM,iBAAiB,IAAI,KAAK;EAEhC,MAAM,aAASE,wCAAiB;EAEhC,MAAM,SAAS,UAAMC,gDAA8B,gBAAgB,MAAM;EAKzE,IAAI,OAAO,WAAW,cACpB,UAAMC,oDAA4B,OAAO,MAAM,MAAM,CAAC,CAAC,OAAO,UAC5D,QAAQ,MAAM,KAAK,CACrB;EAIF,MAAM,uBAAmBC,gBACvB,OAAO,OAAO,SACd,2BACF;EACA,6CAAiB,gBAAgB;EAEjC,IAAI,cAAc;EAElB,QAAQ,OAAO,QAAf;GACE,KAAK;IACH,kBAAcC,oBAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAGF,KAAK;IACH,kBAAcA,oBAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,KAAK;IACH,kBAAcA,oBAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,KAAK;IACH,kBAAcA,oBAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,SACE,kBAAcA,oBAAE;IACd,IAAI;IACJ,IAAI;IACJ,IAAI;GACN,CAAC;EAGL;EAEA,MAAM,oBAAoBN,0CACxB;GACE,MAAM;GACN,aAASM,oBAAE;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;GACN,CAAC;GACD;EACF,CACF;EAEA,OAAO,IAAI,KAAK,iBAAiB;CACnC,SAAS,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;EACV;EAEA,QAAQ,MAAM,YAAY;EAE1B,MAAM,yBACJN,0CAAkD;GAChD,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;GACT;GACA,QAAQ,aAAa,UAAU;EACjC,CAAC;EAEH,OAAO,IAAI,KAAK,sBAAsB;CACxC;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { formatResponse } from "../utils/responseData.mjs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
+
import { rebuildUnmergedDictionaries, writeContentDeclaration as writeContentDeclaration$1 } from "@intlayer/engine/build";
|
|
4
5
|
import { clearModuleCache } from "@intlayer/config/utils";
|
|
5
6
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
6
|
-
import { writeContentDeclaration as writeContentDeclaration$1 } from "@intlayer/engine/build";
|
|
7
7
|
import { t } from "fastify-intlayer";
|
|
8
8
|
|
|
9
9
|
//#region src/controllers/dictionary.controller.ts
|
|
@@ -38,6 +38,7 @@ const writeContentDeclaration = async (req, res) => {
|
|
|
38
38
|
const dictionaryData = req.body.dictionary;
|
|
39
39
|
const config = getConfiguration();
|
|
40
40
|
const result = await writeContentDeclaration$1(dictionaryData, config);
|
|
41
|
+
if (result.status !== "up-to-date") await rebuildUnmergedDictionaries(result.path, config).catch((error) => console.error(error));
|
|
41
42
|
const dictionariesPath = join(config.system.mainDir, `unmerged_dictionaries.cjs`);
|
|
42
43
|
clearModuleCache(dictionariesPath);
|
|
43
44
|
let description = "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/dictionaries-entry/unmerged';\nimport {\n type DictionaryStatus,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/engine/build';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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 // 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":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"dictionary.controller.mjs","names":["writeContentDeclarationEditor"],"sources":["../../src/controllers/dictionary.controller.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { clearModuleCache } from '@intlayer/config/utils';\nimport {\n getUnmergedDictionaries,\n type UnmergedDictionaries,\n} from '@intlayer/dictionaries-entry/unmerged';\nimport {\n type DictionaryStatus,\n rebuildUnmergedDictionaries,\n writeContentDeclaration as writeContentDeclarationEditor,\n} from '@intlayer/engine/build';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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 // Rebuild the unmerged dictionaries before answering, so a read right\n // after the write returns the new content instead of waiting for the app\n // watcher. The write itself succeeded: a failed rebuild only delays it.\n if (result.status !== 'up-to-date') {\n await rebuildUnmergedDictionaries(result.path, config).catch((error) =>\n console.error(error)\n );\n }\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":";;;;;;;;;;;;AAsBA,MAAa,kBAAkB,OAC7B,MACA,QACkB;CAClB,IAAI;EACF,MAAM,oBAAoB,eAAqC,EAC7D,MAAM,wBAAwB,EAChC,CAAC;EAED,OAAO,IAAI,KAAK,iBAAiB;CACnC,SAAS,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;EACV;EAEA,MAAM,yBAAyB,eAAqC;GAClE,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;GACT;GACA,QAAQ,aAAa,UAAU;EACjC,CAAC;EAED,OAAO,IAAI,KAAK,sBAAsB;CACxC;AACF;;;;AAaA,MAAa,0BAA0B,OACrC,KACA,QACkB;CAClB,IAAI;EACF,MAAM,iBAAiB,IAAI,KAAK;EAEhC,MAAM,SAAS,iBAAiB;EAEhC,MAAM,SAAS,MAAMA,0BAA8B,gBAAgB,MAAM;EAKzE,IAAI,OAAO,WAAW,cACpB,MAAM,4BAA4B,OAAO,MAAM,MAAM,CAAC,CAAC,OAAO,UAC5D,QAAQ,MAAM,KAAK,CACrB;EAIF,MAAM,mBAAmB,KACvB,OAAO,OAAO,SACd,2BACF;EACA,iBAAiB,gBAAgB;EAEjC,IAAI,cAAc;EAElB,QAAQ,OAAO,QAAf;GACE,KAAK;IACH,cAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAGF,KAAK;IACH,cAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,KAAK;IACH,cAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,KAAK;IACH,cAAc,EAAE;KACd,IAAI;KACJ,IAAI;KACJ,IAAI;IACN,CAAC;IACD;GAEF,SACE,cAAc,EAAE;IACd,IAAI;IACJ,IAAI;IACJ,IAAI;GACN,CAAC;EAGL;EAEA,MAAM,oBAAoB,eACxB;GACE,MAAM;GACN,SAAS,EAAE;IACT,IAAI;IACJ,IAAI;IACJ,IAAI;GACN,CAAC;GACD;EACF,CACF;EAEA,OAAO,IAAI,KAAK,iBAAiB;CACnC,SAAS,KAAK;EACZ,MAAM,eAAgB,OAAiD;GACrE,SAAS;GACT,QAAQ;EACV;EAEA,QAAQ,MAAM,YAAY;EAE1B,MAAM,yBACJ,eAAkD;GAChD,OAAO;IACL,SAAS,aAAa,WAAW;IACjC,MAAM;IACN,OAAO;GACT;GACA,QAAQ,aAAa,UAAU;EACjC,CAAC;EAEH,OAAO,IAAI,KAAK,sBAAsB;CACxC;AACF"}
|
package/server/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_routes_auth_routes = require('./routes/auth.routes.cjs');
|
|
2
3
|
const require_routes_config_routes = require('./routes/config.routes.cjs');
|
|
3
4
|
const require_routes_dictionary_routes = require('./routes/dictionary.routes.cjs');
|
|
4
5
|
const require_utils_checkPortAvailability = require('./utils/checkPortAvailability.cjs');
|
|
@@ -22,6 +23,7 @@ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors, 1);
|
|
|
22
23
|
let _intlayer_config_env = require("@intlayer/config/env");
|
|
23
24
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
24
25
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
26
|
+
let _intlayer_engine_build = require("@intlayer/engine/build");
|
|
25
27
|
let fastify_intlayer = require("fastify-intlayer");
|
|
26
28
|
let fastify = require("fastify");
|
|
27
29
|
fastify = require_runtime.__toESM(fastify, 1);
|
|
@@ -37,13 +39,11 @@ const envFileOptions = {
|
|
|
37
39
|
const FALLBACK_PORT = 8e3;
|
|
38
40
|
const config = (0, _intlayer_config_node.getConfiguration)(envFileOptions);
|
|
39
41
|
const appLogger = (0, _intlayer_config_logger.getAppLogger)(config);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
process.exit(0);
|
|
44
|
-
}
|
|
42
|
+
/** Port tried first; the next free one is used when it is taken. */
|
|
43
|
+
const preferredPort = config.editor.port ?? FALLBACK_PORT;
|
|
44
|
+
const HOST = "0.0.0.0";
|
|
45
45
|
const packageJson = JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(__dirname$1, "../../package.json"), "utf8"));
|
|
46
|
-
const app = (0, fastify.default)({ disableRequestLogging: true });
|
|
46
|
+
const app = (0, fastify.default)({ logController: new fastify.LogController({ disableRequestLogging: true }) });
|
|
47
47
|
app.register(fastify_intlayer.intlayer);
|
|
48
48
|
const clientDistPath = (0, node_path.resolve)(__dirname$1, "../../client/dist");
|
|
49
49
|
const corsOptions = {
|
|
@@ -51,12 +51,39 @@ const corsOptions = {
|
|
|
51
51
|
credentials: true
|
|
52
52
|
};
|
|
53
53
|
const startServer = async (app) => {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const port = await require_utils_checkPortAvailability.findAvailablePort(preferredPort, HOST);
|
|
55
|
+
if (port === void 0) {
|
|
56
|
+
appLogger(`Error: Port ${preferredPort} and the next ones are in use.`, { level: "error" });
|
|
56
57
|
process.exit(255);
|
|
57
58
|
}
|
|
59
|
+
if (port !== preferredPort) appLogger(`Port ${preferredPort} is in use, using port ${port} instead.`, { level: "warn" });
|
|
60
|
+
process.env[_intlayer_config_node.EDITOR_SERVER_PORT_ENV_VAR] = String(port);
|
|
61
|
+
const overriddenKeys = await (0, _intlayer_engine_build.overrideBuiltEditorConfiguration)(config, {
|
|
62
|
+
enabled: true,
|
|
63
|
+
editorURL: (0, _intlayer_config_node.getEditorURLForPort)(config.editor.editorURL, port)
|
|
64
|
+
});
|
|
65
|
+
if (overriddenKeys.length > 0) {
|
|
66
|
+
const overriddenSettings = overriddenKeys.map((key) => (0, _intlayer_config_logger.colorize)(`editor.${key}`, _intlayer_config_colors.BLUE));
|
|
67
|
+
appLogger(`${overriddenSettings.join(" and ")} temporarily adapted in ${(0, _intlayer_config_logger.colorizePath)((0, node_path.relative)(config.system.baseDir, config.system.configDir))}. Set it in ${(0, _intlayer_config_logger.colorizePath)("intlayer.config.ts")} to keep it after the next build.`, { level: "warn" });
|
|
68
|
+
}
|
|
58
69
|
await app.register(_fastify_helmet.default, {
|
|
59
|
-
contentSecurityPolicy:
|
|
70
|
+
contentSecurityPolicy: {
|
|
71
|
+
useDefaults: false,
|
|
72
|
+
directives: {
|
|
73
|
+
defaultSrc: _fastify_helmet.default.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
|
|
74
|
+
frameAncestors: [
|
|
75
|
+
"'self'",
|
|
76
|
+
"vscode-webview:",
|
|
77
|
+
"vscode-file:",
|
|
78
|
+
"https://*.vscode-cdn.net",
|
|
79
|
+
"https://*.vscode-webview.net",
|
|
80
|
+
"localhost:*",
|
|
81
|
+
"http://localhost:*",
|
|
82
|
+
"http://127.0.0.1:*"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
frameguard: false,
|
|
60
87
|
global: true
|
|
61
88
|
});
|
|
62
89
|
await app.register(_fastify_cors.default, corsOptions);
|
|
@@ -65,6 +92,7 @@ const startServer = async (app) => {
|
|
|
65
92
|
await app.register(_fastify_formbody.default);
|
|
66
93
|
await app.register(require_routes_dictionary_routes.dictionaryRouter, { prefix: "/api/dictionary" });
|
|
67
94
|
await app.register(require_routes_config_routes.configurationRouter, { prefix: "/api/config" });
|
|
95
|
+
await app.register(require_routes_auth_routes.authRouter, { prefix: "/api/auth" });
|
|
68
96
|
await app.register(_fastify_static.default, {
|
|
69
97
|
root: clientDistPath,
|
|
70
98
|
wildcard: false
|
|
@@ -80,7 +108,7 @@ const startServer = async (app) => {
|
|
|
80
108
|
try {
|
|
81
109
|
await app.listen({
|
|
82
110
|
port,
|
|
83
|
-
host:
|
|
111
|
+
host: HOST
|
|
84
112
|
});
|
|
85
113
|
const dotEnvFilePath = (0, _intlayer_config_env.getEnvFilePath)(envFileOptions.env, envFileOptions.envFile);
|
|
86
114
|
console.log(`
|
|
@@ -91,9 +119,9 @@ const startServer = async (app) => {
|
|
|
91
119
|
${(0, _intlayer_config_logger.colorize)("➜", _intlayer_config_colors.GREY_DARK)} Access key: ${config.editor.clientId ?? "-"}
|
|
92
120
|
${(0, _intlayer_config_logger.colorize)("➜", _intlayer_config_colors.GREY_DARK)} Environment: ${dotEnvFilePath ?? "-"}
|
|
93
121
|
`);
|
|
94
|
-
} catch (
|
|
95
|
-
|
|
96
|
-
process.exit(1);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
appLogger(`Failed to start the editor: ${error.message}`, { level: "error" });
|
|
124
|
+
process.exit(error.code === "EADDRINUSE" ? 255 : 1);
|
|
97
125
|
}
|
|
98
126
|
};
|
|
99
127
|
startServer(app);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__dirname","dirname","fileURLToPath","getConfiguration","getAppLogger","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__dirname","dirname","fileURLToPath","getConfiguration","getAppLogger","readFileSync","resolve","Fastify","LogController","intlayer","findAvailablePort","EDITOR_SERVER_PORT_ENV_VAR","overrideBuiltEditorConfiguration","getEditorURLForPort","colorize","ANSIColors","colorizePath","relative","fastifyHelmet","fastifyCors","fastifyCompress","fastifyCookie","fastifyFormbody","dictionaryRouter","configurationRouter","authRouter","fastifyStatic","join","existsSync","lstatSync","getEnvFilePath"],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync, lstatSync, readFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport fastifyCompress from '@fastify/compress';\nimport fastifyCookie from '@fastify/cookie';\nimport fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';\nimport fastifyFormbody from '@fastify/formbody';\nimport fastifyHelmet from '@fastify/helmet';\nimport fastifyStatic from '@fastify/static';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport { colorize, colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport {\n EDITOR_SERVER_PORT_ENV_VAR,\n getConfiguration,\n getEditorURLForPort,\n} from '@intlayer/config/node';\nimport { overrideBuiltEditorConfiguration } from '@intlayer/engine/build';\nimport { authRouter } from '@routes/auth.routes';\nimport { configurationRouter } from '@routes/config.routes';\nimport { dictionaryRouter } from '@routes/dictionary.routes';\nimport { findAvailablePort } from '@utils/checkPortAvailability';\nimport Fastify, { type FastifyInstance, LogController } from 'fastify';\nimport { intlayer } from 'fastify-intlayer';\nimport mime from 'mime';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst envFileOptions = {\n env: process.env.NODE_ENV,\n envFile: process.env.ENV_FILE,\n};\n\nconst FALLBACK_PORT = 8000;\nconst config = getConfiguration(envFileOptions);\n\nconst appLogger = getAppLogger(config);\n/** Port tried first; the next free one is used when it is taken. */\nconst preferredPort = config.editor.port ?? FALLBACK_PORT;\nconst HOST = '0.0.0.0';\n\n// Load package.json\nconst packageJson = JSON.parse(\n readFileSync(resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nconst app: FastifyInstance = Fastify({\n logController: new LogController({\n disableRequestLogging: true, // Keep logs clean like the original\n }),\n});\n\n// Load internationalization plugin\n// Assuming fastify-intlayer is the Fastify equivalent of express-intlayer\napp.register(intlayer);\n\nconst clientDistPath = resolve(__dirname, '../../client/dist');\n\nconst corsOptions: FastifyCorsOptions = {\n origin: '*',\n credentials: true,\n};\n\nconst startServer = async (app: FastifyInstance) => {\n const port = await findAvailablePort(preferredPort, HOST);\n\n if (port === undefined) {\n appLogger(`Error: Port ${preferredPort} and the next ones are in use.`, {\n level: 'error',\n });\n process.exit(255);\n }\n\n if (port !== preferredPort) {\n appLogger(`Port ${preferredPort} is in use, using port ${port} instead.`, {\n level: 'warn',\n });\n }\n\n // Served by `/api/config`: the client calls the editor at its actual URL\n process.env[EDITOR_SERVER_PORT_ENV_VAR] = String(port);\n\n // Adapted in the built configuration only: the application must load the\n // editor client, and accept messages from the URL the editor is served at\n const overriddenKeys = await overrideBuiltEditorConfiguration(config, {\n enabled: true,\n editorURL: getEditorURLForPort(config.editor.editorURL, port),\n });\n\n if (overriddenKeys.length > 0) {\n const overriddenSettings = overriddenKeys.map((key) =>\n colorize(`editor.${key}`, ANSIColors.BLUE)\n );\n\n appLogger(\n `${overriddenSettings.join(' and ')} temporarily adapted in ${colorizePath(relative(config.system.baseDir, config.system.configDir))}. Set it in ${colorizePath('intlayer.config.ts')} to keep it after the next build.`,\n {\n level: 'warn',\n }\n );\n }\n\n // Security Headers\n await app.register(fastifyHelmet, {\n // Only restrict who may frame the editor: itself and IDE webviews (the\n // VS Code extension panel). `X-Frame-Options` cannot list a scheme.\n contentSecurityPolicy: {\n useDefaults: false,\n directives: {\n // Helmet requires a `default-src`; the editor sets no other policy\n defaultSrc:\n fastifyHelmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc,\n frameAncestors: [\n \"'self'\",\n 'vscode-webview:',\n 'vscode-file:',\n 'https://*.vscode-cdn.net',\n 'https://*.vscode-webview.net',\n 'localhost:*',\n 'http://localhost:*',\n 'http://127.0.0.1:*',\n ],\n },\n },\n frameguard: false,\n global: true,\n });\n\n // CORS\n await app.register(fastifyCors, corsOptions);\n\n // Compression\n await app.register(fastifyCompress);\n\n // Cookie Parser\n await app.register(fastifyCookie);\n\n // Parse application/x-www-form-urlencoded\n await app.register(fastifyFormbody);\n\n // Register Routes\n await app.register(dictionaryRouter, { prefix: '/api/dictionary' });\n await app.register(configurationRouter, { prefix: '/api/config' });\n await app.register(authRouter, { prefix: '/api/auth' });\n\n // Serve Static Files\n await app.register(fastifyStatic, {\n root: clientDistPath,\n wildcard: false, // We handle the fallback manually to match SPA logic\n });\n\n // For single-page applications, redirect all unmatched routes to index.html\n app.setNotFoundHandler((req, reply) => {\n const requestedPath = join(clientDistPath, req.raw.url || '/');\n\n if (existsSync(requestedPath) && lstatSync(requestedPath).isFile()) {\n const mimeType =\n mime.getType(requestedPath) ?? 'application/octet-stream';\n reply.header('Content-Type', mimeType);\n return reply.sendFile(req.raw.url?.split('/').pop() || 'index.html');\n } else {\n return reply.sendFile('index.html');\n }\n });\n\n try {\n await app.listen({ port, host: HOST });\n\n const dotEnvFilePath = getEnvFilePath(\n envFileOptions.env,\n envFileOptions.envFile\n );\n\n console.log(`\n ${colorize(colorize('INTLAYER', ANSIColors.BOLD), ANSIColors.GREY_DARK)} ${colorize(`v${packageJson.version}`, ANSIColors.GREY_DARK)}\n\n Editor running at: ${colorizePath(`http://localhost:${port}`)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Watching application at: ${config.editor.applicationURL === '' ? '-' : colorizePath(config.editor.applicationURL)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? '-'}\n ${colorize('➜', ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? '-'}\n `);\n } catch (error) {\n // The Fastify logger is disabled, so `app.log` would swallow this\n appLogger(`Failed to start the editor: ${(error as Error).message}`, {\n level: 'error',\n });\n process.exit(\n (error as NodeJS.ErrnoException).code === 'EADDRINUSE' ? 255 : 1\n );\n }\n};\n\n// Start it up!\nstartServer(app);\n"],"mappings":"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"}
|
package/server/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { authRouter } from "./routes/auth.routes.mjs";
|
|
1
2
|
import { configurationRouter } from "./routes/config.routes.mjs";
|
|
2
3
|
import { dictionaryRouter } from "./routes/dictionary.routes.mjs";
|
|
3
|
-
import {
|
|
4
|
+
import { findAvailablePort } from "./utils/checkPortAvailability.mjs";
|
|
4
5
|
import { existsSync, lstatSync, readFileSync } from "node:fs";
|
|
5
|
-
import { dirname, join, resolve } from "node:path";
|
|
6
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
8
|
import fastifyCompress from "@fastify/compress";
|
|
8
9
|
import fastifyCookie from "@fastify/cookie";
|
|
@@ -13,9 +14,10 @@ import fastifyStatic from "@fastify/static";
|
|
|
13
14
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
14
15
|
import { getEnvFilePath } from "@intlayer/config/env";
|
|
15
16
|
import { colorize, colorizePath, getAppLogger } from "@intlayer/config/logger";
|
|
16
|
-
import { getConfiguration } from "@intlayer/config/node";
|
|
17
|
+
import { EDITOR_SERVER_PORT_ENV_VAR, getConfiguration, getEditorURLForPort } from "@intlayer/config/node";
|
|
18
|
+
import { overrideBuiltEditorConfiguration } from "@intlayer/engine/build";
|
|
17
19
|
import { intlayer } from "fastify-intlayer";
|
|
18
|
-
import Fastify from "fastify";
|
|
20
|
+
import Fastify, { LogController } from "fastify";
|
|
19
21
|
import mime from "mime";
|
|
20
22
|
|
|
21
23
|
//#region src/index.ts
|
|
@@ -27,13 +29,11 @@ const envFileOptions = {
|
|
|
27
29
|
const FALLBACK_PORT = 8e3;
|
|
28
30
|
const config = getConfiguration(envFileOptions);
|
|
29
31
|
const appLogger = getAppLogger(config);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
process.exit(0);
|
|
34
|
-
}
|
|
32
|
+
/** Port tried first; the next free one is used when it is taken. */
|
|
33
|
+
const preferredPort = config.editor.port ?? FALLBACK_PORT;
|
|
34
|
+
const HOST = "0.0.0.0";
|
|
35
35
|
const packageJson = JSON.parse(readFileSync(resolve(__dirname, "../../package.json"), "utf8"));
|
|
36
|
-
const app = Fastify({ disableRequestLogging: true });
|
|
36
|
+
const app = Fastify({ logController: new LogController({ disableRequestLogging: true }) });
|
|
37
37
|
app.register(intlayer);
|
|
38
38
|
const clientDistPath = resolve(__dirname, "../../client/dist");
|
|
39
39
|
const corsOptions = {
|
|
@@ -41,12 +41,39 @@ const corsOptions = {
|
|
|
41
41
|
credentials: true
|
|
42
42
|
};
|
|
43
43
|
const startServer = async (app) => {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const port = await findAvailablePort(preferredPort, HOST);
|
|
45
|
+
if (port === void 0) {
|
|
46
|
+
appLogger(`Error: Port ${preferredPort} and the next ones are in use.`, { level: "error" });
|
|
46
47
|
process.exit(255);
|
|
47
48
|
}
|
|
49
|
+
if (port !== preferredPort) appLogger(`Port ${preferredPort} is in use, using port ${port} instead.`, { level: "warn" });
|
|
50
|
+
process.env[EDITOR_SERVER_PORT_ENV_VAR] = String(port);
|
|
51
|
+
const overriddenKeys = await overrideBuiltEditorConfiguration(config, {
|
|
52
|
+
enabled: true,
|
|
53
|
+
editorURL: getEditorURLForPort(config.editor.editorURL, port)
|
|
54
|
+
});
|
|
55
|
+
if (overriddenKeys.length > 0) {
|
|
56
|
+
const overriddenSettings = overriddenKeys.map((key) => colorize(`editor.${key}`, ANSIColors.BLUE));
|
|
57
|
+
appLogger(`${overriddenSettings.join(" and ")} temporarily adapted in ${colorizePath(relative(config.system.baseDir, config.system.configDir))}. Set it in ${colorizePath("intlayer.config.ts")} to keep it after the next build.`, { level: "warn" });
|
|
58
|
+
}
|
|
48
59
|
await app.register(fastifyHelmet, {
|
|
49
|
-
contentSecurityPolicy:
|
|
60
|
+
contentSecurityPolicy: {
|
|
61
|
+
useDefaults: false,
|
|
62
|
+
directives: {
|
|
63
|
+
defaultSrc: fastifyHelmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc,
|
|
64
|
+
frameAncestors: [
|
|
65
|
+
"'self'",
|
|
66
|
+
"vscode-webview:",
|
|
67
|
+
"vscode-file:",
|
|
68
|
+
"https://*.vscode-cdn.net",
|
|
69
|
+
"https://*.vscode-webview.net",
|
|
70
|
+
"localhost:*",
|
|
71
|
+
"http://localhost:*",
|
|
72
|
+
"http://127.0.0.1:*"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
frameguard: false,
|
|
50
77
|
global: true
|
|
51
78
|
});
|
|
52
79
|
await app.register(fastifyCors, corsOptions);
|
|
@@ -55,6 +82,7 @@ const startServer = async (app) => {
|
|
|
55
82
|
await app.register(fastifyFormbody);
|
|
56
83
|
await app.register(dictionaryRouter, { prefix: "/api/dictionary" });
|
|
57
84
|
await app.register(configurationRouter, { prefix: "/api/config" });
|
|
85
|
+
await app.register(authRouter, { prefix: "/api/auth" });
|
|
58
86
|
await app.register(fastifyStatic, {
|
|
59
87
|
root: clientDistPath,
|
|
60
88
|
wildcard: false
|
|
@@ -70,7 +98,7 @@ const startServer = async (app) => {
|
|
|
70
98
|
try {
|
|
71
99
|
await app.listen({
|
|
72
100
|
port,
|
|
73
|
-
host:
|
|
101
|
+
host: HOST
|
|
74
102
|
});
|
|
75
103
|
const dotEnvFilePath = getEnvFilePath(envFileOptions.env, envFileOptions.envFile);
|
|
76
104
|
console.log(`
|
|
@@ -81,9 +109,9 @@ const startServer = async (app) => {
|
|
|
81
109
|
${colorize("➜", ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? "-"}
|
|
82
110
|
${colorize("➜", ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? "-"}
|
|
83
111
|
`);
|
|
84
|
-
} catch (
|
|
85
|
-
|
|
86
|
-
process.exit(1);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
appLogger(`Failed to start the editor: ${error.message}`, { level: "error" });
|
|
114
|
+
process.exit(error.code === "EADDRINUSE" ? 255 : 1);
|
|
87
115
|
}
|
|
88
116
|
};
|
|
89
117
|
startServer(app);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync, lstatSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport fastifyCompress from '@fastify/compress';\nimport fastifyCookie from '@fastify/cookie';\nimport fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';\nimport fastifyFormbody from '@fastify/formbody';\nimport fastifyHelmet from '@fastify/helmet';\nimport fastifyStatic from '@fastify/static';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport { colorize, colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { existsSync, lstatSync, readFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport fastifyCompress from '@fastify/compress';\nimport fastifyCookie from '@fastify/cookie';\nimport fastifyCors, { type FastifyCorsOptions } from '@fastify/cors';\nimport fastifyFormbody from '@fastify/formbody';\nimport fastifyHelmet from '@fastify/helmet';\nimport fastifyStatic from '@fastify/static';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport { colorize, colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport {\n EDITOR_SERVER_PORT_ENV_VAR,\n getConfiguration,\n getEditorURLForPort,\n} from '@intlayer/config/node';\nimport { overrideBuiltEditorConfiguration } from '@intlayer/engine/build';\nimport { authRouter } from '@routes/auth.routes';\nimport { configurationRouter } from '@routes/config.routes';\nimport { dictionaryRouter } from '@routes/dictionary.routes';\nimport { findAvailablePort } from '@utils/checkPortAvailability';\nimport Fastify, { type FastifyInstance, LogController } from 'fastify';\nimport { intlayer } from 'fastify-intlayer';\nimport mime from 'mime';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst envFileOptions = {\n env: process.env.NODE_ENV,\n envFile: process.env.ENV_FILE,\n};\n\nconst FALLBACK_PORT = 8000;\nconst config = getConfiguration(envFileOptions);\n\nconst appLogger = getAppLogger(config);\n/** Port tried first; the next free one is used when it is taken. */\nconst preferredPort = config.editor.port ?? FALLBACK_PORT;\nconst HOST = '0.0.0.0';\n\n// Load package.json\nconst packageJson = JSON.parse(\n readFileSync(resolve(__dirname, '../../package.json'), 'utf8')\n);\n\nconst app: FastifyInstance = Fastify({\n logController: new LogController({\n disableRequestLogging: true, // Keep logs clean like the original\n }),\n});\n\n// Load internationalization plugin\n// Assuming fastify-intlayer is the Fastify equivalent of express-intlayer\napp.register(intlayer);\n\nconst clientDistPath = resolve(__dirname, '../../client/dist');\n\nconst corsOptions: FastifyCorsOptions = {\n origin: '*',\n credentials: true,\n};\n\nconst startServer = async (app: FastifyInstance) => {\n const port = await findAvailablePort(preferredPort, HOST);\n\n if (port === undefined) {\n appLogger(`Error: Port ${preferredPort} and the next ones are in use.`, {\n level: 'error',\n });\n process.exit(255);\n }\n\n if (port !== preferredPort) {\n appLogger(`Port ${preferredPort} is in use, using port ${port} instead.`, {\n level: 'warn',\n });\n }\n\n // Served by `/api/config`: the client calls the editor at its actual URL\n process.env[EDITOR_SERVER_PORT_ENV_VAR] = String(port);\n\n // Adapted in the built configuration only: the application must load the\n // editor client, and accept messages from the URL the editor is served at\n const overriddenKeys = await overrideBuiltEditorConfiguration(config, {\n enabled: true,\n editorURL: getEditorURLForPort(config.editor.editorURL, port),\n });\n\n if (overriddenKeys.length > 0) {\n const overriddenSettings = overriddenKeys.map((key) =>\n colorize(`editor.${key}`, ANSIColors.BLUE)\n );\n\n appLogger(\n `${overriddenSettings.join(' and ')} temporarily adapted in ${colorizePath(relative(config.system.baseDir, config.system.configDir))}. Set it in ${colorizePath('intlayer.config.ts')} to keep it after the next build.`,\n {\n level: 'warn',\n }\n );\n }\n\n // Security Headers\n await app.register(fastifyHelmet, {\n // Only restrict who may frame the editor: itself and IDE webviews (the\n // VS Code extension panel). `X-Frame-Options` cannot list a scheme.\n contentSecurityPolicy: {\n useDefaults: false,\n directives: {\n // Helmet requires a `default-src`; the editor sets no other policy\n defaultSrc:\n fastifyHelmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc,\n frameAncestors: [\n \"'self'\",\n 'vscode-webview:',\n 'vscode-file:',\n 'https://*.vscode-cdn.net',\n 'https://*.vscode-webview.net',\n 'localhost:*',\n 'http://localhost:*',\n 'http://127.0.0.1:*',\n ],\n },\n },\n frameguard: false,\n global: true,\n });\n\n // CORS\n await app.register(fastifyCors, corsOptions);\n\n // Compression\n await app.register(fastifyCompress);\n\n // Cookie Parser\n await app.register(fastifyCookie);\n\n // Parse application/x-www-form-urlencoded\n await app.register(fastifyFormbody);\n\n // Register Routes\n await app.register(dictionaryRouter, { prefix: '/api/dictionary' });\n await app.register(configurationRouter, { prefix: '/api/config' });\n await app.register(authRouter, { prefix: '/api/auth' });\n\n // Serve Static Files\n await app.register(fastifyStatic, {\n root: clientDistPath,\n wildcard: false, // We handle the fallback manually to match SPA logic\n });\n\n // For single-page applications, redirect all unmatched routes to index.html\n app.setNotFoundHandler((req, reply) => {\n const requestedPath = join(clientDistPath, req.raw.url || '/');\n\n if (existsSync(requestedPath) && lstatSync(requestedPath).isFile()) {\n const mimeType =\n mime.getType(requestedPath) ?? 'application/octet-stream';\n reply.header('Content-Type', mimeType);\n return reply.sendFile(req.raw.url?.split('/').pop() || 'index.html');\n } else {\n return reply.sendFile('index.html');\n }\n });\n\n try {\n await app.listen({ port, host: HOST });\n\n const dotEnvFilePath = getEnvFilePath(\n envFileOptions.env,\n envFileOptions.envFile\n );\n\n console.log(`\n ${colorize(colorize('INTLAYER', ANSIColors.BOLD), ANSIColors.GREY_DARK)} ${colorize(`v${packageJson.version}`, ANSIColors.GREY_DARK)}\n\n Editor running at: ${colorizePath(`http://localhost:${port}`)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Watching application at: ${config.editor.applicationURL === '' ? '-' : colorizePath(config.editor.applicationURL)}\n ${colorize('➜', ANSIColors.GREY_DARK)} Access key: ${config.editor.clientId ?? '-'}\n ${colorize('➜', ANSIColors.GREY_DARK)} Environment: ${dotEnvFilePath ?? '-'}\n `);\n } catch (error) {\n // The Fastify logger is disabled, so `app.log` would swallow this\n appLogger(`Failed to start the editor: ${(error as Error).message}`, {\n level: 'error',\n });\n process.exit(\n (error as NodeJS.ErrnoException).code === 'EADDRINUSE' ? 255 : 1\n );\n }\n};\n\n// Start it up!\nstartServer(app);\n"],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_controllers_auth_controller = require('../controllers/auth.controller.cjs');
|
|
3
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
4
|
+
|
|
5
|
+
//#region src/routes/auth.routes.ts
|
|
6
|
+
const { editor } = (0, _intlayer_config_node.getConfiguration)();
|
|
7
|
+
const getBaseURL = () => `${editor.editorURL}/api/auth`;
|
|
8
|
+
const getAuthRoutes = () => ({
|
|
9
|
+
getEditorAuth: {
|
|
10
|
+
urlModel: "/",
|
|
11
|
+
url: getBaseURL(),
|
|
12
|
+
method: "GET"
|
|
13
|
+
},
|
|
14
|
+
startLogin: {
|
|
15
|
+
urlModel: "/login",
|
|
16
|
+
url: `${getBaseURL()}/login`,
|
|
17
|
+
method: "POST"
|
|
18
|
+
},
|
|
19
|
+
logout: {
|
|
20
|
+
urlModel: "/logout",
|
|
21
|
+
url: `${getBaseURL()}/logout`,
|
|
22
|
+
method: "POST"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const authRouter = async (fastify) => {
|
|
26
|
+
fastify.addHook("onRequest", require_controllers_auth_controller.assertSameOrigin);
|
|
27
|
+
fastify.get(getAuthRoutes().getEditorAuth.urlModel, require_controllers_auth_controller.getEditorAuth);
|
|
28
|
+
fastify.post(getAuthRoutes().startLogin.urlModel, require_controllers_auth_controller.startLogin);
|
|
29
|
+
fastify.post(getAuthRoutes().logout.urlModel, require_controllers_auth_controller.logout);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.authRouter = authRouter;
|
|
34
|
+
exports.getAuthRoutes = getAuthRoutes;
|
|
35
|
+
//# sourceMappingURL=auth.routes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.routes.cjs","names":["getConfiguration","assertSameOrigin","getEditorAuth","startLogin","logout"],"sources":["../../src/routes/auth.routes.ts"],"sourcesContent":["import {\n assertSameOrigin,\n getEditorAuth,\n logout,\n startLogin,\n} from '@controllers/auth.controller';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/auth`;\n\nexport const getAuthRoutes = () =>\n ({\n getEditorAuth: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n startLogin: {\n urlModel: '/login',\n url: `${getBaseURL()}/login`,\n method: 'POST',\n },\n logout: {\n urlModel: '/logout',\n url: `${getBaseURL()}/logout`,\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const authRouter = async (fastify: FastifyInstance) => {\n fastify.addHook('onRequest', assertSameOrigin);\n\n fastify.get(getAuthRoutes().getEditorAuth.urlModel, getEditorAuth);\n fastify.post(getAuthRoutes().startLogin.urlModel, startLogin);\n fastify.post(getAuthRoutes().logout.urlModel, logout);\n};\n"],"mappings":";;;;;AAUA,MAAM,EAAE,eAAWA,wCAAiB;AAEpC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,uBACV;CACC,eAAe;EACb,UAAU;EACV,KAAK,WAAW;EAChB,QAAQ;CACV;CACA,YAAY;EACV,UAAU;EACV,KAAK,GAAG,WAAW,EAAE;EACrB,QAAQ;CACV;CACA,QAAQ;EACN,UAAU;EACV,KAAK,GAAG,WAAW,EAAE;EACrB,QAAQ;CACV;AACF;AAEF,MAAa,aAAa,OAAO,YAA6B;CAC5D,QAAQ,QAAQ,aAAaC,oDAAgB;CAE7C,QAAQ,IAAI,cAAc,CAAC,CAAC,cAAc,UAAUC,iDAAa;CACjE,QAAQ,KAAK,cAAc,CAAC,CAAC,WAAW,UAAUC,8CAAU;CAC5D,QAAQ,KAAK,cAAc,CAAC,CAAC,OAAO,UAAUC,0CAAM;AACtD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FastifyInstance } from "fastify";
|
|
2
|
+
//#region src/routes/auth.routes.d.ts
|
|
3
|
+
export declare const getAuthRoutes: () => {
|
|
4
|
+
getEditorAuth: {
|
|
5
|
+
urlModel: string;
|
|
6
|
+
url: string;
|
|
7
|
+
method: "GET";
|
|
8
|
+
};
|
|
9
|
+
startLogin: {
|
|
10
|
+
urlModel: string;
|
|
11
|
+
url: string;
|
|
12
|
+
method: "POST";
|
|
13
|
+
};
|
|
14
|
+
logout: {
|
|
15
|
+
urlModel: string;
|
|
16
|
+
url: string;
|
|
17
|
+
method: "POST";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare const authRouter: (fastify: FastifyInstance) => Promise<void>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=auth.routes.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { assertSameOrigin, getEditorAuth, logout, startLogin } from "../controllers/auth.controller.mjs";
|
|
2
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
+
|
|
4
|
+
//#region src/routes/auth.routes.ts
|
|
5
|
+
const { editor } = getConfiguration();
|
|
6
|
+
const getBaseURL = () => `${editor.editorURL}/api/auth`;
|
|
7
|
+
const getAuthRoutes = () => ({
|
|
8
|
+
getEditorAuth: {
|
|
9
|
+
urlModel: "/",
|
|
10
|
+
url: getBaseURL(),
|
|
11
|
+
method: "GET"
|
|
12
|
+
},
|
|
13
|
+
startLogin: {
|
|
14
|
+
urlModel: "/login",
|
|
15
|
+
url: `${getBaseURL()}/login`,
|
|
16
|
+
method: "POST"
|
|
17
|
+
},
|
|
18
|
+
logout: {
|
|
19
|
+
urlModel: "/logout",
|
|
20
|
+
url: `${getBaseURL()}/logout`,
|
|
21
|
+
method: "POST"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const authRouter = async (fastify) => {
|
|
25
|
+
fastify.addHook("onRequest", assertSameOrigin);
|
|
26
|
+
fastify.get(getAuthRoutes().getEditorAuth.urlModel, getEditorAuth);
|
|
27
|
+
fastify.post(getAuthRoutes().startLogin.urlModel, startLogin);
|
|
28
|
+
fastify.post(getAuthRoutes().logout.urlModel, logout);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { authRouter, getAuthRoutes };
|
|
33
|
+
//# sourceMappingURL=auth.routes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.routes.mjs","names":[],"sources":["../../src/routes/auth.routes.ts"],"sourcesContent":["import {\n assertSameOrigin,\n getEditorAuth,\n logout,\n startLogin,\n} from '@controllers/auth.controller';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { FastifyInstance } from 'fastify';\nimport type { Routes } from '@/types/Routes';\n\nconst { editor } = getConfiguration();\n\nconst getBaseURL = () => `${editor.editorURL}/api/auth`;\n\nexport const getAuthRoutes = () =>\n ({\n getEditorAuth: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'GET',\n },\n startLogin: {\n urlModel: '/login',\n url: `${getBaseURL()}/login`,\n method: 'POST',\n },\n logout: {\n urlModel: '/logout',\n url: `${getBaseURL()}/logout`,\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const authRouter = async (fastify: FastifyInstance) => {\n fastify.addHook('onRequest', assertSameOrigin);\n\n fastify.get(getAuthRoutes().getEditorAuth.urlModel, getEditorAuth);\n fastify.post(getAuthRoutes().startLogin.urlModel, startLogin);\n fastify.post(getAuthRoutes().logout.urlModel, logout);\n};\n"],"mappings":";;;;AAUA,MAAM,EAAE,WAAW,iBAAiB;AAEpC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,uBACV;CACC,eAAe;EACb,UAAU;EACV,KAAK,WAAW;EAChB,QAAQ;CACV;CACA,YAAY;EACV,UAAU;EACV,KAAK,GAAG,WAAW,EAAE;EACrB,QAAQ;CACV;CACA,QAAQ;EACN,UAAU;EACV,KAAK,GAAG,WAAW,EAAE;EACrB,QAAQ;CACV;AACF;AAEF,MAAa,aAAa,OAAO,YAA6B;CAC5D,QAAQ,QAAQ,aAAa,gBAAgB;CAE7C,QAAQ,IAAI,cAAc,CAAC,CAAC,cAAc,UAAU,aAAa;CACjE,QAAQ,KAAK,cAAc,CAAC,CAAC,WAAW,UAAU,UAAU;CAC5D,QAAQ,KAAK,cAAc,CAAC,CAAC,OAAO,UAAU,MAAM;AACtD"}
|