best-email-builder 0.17.0 → 0.18.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 +20 -0
- package/dist/ai-server.js +3 -3
- package/dist/ai.js +6 -6
- package/dist/builder.js +8 -8
- package/dist/{chunk-FPJF77MO.js → chunk-2B3N6CH4.js} +49 -1
- package/dist/chunk-2B3N6CH4.js.map +1 -0
- package/dist/{chunk-QDAVDMA4.js → chunk-2M44NIFG.js} +2 -2
- package/dist/{chunk-PCLRIXAQ.js → chunk-37PEEEBB.js} +2 -2
- package/dist/{chunk-U3BA4NK3.js → chunk-BER25JS7.js} +2 -2
- package/dist/{chunk-DOK6E6GK.js → chunk-D46HKFV5.js} +25 -3
- package/dist/chunk-D46HKFV5.js.map +1 -0
- package/dist/{chunk-V2PO42EN.js → chunk-F3566ZQB.js} +3 -3
- package/dist/{chunk-4AUHYQPE.js → chunk-JLQDVA4B.js} +4 -4
- package/dist/{chunk-5OUMNUJS.js → chunk-L7NSAYYX.js} +3 -3
- package/dist/{chunk-5OUMNUJS.js.map → chunk-L7NSAYYX.js.map} +1 -1
- package/dist/{chunk-ZRER4JD4.js → chunk-LKD6QZMD.js} +3 -3
- package/dist/{chunk-2F7P4FXX.js → chunk-POUAC5TN.js} +2 -2
- package/dist/{chunk-X4WTY6LC.js → chunk-W4UKDEB4.js} +150 -71
- package/dist/chunk-W4UKDEB4.js.map +1 -0
- package/dist/index.js +10 -10
- package/dist/library.js +5 -5
- package/dist/server.js +48 -5
- package/dist/server.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/core/constants.d.ts +1 -1
- package/dist/types/engine/NativeAdapter.d.ts +1 -1
- package/dist/types/features/variables/VariablesPanel.d.ts +4 -0
- package/dist/types/server/variables.d.ts +12 -0
- package/dist/types/storage/client.d.ts +4 -0
- package/dist/types/ui/primitives/fields.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-DOK6E6GK.js.map +0 -1
- package/dist/chunk-FPJF77MO.js.map +0 -1
- package/dist/chunk-X4WTY6LC.js.map +0 -1
- /package/dist/{chunk-QDAVDMA4.js.map → chunk-2M44NIFG.js.map} +0 -0
- /package/dist/{chunk-PCLRIXAQ.js.map → chunk-37PEEEBB.js.map} +0 -0
- /package/dist/{chunk-U3BA4NK3.js.map → chunk-BER25JS7.js.map} +0 -0
- /package/dist/{chunk-V2PO42EN.js.map → chunk-F3566ZQB.js.map} +0 -0
- /package/dist/{chunk-4AUHYQPE.js.map → chunk-JLQDVA4B.js.map} +0 -0
- /package/dist/{chunk-ZRER4JD4.js.map → chunk-LKD6QZMD.js.map} +0 -0
- /package/dist/{chunk-2F7P4FXX.js.map → chunk-POUAC5TN.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -15,24 +15,24 @@ import {
|
|
|
15
15
|
emailBlocks,
|
|
16
16
|
emailBuilderFeatures,
|
|
17
17
|
isFeatureEnabled
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-W4UKDEB4.js";
|
|
19
19
|
import {
|
|
20
20
|
TemplateLibrary
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JLQDVA4B.js";
|
|
22
22
|
import {
|
|
23
23
|
withPlaceholderImages
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-F3566ZQB.js";
|
|
25
25
|
import {
|
|
26
26
|
applyVariables,
|
|
27
27
|
applyVariablesToText,
|
|
28
28
|
unknownVariables,
|
|
29
29
|
usedVariables
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-
|
|
30
|
+
} from "./chunk-2M44NIFG.js";
|
|
31
|
+
import "./chunk-BER25JS7.js";
|
|
32
32
|
import {
|
|
33
33
|
simulateDarkMode
|
|
34
34
|
} from "./chunk-UFKCLU2D.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-37PEEEBB.js";
|
|
36
36
|
import {
|
|
37
37
|
StorageError,
|
|
38
38
|
UiProvider,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
createMemoryStorage,
|
|
41
41
|
useT,
|
|
42
42
|
useUi
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-D46HKFV5.js";
|
|
44
44
|
import {
|
|
45
45
|
EMAIL_BUILDER_VERSION,
|
|
46
46
|
EMAIL_DEVICES,
|
|
@@ -58,8 +58,8 @@ import {
|
|
|
58
58
|
serializeDocument,
|
|
59
59
|
serializeMjml,
|
|
60
60
|
validateTag
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import "./chunk-
|
|
61
|
+
} from "./chunk-L7NSAYYX.js";
|
|
62
|
+
import "./chunk-POUAC5TN.js";
|
|
63
63
|
import {
|
|
64
64
|
CUSTOM_GROUP,
|
|
65
65
|
DEFAULT_ASSETS_PATH,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
tokenOf,
|
|
77
77
|
translatorFor,
|
|
78
78
|
validateCustomVariable
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-2B3N6CH4.js";
|
|
80
80
|
|
|
81
81
|
// src/ui/EmailStudio.jsx
|
|
82
82
|
import { useMemo, useState } from "react";
|
package/dist/library.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TemplateLibrary
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JLQDVA4B.js";
|
|
4
4
|
import {
|
|
5
5
|
withPlaceholderImages
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-F3566ZQB.js";
|
|
7
7
|
import "./chunk-UFKCLU2D.js";
|
|
8
8
|
import {
|
|
9
9
|
StorageError,
|
|
10
10
|
createHttpStorage,
|
|
11
11
|
createMemoryStorage
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-D46HKFV5.js";
|
|
13
13
|
import {
|
|
14
14
|
EMAIL_BUILDER_VERSION,
|
|
15
15
|
MAX_TEMPLATE_TAGS,
|
|
16
16
|
TAG_COLORS,
|
|
17
17
|
validateTag
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-L7NSAYYX.js";
|
|
19
19
|
import {
|
|
20
20
|
LOCALES,
|
|
21
21
|
createTranslator,
|
|
22
22
|
translatorFor
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-2B3N6CH4.js";
|
|
24
24
|
export {
|
|
25
25
|
EMAIL_BUILDER_VERSION,
|
|
26
26
|
LOCALES,
|
package/dist/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
sampleValues,
|
|
6
6
|
unknownVariables,
|
|
7
7
|
usedVariables
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-2M44NIFG.js";
|
|
9
9
|
import {
|
|
10
10
|
BRAND_IMPORT_ERRORS,
|
|
11
11
|
brandFromCss,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
logoWidthFor,
|
|
16
16
|
prepareMjml,
|
|
17
17
|
readPage
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-BER25JS7.js";
|
|
19
19
|
import {
|
|
20
20
|
simulateDarkMode
|
|
21
21
|
} from "./chunk-UFKCLU2D.js";
|
|
@@ -38,14 +38,14 @@ import {
|
|
|
38
38
|
serializeDocument,
|
|
39
39
|
sortTags,
|
|
40
40
|
validateTag
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-L7NSAYYX.js";
|
|
42
42
|
import {
|
|
43
43
|
IMAGE_ATTRIBUTES,
|
|
44
44
|
LINK_ATTRIBUTES,
|
|
45
45
|
assertValidMjml,
|
|
46
46
|
isSafeUrl,
|
|
47
47
|
validateMjml
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-POUAC5TN.js";
|
|
49
49
|
import {
|
|
50
50
|
DEFAULT_ASSETS_PATH,
|
|
51
51
|
DEFAULT_VARIABLES,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
translatorFor,
|
|
66
66
|
validateCustomVariable,
|
|
67
67
|
validateVariableEdit
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-2B3N6CH4.js";
|
|
69
69
|
|
|
70
70
|
// src/server/assets.js
|
|
71
71
|
import { createHash } from "crypto";
|
|
@@ -725,6 +725,29 @@ function createVariableService({ repository = null, system = DEFAULT_VARIABLES,
|
|
|
725
725
|
}
|
|
726
726
|
return name;
|
|
727
727
|
},
|
|
728
|
+
/**
|
|
729
|
+
* Renames a stored group, or stores `to` when `from` is not; its variables
|
|
730
|
+
* are moved by the builder, one by one, as a drag moves them.
|
|
731
|
+
* @param {string} from @param {unknown} input
|
|
732
|
+
*/
|
|
733
|
+
async renameGroup(from, input) {
|
|
734
|
+
const name = typeof input === "string" ? input.trim() : "";
|
|
735
|
+
if (!name || name.length > 40) throw new HttpError(400, t("Name is required"), "INVALID_GROUP");
|
|
736
|
+
const store = requireRepository();
|
|
737
|
+
if (!store.renameGroup) throw new HttpError(501, t("Custom variables are not configured"), "NO_GROUP_STORE");
|
|
738
|
+
const others = (await service.listGroups()).filter((group) => group !== from);
|
|
739
|
+
if (others.some((group) => group.toLowerCase() === name.toLowerCase()) || !await store.renameGroup(from, name)) {
|
|
740
|
+
throw new HttpError(409, t("This group already exists."), "DUPLICATE_GROUP");
|
|
741
|
+
}
|
|
742
|
+
return name;
|
|
743
|
+
},
|
|
744
|
+
/** Forgets a stored group; the builder has moved its variables out first. @param {string} name */
|
|
745
|
+
async removeGroup(name) {
|
|
746
|
+
const store = requireRepository();
|
|
747
|
+
if (!store.removeGroup) throw new HttpError(501, t("Custom variables are not configured"), "NO_GROUP_STORE");
|
|
748
|
+
await store.removeGroup(name);
|
|
749
|
+
return { name };
|
|
750
|
+
},
|
|
728
751
|
/** Custom variables, and the edits of system ones (no `custom` flag). */
|
|
729
752
|
async listCustom() {
|
|
730
753
|
return repository ? (await repository.list()).map((row) => toVariable(row, !systemKeys.has(row.key))) : [];
|
|
@@ -782,6 +805,16 @@ function createMemoryVariableRepository() {
|
|
|
782
805
|
groups.add(name);
|
|
783
806
|
return true;
|
|
784
807
|
},
|
|
808
|
+
async renameGroup(from, to) {
|
|
809
|
+
if ([...groups].some((group) => group !== from && group.toLowerCase() === to.toLowerCase())) return false;
|
|
810
|
+
const renamed = groups.has(from) ? [...groups].map((group) => group === from ? to : group) : [...groups, to];
|
|
811
|
+
groups.clear();
|
|
812
|
+
for (const group of renamed) groups.add(group);
|
|
813
|
+
return true;
|
|
814
|
+
},
|
|
815
|
+
async removeGroup(name) {
|
|
816
|
+
groups.delete(name);
|
|
817
|
+
},
|
|
785
818
|
async list() {
|
|
786
819
|
return [...rows.values()].map((row) => ({ ...row })).sort((a, b) => a.label.localeCompare(b.label));
|
|
787
820
|
},
|
|
@@ -1544,6 +1577,16 @@ function createEmailBuilderHandler(options) {
|
|
|
1544
1577
|
return json({ data: await customVariables.createGroup((await readJson(request))?.name) }, 201);
|
|
1545
1578
|
}
|
|
1546
1579
|
}
|
|
1580
|
+
if (section === "variable-groups" && id && !sub) {
|
|
1581
|
+
if (method === "PUT") {
|
|
1582
|
+
await userFor(request, "write");
|
|
1583
|
+
return json({ data: await customVariables.renameGroup(id, (await readJson(request))?.name) });
|
|
1584
|
+
}
|
|
1585
|
+
if (method === "DELETE") {
|
|
1586
|
+
await userFor(request, "write");
|
|
1587
|
+
return json({ data: await customVariables.removeGroup(id) });
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1547
1590
|
if (section === "variables") {
|
|
1548
1591
|
if (!id && method === "GET") {
|
|
1549
1592
|
await userFor(request, "read");
|