intlayer-editor 9.7.3 → 9.8.0-canary.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.
@@ -1 +1 @@
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 {\n type BuiltEditorOverride,\n overrideBuiltEditorConfiguration,\n watchBuiltEditorConfiguration,\n} 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 editorOverride: BuiltEditorOverride = {\n enabled: true,\n editorURL: getEditorURLForPort(config.editor.editorURL, port),\n };\n const overriddenKeys = await overrideBuiltEditorConfiguration(\n config,\n editorOverride\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 // An application (re)started aside rebuilds the configuration without them\n watchBuiltEditorConfiguration(config.system.configDir, {\n loadConfiguration: () =>\n getConfiguration({ ...envFileOptions, cache: false }),\n editorOverride,\n onRestore: () =>\n appLogger(\n `${overriddenSettings.join(' and ')} adapted again in ${colorizePath(relative(config.system.baseDir, config.system.configDir))} after the application rebuilt it.`\n ),\n onError: (error) =>\n appLogger(\n `Failed to keep the editor settings in the built configuration: ${(error as Error).message}`,\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":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAM,iBAAiB;CACrB;CACA,SAAS,QAAQ,IAAI;AACvB;AAEA,MAAM,gBAAgB;AACtB,MAAM,SAAS,iBAAiB,cAAc;AAE9C,MAAM,YAAY,aAAa,MAAM;;AAErC,MAAM,gBAAgB,OAAO,OAAO,QAAQ;AAC5C,MAAM,OAAO;AAGb,MAAM,cAAc,KAAK,MACvB,aAAa,QAAQ,WAAW,oBAAoB,GAAG,MAAM,CAC/D;AAEA,MAAM,MAAuB,QAAQ,EACnC,eAAe,IAAI,cAAc,EAC/B,uBAAuB,KACzB,CAAC,EACH,CAAC;AAID,IAAI,SAAS,QAAQ;AAErB,MAAM,iBAAiB,QAAQ,WAAW,mBAAmB;AAE7D,MAAM,cAAkC;CACtC,QAAQ;CACR,aAAa;AACf;AAEA,MAAM,cAAc,OAAO,QAAyB;CAClD,MAAM,OAAO,MAAM,kBAAkB,eAAe,IAAI;CAExD,IAAI,SAAS,QAAW;EACtB,UAAU,eAAe,cAAc,iCAAiC,EACtE,OAAO,QACT,CAAC;EACD,QAAQ,KAAK,GAAG;CAClB;CAEA,IAAI,SAAS,eACX,UAAU,QAAQ,cAAc,yBAAyB,KAAK,YAAY,EACxE,OAAO,OACT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E,QAAQ,YAAY,CAAC;CAGtD,MAAM,IAAI,SAAS,eAAe;EAChC,MAAM;EACN,UAAU;CACZ,CAAC;CAGD,IAAI,oBAAoB,KAAK,UAAU;EACrC,MAAM,gBAAgB,KAAK,gBAAgB,IAAI,IAAI,OAAO,GAAG;EAE7D,IAAI,WAAW,aAAa,KAAK,UAAU,aAAa,CAAC,CAAC,OAAO,GAAG;GAClE,MAAM,WACJ,KAAK,QAAQ,aAAa,KAAK;GACjC,MAAM,OAAO,gBAAgB,QAAQ;GACrC,OAAO,MAAM,SAAS,IAAI,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,YAAY;EACrE,OACE,OAAO,MAAM,SAAS,YAAY;CAEtC,CAAC;CAED,IAAI;EACF,MAAM,IAAI,OAAO;GAAE;GAAM,MAAM;EAAK,CAAC;EAErC,MAAM,iBAAiB,eACrB,eAAe,KACf,eAAe,OACjB;EAEA,QAAQ,IAAI;MACV,SAAS,SAAS,YAAY,WAAW,IAAI,GAAG,WAAW,SAAS,EAAE,GAAG,SAAS,IAAI,YAAY,WAAW,WAAW,SAAS,EAAE;;mCAEtG,aAAa,oBAAoB,MAAM,EAAE;MACtE,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,OAAO,OAAO,mBAAmB,KAAK,MAAM,aAAa,OAAO,OAAO,cAAc,EAAE;MACzJ,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,OAAO,OAAO,YAAY,IAAI;MAChG,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,kBAAkB,IAAI;KACzF;CACH,SAAS,OAAO;EAEd,UAAU,+BAAgC,MAAgB,WAAW,EACnE,OAAO,QACT,CAAC;EACD,QAAQ,KACL,MAAgC,SAAS,eAAe,MAAM,CACjE;CACF;AACF;AAGA,YAAY,GAAG"}
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 {\n type BuiltEditorOverride,\n overrideBuiltEditorConfiguration,\n watchBuiltEditorConfiguration,\n} from '@intlayer/engine/build';\nimport { authRouter } from '@routes/auth.routes';\nimport { clientLogRouter } from '@routes/clientLog.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 editorOverride: BuiltEditorOverride = {\n enabled: true,\n editorURL: getEditorURLForPort(config.editor.editorURL, port),\n };\n const overriddenKeys = await overrideBuiltEditorConfiguration(\n config,\n editorOverride\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 // An application (re)started aside rebuilds the configuration without them\n watchBuiltEditorConfiguration(config.system.configDir, {\n loadConfiguration: () =>\n getConfiguration({ ...envFileOptions, cache: false }),\n editorOverride,\n onRestore: () =>\n appLogger(\n `${overriddenSettings.join(' and ')} adapted again in ${colorizePath(relative(config.system.baseDir, config.system.configDir))} after the application rebuilt it.`\n ),\n onError: (error) =>\n appLogger(\n `Failed to keep the editor settings in the built configuration: ${(error as Error).message}`,\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 await app.register(clientLogRouter, { prefix: '/api/log' });\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":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAM,iBAAiB;CACrB;CACA,SAAS,QAAQ,IAAI;AACvB;AAEA,MAAM,gBAAgB;AACtB,MAAM,SAAS,iBAAiB,cAAc;AAE9C,MAAM,YAAY,aAAa,MAAM;;AAErC,MAAM,gBAAgB,OAAO,OAAO,QAAQ;AAC5C,MAAM,OAAO;AAGb,MAAM,cAAc,KAAK,MACvB,aAAa,QAAQ,WAAW,oBAAoB,GAAG,MAAM,CAC/D;AAEA,MAAM,MAAuB,QAAQ,EACnC,eAAe,IAAI,cAAc,EAC/B,uBAAuB,KACzB,CAAC,EACH,CAAC;AAID,IAAI,SAAS,QAAQ;AAErB,MAAM,iBAAiB,QAAQ,WAAW,mBAAmB;AAE7D,MAAM,cAAkC;CACtC,QAAQ;CACR,aAAa;AACf;AAEA,MAAM,cAAc,OAAO,QAAyB;CAClD,MAAM,OAAO,MAAM,kBAAkB,eAAe,IAAI;CAExD,IAAI,SAAS,QAAW;EACtB,UAAU,eAAe,cAAc,iCAAiC,EACtE,OAAO,QACT,CAAC;EACD,QAAQ,KAAK,GAAG;CAClB;CAEA,IAAI,SAAS,eACX,UAAU,QAAQ,cAAc,yBAAyB,KAAK,YAAY,EACxE,OAAO,OACT,CAAC;CAIH,QAAQ,IAAI,8BAA8B,OAAO,IAAI;CAIrD,MAAM,iBAAsC;EAC1C,SAAS;EACT,WAAW,oBAAoB,OAAO,OAAO,WAAW,IAAI;CAC9D;CACA,MAAM,iBAAiB,MAAM,iCAC3B,QACA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K,UAAU;EACrC,MAAM,gBAAgB,KAAK,gBAAgB,IAAI,IAAI,OAAO,GAAG;EAE7D,IAAI,WAAW,aAAa,KAAK,UAAU,aAAa,CAAC,CAAC,OAAO,GAAG;GAClE,MAAM,WACJ,KAAK,QAAQ,aAAa,KAAK;GACjC,MAAM,OAAO,gBAAgB,QAAQ;GACrC,OAAO,MAAM,SAAS,IAAI,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,YAAY;EACrE,OACE,OAAO,MAAM,SAAS,YAAY;CAEtC,CAAC;CAED,IAAI;EACF,MAAM,IAAI,OAAO;GAAE;GAAM,MAAM;EAAK,CAAC;EAErC,MAAM,iBAAiB,eACrB,eAAe,KACf,eAAe,OACjB;EAEA,QAAQ,IAAI;MACV,SAAS,SAAS,YAAY,WAAW,IAAI,GAAG,WAAW,SAAS,EAAE,GAAG,SAAS,IAAI,YAAY,WAAW,WAAW,SAAS,EAAE;;mCAEtG,aAAa,oBAAoB,MAAM,EAAE;MACtE,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,OAAO,OAAO,mBAAmB,KAAK,MAAM,aAAa,OAAO,OAAO,cAAc,EAAE;MACzJ,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,OAAO,OAAO,YAAY,IAAI;MAChG,SAAS,KAAK,WAAW,SAAS,EAAE,8BAA8B,kBAAkB,IAAI;KACzF;CACH,SAAS,OAAO;EAEd,UAAU,+BAAgC,MAAgB,WAAW,EACnE,OAAO,QACT,CAAC;EACD,QAAQ,KACL,MAAgC,SAAS,eAAe,MAAM,CACjE;CACF;AACF;AAGA,YAAY,GAAG"}
@@ -0,0 +1,21 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_controllers_auth_controller = require("../controllers/auth.controller.cjs");
3
+ const require_controllers_clientLog_controller = require("../controllers/clientLog.controller.cjs");
4
+ let _intlayer_config_node = require("@intlayer/config/node");
5
+
6
+ // src/routes/clientLog.routes.ts
7
+ const { editor } = (0, _intlayer_config_node.getConfiguration)();
8
+ const getBaseURL = () => `${editor.editorURL}/api/log`;
9
+ const getClientLogRoutes = () => ({ logClientEvent: {
10
+ urlModel: "/",
11
+ url: getBaseURL(),
12
+ method: "POST"
13
+ } });
14
+ const clientLogRouter = async (fastify) => {
15
+ fastify.addHook("onRequest", require_controllers_auth_controller.assertSameOrigin);
16
+ fastify.post(getClientLogRoutes().logClientEvent.urlModel, require_controllers_clientLog_controller.logClientEvent);
17
+ };
18
+
19
+ exports.clientLogRouter = clientLogRouter;
20
+ exports.getClientLogRoutes = getClientLogRoutes;
21
+ //# sourceMappingURL=clientLog.routes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientLog.routes.cjs","names":["getConfiguration","assertSameOrigin","logClientEvent"],"sources":["../../src/routes/clientLog.routes.ts"],"sourcesContent":["import { assertSameOrigin } from '@controllers/auth.controller';\nimport { logClientEvent } from '@controllers/clientLog.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/log`;\n\nexport const getClientLogRoutes = () =>\n ({\n logClientEvent: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const clientLogRouter = async (fastify: FastifyInstance) => {\n // Only the editor client may print in the terminal, not any open page\n fastify.addHook('onRequest', assertSameOrigin);\n\n fastify.post(getClientLogRoutes().logClientEvent.urlModel, logClientEvent);\n};\n"],"mappings":";;;;;;AAMA,MAAM,EAAE,eAAWA,wCAAiB;AAEpC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,4BACV,EACC,gBAAgB;CACd,UAAU;CACV,KAAK,WAAW;CAChB,QAAQ;AACV,EACF;AAEF,MAAa,kBAAkB,OAAO,YAA6B;CAEjE,QAAQ,QAAQ,aAAaC,oDAAgB;CAE7C,QAAQ,KAAK,mBAAmB,CAAC,CAAC,eAAe,UAAUC,uDAAc;AAC3E"}
@@ -0,0 +1,9 @@
1
+ import { FastifyInstance } from "fastify";
2
+ export declare const getClientLogRoutes: () => {
3
+ logClientEvent: {
4
+ urlModel: string;
5
+ url: string;
6
+ method: "POST";
7
+ };
8
+ };
9
+ export declare const clientLogRouter: (fastify: FastifyInstance) => Promise<void>;
@@ -0,0 +1,19 @@
1
+ import { assertSameOrigin } from "../controllers/auth.controller.mjs";
2
+ import { logClientEvent } from "../controllers/clientLog.controller.mjs";
3
+ import { getConfiguration } from "@intlayer/config/node";
4
+
5
+ // src/routes/clientLog.routes.ts
6
+ const { editor } = getConfiguration();
7
+ const getBaseURL = () => `${editor.editorURL}/api/log`;
8
+ const getClientLogRoutes = () => ({ logClientEvent: {
9
+ urlModel: "/",
10
+ url: getBaseURL(),
11
+ method: "POST"
12
+ } });
13
+ const clientLogRouter = async (fastify) => {
14
+ fastify.addHook("onRequest", assertSameOrigin);
15
+ fastify.post(getClientLogRoutes().logClientEvent.urlModel, logClientEvent);
16
+ };
17
+
18
+ export { clientLogRouter, getClientLogRoutes };
19
+ //# sourceMappingURL=clientLog.routes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientLog.routes.mjs","names":[],"sources":["../../src/routes/clientLog.routes.ts"],"sourcesContent":["import { assertSameOrigin } from '@controllers/auth.controller';\nimport { logClientEvent } from '@controllers/clientLog.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/log`;\n\nexport const getClientLogRoutes = () =>\n ({\n logClientEvent: {\n urlModel: '/',\n url: getBaseURL(),\n method: 'POST',\n },\n }) satisfies Routes;\n\nexport const clientLogRouter = async (fastify: FastifyInstance) => {\n // Only the editor client may print in the terminal, not any open page\n fastify.addHook('onRequest', assertSameOrigin);\n\n fastify.post(getClientLogRoutes().logClientEvent.urlModel, logClientEvent);\n};\n"],"mappings":";;;;;AAMA,MAAM,EAAE,WAAW,iBAAiB;AAEpC,MAAM,mBAAmB,GAAG,OAAO,UAAU;AAE7C,MAAa,4BACV,EACC,gBAAgB;CACd,UAAU;CACV,KAAK,WAAW;CAChB,QAAQ;AACV,EACF;AAEF,MAAa,kBAAkB,OAAO,YAA6B;CAEjE,QAAQ,QAAQ,aAAa,gBAAgB;CAE7C,QAAQ,KAAK,mBAAmB,CAAC,CAAC,eAAe,UAAU,cAAc;AAC3E"}
@@ -1 +0,0 @@
1
- export{t as MarkdownRenderer}from"./MarkDownRender-Jcoifdy4.js";