@cripty2001/utils 0.0.60 → 0.0.61

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.
@@ -26,4 +26,6 @@ export declare const TEMPLATE_SCHEMA: import("@sinclair/typebox").TObject<{
26
26
  }>]>>;
27
27
  }>;
28
28
  export type Template = Static<typeof TEMPLATE_SCHEMA>;
29
- export declare function genBuilder<T extends any>(config: Template): HandlebarsTemplateDelegate<T>;
29
+ export declare function genBuilder<T extends any>(config: Template): (params: T) => {
30
+ html: string;
31
+ };
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TEMPLATE_SCHEMA = void 0;
7
7
  exports.genBuilder = genBuilder;
8
8
  const handlebars_1 = __importDefault(require("handlebars"));
9
+ const mjml_1 = __importDefault(require("mjml"));
9
10
  const server_1 = require("@cripty2001/utils/appserver/server");
10
11
  const image_js_1 = require("./image.js");
11
12
  const raw_js_1 = require("./raw.js");
@@ -38,7 +39,7 @@ function genBuilder(config) {
38
39
  }
39
40
  })
40
41
  .join('\n');
41
- return handlebars_1.default.compile(`
42
+ const builder = handlebars_1.default.compile(`
42
43
  <mjml>
43
44
  <mj-head>
44
45
  <mj-style>
@@ -77,4 +78,14 @@ function genBuilder(config) {
77
78
  </mj-body>
78
79
  </mjml>
79
80
  `);
81
+ return (data) => {
82
+ let { html, errors } = (0, mjml_1.default)(builder(data), {
83
+ validationLevel: 'soft'
84
+ });
85
+ if (errors.length > 0)
86
+ throw new Error(`Invalid template: ${errors.map(e => e.message).join(', ')}`);
87
+ return {
88
+ html: html,
89
+ };
90
+ };
80
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {
@@ -27,6 +27,8 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/express": "^5.0.5",
30
+ "@types/lodash": "^4.17.21",
31
+ "@types/mjml": "^4.7.4",
30
32
  "@types/node": "^24.9.1",
31
33
  "@types/react": "^19",
32
34
  "react": "^19",
@@ -37,9 +39,10 @@
37
39
  "@sinclair/typebox": "^0.34.41",
38
40
  "dotenv": "^17.2.3",
39
41
  "express": "^5.1.0",
42
+ "handlebars": "^4.7.8",
40
43
  "lucide-react": "^0.552.0",
41
- "react": "^19",
42
- "handlebars": "^4.7.8"
44
+ "mjml": "^4.17.1",
45
+ "react": "^19"
43
46
  },
44
47
  "peerDependenciesMeta": {
45
48
  "react": {