@cripty2001/utils 0.0.59 → 0.0.60

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.
@@ -0,0 +1,10 @@
1
+ import { type Static } from "@cripty2001/utils/appserver/server";
2
+ export declare const SCHEMA: import("@sinclair/typebox").TObject<{
3
+ type: import("@sinclair/typebox").TLiteral<"image">;
4
+ mobile: import("@sinclair/typebox").TString;
5
+ desktop: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
6
+ link: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
7
+ alt: import("@sinclair/typebox").TString;
8
+ }>;
9
+ export type T = Static<typeof SCHEMA>;
10
+ export declare function build(config: T): string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCHEMA = void 0;
4
+ exports.build = build;
5
+ const server_1 = require("@cripty2001/utils/appserver/server");
6
+ exports.SCHEMA = server_1.Type.Object({
7
+ type: server_1.Type.Literal("image"),
8
+ mobile: server_1.Type.String(),
9
+ desktop: server_1.Type.Union([server_1.Type.String(), server_1.Type.Null()]),
10
+ link: server_1.Type.Union([server_1.Type.String(), server_1.Type.Null()]),
11
+ alt: server_1.Type.String()
12
+ });
13
+ function build(config) {
14
+ const img = (breakpoint, url) => `
15
+ <mj-image
16
+ css-class="${breakpoint ?? ''}"
17
+ src="${url}"
18
+ alt="${config.alt}"
19
+ ${config.link ? `href="${config.link}"` : ''}
20
+ padding="0"
21
+ />
22
+ `;
23
+ const imgs = config.desktop === null ?
24
+ img(null, config.mobile) :
25
+ [
26
+ img("onlyDesktop", config.desktop),
27
+ img("onlyMobile", config.mobile)
28
+ ].join('\n');
29
+ const toReturn = `
30
+ <mj-section padding="0">
31
+ <mj-column width="100%" padding="0">
32
+ ${imgs}
33
+ </mj-column>
34
+ </mj-section>
35
+ `;
36
+ return toReturn;
37
+ }
@@ -0,0 +1,29 @@
1
+ import { type Static } from "@cripty2001/utils/appserver/server";
2
+ export declare const TEMPLATE_SCHEMA: import("@sinclair/typebox").TObject<{
3
+ style: import("@sinclair/typebox").TObject<{
4
+ font: import("@sinclair/typebox").TString;
5
+ backgroundColor: import("@sinclair/typebox").TString;
6
+ textColor: import("@sinclair/typebox").TString;
7
+ }>;
8
+ content: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
9
+ type: import("@sinclair/typebox").TLiteral<"image">;
10
+ mobile: import("@sinclair/typebox").TString;
11
+ desktop: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
12
+ link: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
13
+ alt: import("@sinclair/typebox").TString;
14
+ }>, import("@sinclair/typebox").TObject<{
15
+ type: import("@sinclair/typebox").TLiteral<"text">;
16
+ size: import("@sinclair/typebox").TNumber;
17
+ weight: import("@sinclair/typebox").TNumber;
18
+ color: import("@sinclair/typebox").TString;
19
+ padding: import("@sinclair/typebox").TObject<{
20
+ top: import("@sinclair/typebox").TNumber;
21
+ }>;
22
+ content: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
23
+ }>, import("@sinclair/typebox").TObject<{
24
+ type: import("@sinclair/typebox").TLiteral<"raw">;
25
+ data: import("@sinclair/typebox").TString;
26
+ }>]>>;
27
+ }>;
28
+ export type Template = Static<typeof TEMPLATE_SCHEMA>;
29
+ export declare function genBuilder<T extends any>(config: Template): HandlebarsTemplateDelegate<T>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TEMPLATE_SCHEMA = void 0;
7
+ exports.genBuilder = genBuilder;
8
+ const handlebars_1 = __importDefault(require("handlebars"));
9
+ const server_1 = require("@cripty2001/utils/appserver/server");
10
+ const image_js_1 = require("./image.js");
11
+ const raw_js_1 = require("./raw.js");
12
+ const text_js_1 = require("./text.js");
13
+ exports.TEMPLATE_SCHEMA = server_1.Type.Object({
14
+ style: server_1.Type.Object({
15
+ font: server_1.Type.String(),
16
+ backgroundColor: server_1.Type.String(),
17
+ textColor: server_1.Type.String()
18
+ }),
19
+ content: server_1.Type.Array(server_1.Type.Union([
20
+ image_js_1.SCHEMA,
21
+ text_js_1.SCHEMA,
22
+ raw_js_1.SCHEMA
23
+ ]))
24
+ });
25
+ function genBuilder(config) {
26
+ const mappedContent = config.content
27
+ .map(item => {
28
+ switch (item.type) {
29
+ case "image":
30
+ return (0, image_js_1.build)(item);
31
+ case "raw":
32
+ return (0, raw_js_1.build)(item);
33
+ case "text":
34
+ return (0, text_js_1.build)(item);
35
+ default:
36
+ // @ts-expect-error Should never happen
37
+ throw new Error(`Invalid type ${item.type}`);
38
+ }
39
+ })
40
+ .join('\n');
41
+ return handlebars_1.default.compile(`
42
+ <mjml>
43
+ <mj-head>
44
+ <mj-style>
45
+ .onlyMobile {
46
+ display: none !important;
47
+ }
48
+ .onlyDesktop {
49
+ display: block !important;
50
+ }
51
+ @media only screen and (max-width: 500px) {
52
+ .onlyMobile {
53
+ display: block !important;
54
+ }
55
+ .onlyDesktop {
56
+ display: none !important;
57
+ }
58
+ }
59
+ </mj-style>
60
+
61
+ <mj-attributes>
62
+ <mj-all
63
+ font-family="${config.style.font}, Arial, Helvetica, sans-serif"
64
+ />
65
+ <mj-text
66
+ font-size="18px"
67
+ line-height="1.5"
68
+ color="${config.style.textColor}"
69
+ />
70
+ <mj-body width="700px" />
71
+ <mj-section width="700px" padding="0" />
72
+ </mj-attributes>
73
+ </mj-head>
74
+
75
+ <mj-body background-color="${config.style.backgroundColor}">
76
+ ${mappedContent}
77
+ </mj-body>
78
+ </mjml>
79
+ `);
80
+ }
@@ -0,0 +1,7 @@
1
+ import { type Static } from "@cripty2001/utils/appserver/server";
2
+ export declare const SCHEMA: import("@sinclair/typebox").TObject<{
3
+ type: import("@sinclair/typebox").TLiteral<"raw">;
4
+ data: import("@sinclair/typebox").TString;
5
+ }>;
6
+ export type T = Static<typeof SCHEMA>;
7
+ export declare function build(config: T): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCHEMA = void 0;
4
+ exports.build = build;
5
+ const server_1 = require("@cripty2001/utils/appserver/server");
6
+ exports.SCHEMA = server_1.Type.Object({
7
+ type: server_1.Type.Literal("raw"),
8
+ data: server_1.Type.String()
9
+ });
10
+ function build(config) {
11
+ return config.data;
12
+ }
@@ -0,0 +1,13 @@
1
+ import { type Static } from "@cripty2001/utils/appserver/server";
2
+ export declare const SCHEMA: import("@sinclair/typebox").TObject<{
3
+ type: import("@sinclair/typebox").TLiteral<"text">;
4
+ size: import("@sinclair/typebox").TNumber;
5
+ weight: import("@sinclair/typebox").TNumber;
6
+ color: import("@sinclair/typebox").TString;
7
+ padding: import("@sinclair/typebox").TObject<{
8
+ top: import("@sinclair/typebox").TNumber;
9
+ }>;
10
+ content: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
11
+ }>;
12
+ export type T = Static<typeof SCHEMA>;
13
+ export declare function build(config: T): string;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCHEMA = void 0;
4
+ exports.build = build;
5
+ const server_1 = require("@cripty2001/utils/appserver/server");
6
+ exports.SCHEMA = server_1.Type.Object({
7
+ type: server_1.Type.Literal("text"),
8
+ size: server_1.Type.Number(),
9
+ weight: server_1.Type.Number(),
10
+ color: server_1.Type.String(),
11
+ padding: server_1.Type.Object({
12
+ top: server_1.Type.Number()
13
+ }),
14
+ content: server_1.Type.Array(server_1.Type.String())
15
+ });
16
+ function build(config) {
17
+ return `
18
+ <mj-section padding="0">
19
+ <mj-column width="100%" padding-top="${config.padding.top}px">
20
+ ${config.content.map(item => `
21
+ <mj-text font-size="${config.size}px" font-weight="${config.weight}" color="${config.color}">
22
+ ${item}
23
+ </mj-text>
24
+ `).join('')}
25
+ </mj-column>
26
+ </mj-section>
27
+ `;
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
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": {
@@ -21,6 +21,10 @@
21
21
  "files": [
22
22
  "dist"
23
23
  ],
24
+ "dependencies": {
25
+ "@cripty2001/whispr": "^0.2.0",
26
+ "lodash": "^4.17.21"
27
+ },
24
28
  "devDependencies": {
25
29
  "@types/express": "^5.0.5",
26
30
  "@types/node": "^24.9.1",
@@ -28,18 +32,14 @@
28
32
  "react": "^19",
29
33
  "typescript": "^5.9.3"
30
34
  },
31
- "dependencies": {
32
- "@cripty2001/whispr": "^0.2.0",
33
- "@types/lodash": "^4.17.20",
34
- "lodash": "^4.17.21"
35
- },
36
35
  "peerDependencies": {
37
- "lucide-react": "^0.552.0",
38
36
  "@msgpack/msgpack": "^3.1.2",
39
37
  "@sinclair/typebox": "^0.34.41",
40
38
  "dotenv": "^17.2.3",
41
39
  "express": "^5.1.0",
42
- "react": "^19"
40
+ "lucide-react": "^0.552.0",
41
+ "react": "^19",
42
+ "handlebars": "^4.7.8"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "react": {
@@ -74,6 +74,10 @@
74
74
  "./appserver/client": {
75
75
  "import": "./dist/Appserver/client.js",
76
76
  "types": "./dist/Appserver/client.d.ts"
77
+ },
78
+ "./mail-template": {
79
+ "import": "./dist/MailTemplate/index.js",
80
+ "types": "./dist/MailTemplate/index.d.ts"
77
81
  }
78
82
  }
79
83
  }