@leancodepl/mail-translation 10.3.1 → 10.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.5.0](https://github.com/leancodepl/js_corelibrary/compare/v10.4.0...v10.5.0) (2026-07-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - resolve pre-existing typecheck errors in logger affected set
11
+ ([9bb40cf](https://github.com/leancodepl/js_corelibrary/commit/9bb40cf62ffd84b55f1bb20a19aef1fcf7a15dff))
12
+
13
+ # Change Log
14
+
15
+ All notable changes to this project will be documented in this file. See
16
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
17
+
18
+ # [10.4.0](https://github.com/leancodepl/js_corelibrary/compare/v10.3.1...v10.4.0) (2026-06-23)
19
+
20
+ **Note:** Version bump only for package @leancodepl/mail-translation
21
+
22
+ # Change Log
23
+
24
+ All notable changes to this project will be documented in this file. See
25
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
26
+
6
27
  ## [10.3.1](https://github.com/leancodepl/js_corelibrary/compare/v10.3.0...v10.3.1) (2026-05-20)
7
28
 
8
29
  **Note:** Version bump only for package @leancodepl/mail-translation
package/dist/bin.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const c=require("yargs/helpers"),u=require("yargs/yargs"),n=require("./saveOutputs-RV5ZMO78.cjs"),g=require("lilconfig"),d=require("yaml"),t=require("zod/v4");function p(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(a,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return a.default=e,Object.freeze(a)}const f=p(d),m=t.z.enum(["kratos","razor"]),h=t.z.object({translationsPath:t.z.string().optional().describe("Path to directory containing translation JSON files. When omitted, templates are compiled without translations. Each JSON file should be named with the language code (e.g., en.json, pl.json)."),mailsPath:t.z.string().describe("Path to directory containing MJML email templates. All .mjml files in this directory will be processed."),plaintextMailsPath:t.z.string().optional().describe("Path to directory containing plaintext templates. If not specified, defaults to the same value as mailsPath. Used for generating text-only versions of emails alongside HTML versions."),outputPath:t.z.string().describe("Directory where processed templates will be saved. The tool will create this directory if it doesn't exist."),outputMode:m.describe("Target templating system format: 'kratos' for Go template files compatible with Ory Kratos, 'razor' for C# Razor template files."),defaultLanguage:t.z.string().optional().describe("Default language code for templates with translations. Required when translationsPath is provided."),languages:t.z.array(t.z.string()).optional().describe("Array of language codes to process. When omitted, all languages found in translation files are automatically processed. Use this to limit output to specific languages."),kratosLanguageVariable:t.z.string().optional().describe("Variable path used for language detection in Kratos templates. Defaults to '.Identity.traits.lang'. This determines how the generated template will access the user's language preference. Only used in Kratos mode.")});function s(e,a){return f.parse(a)}const o="mail-translation",y={searchPlaces:[`.${o}rc`,`.${o}rc.json`,`.${o}rc.yaml`,`.${o}rc.yml`,`.${o}rc.js`,`.${o}rc.cjs`,`${o}.config.js`,`${o}.config.cjs`],loaders:{".yaml":s,".yml":s}};function b(e){const a=g.lilconfigSync("mail-translation",y),r=e?a.load(e):a.search();if(!r)throw new Error("No configuration file found");try{return h.parse(r.config)}catch(i){throw new Error(`Failed to load configuration: ${i}`)}}const w=u(c.hideBin(process.argv)).option("config",{alias:"c",type:"string",description:"Config file location"}).parseSync(),l=b(w.config);n.generate(l).then(e=>n.saveOutputs({processedTemplates:e,outputPath:l.outputPath}));
2
+ "use strict";const c=require("yargs/helpers"),u=require("yargs/yargs"),n=require("./saveOutputs-Dq_vvJdp.cjs"),g=require("lilconfig"),d=require("yaml"),t=require("zod/v4");function p(e){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(a,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return a.default=e,Object.freeze(a)}const f=p(d),m=t.z.enum(["kratos","razor"]),h=t.z.object({translationsPath:t.z.string().optional().describe("Path to directory containing translation JSON files. When omitted, templates are compiled without translations. Each JSON file should be named with the language code (e.g., en.json, pl.json)."),mailsPath:t.z.string().describe("Path to directory containing MJML email templates. All .mjml files in this directory will be processed."),plaintextMailsPath:t.z.string().optional().describe("Path to directory containing plaintext templates. If not specified, defaults to the same value as mailsPath. Used for generating text-only versions of emails alongside HTML versions."),outputPath:t.z.string().describe("Directory where processed templates will be saved. The tool will create this directory if it doesn't exist."),outputMode:m.describe("Target templating system format: 'kratos' for Go template files compatible with Ory Kratos, 'razor' for C# Razor template files."),defaultLanguage:t.z.string().optional().describe("Default language code for templates with translations. Required when translationsPath is provided."),languages:t.z.array(t.z.string()).optional().describe("Array of language codes to process. When omitted, all languages found in translation files are automatically processed. Use this to limit output to specific languages."),kratosLanguageVariable:t.z.string().optional().describe("Variable path used for language detection in Kratos templates. Defaults to '.Identity.traits.lang'. This determines how the generated template will access the user's language preference. Only used in Kratos mode.")});function s(e,a){return f.parse(a)}const o="mail-translation",y={searchPlaces:[`.${o}rc`,`.${o}rc.json`,`.${o}rc.yaml`,`.${o}rc.yml`,`.${o}rc.js`,`.${o}rc.cjs`,`${o}.config.js`,`${o}.config.cjs`],loaders:{".yaml":s,".yml":s}};function b(e){const a=g.lilconfigSync("mail-translation",y),r=e?a.load(e):a.search();if(!r)throw new Error("No configuration file found");try{return h.parse(r.config)}catch(i){throw new Error(`Failed to load configuration: ${i}`)}}const w=u(c.hideBin(process.argv)).option("config",{alias:"c",type:"string",description:"Config file location"}).parseSync(),l=b(w.config);n.generate(l).then(e=>n.saveOutputs({processedTemplates:e,outputPath:l.outputPath}));
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { hideBin as l } from "yargs/helpers";
3
3
  import c from "yargs/yargs";
4
- import { g, s as d } from "./saveOutputs-CLBuFr2L.js";
4
+ import { g, s as d } from "./saveOutputs-UaR47fWW.js";
5
5
  import { lilconfigSync as m } from "lilconfig";
6
6
  import * as p from "yaml";
7
7
  import { z as t } from "zod/v4";
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./saveOutputs-RV5ZMO78.cjs");exports.generate=e.generate;exports.saveOutputs=e.saveOutputs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./saveOutputs-Dq_vvJdp.cjs");exports.generate=e.generate;exports.saveOutputs=e.saveOutputs;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { g as a, s as t } from "./saveOutputs-CLBuFr2L.js";
1
+ import { g as a, s as t } from "./saveOutputs-UaR47fWW.js";
2
2
  export {
3
3
  a as generate,
4
4
  t as saveOutputs
@@ -0,0 +1,3 @@
1
+ import { CliLogger } from '@leancodepl/logger/cli';
2
+ export declare const logger: CliLogger;
3
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,wBAAwB,CAAA;AAExE,eAAO,MAAM,MAAM,EAAE,SAA6B,CAAA"}
@@ -1,4 +1,4 @@
1
- "use strict";const m=require("node:fs/promises"),c=require("node:path"),j=require("js-beautify"),y=require("mjml"),T=require("intl-messageformat"),P=require("@leancodepl/logger/cli");async function $(t){try{const r=(await m.readdir(t)).filter(e=>c.extname(e)===".mjml");return Promise.all(r.map(async e=>{const a=c.basename(e,".mjml"),s=c.join(t,e),i=await m.readFile(s,"utf8");return{name:a,content:i,isPlaintext:!1}}))}catch(n){throw new Error(`Failed to load templates: ${n}`)}}async function v({plaintextMailsPath:t,outputMode:n}){try{const r=await m.readdir(t),e=n==="kratos"?r.filter(a=>a.endsWith(".plaintext.gotmpl")):r.filter(a=>a.endsWith(".txt.cshtml"));return Promise.all(e.map(async a=>{const s=n==="kratos"?a.replace(/\.plaintext\.gotmpl$/,""):a.replace(/\.txt\.cshtml$/,""),i=c.join(t,a),o=await m.readFile(i,"utf8");return{name:s,content:o,isPlaintext:!0}}))}catch(r){throw new Error(`Failed to load plaintext templates: ${r}`)}}const u=P.createCliLogger();async function E(t){const n={};if(!t)return n;try{const e=(await m.readdir(t)).filter(a=>c.extname(a)===".json");if(e.length===0)return u.warn(`No translation files found in: ${t}. Continuing without translations.`),n;for(const a of e){const s=c.basename(a,".json"),i=c.join(t,a);try{const o=await m.readFile(i,"utf8"),l=JSON.parse(o);n[s]=l}catch(o){u.warn(`Failed to load translation file ${a}:`,o)}}return n}catch(r){return u.warn(`Failed to load translations: ${r}. Continuing without translations.`),n}}const{html:F}=j;function O({mjmlContent:t,filePath:n}){try{const r=y(t,{keepComments:!1,validationLevel:"soft",filePath:n});return{html:F(r.html,{indent_size:2,preserve_newlines:!0,max_preserve_newlines:1}),mjmlParseErrors:r.errors||[]}}catch(r){throw new Error(`MJML compilation failed: ${r}`)}}function M({translatedTemplates:t,defaultLanguage:n,kratosLanguageVariable:r}){const e=t.filter(o=>o.isPlaintext),a=t.filter(o=>!o.isPlaintext),s=a.map(o=>({filename:`${o.name}.gotmpl`,content:d({templates:a,defaultLanguage:n,kratosLanguageVariable:r})})),i=e.map(o=>({filename:`${o.name}.plaintext.gotmpl`,content:d({templates:e,defaultLanguage:n,kratosLanguageVariable:r})}));return[...s,...i]}function d({templates:t,defaultLanguage:n,kratosLanguageVariable:r=".Identity.traits.lang"}){if(t.length===1||!n)return t[0].content;let e="";return t.forEach(s=>{e+=`{{define "${s.language}"}}
1
+ "use strict";const m=require("node:fs/promises"),c=require("node:path"),j=require("js-beautify"),y=require("mjml"),T=require("intl-messageformat"),P=require("@leancodepl/logger/cli");async function $(t){try{const r=(await m.readdir(t)).filter(e=>c.extname(e)===".mjml");return Promise.all(r.map(async e=>{const a=c.basename(e,".mjml"),s=c.join(t,e),i=await m.readFile(s,"utf8");return{name:a,content:i,isPlaintext:!1}}))}catch(n){throw new Error(`Failed to load templates: ${n}`)}}async function v({plaintextMailsPath:t,outputMode:n}){try{const r=await m.readdir(t),e=n==="kratos"?r.filter(a=>a.endsWith(".plaintext.gotmpl")):r.filter(a=>a.endsWith(".txt.cshtml"));return Promise.all(e.map(async a=>{const s=n==="kratos"?a.replace(/\.plaintext\.gotmpl$/,""):a.replace(/\.txt\.cshtml$/,""),i=c.join(t,a),o=await m.readFile(i,"utf8");return{name:s,content:o,isPlaintext:!0}}))}catch(r){throw new Error(`Failed to load plaintext templates: ${r}`)}}const u=P.createCliLogger();async function E(t){const n={};if(!t)return n;try{const e=(await m.readdir(t)).filter(a=>c.extname(a)===".json");if(e.length===0)return u.warn(`No translation files found in: ${t}. Continuing without translations.`),n;for(const a of e){const s=c.basename(a,".json"),i=c.join(t,a);try{const o=await m.readFile(i,"utf8"),l=JSON.parse(o);n[s]=l}catch(o){u.warn(`Failed to load translation file ${a}:`,o)}}return n}catch(r){return u.warn(`Failed to load translations: ${r}. Continuing without translations.`),n}}const{html:F}=j;function O({mjmlContent:t,filePath:n}){try{const r=y(t,{keepComments:!1,validationLevel:"soft",filePath:n});return{html:F(r.html,{indent_size:2,preserve_newlines:!0,max_preserve_newlines:1}),mjmlParseErrors:r.errors||[]}}catch(r){throw new Error(`MJML compilation failed: ${r}`)}}function M({translatedTemplates:t,defaultLanguage:n,kratosLanguageVariable:r}){const e=t.filter(o=>o.isPlaintext),a=t.filter(o=>!o.isPlaintext),s=a.map(o=>({filename:`${o.name}.gotmpl`,content:d({templates:a,defaultLanguage:n,kratosLanguageVariable:r})})),i=e.map(o=>({filename:`${o.name}.plaintext.gotmpl`,content:d({templates:e,defaultLanguage:n,kratosLanguageVariable:r})}));return[...s,...i]}function d({templates:t,defaultLanguage:n,kratosLanguageVariable:r=".Identity.traits.lang"}){if(t.length===1||!n)return t[0]?.content??"";let e="";return t.forEach(s=>{e+=`{{define "${s.language}"}}
2
2
  `,e+=s.content,e+=`
3
3
  {{end}}
4
4
 
@@ -112,7 +112,7 @@ function d({
112
112
  kratosLanguageVariable: r = ".Identity.traits.lang"
113
113
  }) {
114
114
  if (t.length === 1 || !n)
115
- return t[0].content;
115
+ return t[0]?.content ?? "";
116
116
  let e = "";
117
117
  return t.forEach((o) => {
118
118
  e += `{{define "${o.language}"}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/mail-translation",
3
- "version": "10.3.1",
3
+ "version": "10.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "mail-translation": "./dist/bin.js"
19
19
  },
20
20
  "dependencies": {
21
- "@leancodepl/logger": "10.3.1",
21
+ "@leancodepl/logger": "10.5.0",
22
22
  "intl-messageformat": "^10.7.16",
23
23
  "js-beautify": "^1.15.4",
24
24
  "lilconfig": "^3.1.3",