@useinsider/guido 3.16.0-beta.ca26c4e → 3.16.0-beta.efbb91f
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/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +78 -76
- package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +74 -43
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +45 -23
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +61 -0
- package/dist/components/wrappers/WpDrawer.vue.js +9 -7
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/composables/useHtmlValidator.js +1 -0
- package/dist/composables/useSave.js +84 -41
- package/dist/composables/useSaveValidation.js +276 -0
- package/dist/composables/useSaveValidationRollout.js +9 -0
- package/dist/composables/validators/useCouponBlockValidator.js +24 -21
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
- package/dist/config/migrator/itemsBlockMigrator.js +1 -1
- package/dist/enums/recommendation.js +17 -17
- package/dist/enums/save-validation.js +4 -0
- package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +31 -24
- package/dist/guido.css +1 -1
- package/dist/src/@types/save-validation.d.ts +19 -0
- package/dist/src/components/Guido.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
- package/dist/src/composables/useHtmlValidator.d.ts +14 -0
- package/dist/src/composables/useSave.d.ts +6 -1
- package/dist/src/composables/useSaveValidation.d.ts +6 -0
- package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
- package/dist/src/enums/save-validation.d.ts +27 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -0
- package/dist/src/stores/config.d.ts +5 -0
- package/dist/src/stores/save-validation.d.ts +22 -0
- package/dist/src/utils/templatePreparation.d.ts +30 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/save-validation.js +30 -0
- package/dist/utils/templatePreparation.js +28 -25
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable discriminators for each save-validation rule site — one per rule that
|
|
3
|
+
* can produce a drawer row, kept in sync with the collector + legacy validator chains.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum SaveValidationRule {
|
|
6
|
+
CouponTagModified = "coupon-tag-modified",
|
|
7
|
+
DuplicateUnsubBlock = "duplicate-unsub-block",
|
|
8
|
+
UnsubBlockMissingTemplate = "unsub-block-missing-template",
|
|
9
|
+
LiquidSyntax = "liquid-syntax",
|
|
10
|
+
InvalidLinks = "invalid-links",
|
|
11
|
+
LinkCheckInProgress = "link-check-in-progress",
|
|
12
|
+
CustomFieldScript = "custom-field-script",
|
|
13
|
+
EmptyHtml = "empty-html",
|
|
14
|
+
MismatchedBraces = "mismatched-braces",
|
|
15
|
+
InvalidDynamicTag = "invalid-dynamic-tag",
|
|
16
|
+
InvalidCustomField = "invalid-custom-field",
|
|
17
|
+
ConditionsSyntax = "conditions-syntax",
|
|
18
|
+
WrongEqualityOperator = "wrong-equality-operator",
|
|
19
|
+
MissingIfEndif = "missing-if-endif",
|
|
20
|
+
ConditionTagSpacing = "condition-tag-spacing",
|
|
21
|
+
BracesInsideIfTag = "braces-inside-if-tag",
|
|
22
|
+
RecommendationRequiredFields = "recommendation-required-fields",
|
|
23
|
+
RecommendationFilters = "recommendation-filters",
|
|
24
|
+
InvalidImageType = "invalid-image-type",
|
|
25
|
+
CheckboxUnsubGroup = "checkbox-unsub-group",
|
|
26
|
+
RadioButtonUnsubGroup = "radio-button-unsub-group"
|
|
27
|
+
}
|
|
@@ -286,6 +286,11 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
|
|
|
286
286
|
* every block's recommendationConfigs across user edits.
|
|
287
287
|
*/
|
|
288
288
|
hasInvalidBlock(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Per-instance counterpart to `hasInvalidBlock`: the ids of every block
|
|
291
|
+
* that fails required-field validation, one drawer row each (SD-147430).
|
|
292
|
+
*/
|
|
293
|
+
invalidBlockIds(): string[];
|
|
289
294
|
fetchRecommendationProducts(): Promise<void>;
|
|
290
295
|
_doFetchProducts(): Promise<void>;
|
|
291
296
|
}>;
|
|
@@ -2106,6 +2106,11 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2106
2106
|
};
|
|
2107
2107
|
} | null;
|
|
2108
2108
|
} & import("pinia").PiniaCustomStateProperties<ConfigStoreState>) => number;
|
|
2109
|
+
/**
|
|
2110
|
+
* Transactional campaigns keep the hard save block. Reactive getter, so
|
|
2111
|
+
* consumers stay safe in setup where a raw config read snapshots null (SD-147945).
|
|
2112
|
+
*/
|
|
2113
|
+
isTransactional(): boolean;
|
|
2109
2114
|
/**
|
|
2110
2115
|
* Get the username
|
|
2111
2116
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SaveValidationError, SaveValidationIntent } from '@@/Types/save-validation';
|
|
2
|
+
interface SaveValidationState {
|
|
3
|
+
errors: SaveValidationError[];
|
|
4
|
+
isDrawerOpen: boolean;
|
|
5
|
+
intent: SaveValidationIntent | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const useSaveValidationStore: import("pinia").StoreDefinition<"guidoSaveValidation", SaveValidationState, {
|
|
8
|
+
errorCount: (state: {
|
|
9
|
+
errors: {
|
|
10
|
+
rule: import("../enums/save-validation").SaveValidationRule;
|
|
11
|
+
message: string;
|
|
12
|
+
detail?: string | undefined;
|
|
13
|
+
type: import("../enums/toaster").ToasterTypeOptions;
|
|
14
|
+
}[];
|
|
15
|
+
isDrawerOpen: boolean;
|
|
16
|
+
intent: SaveValidationIntent | null;
|
|
17
|
+
} & import("pinia").PiniaCustomStateProperties<SaveValidationState>) => number;
|
|
18
|
+
}, {
|
|
19
|
+
open(errors: SaveValidationError[], intent: SaveValidationIntent): void;
|
|
20
|
+
close(): void;
|
|
21
|
+
}>;
|
|
22
|
+
export {};
|
|
@@ -15,6 +15,36 @@ import type { SavedTemplateDetails } from '@@/Types/stripo';
|
|
|
15
15
|
* same source), so it is reliably present regardless of how the block was added.
|
|
16
16
|
*/
|
|
17
17
|
export declare function getHtmlReferencedUnsubscribePages(html: string): number[];
|
|
18
|
+
/**
|
|
19
|
+
* Hydrates the recommendation extension store from the persisted `esd-ext-config`
|
|
20
|
+
* JSON blob on each `.recommendation-block-v2` element in the raw editor HTML.
|
|
21
|
+
*
|
|
22
|
+
* Why this runs before `compileHtml`:
|
|
23
|
+
* The HTML compiler's `prepareRecommendationBlocks` rule asks
|
|
24
|
+
* `useRecommendation.buildCampaignUrl(id)` to assemble each block's API URL
|
|
25
|
+
* from `blockStates[id].recommendationConfigs`. That Pinia entry is normally
|
|
26
|
+
* populated by `RecommendationBlockControl._syncNodeConfigToStore`, which
|
|
27
|
+
* only fires when the user *selects* the block. Saving without ever
|
|
28
|
+
* selecting a migrated block would otherwise build the URL from empty/
|
|
29
|
+
* default state and the campaign URL would not be saved.
|
|
30
|
+
*
|
|
31
|
+
* Why we read raw HTML, not compiled HTML:
|
|
32
|
+
* Stripo's `compileEmail()` strips editor-only attributes (`esd-*`) from the
|
|
33
|
+
* compiled output, so `esd-ext-config` is gone by the time the compiler
|
|
34
|
+
* pipeline sees the HTML. The raw HTML from `getTemplateData()` preserves
|
|
35
|
+
* the attribute as the migrator wrote it.
|
|
36
|
+
*
|
|
37
|
+
* Reference data pre-load:
|
|
38
|
+
* When the template has recommendation blocks, this also pre-loads the
|
|
39
|
+
* shared reference data (languages / currency list) so the save-time
|
|
40
|
+
* required-fields validator can check each block's locale and currency
|
|
41
|
+
* against the partner's real options. Best-effort — on a fetch failure the
|
|
42
|
+
* validator degrades to its empty-list guard (`requiredFields.ts`) instead
|
|
43
|
+
* of blocking the save or stranding the Save button.
|
|
44
|
+
*/
|
|
45
|
+
declare function hydrateRecommendationStoreFromRawHtml(rawHtml: string): Promise<void>;
|
|
18
46
|
export declare const useTemplatePreparation: () => {
|
|
19
47
|
prepareTemplateDetails: () => Promise<Omit<SavedTemplateDetails, "metadata">>;
|
|
48
|
+
hydrateRecommendationStore: typeof hydrateRecommendationStoreFromRawHtml;
|
|
20
49
|
};
|
|
50
|
+
export {};
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../@types/config/schemas.js";
|
|
1
|
+
import { MessageType as o } from "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const
|
|
3
|
+
import { parseConfig as r } from "../@types/config/validator.js";
|
|
4
|
+
import { defineStore as a } from "pinia";
|
|
5
|
+
const g = a("guido-config", {
|
|
6
6
|
state: () => ({
|
|
7
7
|
initialized: !1,
|
|
8
8
|
config: null
|
|
@@ -113,6 +113,13 @@ const f = r("guido-config", {
|
|
|
113
113
|
var e, n;
|
|
114
114
|
return ((n = (e = i.config) == null ? void 0 : e.partner) == null ? void 0 : n.messageType) ?? 1;
|
|
115
115
|
},
|
|
116
|
+
/**
|
|
117
|
+
* Transactional campaigns keep the hard save block. Reactive getter, so
|
|
118
|
+
* consumers stay safe in setup where a raw config read snapshots null (SD-147945).
|
|
119
|
+
*/
|
|
120
|
+
isTransactional() {
|
|
121
|
+
return this.messageType === o.TRANSACTIONAL;
|
|
122
|
+
},
|
|
116
123
|
/**
|
|
117
124
|
* Get the username
|
|
118
125
|
*/
|
|
@@ -143,7 +150,7 @@ const f = r("guido-config", {
|
|
|
143
150
|
* Initialize the config store with validated configuration
|
|
144
151
|
*/
|
|
145
152
|
init(i) {
|
|
146
|
-
const e =
|
|
153
|
+
const e = r(i);
|
|
147
154
|
this.config = e, this.initialized = !0;
|
|
148
155
|
},
|
|
149
156
|
/**
|
|
@@ -155,5 +162,5 @@ const f = r("guido-config", {
|
|
|
155
162
|
}
|
|
156
163
|
});
|
|
157
164
|
export {
|
|
158
|
-
|
|
165
|
+
g as useConfigStore
|
|
159
166
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineStore as n } from "pinia";
|
|
2
|
+
function i(e) {
|
|
3
|
+
const t = /* @__PURE__ */ new Set();
|
|
4
|
+
return e.filter((r) => {
|
|
5
|
+
const s = JSON.stringify([r.message, r.detail ?? ""]);
|
|
6
|
+
return t.has(s) ? !1 : (t.add(s), !0);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const o = n("guidoSaveValidation", {
|
|
10
|
+
state: () => ({
|
|
11
|
+
errors: [],
|
|
12
|
+
isDrawerOpen: !1,
|
|
13
|
+
intent: null
|
|
14
|
+
}),
|
|
15
|
+
getters: {
|
|
16
|
+
errorCount: (e) => e.errors.length
|
|
17
|
+
},
|
|
18
|
+
actions: {
|
|
19
|
+
open(e, t) {
|
|
20
|
+
this.errors = i(e), this.intent = t, this.isDrawerOpen = !0;
|
|
21
|
+
},
|
|
22
|
+
// Errors are retained so rows don't blank during the ~300ms close animation.
|
|
23
|
+
close() {
|
|
24
|
+
this.isDrawerOpen = !1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
o as useSaveValidationStore
|
|
30
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
1
|
+
import { useActionsApi as R } from "../composables/useActionsApi.js";
|
|
2
2
|
import { useConfig as U } from "../composables/useConfig.js";
|
|
3
3
|
import { useHtmlCompiler as x } from "../composables/useHtmlCompiler.js";
|
|
4
4
|
import { DEFAULT_CURRENCY as d, DEFAULT_NODE_CONFIG as s } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
5
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { useRecommendationExtensionStore as T } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
6
6
|
import { mapLegacyStrategy as L } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
7
7
|
import { DATA_ATTRIBUTES as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
8
|
-
import { parsePageList as
|
|
9
|
-
import { useDynamicContentStore as
|
|
10
|
-
import { useEditorStore as
|
|
11
|
-
import { useUnsubscribeStore as
|
|
12
|
-
import { assignTrackingIds as
|
|
13
|
-
function
|
|
8
|
+
import { parsePageList as N } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
9
|
+
import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
|
|
10
|
+
import { useEditorStore as _ } from "../stores/editor.js";
|
|
11
|
+
import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
|
|
12
|
+
import { assignTrackingIds as O } from "./linkTrackingIds.js";
|
|
13
|
+
function M(m) {
|
|
14
14
|
const n = new DOMParser().parseFromString(m, "text/html").querySelectorAll(`[${A.PAGE_LIST}]`), t = [];
|
|
15
15
|
return n.forEach((i) => {
|
|
16
16
|
const o = i.getAttribute(A.PAGE_LIST);
|
|
17
|
-
o && t.push(...
|
|
17
|
+
o && t.push(...N(o));
|
|
18
18
|
}), [...new Set(t)];
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
20
|
+
async function C(m) {
|
|
21
21
|
const a = new DOMParser().parseFromString(m, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
22
22
|
if (a.length === 0)
|
|
23
23
|
return;
|
|
24
|
-
const n =
|
|
24
|
+
const n = T();
|
|
25
25
|
a.forEach((t) => {
|
|
26
26
|
var r, l, g, f, c;
|
|
27
27
|
const i = t.getAttribute("recommendation-id"), o = i ? Number(i) : NaN;
|
|
@@ -68,39 +68,39 @@ async function M(m) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
const Z = () => {
|
|
71
|
-
const m =
|
|
71
|
+
const m = z(), u = _(), a = v(), { getCompiledEmail: n, getTemplateData: t, updateHtmlAndCss: i } = R(), { compileHtml: o, compileAmpHtml: p } = x(), { isFeatureEnabled: e } = U();
|
|
72
72
|
return {
|
|
73
73
|
prepareTemplateDetails: async () => {
|
|
74
74
|
let { html: r, css: l, syncModulesIds: g = [] } = await t();
|
|
75
75
|
if (e("linkTrackingIds"))
|
|
76
76
|
try {
|
|
77
|
-
const { html: y, changed:
|
|
78
|
-
u.trackIdSessionFloor =
|
|
77
|
+
const { html: y, changed: I, nextSeq: k } = O(r, u.trackIdSessionFloor);
|
|
78
|
+
u.trackIdSessionFloor = k, I && (r = y, await i(y, l));
|
|
79
79
|
} catch (y) {
|
|
80
80
|
console.error("Tracking-id step failed, saving anyway:", y);
|
|
81
81
|
}
|
|
82
|
-
const { html: f, ampHtml: c = "", ampErrors:
|
|
82
|
+
const { html: f, ampHtml: c = "", ampErrors: w = [] } = await n({
|
|
83
83
|
minimize: !0,
|
|
84
84
|
resetDataSavedFlag: !1
|
|
85
85
|
});
|
|
86
|
-
a.selectedUnsubscribePages.length && await a.fetchTemplates(), await
|
|
87
|
-
const { compiledHtml:
|
|
86
|
+
a.selectedUnsubscribePages.length && await a.fetchTemplates(), await C(r);
|
|
87
|
+
const { compiledHtml: D, stats: S, appliedRules: E } = o(f), P = c && p(c).compiledHtml, F = m.getSelectedDynamicContentList, H = T(), b = M(r);
|
|
88
88
|
return console.debug("HTML Compilation Stats:", {
|
|
89
89
|
originalSize: S.originalSize,
|
|
90
90
|
compiledSize: S.compiledSize,
|
|
91
91
|
reduction: `${S.reductionPercentage.toFixed(2)}%`,
|
|
92
|
-
appliedRules:
|
|
92
|
+
appliedRules: E,
|
|
93
93
|
executionTime: `${S.executionTime.toFixed(2)}ms`
|
|
94
94
|
}), {
|
|
95
|
-
dynamicContentList:
|
|
96
|
-
compiledHtml:
|
|
95
|
+
dynamicContentList: F,
|
|
96
|
+
compiledHtml: D,
|
|
97
97
|
rawHtml: r,
|
|
98
98
|
css: l,
|
|
99
|
-
ampHtml:
|
|
100
|
-
ampErrors:
|
|
99
|
+
ampHtml: P,
|
|
100
|
+
ampErrors: w,
|
|
101
101
|
modules: g.map(Number),
|
|
102
102
|
recommendation: {
|
|
103
|
-
campaignUrls:
|
|
103
|
+
campaignUrls: H.recommendationCampaignUrls,
|
|
104
104
|
configs: {}
|
|
105
105
|
},
|
|
106
106
|
unsubscribe: {
|
|
@@ -108,10 +108,13 @@ const Z = () => {
|
|
|
108
108
|
config: b
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
}
|
|
111
|
+
},
|
|
112
|
+
// Exposed so the back/test validate-only path can seed the reco store the
|
|
113
|
+
// same way a full save does (required-field findings depend on it).
|
|
114
|
+
hydrateRecommendationStore: C
|
|
112
115
|
};
|
|
113
116
|
};
|
|
114
117
|
export {
|
|
115
|
-
|
|
118
|
+
M as getHtmlReferencedUnsubscribePages,
|
|
116
119
|
Z as useTemplatePreparation
|
|
117
120
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.16.0-beta.
|
|
3
|
+
"version": "3.16.0-beta.efbb91f",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|